From c4700713a8ddd65479235e3f76f298b1ab3cf7ed Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Wed, 11 Oct 2023 17:01:09 +0800 Subject: [PATCH] feat: remove pull protocol config --- README.en.md | 1 - README.md | 1 - client.go | 30 ++++++++++++++---------------- main.go | 1 - 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/README.en.md b/README.en.md index bb117a3..c2e98ed 100644 --- a/README.en.md +++ b/README.en.md @@ -52,7 +52,6 @@ rtsp: rtcpaddr: :8001 readbuffercount: 2048 writebuffercount: 2048 - pullprotocol: tcp # auto, tcp, udp ``` :::tip Configuration override publish and subscribe, any section not configured will use global configuration. diff --git a/README.md b/README.md index 0bb6882..1958e04 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ rtsp: rtcpaddr: :8001 readbuffercount: 2048 # 读取缓存队列大小 writebuffercount: 2048 # 写出缓存队列大小 - pullprotocol: tcp # auto, tcp, udp ``` :::tip 配置覆盖 publish diff --git a/client.go b/client.go index ca2154f..01d2750 100644 --- a/client.go +++ b/client.go @@ -5,6 +5,7 @@ import ( "net" "github.com/bluenviron/gortsplib/v3" + "github.com/bluenviron/gortsplib/v3/pkg/base" "github.com/bluenviron/gortsplib/v3/pkg/url" "go.uber.org/zap" "m7s.live/engine/v4" @@ -33,15 +34,8 @@ func (p *RTSPPuller) Connect() error { ReadBufferCount: rtspConfig.ReadBufferCount, AnyPortEnable: true, } - - switch rtspConfig.PullProtocol { - case "tcp", "TCP": - p.Transport = gortsplib.TransportTCP - client.Transport = &p.Transport - case "udp", "UDP": - p.Transport = gortsplib.TransportUDP - client.Transport = &p.Transport - } + p.Transport = gortsplib.TransportTCP + client.Transport = &p.Transport // parse URL u, err := url.Parse(p.RemoteURL) if err != nil { @@ -58,31 +52,35 @@ func (p *RTSPPuller) Connect() error { func (p *RTSPPuller) Pull() (err error) { u, _ := url.Parse(p.RemoteURL) - if _, err = p.Options(u); err != nil { + var res *base.Response + if res, err = p.Options(u); err != nil { p.Error("Options", zap.Error(err)) return } + p.Debug("Options", zap.Any("res", res)) // find published tracks - tracks, baseURL, _, err := p.Describe(u) + tracks, baseURL, res, err := p.Describe(u) if err != nil { p.Error("Describe", zap.Error(err)) - return + return err } + p.Debug("Describe", zap.Any("res", res)) p.tracks = tracks err = p.SetTracks() if err != nil { p.Error("SetTracks", zap.Error(err)) - return + return err } if err = p.SetupAll(tracks, baseURL); err != nil { p.Error("SetupAndPlay", zap.Error(err)) - return + return err } p.OnPacketRTPAny(p.OnPacket) - _, err = p.Play(nil) + res, err = p.Play(nil) + p.Debug("Play", zap.Any("res", res)) if err != nil { p.Error("Play", zap.Error(err)) - return + return err } return p.Wait() } diff --git a/main.go b/main.go index 8deb02b..7545398 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,6 @@ type RTSPConfig struct { RTCPAddr string `default:":8001"` ReadBufferCount int `default:"2048"` WriteBufferCount int `default:"2048"` - PullProtocol string `default:"tcp"` //tcp、udp、auto sync.Map }