1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-23 10:52:19 +00:00
ghostream/stream/srt/srt.go

36 lines
608 B
Go
Raw Normal View History

2020-09-27 09:14:22 +00:00
package srt
import (
2020-09-27 18:43:00 +00:00
"fmt"
2020-09-27 09:14:22 +00:00
"log"
2020-09-27 18:43:00 +00:00
"github.com/haivision/srtgo"
2020-09-27 09:14:22 +00:00
)
// 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)
2020-09-27 18:43:00 +00:00
options := make(map[string]string)
options["transtype"] = "file"
// FIXME: cfg.ListenAddress -> host and port
sck := srtgo.NewSrtSocket("0.0.0.0", 9710, options)
sck.Listen(1)
s, _ := sck.Accept()
2020-09-27 09:14:22 +00:00
2020-09-27 18:43:00 +00:00
buff := make([]byte, 2048)
for {
n, _ := s.Read(buff, 10000)
if n == 0 {
break
}
2020-09-27 19:21:58 +00:00
fmt.Printf("Received %d bytes", n)
2020-09-27 09:14:22 +00:00
}
}