ZLMediaKit支持的HTTP API

MediaServer是ZLMediaKit的主进程,目前支持以下http api接口,这些接口全部支持GET/POST方式,

      "/index/api/addFFmpegSource",
      "/index/api/addStreamProxy",
      "/index/api/close_stream",
      "/index/api/delFFmepgSource",
      "/index/api/delStreamProxy",
      "/index/api/getAllSession",
      "/index/api/getApiList",
      "/index/api/getMediaList",
      "/index/api/getServerConfig",
      "/index/api/getThreadsLoad",
      "/index/api/kick_session",
      "/index/api/restartServer",
      "/index/api/setServerConfig",

其中POST方式,参数既可以使用urlencoded方式也可以使用json方式。
操作这些api一般需要提供secret参数以便鉴权,如果操作ip是127.0.0.1,那么可以无需鉴权。

API详解

/index/api/getThreadsLoad
  • 功能:获取各epoll(或select)线程负载以及延时

  • 参数:无

  • 响应:

    {
       "data" : [
          {
             "delay" : 0, #该线程延时
             "load" : 0 #该线程负载,0 ~ 100
          },
          {
             "delay" : 0,
             "load" : 0
          }
       ]
    }
    /index/api/getServerConfig
    
    

  • 功能:获取服务器配置

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : [
          {
             "api.apiDebug" : "1",
             "api.secret" : "035c73f7-bb6b-4889-a715-d9eb2d1925cc",
             "ffmpeg.bin" : "/usr/local/bin/ffmpeg",
             "ffmpeg.cmd" : "%s -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s",
             "ffmpeg.log" : "/Users/xzl/git/ZLMediaKit/cmake-build-debug/bin/ffmpeg/ffmpeg.log",
             "general.enableVhost" : "1",
             "general.flowThreshold" : "1024",
             "general.maxStreamWaitMS" : "5000",
             "general.streamNoneReaderDelayMS" : "5000",
             "hls.fileBufSize" : "65536",
             "hls.filePath" : "/Users/xzl/git/ZLMediaKit/cmake-build-debug/bin/httpRoot",
             "hls.segDur" : "3",
             "hls.segNum" : "3",
             "hook.access_file_except_hls" : "1",
             "hook.admin_params" : "secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc",
             "hook.enable" : "1",
             "hook.on_flow_report" : "https://127.0.0.1/index/hook/on_flow_report",
             "hook.on_http_access" : "https://127.0.0.1/index/hook/on_http_access",
             "hook.on_play" : "https://127.0.0.1/index/hook/on_play",
             "hook.on_publish" : "https://127.0.0.1/index/hook/on_publish",
             "hook.on_record_mp4" : "https://127.0.0.1/index/hook/on_record_mp4",
             "hook.on_rtsp_auth" : "https://127.0.0.1/index/hook/on_rtsp_auth",
             "hook.on_rtsp_realm" : "https://127.0.0.1/index/hook/on_rtsp_realm",
             "hook.on_shell_login" : "https://127.0.0.1/index/hook/on_shell_login",
             "hook.on_stream_changed" : "https://127.0.0.1/index/hook/on_stream_changed",
             "hook.on_stream_none_reader" : "https://127.0.0.1/index/hook/on_stream_none_reader",
             "hook.on_stream_not_found" : "https://127.0.0.1/index/hook/on_stream_not_found",
             "hook.timeoutSec" : "10",
             "http.charSet" : "utf-8",
             "http.keepAliveSecond" : "100",
             "http.maxReqCount" : "100",
             "http.maxReqSize" : "4096",
             "http.notFound" : "<html><head><title>404 Not Found</title></head><body bgcolor=\"white\"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit-4.0</center></body></html>",
             "http.port" : "80",
             "http.rootPath" : "/Users/xzl/git/ZLMediaKit/cmake-build-debug/bin/httpRoot",
             "http.sendBufSize" : "65536",
             "http.sslport" : "443",
             "multicast.addrMax" : "239.255.255.255",
             "multicast.addrMin" : "239.0.0.0",
             "multicast.udpTTL" : "64",
             "record.appName" : "record",
             "record.filePath" : "/Users/xzl/git/ZLMediaKit/cmake-build-debug/bin/httpRoot",
             "record.fileSecond" : "3600",
             "record.sampleMS" : "100",
             "rtmp.handshakeSecond" : "15",
             "rtmp.keepAliveSecond" : "15",
             "rtmp.modifyStamp" : "1",
             "rtmp.port" : "1935",
             "rtp.audioMtuSize" : "600",
             "rtp.clearCount" : "10",
             "rtp.cycleMS" : "46800000",
             "rtp.maxRtpCount" : "50",
             "rtp.videoMtuSize" : "1400",
             "rtsp.authBasic" : "0",
             "rtsp.handshakeSecond" : "15",
             "rtsp.keepAliveSecond" : "15",
             "rtsp.port" : "554",
             "rtsp.sslport" : "322",
             "shell.maxReqSize" : "1024",
             "shell.port" : "9000"
          }
       ]
    }

     

    /index/api/setServerConfig

  • 功能:设置服务器配置

  • 参数:

    响应:

    {
       "changed" : 0, #配置项变更个数
       "code" : 0     #0代表成功
    }

     

    /index/api/restartServer

  • 功能:重启服务器,只有Daemon方式才能重启,否则是直接关闭!

  • 参数:

    响应:

    {
       "code" : 0,
       "msg" : "服务器将在一秒后自动重启"
    }

     

    /index/api/getMediaList

  • 功能:获取流列表,可选筛选参数

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : [
          {
             "app" : "live",
             "schema" : "rtsp",
             "stream" : "0",
             "vhost" : "__defaultVhost__"
          },
          {
             "app" : "live",
             "schema" : "rtmp",
             "stream" : "0",
             "vhost" : "__defaultVhost__"
          }
       ],
       "msg" : "success"
    }
    /index/api/close_stream

     

  • 功能:关闭流(目前所有类型的流都支持关闭)

  • 参数:

    响应:

    {
       "code" : 0,# 0:成功,-1:关闭失败,-2:该流不存在
       "msg" : "success"
    }

     

    /index/api/getAllSession

  • 功能:获取所有TcpSession列表(获取所有tcp客户端相关信息)

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : [
          {
             "id" : "140614477848784",
             "local_ip" : "127.0.0.1",
             "local_port" : 80,
             "peer_ip" : "127.0.0.1",
             "peer_port" : 51136,
             "typeid" : "16WebSocketSessionI11EchoSessionN8mediakit11HttpSessionEE"
          },
          {
             "id" : "140614443300192",
             "local_ip" : "127.0.0.1",
             "local_port" : 80,
             "peer_ip" : "127.0.0.1",
             "peer_port" : 51135,
             "typeid" : "16WebSocketSessionI11EchoSessionN8mediakit11HttpSessionEE"
          },
          {
             "id" : "140614440178720",  # 该tcp链接唯一id
             "local_ip" : "127.0.0.1",  # 本机网卡ip
             "local_port" : 1935,           # 本机端口号 (这是个rtmp播放器或推流器)
             "peer_ip" : "127.0.0.1",   # 客户端ip 
             "peer_port" : 51130,               # 客户端端口号
             "typeid" : "N8mediakit11RtmpSessionE"  # 客户端TCPSession typeid
          }
       ]
    }
    /index/api/kick_session

     

  • 功能:断开tcp连接,比如说可以断开rtsp、rtmp播放器等

  • 参数:

响应:

{
   "code" : 0,
   "msg" : "success"
}

 

/index/api/addStreamProxy
  • 功能:动态添加rtsp/rtmp拉流代理(只支持H264/H265/aac负载)

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : {
          "key" : "__defaultVhost__/proxy/0"  # 流的唯一标识
       }
    }

     

    /index/api/delStreamProxy

  • 功能:关闭拉流代理

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : {
          "flag" : true # 成功与否
       }
    }

     

    /index/api/addFFmpegSource(目前windows下无效)

  • 功能:通过fork FFmpeg进程的方式拉流代理,支持任意协议

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : {
          "key" : "5f748d2ef9712e4b2f6f970c1d44d93a"  #唯一key
       }
    }

     

    /index/api/delFFmepgSource(目前windows下无效)

  • 功能:关闭ffmpeg拉流代理

  • 参数:

    响应:

    {
       "code" : 0,
       "data" : {
          "flag" : true # 成功与否
       }
    }

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值