From ad9a22c0b2f1b213fa904ebd0c23c6fb72f5fa8f Mon Sep 17 00:00:00 2001 From: mask-pp Date: Mon, 3 Aug 2020 19:26:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84rtspclien?= =?UTF-8?q?t=E5=88=9B=E5=BB=BA=E5=BC=80=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 192cb718..45ecd2d3 100644 --- a/main.go +++ b/main.go @@ -136,6 +136,9 @@ func (p *program) Start(s service.Service) (err error) { } for i := len(streams) - 1; i > -1; i-- { v := streams[i] + if rtsp.GetServer().GetPusher(v.CustomPath) != nil { + continue + } agent := fmt.Sprintf("EasyDarwinGo/%s", routers.BuildVersion) if routers.BuildDateTime != "" { agent = fmt.Sprintf("%s(%s)", agent, routers.BuildDateTime) @@ -146,15 +149,12 @@ func (p *program) Start(s service.Service) (err error) { } client.CustomPath = v.CustomPath - pusher := rtsp.NewClientPusher(client) - if rtsp.GetServer().GetPusher(pusher.Path()) != nil { - continue - } err = client.Start(time.Duration(v.IdleTimeout) * time.Second) if err != nil { log.Printf("Pull stream err :%v", err) continue } + pusher := rtsp.NewClientPusher(client) rtsp.GetServer().AddPusher(pusher) //streams = streams[0:i] //streams = append(streams[:i], streams[i+1:]...) From 785f293376e5b03cc5300d4a5effbf93c825401a Mon Sep 17 00:00:00 2001 From: mask-pp Date: Mon, 3 Aug 2020 19:29:49 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtsp/pusher.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rtsp/pusher.go b/rtsp/pusher.go index 962e8512..13263938 100644 --- a/rtsp/pusher.go +++ b/rtsp/pusher.go @@ -354,12 +354,8 @@ func (pusher *Pusher) RemovePlayer(player *Player) *Pusher { func (pusher *Pusher) ClearPlayer() { // copy a new map to avoid deadlock - players := make(map[string]*Player) pusher.playersLock.Lock() - for k, v := range pusher.players { - //v.Stop() - players[k] = v - } + players := pusher.players pusher.players = make(map[string]*Player) pusher.playersLock.Unlock() go func() { // do not block From b37df00d5f0763fcea5ce8b8e1ce565deb6e334a Mon Sep 17 00:00:00 2001 From: mask-pp Date: Mon, 3 Aug 2020 19:39:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtsp/rtsp-session.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rtsp/rtsp-session.go b/rtsp/rtsp-session.go index ed9b077c..6225fe38 100644 --- a/rtsp/rtsp-session.go +++ b/rtsp/rtsp-session.go @@ -249,11 +249,7 @@ func (session *Session) Start() { Buffer: rtpBuf, } default: - logger.Printf("unknow rtp pack type, %v", pack.Type) - continue - } - if pack == nil { - logger.Printf("session tcp got nil rtp pack") + logger.Printf("unknow rtp pack type, %v", channel) continue } session.InBytes += rtpLen + 4 From 1421d6d9da0687d202b6b64463733b7c76920b1f Mon Sep 17 00:00:00 2001 From: mask-pp Date: Mon, 3 Aug 2020 19:58:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtsp/rtsp-client.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rtsp/rtsp-client.go b/rtsp/rtsp-client.go index 37b22182..2b4c3422 100644 --- a/rtsp/rtsp-client.go +++ b/rtsp/rtsp-client.go @@ -48,8 +48,8 @@ type RTSPClient struct { OptionIntervalMillis int64 SDPRaw string - debugLogEnable bool - lastRtpSN uint16 + debugLogEnable bool + lastRtpSN uint16 Agent string authLine string @@ -418,17 +418,13 @@ func (client *RTSPClient) startStream() { client.logger.Printf("unknow rtp pack type, channel:%v", channel) continue } - if pack == nil { - client.logger.Printf("session tcp got nil rtp pack") - continue - } if client.debugLogEnable { rtp := ParseRTP(pack.Buffer.Bytes()) if rtp != nil { rtpSN := uint16(rtp.SequenceNumber) - if client.lastRtpSN != 0 && client.lastRtpSN + 1 != rtpSN { - client.logger.Printf("%s, %d packets lost, current SN=%d, last SN=%d\n", client.String(), rtpSN - client.lastRtpSN, rtpSN, client.lastRtpSN) + if client.lastRtpSN != 0 && client.lastRtpSN+1 != rtpSN { + client.logger.Printf("%s, %d packets lost, current SN=%d, last SN=%d\n", client.String(), rtpSN-client.lastRtpSN, rtpSN, client.lastRtpSN) } client.lastRtpSN = rtpSN }