diff --git a/README.md b/README.md index b3a3578..ed3fe1a 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,8 @@ rtsp: waittimeout: 10 pull: repull: 0 - pullonstart: false - pullonsubscribe: false - pulllist: {} + pullonstart: {} + pullonsub: {} push: repush: 0 pushlist: {} diff --git a/go.mod b/go.mod index bac790d..88cd33a 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/go.sum b/go.sum index 15c5e66..17f7099 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/main.go b/main.go index df2c523..a69a764 100644 --- a/main.go +++ b/main.go @@ -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 {