Files
core/vendor/github.com/datarhei/gosrt/doc.go
Jan Stabenow eb1cc37456 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>
2022-06-23 22:13:58 +02:00

62 lines
1.3 KiB
Go

/*
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