From 0948a3df310eb388c9cd4489a376005917ad8b31 Mon Sep 17 00:00:00 2001 From: PioLing <964472638@qq.com> Date: Sat, 3 Sep 2022 09:54:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8addStreamProxy?= =?UTF-8?q?=E5=92=8Con=5Fpublish=E4=B8=AD=E6=8E=A7=E5=88=B6=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E6=B5=81=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E8=A6=86=E7=9B=96=20(#1930)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postman/ZLMediaKit.postman_collection.json | 6 ++++++ server/WebApi.cpp | 1 + server/WebHook.cpp | 3 +++ src/Common/MultiMediaSourceMuxer.cpp | 7 ++++--- src/Common/MultiMediaSourceMuxer.h | 3 +++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 19e7b183..e456ed08 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -578,6 +578,12 @@ "value": null, "description": "hls保存根目录,置空使用默认目录", "disabled": true + }, + { + "key": "modify_stamp", + "value": null, + "description": "是否重新计算时间戳", + "disabled": true } ] } diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 83089bc6..b5ab143e 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1007,6 +1007,7 @@ void installWebApi() { getArgsValue(allArgs, "mp4_save_path", option.mp4_save_path); getArgsValue(allArgs, "mp4_max_second", option.mp4_max_second); getArgsValue(allArgs, "hls_save_path", option.hls_save_path); + getArgsValue(allArgs, "modify_stamp", option.modify_stamp); addStreamProxy(allArgs["vhost"], allArgs["app"], diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 58d270fb..0bfd4fda 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -353,6 +353,9 @@ void installWebHook(){ if (obj.isMember("mp4_as_player")) { option.mp4_as_player = obj["mp4_as_player"].asBool(); } + if (obj.isMember("modify_stamp")) { + option.modify_stamp = obj["modify_stamp"].asBool(); + } invoker(err, option); } else { //推流鉴权失败 diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 291f0ef1..a6118f61 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -28,6 +28,7 @@ ProtocolOption::ProtocolOption() { GET_CONFIG(bool, s_add_mute_audio, General::kAddMuteAudio); GET_CONFIG(bool, s_mp4_as_player, Record::kMP4AsPlayer); GET_CONFIG(uint32_t, s_continue_push_ms, General::kContinuePushMS); + GET_CONFIG(bool, s_modify_stamp, General::kModifyStamp); enable_hls = s_to_hls; enable_mp4 = s_to_mp4; @@ -35,6 +36,7 @@ ProtocolOption::ProtocolOption() { add_mute_audio = s_add_mute_audio; continue_push_ms = s_continue_push_ms; mp4_as_player = s_mp4_as_player; + modify_stamp = s_modify_stamp; } static std::shared_ptr makeRecorder(MediaSource &sender, const vector &tracks, Recorder::type type, const string &custom_path, size_t max_second){ @@ -401,9 +403,8 @@ void MultiMediaSourceMuxer::resetTracks() { } bool MultiMediaSourceMuxer::onTrackFrame(const Frame::Ptr &frame_in) { - GET_CONFIG(bool, modify_stamp, General::kModifyStamp); auto frame = frame_in; - if (modify_stamp) { + if (_option.modify_stamp) { //开启了时间戳覆盖 frame = std::make_shared(frame, _stamp[frame->getTrackType()],true); } @@ -471,4 +472,4 @@ bool MultiMediaSourceMuxer::isEnabled(){ return _is_enable; } -}//namespace mediakit \ No newline at end of file +}//namespace mediakit diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index d9ccb368..0dd99d2e 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -57,6 +57,9 @@ public: //断连续推延时,单位毫秒,默认采用配置文件 uint32_t continue_push_ms; + + //时间戳修复这一路流标志位 + bool modify_stamp; }; class MultiMediaSourceMuxer : public MediaSourceEventInterceptor, public MediaSink, public std::enable_shared_from_this{