add env variables to rtsp
This commit is contained in:
parent
f4a985a822
commit
ae2a785dd7
1 changed files with 19 additions and 1 deletions
20
actioncam.go
20
actioncam.go
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/jonas-koeritz/actioncam/libipcamera"
|
"github.com/jonas-koeritz/actioncam/libipcamera"
|
||||||
"github.com/jonas-koeritz/actioncam/rtsp"
|
"github.com/jonas-koeritz/actioncam/rtsp"
|
||||||
|
|
@ -254,7 +255,24 @@ func main() {
|
||||||
Short: "Start an RTSP-Server serving the cameras preview.",
|
Short: "Start an RTSP-Server serving the cameras preview.",
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
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()
|
defer rtspServer.Stop()
|
||||||
|
|
||||||
log.Printf("Created RTSP Server\n")
|
log.Printf("Created RTSP Server\n")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue