ZLMediaKit http api and webhook implement.
-
0.
/index/api/getApiList获取API列表 -
1.
/index/api/getThreadsLoad获取各 epoll(或 select)线程负载以及延时 -
2.
/index/api/getWorkThreadsLoad获取各后台 epoll(或 select)线程负载以及延时 -
3.
/index/api/getServerConfig获取服务器配置 -
4.
/index/api/setServerConfig设置服务器配置 -
5.
/index/api/restartServer重启服务器, 只有Daemon方式才能重启, 否则是直接关闭! -
6.
/index/api/getMediaList获取流列表, 可选筛选参数 -
7.
关闭流(已过期, 请使用close_streams接口替换)/index/api/close_stream -
8.
/index/api/close_streams关闭流(目前所有类型的流都支持关闭), 有人在观看是否强制关闭 -
9.
/index/api/getAllSession获取所有TcpSession列表(获取所有tcp客户端相关信息) -
10.
/index/api/kick_session断开tcp连接, 比如说可以断开rtsp、rtmp播放器等 -
11.
/index/api/kick_sessions断开tcp连接, 比如说可以断开rtsp、rtmp播放器等 -
12.
/index/api/addStreamProxy动态添加拉流代理rtsp/rtmp/hls/http-ts/http-flv(只支持 H264/H265/aac/G711/opus 负载) -
13.
/index/api/delStreamProxy关闭拉流代理(流注册成功后, 也可以使用close_streams接口替代) -
13.1.
/index/api/listStreamProxy获取拉流代理列表 -
13.2.
/index/api/getProxyInfo获取拉流代理信息 -
14.
/index/api/addFFmpegSource通过 fork FFmpeg 进程的方式拉流代理, 支持任意协议 -
15.
/index/api/delFFmpegSource关闭 ffmpeg 拉流代理(流注册成功后, 也可以使用close_streams接口替代) -
15.1
/index/api/listFFmpegSource获取FFmpeg代理 -
16.
判断直播流是否在线(已过期, 请使用getMediaList接口替代)/index/api/isMediaOnline -
17.
获取流相关信息(已过期, 请使用getMediaList接口替代)/index/api/getMediaInfo -
18.
/index/api/getRtpInfo获取rtp推流信息 -
19.
/index/api/getMp4RecordFile搜索文件系统, 获取流对应的录像文件列表或日期文件夹列表 -
20.
/index/api/startRecord开始录制hls或MP4 -
21.
/index/api/stopRecord停止录制流 -
22.
/index/api/isRecording获取流录制状态 -
22.1.
/index/api/deleteRecordDirectory删除录像文件夹 -
23.
/index/api/getSnap获取截图或生成实时截图并返回 -
24.
/index/api/openRtpServer创建GB28181 RTP 接收端口, 如果该端口接收数据超时, 则会自动被回收(不用调用 closeRtpServer 接口) -
25.
/index/api/closeRtpServer关闭 GB28181 RTP接收端口 -
26.
/index/api/listRtpServer获取 openRtpServer 接口创建的所有 RTP 服务器 -
27.
/index/api/startSendRtp作为GB28181客户端, 启动 ps-rtp 推流, 支持rtp/udp方式. -
28.
/index/api/stopSendRtp作为GB28181客户端, 停止GB28181 ps-rtp 推流 -
29.
/index/api/getStatistic获取主要对象个数统计, 主要用于分析内存性能. -
30.
/index/api/addStreamPusherProxy添加rtsp/rtmp主动推流代理(把本服务器的直播流推送到其他服务器去) -
31.
/index/api/delStreamPusherProxy关闭推流代理(可以使用close_streams接口关闭源直播流也可以停止推流) -
31.1
/index/api/listStreamPusherProxy获取推流代理列表 -
31.2
/index/api/getProxyPusherInfo获取推流代理信息 -
32.
index/api/version获取版本信息, 如分支, commit id, 编译时间 -
33.
/index/api/getMediaPlayerList获取某个流观看者列表 -
100.
/index/api/downloadFile下载文件, 直接下载, 建议加鉴权, 避免任意文件被下载.file_path(必选参数): 文件绝对路径, 根据文件名生成Content-Type该接口将触发on_http_access hook.save_name(可选参数): 浏览器下载文件后保存文件名.
Link: WebHook api
-
on_flow_report流量统计事件 -
on_http_access访问http文件服务器上hls之外的文件时触发 -
on_play播放器鉴权事件(如果rtsp启用专有鉴权, 将不会触发该事件) -
on_publish推流鉴权事件 -
on_record_mp4录制mp4完成后通知事件; 此事件对回复不敏感. -
on_record_ts录制hls完成后通知事件; 此事件对回复不敏感. -
on_rtp_server_timeout调用openRtpServer接口, rtp server长时间未收到数据, 执行此 web hook, 对回复不敏感. -
on_send_rtp_stopped发送rtp(startSendRtp)被动关闭时回调 -
on_rtsp_authrtsp专用的鉴权事件, 先触发on_rtsp_realm事件然后才会触发on_rtsp_auth事件. -
on_rtsp_realm该rtsp流是否开启rtsp专用方式的鉴权事件, 开启后才会触发on_rtsp_auth事件 -
on_shell_loginshell登录鉴权, telnet调试方式 -
on_stream_changedrtsp/rtmp 流注册或注销时触发此事件; 此事件对回复不敏感. -
on_stream_none_reader流无人观看时事件 -
on_stream_not_found流未找到事件 -
on_server_started服务器启动事件 -
on_server_exited服务器退出事件 -
on_server_keepalive服务器定时上报, 上报间隔可配置, 默认10s上报一次
详细查看原文档: 播放url规则
以rtsp://somedomain.com:554/live/0?token=abcdefg&field=value为例,该url分为以下几个部分:
- 协议(
schema): rtsp 协议, 默认端口 554 - 虚拟主机(
vhost):somedomain.com, 该字段既可以是域名也可以是ip, 如果是ip则对应的虚拟主机为__defaultVhost__ - 服务端口号(
port): 554, 如果不指定端口号, 则使用协议默认端口号 - 应用名(
app): live - 流id(
streamid): 0 - 参数(
args):token=abcdefg&field=value
在ZLMediaKit中, 流媒体源是一种可以被用于直播转发、推流转发等功能的数据对象, 在本项目中被称作为MediaSource, 目前支持 5 种类型的流媒体源, 分别是RtspMediaSource、RtmpMediaSource、HlsMediaSource、TSMediaSource、FMP4MediaSource.
定位一个流媒体源, 主要通过4个元素(我们后续称其为4元组), 分别是:
- 协议(
scheam) - 虚拟主机(
vhost) - 应用名(
app) - 流id(
streamid)
RtspMediaSource支持 rtsp 播放、rtsp 推流、webrtc 播放、webrtc 推流.
RtmpMediaSource支持 rtmp 推流/播放、http-flv 播放、ws-flv 播放.
HlsMediaSource支持 hls 播放.
TSMediaSource 支持 http-ts 播放、ws-ts 播放.
FMP4MediaSource支持 http-fmp4 播放、ws-fmp4 播放.
rtsp://<username>:<password>@<ip>:<port>/cam/realmonitor?channel=<channel>&subtype=<subtype>
username: 登录用户名password: 登录密码ip: 摄像头ip地址port: 摄像头端口号, 默认554可省略channel: 通道号, 通常从1开始,subtype: 码流类型, 一般为0表示主码流(高清),1表示子码流(低码率).
rtsp://<username>:<password>@<ip>:<port>/Streaming/Channels/<channel>0<stream>
username: 登录用户名password: 登录密码ip: 摄像头ip地址port: 摄像头端口号, 默认554可省略channel: 通道号(1表示第一路, 2表示第二路)stream: 码流类型(1表示主码流, 2表示子码流)