From 077566d1e16653f6338e0c301c3344c14a158c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Sat, 8 Jul 2023 21:32:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=94=AF=E6=8C=81on=5Fpublis?= =?UTF-8?q?h=20hook=E8=BF=94=E5=9B=9Estream=5Freplace=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E6=B5=81id=20(#2641)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MediaSource.h | 4 ++++ src/Common/MultiMediaSourceMuxer.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index 3438e350..0f58456d 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -187,6 +187,9 @@ public: //hls录制保存路径 std::string hls_save_path; + // 支持通过on_publish返回值替换stream_id + std::string stream_replace; + template ProtocolOption(const MAP &allArgs) : ProtocolOption() { #define GET_OPT_VALUE(key) getArgsValue(allArgs, #key, key) @@ -214,6 +217,7 @@ public: GET_OPT_VALUE(mp4_save_path); GET_OPT_VALUE(hls_save_path); + GET_OPT_VALUE(stream_replace); } private: diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index f70bc2a1..40fb1eb6 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -80,6 +80,10 @@ std::string MultiMediaSourceMuxer::shortUrl() const { } MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_sec, const ProtocolOption &option): _tuple(tuple) { + if (!option.stream_replace.empty()) { + // 支持在on_publish hook中替换stream_id + _tuple.stream = option.stream_replace; + } _poller = EventPollerPool::Instance().getPoller(); _create_in_poller = _poller->isCurrentThread(); _option = option;