适配engine v4.9.5

This commit is contained in:
dexter
2022-12-31 22:18:50 +08:00
parent 1f3f4bfb0e
commit 187335d311
4 changed files with 16 additions and 19 deletions

View File

@@ -53,9 +53,8 @@ rtsp:
waittimeout: 10
pull:
repull: 0
pullonstart: false
pullonsubscribe: false
pulllist: {}
pullonstart: {}
pullonsub: {}
push:
repush: 0
pushlist: {}

2
go.mod
View File

@@ -5,7 +5,7 @@ go 1.18
require (
github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129
go.uber.org/zap v1.23.0
m7s.live/engine/v4 v4.9.3
m7s.live/engine/v4 v4.9.5
)
require (

4
go.sum
View File

@@ -259,5 +259,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
m7s.live/engine/v4 v4.9.3 h1:FP5duB4mdv0vw60dB1cQ5whkQqZZ3Ekw1J98Srb66As=
m7s.live/engine/v4 v4.9.3/go.mod h1:OgI9lOQ1bE64s9rApdGGop1MBAJIpc/V2MJ190d9ig4=
m7s.live/engine/v4 v4.9.5 h1:xTZYokxH/kNOqrGzQlkOQIsElbkb8VsfwlktjjOXZ08=
m7s.live/engine/v4 v4.9.5/go.mod h1:OgI9lOQ1bE64s9rApdGGop1MBAJIpc/V2MJ190d9ig4=

24
main.go
View File

@@ -2,6 +2,7 @@ package rtsp
import (
"net/http"
"strconv"
"sync"
"time"
@@ -41,11 +42,9 @@ func (conf *RTSPConfig) OnEvent(event any) {
RTSPPlugin.Error("server start", zap.Error(err))
v["enable"] = false
}
if conf.PullOnStart {
for streamPath, url := range conf.PullList {
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), false); err != nil {
RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
for streamPath, url := range conf.PullOnStart {
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
}
case SEpublish:
@@ -57,14 +56,12 @@ func (conf *RTSPConfig) OnEvent(event any) {
}
}
case *Stream: //按需拉流
if conf.PullOnSubscribe {
for streamPath, url := range conf.PullList {
if streamPath == v.Path {
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), false); err != nil {
RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
break
for streamPath, url := range conf.PullOnSub {
if streamPath == v.Path {
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
break
}
}
}
@@ -95,7 +92,8 @@ func (*RTSPConfig) API_list(w http.ResponseWriter, r *http.Request) {
}
func (*RTSPConfig) API_Pull(rw http.ResponseWriter, r *http.Request) {
err := RTSPPlugin.Pull(r.URL.Query().Get("streamPath"), r.URL.Query().Get("target"), new(RTSPPuller), r.URL.Query().Has("save"))
save, _ := strconv.Atoi(r.URL.Query().Get("save"))
err := RTSPPlugin.Pull(r.URL.Query().Get("streamPath"), r.URL.Query().Get("target"), new(RTSPPuller), save)
if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest)
} else {