From d15f44bf775cfde0646e027ea1d862d6beebe15b Mon Sep 17 00:00:00 2001 From: Anton Schubert Date: Wed, 11 Nov 2020 23:02:24 +0100 Subject: [PATCH] allow passing port, latency via cmdline --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 4ab3b9f..b94a2de 100644 --- a/main.go +++ b/main.go @@ -1,29 +1,34 @@ package main import ( + "flag" "log" + "strconv" "github.com/haivision/srtgo" "github.com/voc/srtrelay/server" ) func main() { + var port = flag.Int("port", 1337, "relay port (default 1337)") + var latency = flag.Int("latency", 300, "srt latency in ms (default 300)") + flag.Parse() + options := make(map[string]string) options["blocking"] = "0" options["transtype"] = "live" - options["latency"] = "300" + options["latency"] = strconv.Itoa(*latency) address := "0.0.0.0" - port := uint16(8090) buffersize := uint(384000) // 1s @ 3Mbits/ - sck := srtgo.NewSrtSocket(address, port, options) + sck := srtgo.NewSrtSocket(address, uint16(*port), options) err := sck.Listen(1) defer sck.Close() if err != nil { log.Fatalln("listen failed", err) } - log.Printf("Listening on %s:%d\n", address, port) + log.Printf("Listening on %s:%d\n", address, *port) server := server.NewServer(buffersize) for {