From 1c26851f39e701315b706dd091eac5dd6df3d562 Mon Sep 17 00:00:00 2001 From: qydysky Date: Wed, 12 Jul 2023 09:45:24 +0800 Subject: [PATCH] =?utf8?q?Fix=20#77=20flv=E9=81=87=E5=8D=A1=E9=A1=BF?= =?utf8?q?=E6=A6=82=E7=8E=87=E4=B8=8D=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/stream.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Reply/stream.go b/Reply/stream.go index d6ae8aa..1797d25 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -736,11 +736,12 @@ func (t *M4SStream) saveStreamFlv() (e error) { frameCount = 0 ) defer ticker.Stop() + defer t.Stream_msg.PushLock_tag(`close`, nil) for { n, e := rc.Read(buf) _ = buff.Append(buf[:n]) if e != nil { - t.Stream_msg.PushLock_tag(`close`, nil) + r.Cancel() break } @@ -775,7 +776,12 @@ func (t *M4SStream) saveStreamFlv() (e error) { t.Stream_msg.PushLock_tag(`data`, t.first_buf) t.msg.Push_tag(`load`, t) } - if len(t.first_buf) != 0 && keyframe.Size() != 0 { + if keyframe.Size() != 0 { + if len(t.first_buf) == 0 { + t.log.L(`W: `, `flv未接收到起始段`) + r.Cancel() + break + } t.bootBufPush(keyframe.GetPureBuf()) keyframe.Reset() t.Stream_msg.PushLock_tag(`data`, t.boot_buf) @@ -1099,7 +1105,7 @@ func (t *M4SStream) saveStreamM4s() (e error) { } // 发送空字节会导致流服务终止 - t.Stream_msg.PushLock_tag(`data`, []byte{}) + t.Stream_msg.PushLock_tag(`close`, nil) return } -- 2.39.2