mirror of
https://github.com/datarhei/core.git
synced 2025-10-07 00:43:39 +08:00
Add GoSRT & improvements (repo-merge)
Commits (Ingo Oppermann): - Add experimental SRT connection stats and logs - Hide /config/reload endpoint in reade-only mode - Add SRT server - Create v16 in go.mod - Fix data races, tests, lint, and update dependencies - Add trailing slash for routed directories (datarhei/restreamer#340) - Allow relative URLs in content in static routes Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
This commit is contained in:
61
vendor/github.com/datarhei/gosrt/doc.go
generated
vendored
Normal file
61
vendor/github.com/datarhei/gosrt/doc.go
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Package srt provides an interface for network I/O using the SRT protocol (https://github.com/Haivision/srt).
|
||||
|
||||
The package gives access to the basic interface provided by the Dial, Listen, and Accept functions and the associated
|
||||
Conn and Listener interfaces.
|
||||
|
||||
The Dial function connects to a server:
|
||||
|
||||
conn, err := srt.Dial("srt", "golang.org:6000", srt.Config{
|
||||
StreamId: "...",
|
||||
})
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
buffer := make([]byte, 2048)
|
||||
|
||||
for {
|
||||
n, err := conn.Read(buffer)
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
// handle received data
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
|
||||
The Listen function creates servers:
|
||||
|
||||
ln, err := srt.Listen("srt", ":6000", srt.Config{...})
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
for {
|
||||
conn, mode, err := ln.Accept(handleConnect)
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
if mode == srt.REJECT {
|
||||
// rejected connection, ignore
|
||||
continue
|
||||
}
|
||||
|
||||
if mode == srt.PUBLISH {
|
||||
go handlePublish(conn)
|
||||
} else {
|
||||
go handleSubscribe(conn)
|
||||
}
|
||||
}
|
||||
|
||||
The ln.Accept function expects a function that takes a srt.ConnRequest
|
||||
and returns a srt.ConnType. The srt.ConnRequest lets you retrieve the
|
||||
streamid with on which you can decide what mode (srt.ConnType) to return.
|
||||
|
||||
Check out the Server type that wraps the Listen and Accept into a
|
||||
convenient framework for your own SRT server.
|
||||
*/
|
||||
package srt
|
Reference in New Issue
Block a user