From 9bf48567b237dc312fbbac466b884b773342365b Mon Sep 17 00:00:00 2001 From: cqm Date: Mon, 16 Oct 2023 09:32:26 +0800 Subject: [PATCH] fixed issue #2874, thanks quxiaohui-debug --- webrtc/RtcMediaSource.cpp | 7 ++++++- webrtc/RtcMediaSource.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/webrtc/RtcMediaSource.cpp b/webrtc/RtcMediaSource.cpp index 6b050daa..40af113c 100644 --- a/webrtc/RtcMediaSource.cpp +++ b/webrtc/RtcMediaSource.cpp @@ -89,7 +89,7 @@ bool RtcMediaSourceMuxer::inputFrame(const Frame::Ptr &frame) addTrack(track); if (!_audio_dec) return false; } - if (readerCount()) { + if (readerCount() || !_regist) { _audio_dec->inputFrame(frame, true, false); if (!_count) InfoL << "start transcode " << frame->getCodecName() << "," << frame->pts() << "->Opus"; @@ -108,6 +108,11 @@ bool RtcMediaSourceMuxer::inputFrame(const Frame::Ptr &frame) } #if defined(ENABLE_FFMPEG) +void RtcMediaSourceMuxer::onRegist(MediaSource &sender, bool regist) +{ + MediaSourceEventInterceptor::onRegist(sender, regist); + _regist = regist; +} bool RtcMediaSourceMuxer::addTrack(const Track::Ptr & track) { diff --git a/webrtc/RtcMediaSource.h b/webrtc/RtcMediaSource.h index 73109d10..342dcb41 100644 --- a/webrtc/RtcMediaSource.h +++ b/webrtc/RtcMediaSource.h @@ -46,11 +46,13 @@ public: #if defined(ENABLE_FFMPEG) ~RtcMediaSourceMuxer() override{resetTracks();} + void onRegist(MediaSource &sender, bool regist) override; bool addTrack(const Track::Ptr & track) override; void resetTracks() override; private: int _count = 0; + bool _regist = false; std::shared_ptr _audio_dec; std::shared_ptr _audio_enc; #endif