diff --git a/MediaServer支持的HTTP-API.md b/MediaServer支持的HTTP-API.md index 163aa55..490f196 100644 --- a/MediaServer支持的HTTP-API.md +++ b/MediaServer支持的HTTP-API.md @@ -32,6 +32,9 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 "/index/api/stopRecord", "/index/api/getRecordStatus", "/index/api/getSnap", + "/index/api/openRtpServer", + "/index/api/closeRtpServer", + "/index/api/listRtpServer", ``` 其中POST方式,参数既可以使用urlencoded方式也可以使用json方式。 @@ -39,15 +42,19 @@ MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些 ## API返回结果约定 + - HTTP层面统一返回200状态码,body统一为json。 - body一般为以下样式: + ```json { "code" : -1, "msg" : "失败提示" } ``` + - code值代表执行结果,目前包含以下类型: + ```c++ typedef enum { Exception = -400,//代码抛异常 @@ -62,6 +69,7 @@ typedef enum { - 如果执行成功,那么`code == 0`,并且一般无`msg`字段。 - `code == -1`时代表业务代码执行不成功,更细的原因一般提供`result`字段,例如以下: + ```json { "code" : -1, # 代表业务代码执行失败 @@ -317,7 +325,7 @@ typedef enum { ] } ``` - + ### 7、`/index/api/close_stream`(已过期,请使用close_streams接口替换) @@ -445,8 +453,9 @@ typedef enum { "msg" : "success" } ``` + - + ### 11、`/index/api/kick_sessions` - 功能:断开tcp连接,比如说可以断开rtsp、rtmp播放器等 @@ -586,8 +595,9 @@ typedef enum { } } ``` + - + ### 16、`/index/api/isMediaOnline(已过期,请使用getMediaList接口替代)` - 功能:判断直播流是否在线 @@ -613,9 +623,9 @@ typedef enum { "online" : true # 是否在线 } ``` + - - + ### 17、`/index/api/getMediaInfo(已过期,请使用getMediaList接口替代)` - 功能:获取流相关信息 @@ -663,7 +673,7 @@ typedef enum { ] } ``` - + ### 18、`/index/api/getRtpInfo` - 功能:获取rtp代理时的某路ssrc rtp信息 @@ -672,10 +682,10 @@ typedef enum { - 参数: - | 参数 | 是否必选 | 释意 | - | :----: | :------: | :----------------------------------------------------------: | - | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | - | stream_id | Y | RTP的ssrc,16进制字符串或者是流的id(openRtpServer接口指定) | + | 参数 | 是否必选 | 释意 | + | :-------: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | stream_id | Y | RTP的ssrc,16进制字符串或者是流的id(openRtpServer接口指定) | - 响应: @@ -690,11 +700,13 @@ typedef enum { "local_port" : 10000 } ``` + - + ### 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) - 参数: @@ -738,8 +750,9 @@ typedef enum { } ``` + - + ### 20、`/index/api/startRecord` - 功能:开始录制hls或MP4 @@ -766,8 +779,9 @@ typedef enum { "result" : true # 成功与否 } ``` + - + ### 21、`/index/api/stopRecord` - 功能:停止录制流 @@ -793,9 +807,9 @@ typedef enum { "result" : true # 成功与否 } ``` + - - + ### 22、`/index/api/isRecording` - 功能:获取流录制状态 @@ -844,5 +858,83 @@ typedef enum { ```json jpeg格式的图片,可以在浏览器直接打开 ``` - - \ No newline at end of file + + + +### 24、`/index/api/openRtpServer` + + - 功能:创建GB28181 RTP接收端口,如果该端口接收数据超时,则会自动被回收(不用调用closeRtpServer接口) + + - 范例:[http://127.0.0.1/index/api/openRtpServer?port=0&enable_tcp=1&stream_id=test](http://127.0.0.1/index/api/openRtpServer?port=0&enable_tcp=1&stream_id=test) + + - 参数: + + | 参数 | 是否必选 | 释意 | + | :--------: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | port | Y | 接收端口,0则为随机端口 | + | enable_tcp | Y | 启用UDP监听的同时是否监听TCP端口 | + | stream_id | Y | 该端口绑定的流ID,该端口只能创建这一个流(而不是根据ssrc创建多个) | + + + - 响应: + + ```json + { + "code" : 0, + "port" : 55463 #接收端口,方便获取随机端口号 + } + ``` + + + +### 25、`/index/api/closeRtpServer` + + - 功能:关闭GB28181 RTP接收端口 + + - 范例:[http://127.0.0.1/index/api/closeRtpServer?stream_id=test](http://127.0.0.1/index/api/closeRtpServer?stream_id=test) + + - 参数: + + | 参数 | 是否必选 | 释意 | + | :-------: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + | stream_id | Y | 调用openRtpServer接口时提供的流ID | + + + - 响应: + + ```json + { + "code": 0, + "hit": 1 #是否找到记录并关闭 + } + ``` + +### 26、`/index/api/listRtpServer` + + - 功能:获取openRtpServer接口创建的所有RTP服务器 + + - 范例:[http://127.0.0.1/index/api/listRtpServer](http://127.0.0.1/index/api/listRtpServer) + + - 参数: + + | 参数 | 是否必选 | 释意 | + | :----: | :------: | :----------------------------------------------------------: | + | secret | Y | api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数 | + + + - 响应: + + ```json + { + "code" : 0, + "data" : [ + { + "port" : 52183, #绑定的端口号 + "stream_id" : "test" #绑定的流ID + } + ] + } + ``` +