diff --git a/actioncam.go b/actioncam.go index 7c9e20f..df4a1d2 100644 --- a/actioncam.go +++ b/actioncam.go @@ -15,6 +15,7 @@ import ( "path/filepath" "runtime" "runtime/pprof" + "strconv" "github.com/jonas-koeritz/actioncam/libipcamera" "github.com/jonas-koeritz/actioncam/rtsp" @@ -254,7 +255,24 @@ func main() { Short: "Start an RTSP-Server serving the cameras preview.", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - rtspServer := rtsp.CreateServer(applicationContext, "127.0.0.1", 8554, camera) + var port_string = os.Getenv("PORT"); + + if(port_string == "") { + port_string = "8554" + } + + port, erra := strconv.Atoi(port_string); + if erra != nil { + log.Printf("ERROR: %s\n", erra) + return + } + + var host = os.Getenv("HOST"); + if(host == "") { + host = "127.0.0.1" + } + + rtspServer := rtsp.CreateServer(applicationContext, host, port, camera) defer rtspServer.Stop() log.Printf("Created RTSP Server\n")