适配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 waittimeout: 10
pull: pull:
repull: 0 repull: 0
pullonstart: false pullonstart: {}
pullonsubscribe: false pullonsub: {}
pulllist: {}
push: push:
repush: 0 repush: 0
pushlist: {} pushlist: {}

2
go.mod
View File

@@ -5,7 +5,7 @@ go 1.18
require ( require (
github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129 github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129
go.uber.org/zap v1.23.0 go.uber.org/zap v1.23.0
m7s.live/engine/v4 v4.9.3 m7s.live/engine/v4 v4.9.5
) )
require ( 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.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 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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.5 h1:xTZYokxH/kNOqrGzQlkOQIsElbkb8VsfwlktjjOXZ08=
m7s.live/engine/v4 v4.9.3/go.mod h1:OgI9lOQ1bE64s9rApdGGop1MBAJIpc/V2MJ190d9ig4= m7s.live/engine/v4 v4.9.5/go.mod h1:OgI9lOQ1bE64s9rApdGGop1MBAJIpc/V2MJ190d9ig4=

16
main.go
View File

@@ -2,6 +2,7 @@ package rtsp
import ( import (
"net/http" "net/http"
"strconv"
"sync" "sync"
"time" "time"
@@ -41,13 +42,11 @@ func (conf *RTSPConfig) OnEvent(event any) {
RTSPPlugin.Error("server start", zap.Error(err)) RTSPPlugin.Error("server start", zap.Error(err))
v["enable"] = false v["enable"] = false
} }
if conf.PullOnStart { for streamPath, url := range conf.PullOnStart {
for streamPath, url := range conf.PullList { if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
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)) RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
} }
} }
}
case SEpublish: case SEpublish:
for streamPath, url := range conf.PushList { for streamPath, url := range conf.PushList {
if streamPath == v.Stream.Path { if streamPath == v.Stream.Path {
@@ -57,17 +56,15 @@ func (conf *RTSPConfig) OnEvent(event any) {
} }
} }
case *Stream: //按需拉流 case *Stream: //按需拉流
if conf.PullOnSubscribe { for streamPath, url := range conf.PullOnSub {
for streamPath, url := range conf.PullList {
if streamPath == v.Path { if streamPath == v.Path {
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), false); err != nil { 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)) RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
} }
break break
} }
} }
} }
}
} }
var rtspConfig = &RTSPConfig{ var rtspConfig = &RTSPConfig{
@@ -95,7 +92,8 @@ func (*RTSPConfig) API_list(w http.ResponseWriter, r *http.Request) {
} }
func (*RTSPConfig) API_Pull(rw 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 { if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest) http.Error(rw, err.Error(), http.StatusBadRequest)
} else { } else {