1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-27 11:28:51 +02:00

Switch to haivision SRT module

This commit is contained in:
Alexandre Iooss
2020-09-27 20:43:00 +02:00
parent 1cba80d53e
commit 622bb42435
3 changed files with 19 additions and 21 deletions

View File

@ -1,10 +1,10 @@
package srt
import (
"fmt"
"log"
"net"
"github.com/openfresh/gosrt/srt"
"github.com/haivision/srtgo"
)
// Options holds web package configuration
@ -15,23 +15,21 @@ type Options struct {
// 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()
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()
buff := make([]byte, 2048)
for {
conn, err := l.Accept()
if err != nil {
log.Println("Error on incoming SRT stream", err)
n, _ := s.Read(buff, 10000)
if n == 0 {
break
}
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)
fmt.Println("Received %d bytes", n)
}
}