From 2adc12c4ab98a0b6334dd318bc961265527c1502 Mon Sep 17 00:00:00 2001 From: cqm Date: Thu, 27 Jul 2023 17:59:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AA=E6=9C=89aac?= =?UTF-8?q?=E7=9A=84Rtmp=E6=B5=81=E6=97=A0=E6=B3=95=E6=B3=A8=E5=86=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MultiMediaSourceMuxer.cpp | 2 +- src/Rtmp/RtmpMediaSourceMuxer.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index f7104e0b..11b51236 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -623,7 +623,7 @@ bool MultiMediaSourceMuxer::onTrackFrame(const Frame::Ptr &frame_in) { } else if (frame->getTrackType() == TrackAudio) { if (rtmp) { - if (_audio_dec && rtmp->readerCount()) + if (_audio_dec && (rtmp->readerCount() || !rtmp->isRegisted())) _audio_dec->inputFrame(frame, true, false, false); rtmp = nullptr; } diff --git a/src/Rtmp/RtmpMediaSourceMuxer.h b/src/Rtmp/RtmpMediaSourceMuxer.h index 3f6b8bd4..8b3d7a20 100644 --- a/src/Rtmp/RtmpMediaSourceMuxer.h +++ b/src/Rtmp/RtmpMediaSourceMuxer.h @@ -43,7 +43,11 @@ public: int readerCount() const{ return _media_src->readerCount(); } - + bool isRegisted() const { return _is_registed; } + void onRegist(MediaSource& sender, bool regist) override { + MediaSourceEventInterceptor::onRegist(sender, regist); + _is_registed = regist; + } void addTrackCompleted() override { RtmpMuxer::addTrackCompleted(); makeConfigPacket(); @@ -76,6 +80,7 @@ public: private: bool _enabled = true; + bool _is_registed = false; bool _clear_cache = false; ProtocolOption _option; RtmpMediaSource::Ptr _media_src;