mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-21 01:13:37 +08:00
添加配置项,控制在关闭hook时,推流是否转协议或录制
This commit is contained in:
parent
9b7d62347e
commit
a8a4f267f7
@ -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性能
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,10 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user