diff --git a/src/Common/config.cpp b/src/Common/config.cpp index fa4a1c44..49f43e7b 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -77,12 +77,15 @@ const string kStreamNoneReaderDelayMS = GENERAL_FIELD"streamNoneReaderDelayMS"; const string kMaxStreamWaitTimeMS = GENERAL_FIELD"maxStreamWaitMS"; const string kEnableVhost = GENERAL_FIELD"enableVhost"; const string kUltraLowDelay = GENERAL_FIELD"ultraLowDelay"; +const string kAddMuteAudio = GENERAL_FIELD"addMuteAudio"; + onceToken token([](){ mINI::Instance()[kFlowThreshold] = 1024; mINI::Instance()[kStreamNoneReaderDelayMS] = 5 * 1000; mINI::Instance()[kMaxStreamWaitTimeMS] = 5 * 1000; mINI::Instance()[kEnableVhost] = 1; mINI::Instance()[kUltraLowDelay] = 1; + mINI::Instance()[kAddMuteAudio] = 1; },nullptr); }//namespace General diff --git a/src/Common/config.h b/src/Common/config.h index d6ab955c..31a27d2d 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -177,6 +177,8 @@ extern const string kMaxStreamWaitTimeMS; extern const string kEnableVhost; //超低延时模式,默认打开,打开后会降低延时但是转发性能会稍差 extern const string kUltraLowDelay; +//拉流代理时是否添加静音音频 +extern const string kAddMuteAudio; }//namespace General diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index 5b821d85..fce309b9 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -244,13 +244,16 @@ void PlayerProxy::onPlaySuccess() { videoTrack->addDelegate(_mediaMuxer); } + //是否添加静音音频 + GET_CONFIG(bool,addMuteAudio,General::kAddMuteAudio); + auto audioTrack = getTrack(TrackAudio, false); if(audioTrack){ //添加音频 _mediaMuxer->addTrack(audioTrack); //音频数据写入_mediaMuxer audioTrack->addDelegate(_mediaMuxer); - }else if(videoTrack){ + }else if(addMuteAudio && videoTrack){ //没有音频信息,产生一个静音音频 MuteAudioMaker::Ptr audioMaker = std::make_shared(); //videoTrack把数据写入MuteAudioMaker