stream-server/main.go

48 lines
859 B
Go
Raw Normal View History

2023-08-09 16:00:21 +05:00
package main
2023-08-21 12:19:31 +05:00
import (
"stream_server/rtmp"
"stream_server/http"
2023-09-18 11:51:55 +05:00
"stream_server/srt"
2023-10-25 15:04:59 +05:00
"flag"
2023-08-21 12:19:31 +05:00
)
2023-08-15 14:28:13 +05:00
2023-08-09 16:00:21 +05:00
const (
2023-10-25 15:04:59 +05:00
SRVTYPE_RTMP uint = iota
2023-09-18 11:51:55 +05:00
SRVTYPE_SRT
2023-08-09 16:00:21 +05:00
)
func main() {
2023-10-25 15:04:59 +05:00
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)
2023-08-09 16:00:21 +05:00
if err != nil {
panic(err)
}
2023-10-25 15:04:59 +05:00
err = NewHTTPServer(*http_port)
2023-08-21 12:19:31 +05:00
if err != nil {
panic(err)
}
2023-08-09 16:00:21 +05:00
for {
}
}
2023-08-15 14:28:13 +05:00
2023-10-25 15:04:59 +05:00
func NewIngestServer(srvr_type uint, port string) (error) {
2023-08-15 14:28:13 +05:00
var err error
switch srvr_type {
case 0:
err = rtmp.NewServer(port)
2023-09-18 11:51:55 +05:00
case 1:
err = srt.NewServer(port)
2023-08-15 14:28:13 +05:00
}
return err
}
2023-08-21 12:19:31 +05:00
func NewHTTPServer(port string) (error) {
err := http.NewServer(port)
return err
}