This commit is contained in:
Soph :3 2025-11-24 20:56:27 +02:00
parent 7eec0f88e4
commit 403dfc5092
5 changed files with 179 additions and 262 deletions

View file

@ -15,10 +15,10 @@ import (
"path/filepath"
"runtime"
"runtime/pprof"
"strconv"
"github.com/jonas-koeritz/actioncam/libipcamera"
"github.com/jonas-koeritz/actioncam/rtsp"
"github.com/spf13/cobra"
)
@ -255,39 +255,13 @@ func main() {
Short: "Start an RTSP-Server serving the cameras preview.",
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
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"
}
relay := libipcamera.CreateRTPRelay(applicationContext)
rtspServer, err := rtsp.CreateServer(applicationContext, host, port, relay)
if rtspServer != nil {
defer rtspServer.Close()
}
camera.StartPreviewStream()
if err := camera.StartPreviewStream(); err != nil {
log.Printf("ERROR preview: %v", err)
return
}
log.Printf("Created RTSP Server\n")
if err != nil {
log.Printf("ERROR starting RTSP Server: %s\n", err)
}
server := rtsp.CreateServer(applicationContext, "0.0.0.0", 8554, relay)
log.Println("Press Ctrl+C to exit")
<-applicationContext.Done()
server.Stop()
},
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {