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;