diff --git a/conf/config.ini b/conf/config.ini index 048971f2..937ff6d2 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -36,6 +36,12 @@ addMuteAudio=1 #拉流代理时如果断流再重连成功是否删除前一次的媒体流数据,如果删除将重新开始, #如果不删除将会接着上一次的数据继续写(录制hls/mp4时会继续在前一个文件后面写) resetWhenRePlay=1 +#是否默认推流时转换成rtsp或rtmp,hook接口(on_publish中可以覆盖该设置) +publishToRtxp=1 +#是否默认推流时转换成hls,hook接口(on_publish中可以覆盖该设置) +publishToHls=1 +#是否默认推流时mp4录像,hook接口(on_publish中可以覆盖该设置) +publishToMP4=0 [hls] #hls写文件的buf大小,调整参数可以提高文件io性能 diff --git a/server/WebHook.cpp b/server/WebHook.cpp index e4c8945e..1391d10a 100644 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -195,7 +195,10 @@ void installWebHook(){ NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastMediaPublish,[](BroadcastMediaPublishArgs){ if(!hook_enable || args._param_strs == hook_adminparams || hook_publish.empty() || sender.get_peer_ip() == "127.0.0.1"){ - invoker("",true, true,false); + GET_CONFIG(bool,toRtxp,General::kPublishToRtxp); + GET_CONFIG(bool,toHls,General::kPublishToHls); + GET_CONFIG(bool,toMP4,General::kPublishToMP4); + invoker("",toRtxp,toHls,toMP4); return; } //异步执行该hook api,防止阻塞NoticeCenter diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 8991d768..39336e69 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -79,6 +79,9 @@ const string kEnableVhost = GENERAL_FIELD"enableVhost"; const string kUltraLowDelay = GENERAL_FIELD"ultraLowDelay"; const string kAddMuteAudio = GENERAL_FIELD"addMuteAudio"; const string kResetWhenRePlay = GENERAL_FIELD"resetWhenRePlay"; +const string kPublishToRtxp = GENERAL_FIELD"publishToRtxp"; +const string kPublishToHls = GENERAL_FIELD"publishToHls"; +const string kPublishToMP4 = GENERAL_FIELD"publishToMP4"; onceToken token([](){ mINI::Instance()[kFlowThreshold] = 1024; @@ -88,6 +91,9 @@ onceToken token([](){ mINI::Instance()[kUltraLowDelay] = 1; mINI::Instance()[kAddMuteAudio] = 1; mINI::Instance()[kResetWhenRePlay] = 1; + mINI::Instance()[kPublishToRtxp] = 1; + mINI::Instance()[kPublishToHls] = 1; + mINI::Instance()[kPublishToMP4] = 0; },nullptr); }//namespace General diff --git a/src/Common/config.h b/src/Common/config.h index 5658bd53..13abe95c 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -182,6 +182,12 @@ extern const string kAddMuteAudio; //拉流代理时如果断流再重连成功是否删除前一次的媒体流数据,如果删除将重新开始, //如果不删除将会接着上一次的数据继续写(录制hls/mp4时会继续在前一个文件后面写) extern const string kResetWhenRePlay; +//是否默认推流时转换成rtsp或rtmp,hook接口(on_publish中可以覆盖该设置) +extern const string kPublishToRtxp ; +//是否默认推流时转换成hls,hook接口(on_publish中可以覆盖该设置) +extern const string kPublishToHls ; +//是否默认推流时mp4录像,hook接口(on_publish中可以覆盖该设置) +extern const string kPublishToMP4 ; }//namespace General diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 62787b1d..e946d275 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -198,7 +198,10 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) { *this); if(!flag){ //该事件无人监听,默认鉴权成功 - onRes("",true,true,false); + GET_CONFIG(bool,toRtxp,General::kPublishToRtxp); + GET_CONFIG(bool,toHls,General::kPublishToHls); + GET_CONFIG(bool,toMP4,General::kPublishToMP4); + onRes("",toRtxp,toHls,toMP4); } } diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 3985ebec..14e2b89a 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -324,8 +324,11 @@ void RtspSession::handleReq_RECORD(const Parser &parser){ auto flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaPublish,_mediaInfo,invoker,*this); if(!flag){ //该事件无人监听,默认不鉴权 - onRes("",true,true,false); - } + GET_CONFIG(bool,toRtxp,General::kPublishToRtxp); + GET_CONFIG(bool,toHls,General::kPublishToHls); + GET_CONFIG(bool,toMP4,General::kPublishToMP4); + onRes("",toRtxp,toHls,toMP4); + } } void RtspSession::handleReq_Describe(const Parser &parser) {