1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-02-06 17:12:59 +00:00

36 lines
609 B
Go
Raw Normal View History

2020-09-27 11:14:22 +02:00
package srt
import (
2020-09-27 20:43:00 +02:00
"fmt"
2020-09-27 11:14:22 +02:00
"log"
2020-09-27 20:43:00 +02:00
"github.com/haivision/srtgo"
2020-09-27 11:14:22 +02: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 20:43:00 +02: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 11:14:22 +02:00
2020-09-27 20:43:00 +02:00
buff := make([]byte, 2048)
for {
n, _ := s.Read(buff, 10000)
if n == 0 {
break
}
fmt.Println("Received %d bytes", n)
2020-09-27 11:14:22 +02:00
}
}