修改rtsp自动拉流配置结构

This commit is contained in:
langhuihui
2021-07-11 21:43:15 +08:00
parent f0a00f3db9
commit 5cdbc220de
4 changed files with 10 additions and 14 deletions

View File

@@ -18,17 +18,14 @@ import (
# 端口接收推流 # 端口接收推流
ListenAddr = ":554" ListenAddr = ":554"
Reconnect = true Reconnect = true
[[RTSP.AutoPullList]] [RTSP.AutoPullList]
URL = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1" "live/rtsp1" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1"
StreamPath = "live/rtsp1" "live/rtsp2" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=2&subtype=1"
[[RTSP.AutoPullList]]
URL = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=2&subtype=1"
StreamPath = "live/rtsp2"
``` ```
- `ListenAddr`是监听的地址 - `ListenAddr`是监听的地址
- `Reconnect` 是否自动重连 - `Reconnect` 是否自动重连
- `RTSP.AutoPullList` 可以配置多项,用于自动拉流,其中`StreamPath`必须是唯一的,自动拉流会在程序启动是自动发起 - `RTSP.AutoPullList` 可以配置多项,用于自动拉流,key是streamPathvalue是远程rtsp地址
## 插件功能 ## 插件功能

2
go.mod
View File

@@ -3,7 +3,7 @@ module github.com/Monibuca/plugin-rtsp/v3
go 1.16 go 1.16
require ( 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/Monibuca/utils/v3 v3.0.0
github.com/pion/rtp v1.6.5 github.com/pion/rtp v1.6.5
github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125 github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125

2
go.sum
View File

@@ -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.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 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.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 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-beta/go.mod h1:mQYP/OMox1tkWP6Qut7pBfARr1TXSRkK662dexQl6kI=
github.com/Monibuca/utils/v3 v3.0.0 h1:i8qCXQPQpRPgjuXKu5C2PYiL5LYzB6GW4xE162mB2ug= github.com/Monibuca/utils/v3 v3.0.0 h1:i8qCXQPQpRPgjuXKu5C2PYiL5LYzB6GW4xE162mB2ug=

View File

@@ -21,10 +21,7 @@ var config = struct {
RemoteAddr string RemoteAddr string
Timeout int Timeout int
Reconnect bool Reconnect bool
AutoPullList []*struct { AutoPullList map[string]string
URL string
StreamPath string
}
}{":554", false, "rtsp://localhost/${streamPath}", 0, false, nil} }{":554", false, "rtsp://localhost/${streamPath}", 0, false, nil}
func init() { func init() {
@@ -65,8 +62,8 @@ func runPlugin() {
} }
}) })
if len(config.AutoPullList) > 0 { if len(config.AutoPullList) > 0 {
for _, info := range config.AutoPullList { for streamPath, url := range config.AutoPullList {
if err := new(RTSP).PullStream(info.StreamPath, info.URL); err != nil { if err := new(RTSP).PullStream(streamPath, url); err != nil {
Println(err) Println(err)
} }
} }