diff --git a/README.md b/README.md index ae46bc6..20f3a04 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,14 @@ import ( # 端口接收推流 ListenAddr = ":554" Reconnect = true -[[RTSP.AutoPullList]] -URL = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1" -StreamPath = "live/rtsp1" -[[RTSP.AutoPullList]] -URL = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=2&subtype=1" -StreamPath = "live/rtsp2" +[RTSP.AutoPullList] +"live/rtsp1" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1" +"live/rtsp2" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=2&subtype=1" ``` - `ListenAddr`是监听的地址 - `Reconnect` 是否自动重连 -- `RTSP.AutoPullList` 可以配置多项,用于自动拉流,其中`StreamPath`必须是唯一的,自动拉流会在程序启动是自动发起 +- `RTSP.AutoPullList` 可以配置多项,用于自动拉流,key是streamPath,value是远程rtsp地址 ## 插件功能 diff --git a/go.mod b/go.mod index a36802a..21870c5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Monibuca/plugin-rtsp/v3 go 1.16 require ( - github.com/Monibuca/engine/v3 v3.1.0 + github.com/Monibuca/engine/v3 v3.1.1 github.com/Monibuca/utils/v3 v3.0.0 github.com/pion/rtp v1.6.5 github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125 diff --git a/go.sum b/go.sum index 1ef173e..267b1fd 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/Monibuca/engine/v3 v3.0.0-beta5 h1:b27ZQDfvf5dBMZbCSIUXItUwVIFs95fpkA github.com/Monibuca/engine/v3 v3.0.0-beta5/go.mod h1:SMgnlwih4pBA/HkTLjKXZFYkv3ukRzFjv65CARRLVIk= github.com/Monibuca/engine/v3 v3.1.0 h1:/U1YV6dYu4nYdLUHJgDhXzbmp1/X0Vwi8xrx1WfyVNA= github.com/Monibuca/engine/v3 v3.1.0/go.mod h1:yz6cssED2VlYu+g/LrxseBB9pcvsLM/o2QXa4gVY650= +github.com/Monibuca/engine/v3 v3.1.1 h1:UZXvAsFO/5Tae6rN42Wppa+UOMxfPcy3erCpPWV+TQY= +github.com/Monibuca/engine/v3 v3.1.1/go.mod h1:yz6cssED2VlYu+g/LrxseBB9pcvsLM/o2QXa4gVY650= github.com/Monibuca/utils/v3 v3.0.0-beta h1:z4p/BSH5J9Ja/gwoDmj1RyN+b0q28Nmn/fqXiwq2hGY= github.com/Monibuca/utils/v3 v3.0.0-beta/go.mod h1:mQYP/OMox1tkWP6Qut7pBfARr1TXSRkK662dexQl6kI= github.com/Monibuca/utils/v3 v3.0.0 h1:i8qCXQPQpRPgjuXKu5C2PYiL5LYzB6GW4xE162mB2ug= diff --git a/main.go b/main.go index bbef661..ba742a0 100644 --- a/main.go +++ b/main.go @@ -21,10 +21,7 @@ var config = struct { RemoteAddr string Timeout int Reconnect bool - AutoPullList []*struct { - URL string - StreamPath string - } + AutoPullList map[string]string }{":554", false, "rtsp://localhost/${streamPath}", 0, false, nil} func init() { @@ -65,8 +62,8 @@ func runPlugin() { } }) if len(config.AutoPullList) > 0 { - for _, info := range config.AutoPullList { - if err := new(RTSP).PullStream(info.StreamPath, info.URL); err != nil { + for streamPath, url := range config.AutoPullList { + if err := new(RTSP).PullStream(streamPath, url); err != nil { Println(err) } }