libsrt
is a CGo-wrapper for the Haivision SRT-library.
Function are added on-demand basis, Pull Requests (e.g. to improve the coverage) are welcomed.
package myfancypkg
import (
"github.com/xaionaro-go/libsrt"
"github.com/xaionaro-go/libsrt/sockopt"
"github.com/xaionaro-go/libsrt/extras/xastiav"
)
func myFancyFunc() {
[...]
// extracting the file descriptor from a go-astiav's structure:
sockS := xastiav.GetFDFromFormatContext(formatCtx)
// manipulating the SRT socket
s := libsrt.SocketFromC(sockC)
err := s.Setsockflag(sockopt.LATENCY, libsrt.BlobInt(5000000)) // 5 seconds
if err != nil {
return fmt.Errorf("unable to set latency to 5 seconds: %w", libsrt.Getlasterror()) // yes, this is how libsrt works, unfortunately, you need to ask for an error code in a thread-unsafe manner.
}
[...]
}