mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
删除无效的hook api
This commit is contained in:
parent
380887c5d3
commit
10663fd3b4
@ -151,43 +151,43 @@ fastRegister=0
|
||||
#是否启用hook事件,启用后,推拉流都将进行鉴权
|
||||
enable=0
|
||||
#播放器或推流器使用流量事件,置空则关闭
|
||||
on_flow_report=https://127.0.0.1/index/hook/on_flow_report
|
||||
on_flow_report=
|
||||
#访问http文件鉴权事件,置空则关闭鉴权
|
||||
on_http_access=https://127.0.0.1/index/hook/on_http_access
|
||||
on_http_access=
|
||||
#播放鉴权事件,置空则关闭鉴权
|
||||
on_play=https://127.0.0.1/index/hook/on_play
|
||||
on_play=
|
||||
#推流鉴权事件,置空则关闭鉴权
|
||||
on_publish=https://127.0.0.1/index/hook/on_publish
|
||||
on_publish=
|
||||
#录制mp4切片完成事件
|
||||
on_record_mp4=https://127.0.0.1/index/hook/on_record_mp4
|
||||
on_record_mp4=
|
||||
# 录制 hls ts(或fmp4) 切片完成事件
|
||||
on_record_ts=https://127.0.0.1/index/hook/on_record_ts
|
||||
on_record_ts=
|
||||
#rtsp播放鉴权事件,此事件中比对rtsp的用户名密码
|
||||
on_rtsp_auth=https://127.0.0.1/index/hook/on_rtsp_auth
|
||||
on_rtsp_auth=
|
||||
#rtsp播放是否开启专属鉴权事件,置空则关闭rtsp鉴权。rtsp播放鉴权还支持url方式鉴权
|
||||
#建议开发者统一采用url参数方式鉴权,rtsp用户名密码鉴权一般在设备上用的比较多
|
||||
#开启rtsp专属鉴权后,将不再触发on_play鉴权事件
|
||||
on_rtsp_realm=https://127.0.0.1/index/hook/on_rtsp_realm
|
||||
on_rtsp_realm=
|
||||
#远程telnet调试鉴权事件
|
||||
on_shell_login=https://127.0.0.1/index/hook/on_shell_login
|
||||
on_shell_login=
|
||||
#直播流注册或注销事件
|
||||
on_stream_changed=https://127.0.0.1/index/hook/on_stream_changed
|
||||
on_stream_changed=
|
||||
#过滤on_stream_changed hook的协议类型,可以选择只监听某些感兴趣的协议;置空则不过滤协议
|
||||
stream_changed_schemas=rtsp/rtmp/fmp4/ts/hls/hls.fmp4
|
||||
#无人观看流事件,通过该事件,可以选择是否关闭无人观看的流。配合general.streamNoneReaderDelayMS选项一起使用
|
||||
on_stream_none_reader=https://127.0.0.1/index/hook/on_stream_none_reader
|
||||
on_stream_none_reader=
|
||||
#播放时,未找到流事件,通过配合hook.on_stream_none_reader事件可以完成按需拉流
|
||||
on_stream_not_found=https://127.0.0.1/index/hook/on_stream_not_found
|
||||
on_stream_not_found=
|
||||
#服务器启动报告,可以用于服务器的崩溃重启事件监听
|
||||
on_server_started=https://127.0.0.1/index/hook/on_server_started
|
||||
on_server_started=
|
||||
#服务器退出报告,当服务器正常退出时触发
|
||||
on_server_exited=https://127.0.0.1/index/hook/on_server_exited
|
||||
on_server_exited=
|
||||
#server保活上报
|
||||
on_server_keepalive=https://127.0.0.1/index/hook/on_server_keepalive
|
||||
on_server_keepalive=
|
||||
#发送rtp(startSendRtp)被动关闭时回调
|
||||
on_send_rtp_stopped=https://127.0.0.1/index/hook/on_send_rtp_stopped
|
||||
on_send_rtp_stopped=
|
||||
#rtp server 超时未收到数据
|
||||
on_rtp_server_timeout=https://127.0.0.1/index/hook/on_rtp_server_timeout
|
||||
on_rtp_server_timeout=
|
||||
|
||||
#hook api最大等待回复时间,单位秒
|
||||
timeoutSec=10
|
||||
|
@ -1808,162 +1808,6 @@ void installWebApi() {
|
||||
// sample_ms设置为0,从配置文件加载;file_repeat可以指定,如果配置文件也指定循环解复用,那么强制开启
|
||||
reader->startReadMP4(0, true, allArgs["file_repeat"]);
|
||||
});
|
||||
|
||||
////////////以下是注册的Hook API////////////
|
||||
api_regist("/index/hook/on_publish",[](API_ARGS_JSON){
|
||||
//开始推流事件
|
||||
//转换hls
|
||||
val["enable_hls"] = true;
|
||||
//不录制mp4
|
||||
val["enable_mp4"] = false;
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_play",[](API_ARGS_JSON){
|
||||
//开始播放事件
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_flow_report",[](API_ARGS_JSON){
|
||||
//流量统计hook api
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_rtsp_realm",[](API_ARGS_JSON){
|
||||
//rtsp是否需要鉴权,默认需要鉴权
|
||||
val["code"] = API::Success;
|
||||
val["realm"] = "zlmediakit_reaml";
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_rtsp_auth",[](API_ARGS_JSON){
|
||||
//rtsp鉴权密码,密码等于用户名
|
||||
//rtsp可以有双重鉴权!后面还会触发on_play事件
|
||||
CHECK_ARGS("user_name");
|
||||
val["code"] = API::Success;
|
||||
val["encrypted"] = false;
|
||||
val["passwd"] = allArgs["user_name"].data();
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_stream_changed",[](API_ARGS_JSON){
|
||||
//媒体注册或反注册事件
|
||||
});
|
||||
|
||||
|
||||
#if !defined(_WIN32)
|
||||
api_regist("/index/hook/on_stream_not_found_ffmpeg",[](API_ARGS_MAP_ASYNC){
|
||||
//媒体未找到事件,我们都及时拉流hks作为替代品,目的是为了测试按需拉流
|
||||
CHECK_SECRET();
|
||||
CHECK_ARGS("vhost","app","stream");
|
||||
//通过FFmpeg按需拉流
|
||||
GET_CONFIG(int,rtmp_port,Rtmp::kPort);
|
||||
GET_CONFIG(int,timeout_sec,Hook::kTimeoutSec);
|
||||
|
||||
string dst_url = StrPrinter
|
||||
<< "rtmp://127.0.0.1:"
|
||||
<< rtmp_port << "/"
|
||||
<< allArgs["app"] << "/"
|
||||
<< allArgs["stream"] << "?vhost="
|
||||
<< allArgs["vhost"];
|
||||
|
||||
addFFmpegSource("", "http://hls-ott-zhibo.wasu.tv/live/272/index.m3u8",/** ffmpeg拉流支持任意编码格式任意协议 **/
|
||||
dst_url,
|
||||
(1000 * timeout_sec) - 500,
|
||||
false,
|
||||
false,
|
||||
[invoker,val,headerOut](const SockException &ex,const string &key) mutable{
|
||||
if(ex){
|
||||
val["code"] = API::OtherFailed;
|
||||
val["msg"] = ex.what();
|
||||
}else{
|
||||
val["data"]["key"] = key;
|
||||
}
|
||||
invoker(200, headerOut, val.toStyledString());
|
||||
});
|
||||
});
|
||||
#endif//!defined(_WIN32)
|
||||
|
||||
api_regist("/index/hook/on_stream_not_found",[](API_ARGS_MAP_ASYNC){
|
||||
//媒体未找到事件,我们都及时拉流hks作为替代品,目的是为了测试按需拉流
|
||||
CHECK_SECRET();
|
||||
CHECK_ARGS("vhost","app","stream", "schema");
|
||||
|
||||
ProtocolOption option;
|
||||
option.enable_hls = allArgs["schema"] == HLS_SCHEMA;
|
||||
option.enable_mp4 = false;
|
||||
|
||||
//通过内置支持的rtsp/rtmp按需拉流
|
||||
addStreamProxy(allArgs["vhost"],
|
||||
allArgs["app"],
|
||||
allArgs["stream"],
|
||||
/** 支持rtsp和rtmp方式拉流 ,rtsp支持h265/h264/aac,rtmp仅支持h264/aac **/
|
||||
"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov",
|
||||
-1,/*无限重试*/
|
||||
option,
|
||||
0,//rtp over tcp方式拉流
|
||||
10,//10秒超时
|
||||
mINI{},
|
||||
[invoker,val,headerOut](const SockException &ex,const string &key) mutable{
|
||||
if(ex){
|
||||
val["code"] = API::OtherFailed;
|
||||
val["msg"] = ex.what();
|
||||
}else{
|
||||
val["data"]["key"] = key;
|
||||
}
|
||||
invoker(200, headerOut, val.toStyledString());
|
||||
});
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_record_mp4",[](API_ARGS_JSON){
|
||||
//录制mp4分片完毕事件
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_shell_login",[](API_ARGS_JSON){
|
||||
//shell登录调试事件
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_stream_none_reader",[](API_ARGS_JSON){
|
||||
//无人观看流默认关闭
|
||||
val["close"] = true;
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_send_rtp_stopped",[](API_ARGS_JSON){
|
||||
//发送rtp(startSendRtp)被动关闭时回调
|
||||
});
|
||||
|
||||
static auto checkAccess = [](const string ¶ms){
|
||||
//我们假定大家都要权限访问
|
||||
return true;
|
||||
};
|
||||
|
||||
api_regist("/index/hook/on_http_access",[](API_ARGS_MAP){
|
||||
//在这里根据allArgs["params"](url参数)来判断该http客户端是否有权限访问该文件
|
||||
if(!checkAccess(allArgs["params"])){
|
||||
//无访问权限
|
||||
val["err"] = "无访问权限";
|
||||
//仅限制访问当前目录
|
||||
val["path"] = "";
|
||||
//标记该客户端无权限1分钟
|
||||
val["second"] = 60;
|
||||
return;
|
||||
}
|
||||
|
||||
//可以访问
|
||||
val["err"] = "";
|
||||
//只能访问当前目录
|
||||
val["path"] = "";
|
||||
//该http客户端用户被授予10分钟的访问权限,该权限仅限访问当前目录
|
||||
val["second"] = 10 * 60;
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_server_started",[](API_ARGS_JSON){
|
||||
//服务器重启报告
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_server_keepalive",[](API_ARGS_JSON){
|
||||
//心跳hook
|
||||
});
|
||||
|
||||
api_regist("/index/hook/on_rtp_server_timeout",[](API_ARGS_JSON){
|
||||
//rtp server 超时
|
||||
TraceL <<allArgs.getArgs().toStyledString();
|
||||
});
|
||||
}
|
||||
|
||||
void unInstallWebApi(){
|
||||
|
Loading…
Reference in New Issue
Block a user