parse options from cmd args

This commit is contained in:
Muaz Ahmad 2023-10-25 15:04:59 +05:00
parent 460150d9ac
commit 9b85fdb456

14
main.go
View file

@ -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: