diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 46231014..08c094ea 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 46231014e2a7ec1903d4a37e96222481ecc779d8 +Subproject commit 08c094ea14f259ecf0c356e6243cb47ee96ce292 diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index deed7c98..ea2031d3 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -122,12 +122,17 @@ private: std::list> _cache; }; -static std::shared_ptr makeRecorder(MediaSource &sender, const vector &tracks, Recorder::type type, const ProtocolOption &option){ - auto recorder = Recorder::createRecorder(type, sender.getMediaTuple(), option); - for (auto &track : tracks) { +std::shared_ptr MultiMediaSourceMuxer::makeRecorder(MediaSource &sender, Recorder::type type) { + auto recorder = Recorder::createRecorder(type, sender.getMediaTuple(), _option); + for (auto &track : getTracks()) { recorder->addTrack(track); } recorder->addTrackCompleted(); + if (_ring) { + _ring->flushGop([&](const Frame::Ptr &frame) { + recorder->inputFrame(frame); + }); + } return recorder; } @@ -305,7 +310,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type // 开始录制 [AUTO-TRANSLATED:36d99250] // Start recording _option.hls_save_path = custom_path; - auto hls = dynamic_pointer_cast(makeRecorder(sender, getTracks(), type, _option)); + auto hls = dynamic_pointer_cast(makeRecorder(sender, type)); if (hls) { // 设置HlsMediaSource的事件监听器 [AUTO-TRANSLATED:69990c92] // Set the event listener for HlsMediaSource @@ -325,7 +330,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type // Start recording _option.mp4_save_path = custom_path; _option.mp4_max_second = max_second; - _mp4 = makeRecorder(sender, getTracks(), type, _option); + _mp4 = makeRecorder(sender, type); } else if (!start && _mp4) { // 停止录制 [AUTO-TRANSLATED:3dee9292] // Stop recording @@ -338,7 +343,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type // 开始录制 [AUTO-TRANSLATED:36d99250] // Start recording _option.hls_save_path = custom_path; - auto hls = dynamic_pointer_cast(makeRecorder(sender, getTracks(), type, _option)); + auto hls = dynamic_pointer_cast(makeRecorder(sender, type)); if (hls) { // 设置HlsMediaSource的事件监听器 [AUTO-TRANSLATED:69990c92] // Set the event listener for HlsMediaSource @@ -354,7 +359,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type } case Recorder::type_fmp4: { if (start && !_fmp4) { - auto fmp4 = dynamic_pointer_cast(makeRecorder(sender, getTracks(), type, _option)); + auto fmp4 = dynamic_pointer_cast(makeRecorder(sender, type)); if (fmp4) { fmp4->setListener(shared_from_this()); } @@ -366,7 +371,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type } case Recorder::type_ts: { if (start && !_ts) { - auto ts = dynamic_pointer_cast(makeRecorder(sender, getTracks(), type, _option)); + auto ts = dynamic_pointer_cast(makeRecorder(sender, type)); if (ts) { ts->setListener(shared_from_this()); } diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index 0ec4de65..cd5279d0 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -232,6 +232,7 @@ protected: private: void createGopCacheIfNeed(); + std::shared_ptr makeRecorder(MediaSource &sender, Recorder::type type); private: bool _is_enable = false;