From 9b85fdb45603dd2ea111813ea9e6042c6ea536e9 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Wed, 25 Oct 2023 15:04:59 +0500 Subject: [PATCH] parse options from cmd args --- main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index f540bf6..fb4540e 100644 --- a/main.go +++ b/main.go @@ -4,19 +4,25 @@ import ( "stream_server/rtmp" "stream_server/http" "stream_server/srt" + "flag" ) const ( - SRVTYPE_RTMP uint8 = iota + SRVTYPE_RTMP uint = iota SRVTYPE_SRT ) func main() { - err := NewIngestServer(SRVTYPE_SRT, "7878") + ingest_type := flag.Uint("ingest_type", 0, "Ingest server type, 0 for RTMP, 1 for SRT") + ingest_port := flag.String("ingest_port", "7878", "Port for stream intake") + http_port := flag.String("http_port", "7879", "Port to serve http requests") + + flag.Parse() + err := NewIngestServer(*ingest_type, *ingest_port) if err != nil { panic(err) } - err = NewHTTPServer("7879") + err = NewHTTPServer(*http_port) if err != nil { panic(err) } @@ -24,7 +30,7 @@ func main() { } } -func NewIngestServer(srvr_type uint8, port string) (error) { +func NewIngestServer(srvr_type uint, port string) (error) { var err error switch srvr_type { case 0: