smart rtmpd 第三方鉴权接口说明

28 篇文章 21 订阅
27 篇文章 3 订阅

----------------------------------------------------------------------------------------------------------------------------------------

一分钟快速搭建 rtmpd 服务器: https://blog.csdn.net/freeabc/article/details/102880984

软件下载地址: http://www.qiyicc.com/download/rtmpd.rar

github 地址:https://github.com/superconvert/smart_rtmpd

-----------------------------------------------------------------------------------------------------------------------------------------

接口:

smart rtmpd 发送 http request ( PUT url + param )
第三方平台  响应 http response (成功:200 OK,其余表示失败)

要求:要求 500 ms 内返回鉴定结果

 

准备:

如果想支持第三方鉴权,需要在 smart rtmpd 的配置文件 config.xml 里
配置选项 <authurl> 。如果你鉴权服务器地址为: 192.168.1.1,端口: 8080
那么就需要修改配置文件 config.xml 里的 <authurl>    

<authurl>192.168.1.1:8080</authurl>

配置完毕启动或重启 smart rtmpd

 

功能:

鉴权针对 rtmp 推流,拉流,http-flv, http-hls, http-dash 拉流,rtsp 推流,
拉流等进行鉴权服务。可以把 smart rtmpd 完美的对接到您现有的运营系统。

 

rtmp 鉴权 url 说明:

针对 rtmp 推流或拉流,一般 rtmp 推流或拉流 url 是这种格式  

rtmp://192.168.1.1/live/stream?user=admin&token=xqtv312

那么进行鉴权时,smart rtmpd 会把此 url 转换成鉴权 url 如下面格式  

http://第三方鉴权地址/live/stream?user=admin&token=xqtv312&type=rtmp&role=publisher

smart rtmpd 会追加自己的参数进去,追加字段如下:
1. 参数 type 表示协议类型,目前只有 rtmp, http, rtsp 三种。
2. 参数 role 表示这个 url 的角色,目前只分为 publisher(发布者), player (播放端)以及 api ( 后台接口 )

其余 url 会保持不变,只会去掉前面的 rtmp://192.168.1.1,后面的保持不变

再举一例 rtmp 推流或拉流 url  

rtmp://192.168.1.1/rec/stream?user=admin&token=xqtv312

那么鉴权 url  

http://第三方鉴权地址/rec/stream?user=admin&token=xqtv312&type=rtmp&role=publisher

live 表示直播,rec 表示点播,api 表示后台接口的查询交互 (查询 rec 列表, 统计,流信息等),第三方平台可以解析这些字段判断用户是直播还是点播

 

http 鉴权 url 格式说明:

对于 http-flv, http-hls, http-dash 的拉流 url 格式一般如下

  http://192.168.1.1/api/rec/sport?token=x31wey ( http-mpd )
  http://192.168.1.1/live/stream.flv?user=admin&token=xqtv312 ( http-flv )
  http://192.168.1.1/live/stream.m3u8?user=admin&token=xqtv312 ( http-m3u8 )
  http://192.168.1.1/live/stream.mpd?user=admin&token=xqtv312 ( http-mpd )

那么 smart rtmpd 会把此 url 转换成鉴权 url 如下面格式

  http://192.168.1.1/api/rec/sport?token=x31wey&type=http&role=api ( http-mpd )
  http://第三方鉴权地址/live/stream.flv?user=admin&token=xqtv312&type=http&role=player
  http://第三方鉴权地址/live/stream.m3u8?user=admin&token=xqtv312&type=http&role=player
  http://第三方鉴权地址/live/stream.mpd?user=admin&token=xqtv312&type=http&role=player

同样 smart rtmpd 会追加参数 type 和 role,同时把 http://192.168.1.1 去掉,后面的保持不变
 

rtsp 鉴权 url 格式说明:

对于 rtsp 推流和拉流 url 格式一般如下  

rtsp://192.168.1.1/live/stream?user=admin&token=xqtv312

那么 smart rtmpd 会把此 url 转换成鉴权 url 如下面格式  

http://第三方鉴权地址/live/stream?user=admin&token=xqtv312&type=rtsp&role=player

同样 smart rtmpd 会追加参数 type 和 role,同时把 http://192.168.1.1 去掉,后面的保持不变

 

怎么防止第三方鉴权劫持

 

 

如果做第三方鉴权,担心被劫持,可以先做一个简单的 proxy ,比如用 python 实现一个简单的 proxy ,然后 proxy 与鉴权服务器之间采用 https ,基本上就保证安全了。关于细节我就不多讲了,能想到这个,应该能看明白怎么去实现。 

 

请求报文实例

//------------------------------------------------------------------------
// vod 目录查询
//------------------------------------------------------------------------

  // 请求
  PUT /api/vod?type=http&role=api HTTP/1.0
  Host: 192.168.1.108
  Connection: close
  User-Agent: smart_rtmpd
  Content-Type: text/plain;charset=UTF-8 

  // 响应
  HTTP/1.0 200 OK
  Server: Microsoft-IIS/5.1
  Date: Fri, 03 Mar 2020 06:34:03 GMT


//-----------------------------------------------------------------------
// 直播 鉴权
//-----------------------------------------------------------------------

  // 推流 url
  rtmp://192.168.1.1/live/camera?token=uqw25Pxt8

  // smart rtmpd 发往鉴权服务器报文
  // 请求
  PUT /live/camera?token=uqw25Pxt8&type=rtmp&role=publisher HTTP/1.0
  Host: 192.168.1.108
  Connection: close
  User-Agent: smart_rtmpd
  Content-Type: text/plain;charset=UTF-8

  // 响应
  HTTP/1.0 200 OK
  Server: Microsoft-IIS/5.1
  Date: Fri, 03 Mar 2020 06:34:03 GMT
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值