增加多个HTTP API接口,包括addStreamPusherProxy、addWebrtcRoomKeeper、broadcastMessage等,更新API返回结果格式,新增删除和查询WebRTC相关功能,优化记录和流管理接口。

xiongziliang
2026-03-17 20:48:37 +08:00
parent aaef1b5b84
commit b9c6531a7f

@@ -12,43 +12,82 @@ MediaServer是ZLMediaKit的主进程目前支持以下http api接口这些
```ini
"/index/api/addFFmpegSource",
"/index/api/addStreamProxy",
"/index/api/addStreamPusherProxy",
"/index/api/addWebrtcRoomKeeper",
"/index/api/broadcastMessage",
"/index/api/closeRtpServer",
"/index/api/close_stream",
"/index/api/close_streams",
"/index/api/connectRtpServer",
"/index/api/delFFmpegSource",
"/index/api/delStreamProxy",
"/index/api/delStreamPusherProxy",
"/index/api/delWebrtcRoomKeeper",
"/index/api/delete_webrtc",
"/index/api/deleteRecordDirectory",
"/index/api/deleteSnapDirectory",
"/index/api/downloadBin",
"/index/api/downloadFile",
"/index/api/getAllSession",
"/index/api/getApiList",
"/index/api/getMediaInfo",
"/index/api/getMediaList",
"/index/api/getMediaPlayerList",
"/index/api/getMP4RecordFile",
"/index/api/getProxyInfo",
"/index/api/getProxyPusherInfo",
"/index/api/getRtpInfo",
"/index/api/getServerConfig",
"/index/api/getSnap",
"/index/api/getStatistic",
"/index/api/getStreamUrl",
"/index/api/getThreadsLoad",
"/index/api/getWebrtcProxyPlayerInfo",
"/index/api/getWorkThreadsLoad",
"/index/api/isMediaOnline",
"/index/api/isRecording",
"/index/api/kick_session",
"/index/api/kick_sessions",
"/index/api/restartServer",
"/index/api/setServerConfig",
"/index/api/isMediaOnline",
"/index/api/getMediaInfo",
"/index/api/getRtpInfo",
"/index/api/getMp4RecordFile",
"/index/api/startRecord",
"/index/api/stopRecord",
"/index/api/getRecordStatus",
"/index/api/getSnap",
"/index/api/openRtpServer",
"/index/api/closeRtpServer",
"/index/api/listFFmpegSource",
"/index/api/listRtpSender",
"/index/api/listRtpServer",
"/index/api/listStreamProxy",
"/index/api/listStreamPusherProxy",
"/index/api/listWebrtcRoomKeepers",
"/index/api/listWebrtcRooms",
"/index/api/loadMP4File",
"/index/api/login",
"/index/api/logout",
"/index/api/openRtpServer",
"/index/api/openRtpServerMultiplex",
"/index/api/pauseRtpCheck",
"/index/api/restartServer",
"/index/api/resumeRtpCheck",
"/index/api/searchOnvifDevice",
"/index/api/seekRecordStamp",
"/index/api/setRecordSpeed",
"/index/api/setServerConfig",
"/index/api/stack/start",
"/index/api/stack/stop",
"/index/api/stack/reset",
"/index/api/startRecord",
"/index/api/startRecordTask",
"/index/api/startSendRtp",
"/index/api/startSendRtpPassive",
"/index/api/startSendRtpTalk",
"/index/api/stopRecord",
"/index/api/stopSendRtp",
"/index/api/getStatistic",
"/index/api/addStreamPusherProxy",
"/index/api/delStreamPusherProxy",
"/index/api/updateRtpServerSSRC",
"/index/api/version",
"/index/api/getMediaPlayerList"
"/index/api/webrtc",
"/index/api/whip",
"/index/api/whep"
```
其中POST方式参数既可以使用urlencoded方式也可以使用json方式。
操作这些api一般需要提供secret参数以便鉴权如果操作ip是127.0.0.1,那么可以无需鉴权
操作这些api一般需要提供secret参数以便鉴权如果调用/index/api/login接口比并处于已cookie登录状态则无需提供secret参数鉴权
~~如果操作ip是127.0.0.1,那么可以无需鉴权。~~
> 新版本已删除上条机制
## API返回结果约定
@@ -104,62 +143,81 @@ typedef enum {
- 响应:
```json
{
"code": 0,
"data": [
"/index/",
"/index/api/addFFmpegSource",
"/index/api/addStreamProxy",
"/index/api/addStreamPusherProxy",
"/index/api/closeRtpServer",
"/index/api/close_stream",
"/index/api/delFFmpegSource",
"/index/api/delStreamProxy",
"/index/api/delStreamPusherProxy",
"/index/api/downloadBin",
"/index/api/getAllSession",
"/index/api/getApiList",
"/index/api/getMediaInfo",
"/index/api/getMediaList",
"/index/api/getMp4RecordFile",
"/index/api/getRtpInfo",
"/index/api/getServerConfig",
"/index/api/getSnap",
"/index/api/getStatistic",
"/index/api/getThreadsLoad",
"/index/api/getWorkThreadsLoad",
"/index/api/isMediaOnline",
"/index/api/isRecording",
"/index/api/kick_session",
"/index/api/kick_sessions",
"/index/api/listRtpServer",
"/index/api/openRtpServer",
"/index/api/pauseRtpCheck",
"/index/api/restartServer",
"/index/api/resumeRtpCheck",
"/index/api/setServerConfig",
"/index/api/startRecord",
"/index/api/startSendRtp",
"/index/api/stopRecord",
"/index/api/stopSendRtp",
"/index/api/version",
"/index/api/webrtc",
"/index/hook/on_flow_report",
"/index/hook/on_http_access",
"/index/hook/on_play",
"/index/hook/on_publish",
"/index/hook/on_record_hls",
"/index/hook/on_record_mp4",
"/index/hook/on_rtsp_auth",
"/index/hook/on_rtsp_realm",
"/index/hook/on_server_started",
"/index/hook/on_shell_login",
"/index/hook/on_stream_changed",
"/index/hook/on_stream_none_reader",
"/index/hook/on_stream_not_found",
"/index/hook/on_stream_not_found_ffmpeg"
]
}
{
"code": 0,
"data": [
"/index/",
"/index/api/addFFmpegSource",
"/index/api/addStreamProxy",
"/index/api/addStreamPusherProxy",
"/index/api/addWebrtcRoomKeeper",
"/index/api/broadcastMessage",
"/index/api/close_stream",
"/index/api/close_streams",
"/index/api/closeRtpServer",
"/index/api/connectRtpServer",
"/index/api/delete_webrtc",
"/index/api/deleteRecordDirectory",
"/index/api/deleteSnapDirectory",
"/index/api/delFFmpegSource",
"/index/api/delStreamProxy",
"/index/api/delStreamPusherProxy",
"/index/api/delWebrtcRoomKeeper",
"/index/api/downloadBin",
"/index/api/downloadFile",
"/index/api/getAllSession",
"/index/api/getApiList",
"/index/api/getMediaInfo",
"/index/api/getMediaList",
"/index/api/getMediaPlayerList",
"/index/api/getMP4RecordFile",
"/index/api/getProxyInfo",
"/index/api/getProxyPusherInfo",
"/index/api/getRtpInfo",
"/index/api/getServerConfig",
"/index/api/getSnap",
"/index/api/getStatistic",
"/index/api/getStreamUrl",
"/index/api/getThreadsLoad",
"/index/api/getWebrtcProxyPlayerInfo",
"/index/api/getWorkThreadsLoad",
"/index/api/isMediaOnline",
"/index/api/isRecording",
"/index/api/kick_session",
"/index/api/kick_sessions",
"/index/api/listFFmpegSource",
"/index/api/listRtpSender",
"/index/api/listRtpServer",
"/index/api/listStreamProxy",
"/index/api/listStreamPusherProxy",
"/index/api/listWebrtcRoomKeepers",
"/index/api/listWebrtcRooms",
"/index/api/loadMP4File",
"/index/api/login",
"/index/api/logout",
"/index/api/openRtpServer",
"/index/api/openRtpServerMultiplex",
"/index/api/pauseRtpCheck",
"/index/api/restartServer",
"/index/api/resumeRtpCheck",
"/index/api/searchOnvifDevice",
"/index/api/seekRecordStamp",
"/index/api/setRecordSpeed",
"/index/api/setServerConfig",
"/index/api/startRecord",
"/index/api/startRecordTask",
"/index/api/startSendRtp",
"/index/api/startSendRtpPassive",
"/index/api/startSendRtpTalk",
"/index/api/stopRecord",
"/index/api/stopSendRtp",
"/index/api/updateRtpServerSSRC",
"/index/api/version",
"/index/api/webrtc",
"/index/api/whep",
"/index/api/whip"
]
}
```
@@ -823,11 +881,11 @@ typedef enum {
### 19、`/index/api/getMp4RecordFile`
### 19、`/index/api/getMP4RecordFile`
- 功能:搜索文件系统,获取流对应的录像文件列表或日期文件夹列表
- 范例:[http://127.0.0.1/index/api/getMp4RecordFile?vhost=`__defaultVhost__`&app=live&stream=ss&period=2020-01](http://127.0.0.1/index/api/getMp4RecordFile?vhost=__defaultVhost__&app=live&stream=ss&period=2020-01)
- 范例:[http://127.0.0.1/index/api/getMP4RecordFile?vhost=`__defaultVhost__`&app=live&stream=ss&period=2020-01](http://127.0.0.1/index/api/getMP4RecordFile?vhost=__defaultVhost__&app=live&stream=ss&period=2020-01)
- 参数:
@@ -1399,3 +1457,588 @@ typedef enum {
![videostack](https://github.com/ZLMediaKit/ZLMediaKit/assets/44298896/b568aa9b-cb4c-4267-a321-6d93185bcb40)
### 35、`/index/api/deleteSnapDirectory`
- 功能:删除截图文件或文件夹
- 范例:[http://127.0.0.1/index/api/deleteSnapDirectory?vhost=`__defaultVhost__`&app=live&stream=test](http://127.0.0.1/index/api/deleteSnapDirectory?vhost=__defaultVhost__&app=live&stream=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| file | N | 文件名,非必选 |
### 36、`/index/api/deleteRecordDirectory`
- 功能:删除录像文件夹
- 范例:[http://127.0.0.1/index/api/deleteRecordDirectory?vhost=`__defaultVhost__`&app=proxy&stream=2&period=2020-01-01](http://127.0.0.1/index/api/deleteRecordDirectory?vhost=__defaultVhost__&app=proxy&stream=2&period=2020-01-01)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| period | Y | 流的录像日期格式为2020-01-01如果不是完整的日期则删除失败 |
### 37、`/index/api/startRecordTask`
- 功能:开始事件视频录制,支持回溯录制和前向录制
- 范例:[http://127.0.0.1/index/api/startRecordTask?vhost=`__defaultVhost__`&app=live&stream=test&path=1.mp4&back_ms=10000&forward_ms=10000](http://127.0.0.1/index/api/startRecordTask?vhost=__defaultVhost__&app=live&stream=test&path=1.mp4&back_ms=10000&forward_ms=10000)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| path | Y | 录像文件保存相对路径,包括名称 |
| back_ms | Y | 回溯录制时长,单位毫秒 |
| forward_ms | Y | 后续录制时长,单位毫秒 |
### 38、`/index/api/setRecordSpeed`
- 功能:设置录像播放速度
- 范例:[http://127.0.0.1/index/api/setRecordSpeed?vhost=`__defaultVhost__`&app=live&stream=obs&speed=2.0](http://127.0.0.1/index/api/setRecordSpeed?vhost=__defaultVhost__&app=live&stream=obs&speed=2.0)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 obs |
| speed | Y | 要设置的录像倍速float类型 |
### 39、`/index/api/seekRecordStamp`
- 功能:设置录像流播放位置
- 范例:[http://127.0.0.1/index/api/seekRecordStamp?vhost=`__defaultVhost__`&app=live&stream=obs&stamp=1000](http://127.0.0.1/index/api/seekRecordStamp?vhost=__defaultVhost__&app=live&stream=obs&stamp=1000)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 obs |
| stamp | Y | 要设置的录像播放位置 |
### 40、`/index/api/listStreamProxy`
- 功能:获取拉流代理列表
- 范例:[http://127.0.0.1/index/api/listStreamProxy](http://127.0.0.1/index/api/listStreamProxy)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
### 41、`/index/api/listStreamPusherProxy`
- 功能:获取推流代理列表
- 范例:[http://127.0.0.1/index/api/listStreamPusherProxy](http://127.0.0.1/index/api/listStreamPusherProxy)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
### 42、`/index/api/listFFmpegSource`
- 功能获取FFmpeg拉流代理列表
- 范例:[http://127.0.0.1/index/api/listFFmpegSource](http://127.0.0.1/index/api/listFFmpegSource)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
### 43、`/index/api/broadcastMessage`
- 功能广播webrtc datachannel消息
- 范例:[http://127.0.0.1/index/api/broadcastMessage?schema=rtsp&vhost=`__defaultVhost__`&app=live&stream=test&msg=Hello](http://127.0.0.1/index/api/broadcastMessage?schema=rtsp&vhost=__defaultVhost__&app=live&stream=test&msg=Hello)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| schema | Y | 协议,例如 rtsp或rtmp |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| msg | Y | 要广播的消息内容 |
### 44、`/index/api/openRtpServerMultiplex`
- 功能创建多路复用GB28181 RTP接收端口
- 范例:[http://127.0.0.1/index/api/openRtpServerMultiplex?port=0&tcp_mode=1&stream_id=test](http://127.0.0.1/index/api/openRtpServerMultiplex?port=0&tcp_mode=1&stream_id=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| port | Y | 绑定的端口0时为随机端口 |
| tcp_mode | Y | tcp模式0时为不启用tcp监听1时为启用tcp监听 |
| stream_id | Y | 该端口绑定的流id |
| only_track | N | 是否为单音频/单视频track0不设置1单音频2单视频 |
| local_ip | N | 指定创建RTP的本地ipipv4可填"0.0.0.0"ipv6可填"::" |
### 45、`/index/api/connectRtpServer`
- 功能连接RTP服务器tcp主动模式
- 范例:[http://127.0.0.1/index/api/connectRtpServer?dst_url=192.168.1.100&dst_port=10000&stream_id=test](http://127.0.0.1/index/api/connectRtpServer?dst_url=192.168.1.100&dst_port=10000&stream_id=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| dst_url | Y | tcp主动模式时服务端地址 |
| dst_port | Y | tcp主动模式时服务端端口 |
| stream_id | Y | OpenRtpServer时绑定的流id |
### 46、`/index/api/updateRtpServerSSRC`
- 功能更新RTP服务器过滤SSRC
- 范例:[http://127.0.0.1/index/api/updateRtpServerSSRC?stream_id=test&ssrc=123456](http://127.0.0.1/index/api/updateRtpServerSSRC?stream_id=test&ssrc=123456)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| stream_id | Y | 该端口绑定的流id |
| ssrc | Y | 十进制ssrc |
### 47、`/index/api/pauseRtpCheck`
- 功能暂停RTP超时检查
- 范例:[http://127.0.0.1/index/api/pauseRtpCheck?stream_id=test](http://127.0.0.1/index/api/pauseRtpCheck?stream_id=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :------------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| stream_id | Y | 该端口绑定的流id |
| pause_seconds | N | 暂停超时监测后将在pause_seconds时间后恢复 |
### 48、`/index/api/resumeRtpCheck`
- 功能恢复RTP超时检查
- 范例:[http://127.0.0.1/index/api/resumeRtpCheck?stream_id=test](http://127.0.0.1/index/api/resumeRtpCheck?stream_id=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| stream_id | Y | 该端口绑定的流id |
### 49、`/index/api/startSendRtpTalk`
- 功能开始双向对讲作为GB28181客户端启动rtp推流并接收对方rtp流
- 范例:[http://127.0.0.1/index/api/startSendRtpTalk?vhost=`__defaultVhost__`&app=rtp&stream=rtc&ssrc=1&recv_stream_id=test](http://127.0.0.1/index/api/startSendRtpTalk?vhost=__defaultVhost__&app=rtp&stream=rtc&ssrc=1&recv_stream_id=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :-------------------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 rtp |
| stream | Y | 流id例如webrtc推流上来的流id |
| ssrc | Y | rtp推流出去的ssrc |
| recv_stream_id | Y | 对方rtp推流上来的流id通过这个链接回复rtp流两个流的app和vhost需一致 |
| from_mp4 | N | 是否推送本地MP4录像 |
| type | N | 0(ES流)、1(PS流)、2(TS流)默认1(PS流) |
| pt | N | rtp payload type默认96 |
| only_audio | N | rtp es方式打包时是否只打包音频 |
| enable_origin_recv_limit | N | 转发rtp(tcp模式)时,发送不出去是否限制源端收流速度 |
### 50、`/index/api/listRtpSender`
- 功能获取rtp发送列表
- 范例:[http://127.0.0.1/index/api/listRtpSender?vhost=`__defaultVhost__`&app=live&stream=test](http://127.0.0.1/index/api/listRtpSender?vhost=__defaultVhost__&app=live&stream=test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 虚拟主机,例如`__defaultVhost__` |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
### 51、`/index/api/getProxyInfo`
- 功能:获取拉流代理信息
- 范例:[http://127.0.0.1/index/api/getProxyInfo?key=`__defaultVhost__`/live/test](http://127.0.0.1/index/api/getProxyInfo?key=__defaultVhost__/live/test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| key | Y | addStreamProxy接口返回的key |
### 52、`/index/api/getProxyPusherInfo`
- 功能:获取推流代理信息
- 范例:[http://127.0.0.1/index/api/getProxyPusherInfo?key=rtmp/`__defaultVhost__`/live/test/xxx](http://127.0.0.1/index/api/getProxyPusherInfo?key=rtmp/__defaultVhost__/live/test/xxx)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| key | Y | addStreamPusherProxy接口返回的key |
### 53、`/index/api/loadMP4File`
- 功能点播mp4文件生成一个直播流
- 范例:[http://127.0.0.1/index/api/loadMP4File?vhost=`__defaultVhost__`&app=live&stream=test&file_path=/path/to/mp4/file.mp4](http://127.0.0.1/index/api/loadMP4File?vhost=__defaultVhost__&app=live&stream=test&file_path=/path/to/mp4/file.mp4)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| vhost | Y | 添加的流的虚拟主机,例如`__defaultVhost__` |
| app | Y | 添加的流的应用名例如live |
| stream | Y | 添加的流的id名例如test |
| file_path | Y | mp4文件绝对路径 |
| file_repeat | N | 是否循环点播mp4文件如果配置文件已开启循环则此参数无效 |
| seek_ms | N | 点播seek到特定位置单位毫秒 |
| speed | N | 播放速度float类型 |
| `enable_hls` | N | 是否转hls-ts |
| `enable_hls_fmp4`| N | 是否转hls-fmp4 |
| `enable_mp4` | N | 是否mp4录制 |
| `enable_rtsp` | N | 是否转协议为rtsp/webrtc |
| `enable_rtmp` | N | 是否转协议为rtmp/flv |
| `enable_ts` | N | 是否转协议为http-ts/ws-ts |
| `enable_fmp4` | N | 是否转协议为http-fmp4/ws-fmp4 |
| `enable_audio` | N | 转协议是否开启音频 |
| `add_mute_audio` | N | 转协议无音频时是否添加静音aac音频 |
| `mp4_save_path` | N | mp4录制保存根目录置空使用默认目录 |
| `mp4_max_second` | N | mp4录制切片大小单位秒 |
| `hls_save_path` | N | hls保存根目录置空使用默认目录 |
| `modify_stamp` | N | 是否修改原始时间戳(0:绝对时间戳/1:系统时间戳/2:相对时间戳) |
| `auto_close` | N | 无人观看时是否直接关闭(不触发on_none_reader hook) |
### 54、`/index/api/downloadFile`
- 功能:下载文件
- 范例:[http://127.0.0.1/index/api/downloadFile?file_path=/path/to/file.ext](http://127.0.0.1/index/api/downloadFile?file_path=/path/to/file.ext)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| file_path | Y | 文件绝对路径根据文件名生成Content-Type将触发on_http_access hook |
| save_name | N | 浏览器下载文件后保存文件名 |
### 55、`/index/api/downloadBin`
- 功能:下载程序二进制文件
- 范例:[http://127.0.0.1/index/api/downloadBin](http://127.0.0.1/index/api/downloadBin)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
### 56、`/index/api/webrtc`
- 功能WebRTC交互接口
- 范例POST [http://127.0.0.1/index/api/webrtc?type=play&app=live&stream=test](http://127.0.0.1/index/api/webrtc?type=play&app=live&stream=test)
- 请求方法POSTContent-Type: application/jsonbody为SDP offer
- 参数:
| 参数 | 是否必选 | 释意 |
| :------------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| type | Y | webrtc类型play为播放push为推流echo为回显测试 |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| preferred_tcp | N | 是否webrtc over tcp优先模式 |
| cand_udp | N | 指定zlm服务器udp candidate |
| cand_tcp | N | 指定zlm服务器tcp candidate |
### 57、`/index/api/whip`
- 功能WebRTC WHIP标准推流接口
- 范例POST [http://127.0.0.1/index/api/whip?app=live&stream=test](http://127.0.0.1/index/api/whip?app=live&stream=test)
- 请求方法POSTContent-Type: application/sdpbody为SDP offer
- 参数:
| 参数 | 是否必选 | 释意 |
| :------------: | :------: | :----------------------------------------------------------: |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| preferred_tcp | N | 是否webrtc over tcp优先模式 |
| cand_udp | N | 指定zlm服务器udp candidate |
| cand_tcp | N | 指定zlm服务器tcp candidate |
- 响应成功返回201状态码Content-Type: application/sdpbody为SDP answer。响应头中Location字段包含delete_webrtc接口的URL。
### 58、`/index/api/whep`
- 功能WebRTC WHEP标准播放接口
- 范例POST [http://127.0.0.1/index/api/whep?app=live&stream=test](http://127.0.0.1/index/api/whep?app=live&stream=test)
- 请求方法POSTContent-Type: application/sdpbody为SDP offer
- 参数:
| 参数 | 是否必选 | 释意 |
| :------------: | :------: | :----------------------------------------------------------: |
| app | Y | 应用名,例如 live |
| stream | Y | 流id例如 test |
| preferred_tcp | N | 是否webrtc over tcp优先模式 |
| cand_udp | N | 指定zlm服务器udp candidate |
| cand_tcp | N | 指定zlm服务器tcp candidate |
- 响应成功返回201状态码Content-Type: application/sdpbody为SDP answer。响应头中Location字段包含delete_webrtc接口的URL。
### 59、`/index/api/delete_webrtc`
- 功能删除WebRTC连接
- 范例DELETE [http://127.0.0.1/index/api/delete_webrtc?id=xxx&token=xxx](http://127.0.0.1/index/api/delete_webrtc?id=xxx&token=xxx)
- 请求方法DELETE
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| id | Y | WebRTC连接的唯一标识 |
| token | Y | 删除操作的验证token |
- 说明id和token由whip/whep接口返回的Location响应头中获取。
### 60、`/index/api/addWebrtcRoomKeeper`
- 功能注册到WebRTC信令服务器
- 范例:[http://127.0.0.1/index/api/addWebrtcRoomKeeper?server_host=127.0.0.1&server_port=3000&room_id=peer_1](http://127.0.0.1/index/api/addWebrtcRoomKeeper?server_host=127.0.0.1&server_port=3000&room_id=peer_1)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| server_host | Y | 要注册到的信令服务器地址 |
| server_port | Y | 要注册到的信令服务器端口 |
| room_id | Y | 要注册到的roomid |
### 61、`/index/api/delWebrtcRoomKeeper`
- 功能从WebRTC信令服务器注销
- 范例:[http://127.0.0.1/index/api/delWebrtcRoomKeeper?room_key=xxx](http://127.0.0.1/index/api/delWebrtcRoomKeeper?room_key=xxx)
- 参数:
| 参数 | 是否必选 | 释意 |
| :------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| room_key | Y | addWebrtcRoomKeeper接口返回的room_key |
### 62、`/index/api/listWebrtcRoomKeepers`
- 功能查看Peer端的WebRTC注册信息
- 范例:[http://127.0.0.1/index/api/listWebrtcRoomKeepers](http://127.0.0.1/index/api/listWebrtcRoomKeepers)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
### 63、`/index/api/listWebrtcRooms`
- 功能信令服务器查看WebRTC注册信息
- 范例:[http://127.0.0.1/index/api/listWebrtcRooms](http://127.0.0.1/index/api/listWebrtcRooms)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
### 64、`/index/api/getWebrtcProxyPlayerInfo`
- 功能查看WebRTCProxyPlayer连接信息
- 范例:[http://127.0.0.1/index/api/getWebrtcProxyPlayerInfo?key=`__defaultVhost__`/live/test](http://127.0.0.1/index/api/getWebrtcProxyPlayerInfo?key=__defaultVhost__/live/test)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| key | Y | 流的唯一标识 |
### 65、`/index/api/searchOnvifDevice`
- 功能搜索Onvif设备
- 范例:[http://127.0.0.1/index/api/searchOnvifDevice?timeout_ms=5000](http://127.0.0.1/index/api/searchOnvifDevice?timeout_ms=5000)
- 参数:
| 参数 | 是否必选 | 释意 |
| :------------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| timeout_ms | N | 搜索超时时间,单位毫秒 |
| subnet_prefix | N | 子网前缀,例如 192.168.1 |
### 66、`/index/api/getStreamUrl`
- 功能获取Onvif设备的流URL
- 范例:[http://127.0.0.1/index/api/getStreamUrl?onvif_url=http://xxxx/onvif/device_service](http://127.0.0.1/index/api/getStreamUrl?onvif_url=http://xxxx/onvif/device_service)
- 参数:
| 参数 | 是否必选 | 释意 |
| :--------: | :------: | :----------------------------------------------------------: |
| secret | Y | api操作密钥(配置文件配置) |
| onvif_url | Y | Onvif设备的service地址 |
### 67、`/index/api/login`
- 功能:登录接口
- 范例:[http://127.0.0.1/index/api/login?digest=xxx](http://127.0.0.1/index/api/login?digest=xxx)
- 参数:
| 参数 | 是否必选 | 释意 |
| :----: | :------: | :----------------------------------------------------------: |
| digest | Y | MD5("zlmediakit:" + ${secret} + ":" + ${cookie}) |
- 注意:**配置文件api.legacyAuth须设置为0**
### 68、`/index/api/logout`
- 功能:登出接口
- 范例:[http://127.0.0.1/index/api/logout](http://127.0.0.1/index/api/logout)
- 参数:无