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:
37
stream/srt/srt.go
Normal file
37
stream/srt/srt.go
Normal 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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user