From 7067472a18675ceed69f402dd4b81b45d4705c0e Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 22 May 2021 10:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=8D=8F=E8=AE=AE=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=85=B3=E9=97=AD=E9=9F=B3=E9=A2=91:#883?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/config.ini | 2 ++ src/Common/MediaSink.cpp | 5 +++++ src/Common/config.cpp | 2 ++ src/Common/config.h | 2 ++ 4 files changed, 11 insertions(+) diff --git a/conf/config.ini b/conf/config.ini index 59a7f06b..0dce3fa6 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -61,6 +61,8 @@ mergeWriteMS=0 modifyStamp=0 #服务器唯一id,用于触发hook时区别是哪台服务器 mediaServerId=your_server_id +#转协议是否全局开启或关闭音频 +enable_audio=1 ###### 以下是按需转协议的开关,在测试ZLMediaKit的接收推流性能时,请把下面开关置1 ###### 如果某种协议你用不到,你可以把以下开关置1以便节省资源(但是还是可以播放,只是第一个播放者体验稍微差点), diff --git a/src/Common/MediaSink.cpp b/src/Common/MediaSink.cpp index be887305..b372b2f2 100644 --- a/src/Common/MediaSink.cpp +++ b/src/Common/MediaSink.cpp @@ -22,6 +22,11 @@ static size_t constexpr kMaxUnreadyFrame = 100; namespace mediakit{ void MediaSink::addTrack(const Track::Ptr &track_in) { + GET_CONFIG(bool, enabel_audio, General::kEnableAudio); + if (!enabel_audio && track_in->getTrackType() == TrackAudio) { + //音频被全局忽略 + return; + } lock_guard lck(_mtx); if (_all_track_ready) { WarnL << "all track is ready, add this track too late!"; diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 47b8177a..0cd509b4 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -74,6 +74,7 @@ const string kRtspDemand = GENERAL_FIELD"rtsp_demand"; const string kRtmpDemand = GENERAL_FIELD"rtmp_demand"; const string kTSDemand = GENERAL_FIELD"ts_demand"; const string kFMP4Demand = GENERAL_FIELD"fmp4_demand"; +const string kEnableAudio = GENERAL_FIELD"enable_audio"; onceToken token([](){ mINI::Instance()[kFlowThreshold] = 1024; @@ -92,6 +93,7 @@ onceToken token([](){ mINI::Instance()[kRtmpDemand] = 0; mINI::Instance()[kTSDemand] = 0; mINI::Instance()[kFMP4Demand] = 0; + mINI::Instance()[kEnableAudio] = 1; },nullptr); diff --git a/src/Common/config.h b/src/Common/config.h index a104a789..9f21fc4a 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -187,6 +187,8 @@ extern const string kRtspDemand; extern const string kRtmpDemand; extern const string kTSDemand; extern const string kFMP4Demand; +//转协议是否全局开启或忽略音频 +extern const string kEnableAudio; }//namespace General