From 928e12c48b05827fa52d805e7d9a06afd83e0453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Thu, 24 Oct 2019 11:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0getWorkThreadsLoad=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MediaServer支持的HTTP-API.md | 235 ++++++++++++++++++++--------------- 1 file changed, 134 insertions(+), 101 deletions(-) diff --git a/MediaServer支持的HTTP-API.md b/MediaServer支持的HTTP-API.md index 57a030c..5d3c57e 100644 --- a/MediaServer支持的HTTP-API.md +++ b/MediaServer支持的HTTP-API.md @@ -1,4 +1,5 @@ ## API预览 + MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些接口全部支持GET/POST方式, ``` @@ -12,6 +13,7 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 "/index/api/getMediaList", "/index/api/getServerConfig", "/index/api/getThreadsLoad", + "/index/api/getWorkThreadsLoad", "/index/api/kick_session", "/index/api/restartServer", "/index/api/setServerConfig", @@ -48,23 +50,50 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 ] } ``` - + -### 2、`/index/api/getServerConfig` +### 2、`/index/api/getWorkThreadsLoad` + + - 功能:获取各后台epoll(或select)线程负载以及延时 + + - 范例:[http://127.0.0.1/index/api/getWorkThreadsLoad](http://127.0.0.1/index/api/getWorkThreadsLoad) + + - 参数:无 + + - 响应: + + ```json + { + "data" : [ + { + "delay" : 0, #该线程延时 + "load" : 0 #该线程负载,0 ~ 100 + }, + { + "delay" : 0, + "load" : 0 + } + ] + } + ``` + + + +### 3、`/index/api/getServerConfig` - 功能:获取服务器配置 - 范例:[http://127.0.0.1/index/api/getServerConfig](http://127.0.0.1/index/api/getServerConfig) - + - 参数: - + | 参数 | 是否必选 | 释意 | | :----: | :------: | :----------------------------------------------------------: | | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - + - 响应: - + ```json { "code" : 0, @@ -134,20 +163,21 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 ] } ``` - + - -### 3、`/index/api/setServerConfig` + +### 4、`/index/api/setServerConfig` - 功能:设置服务器配置 + - 范例:[http://127.0.0.1/index/api/setServerConfig?api.apiDebug=0(例如关闭http api调试)](http://127.0.0.1/index/api/setServerConfig?api.apiDebug=0) - 参数: - - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - + + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + - 响应: ```json @@ -156,11 +186,10 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 "code" : 0 #0代表成功 } ``` - -### 4、`/index/api/restartServer` +### 5、`/index/api/restartServer` - 功能:重启服务器,只有Daemon方式才能重启,否则是直接关闭! @@ -168,9 +197,9 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - 响应: @@ -184,7 +213,7 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 -### 5、`/index/api/getMediaList` +### 6、`/index/api/getMediaList` - 功能:获取流列表,可选筛选参数 @@ -192,12 +221,12 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | schema | N | 筛选协议,例如 rtsp或rtmp | - | vhost | N | 筛选虚拟主机,例如`__defaultVost__` | - | app | N | 筛选应用名,例如 live | + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | schema | N | 筛选协议,例如 rtsp或rtmp | + | vhost | N | 筛选虚拟主机,例如`__defaultVost__` | + | app | N | 筛选应用名,例如 live | - 响应: @@ -224,7 +253,7 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 -### 6、`/index/api/close_stream` +### 7、`/index/api/close_stream` - 功能:关闭流(目前所有类型的流都支持关闭) @@ -232,25 +261,25 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | schema | Y | 协议,例如 rtsp或rtmp | - | vhost | Y | 虚拟主机,例如`__defaultVost__` | - | app | Y | 应用名,例如 live | - | stream | Y | 流id,例如 test | + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | schema | Y | 协议,例如 rtsp或rtmp | + | vhost | Y | 虚拟主机,例如`__defaultVost__` | + | app | Y | 应用名,例如 live | + | stream | Y | 流id,例如 test | | force | N | 是否强制关闭(有人在观看是否还关闭) | - + - 响应: - + ```json { "code" : 0,# 0:成功,-1:关闭失败,-2:该流不存在 "msg" : "success" } ``` - -### 7、`/index/api/getAllSession` + +### 8、`/index/api/getAllSession` - 功能:获取所有TcpSession列表(获取所有tcp客户端相关信息) @@ -258,11 +287,11 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 - 参数: - | 参数 | 是否必选 | 释意 | - | :--------: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | local_port | N | 筛选本机端口,例如筛选rtsp链接:554 | - | peer_ip | N | 筛选客户端ip | + | 参数 | 是否必选 | 释意 | + | :--------: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | local_port | N | 筛选本机端口,例如筛选rtsp链接:554 | + | peer_ip | N | 筛选客户端ip | - 响应: @@ -300,7 +329,7 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 -### 8、`/index/api/kick_session` +### 9、`/index/api/kick_session` - 功能:断开tcp连接,比如说可以断开rtsp、rtmp播放器等 @@ -308,10 +337,10 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | Id | Y | 客户端唯一id,可以通过getAllSession接口获取 | + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | Id | Y | 客户端唯一id,可以通过getAllSession接口获取 | - 响应: @@ -324,28 +353,29 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 -### 9、`/index/api/addStreamProxy` +### 10、`/index/api/addStreamProxy` - 功能:动态添加rtsp/rtmp拉流代理(只支持H264/H265/aac负载) + - 范例:[http://127.0.0.1/index/api/addStreamProxy?vhost=`__defaultVhost__`&app=proxy&stream=0&enable_rtsp=1&enable_rtmp=1&url=rtmp://live.hkstv.hk.lxdns.com/live/hks2](http://127.0.0.1/index/api/addStreamProxy?vhost=__defaultVhost__&app=proxy&stream=0&enable_rtsp=1&enable_rtmp=1&url=rtmp://live.hkstv.hk.lxdns.com/live/hks2) - 参数: - | 参数 | 是否必选 | 释意 | - | :--------: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | vhost | Y | 添加的流的虚拟主机,例如`__defaultVhost__` | - | app | Y | 添加的流的应用名,例如live | - | stream | Y | 添加的流的id名,例如test | - | url | Y | 拉流地址,例如rtmp://live.hkstv.hk.lxdns.com/live/hks2 | - | enable_rtsp | Y | 是否转rtsp | - | enable_rtmp | Y | 是否转rtmp | - | enable_hls | N | 是否转hls | - | enable_mp4 | N | 是否mp4录制 | - | rtp_type | N | rtsp拉流时,拉流方式,0:tcp,1:udp,2:组播 | - + | 参数 | 是否必选 | 释意 | + | :---------: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | vhost | Y | 添加的流的虚拟主机,例如`__defaultVhost__` | + | app | Y | 添加的流的应用名,例如live | + | stream | Y | 添加的流的id名,例如test | + | url | Y | 拉流地址,例如rtmp://live.hkstv.hk.lxdns.com/live/hks2 | + | enable_rtsp | Y | 是否转rtsp | + | enable_rtmp | Y | 是否转rtmp | + | enable_hls | N | 是否转hls | + | enable_mp4 | N | 是否mp4录制 | + | rtp_type | N | rtsp拉流时,拉流方式,0:tcp,1:udp,2:组播 | + - 响应: - + ```json { "code" : 0, @@ -357,20 +387,21 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 -### 10、`/index/api/delStreamProxy` +### 11、`/index/api/delStreamProxy` - 功能:关闭拉流代理 + - 范例:[http://127.0.0.1/index/api/delStreamProxy?key=`__defaultVhost__`/proxy/0](http://127.0.0.1/index/api/delStreamProxy?key=__defaultVhost__/proxy/0) - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | | key | Y | addStreamProxy接口返回的key | - + - 响应: - + ```json { "code" : 0, @@ -383,53 +414,55 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 -### 11、`/index/api/addFFmpegSource`(目前windows下无效) +### 12、`/index/api/addFFmpegSource`(目前windows下无效) - 功能:通过fork FFmpeg进程的方式拉流代理,支持任意协议 + - 范例:[http://127.0.0.1/index/api/addFFmpegSource?src_url=http://live.hkstv.hk.lxdns.com/live/hks2/playlist.m3u8&dst_url=rtmp://127.0.0.1/live/hks2&timeout_ms=10000](http://127.0.0.1/index/api/addFFmpegSource?src_url=http://live.hkstv.hk.lxdns.com/live/hks2/playlist.m3u8&dst_url=rtmp://127.0.0.1/live/hks2&timeout_ms=10000) + - 参数: - - | 参数 | 是否必选 | 释意 | - | :--------: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | src_url | Y | FFmpeg拉流地址,支持任意协议或格式(只要FFmpeg支持即可) | - | dst_url | Y | FFmpeg rtmp推流地址,一般都是推给自己,例如rtmp://127.0.0.1/live/stream_form_ffmpeg | - | timeout_ms | Y | FFmpeg推流成功超时时间 | + + | 参数 | 是否必选 | 释意 | + | :--------: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | src_url | Y | FFmpeg拉流地址,支持任意协议或格式(只要FFmpeg支持即可) | + | dst_url | Y | FFmpeg rtmp推流地址,一般都是推给自己,例如rtmp://127.0.0.1/live/stream_form_ffmpeg | + | timeout_ms | Y | FFmpeg推流成功超时时间 | - 响应: - - ```json - { - "code" : 0, - "data" : { - "key" : "5f748d2ef9712e4b2f6f970c1d44d93a" #唯一key - } - } - ``` + + ```json + { + "code" : 0, + "data" : { + "key" : "5f748d2ef9712e4b2f6f970c1d44d93a" #唯一key + } + } + ``` -### 12、`/index/api/delFFmepgSource`(目前windows下无效) +### 13、`/index/api/delFFmepgSource`(目前windows下无效) - 功能:关闭ffmpeg拉流代理 + - 范例:[http://127.0.0.1/index/api/delFFmepgSource?key=5f748d2ef9712e4b2f6f970c1d44d93a](http://127.0.0.1/index/api/delFFmepgSource?key=5f748d2ef9712e4b2f6f970c1d44d93a) - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | | key | Y | addFFmpegSource接口返回的key | - + - 响应: - - ```json - { - "code" : 0, - "data" : { - "flag" : true # 成功与否 - } - } - ``` - \ No newline at end of file + + ```json + { + "code" : 0, + "data" : { + "flag" : true # 成功与否 + } + } + ``` \ No newline at end of file