1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-27 09:08:50 +02:00

Add basic SRT support

This commit is contained in:
Alexandre Iooss
2020-09-27 11:14:22 +02:00
parent e1d3c4a37f
commit d4aa09c632
5 changed files with 50 additions and 0 deletions

37
stream/srt/srt.go Normal file
View File

@ -0,0 +1,37 @@
package srt
import (
"log"
"net"
"github.com/openfresh/gosrt/srt"
)
// Options holds web package configuration
type Options struct {
ListenAddress string
}
// Serve SRT server
func Serve(cfg *Options) {
log.Printf("SRT server listening on %s", cfg.ListenAddress)
l, _ := srt.Listen("srt", cfg.ListenAddress)
defer l.Close()
for {
conn, err := l.Accept()
if err != nil {
log.Println("Error on incoming SRT stream", err)
}
log.Printf("New incomming SRT stream from %s", conn.RemoteAddr())
go func(sc net.Conn) {
defer sc.Close()
for {
//mon := conn.(*srt.SRTConn).Stats()
//s, _ := json.MarshalIndent(mon, "", "\t")
//fmt.Println(string(s))
}
}(conn)
}
}