安卓基于SRS的Webrtc推拉流

Posted 清霜之辰

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安卓基于SRS的Webrtc推拉流相关的知识,希望对你有一定的参考价值。

安卓基于SRS的Webrtc推拉流

服务端:SRS (Simple Realtime Server,支持RTMP、HTTP-FLV、HLS、WebRTC)
SRS V4 Webrtc Wiki
推流端:ffmpegOBS
拉流端:ffplayVLCsrs播放器
在线表秒 https://miaobiao.bmcx.com/
本文首发地址:https://blog.csdn.net/CSqingchen/article/details/120830028
最新更新地址:https://gitee.com/chenjim/chenjimblog

Https必须需要域名

  • 如果没有域名,用 https://192.*.*.* 访问,会有类似 你的连接不是专用连接 提示页面,地址栏也有 不安全 提示
  • 如果没有域名,出现以上不安全提问,可以在页面空白地方输入 thisisunsafe,或者按页面提示点击,可以继续访问,但是地址栏会有 不安全 提示
  • 如果没有域名,出现以上不安全提问,在 EDGE 或者 Chrome 启动命令后加 " --test-type --ignore-certificate-errors",可以继续访问,但是地址栏会有 不安全 提示
  • 终极完美解决方案是配置域名,如果不在意地址栏提示,也是可以直接用IP的,包括后面提到的推拉流
  • 本文使用 阿里云域名配置域名 s.h89.cn 指向IP 192.168.31.110 , 申请了免费一年有效期证书,下载 apache 证书
  • 环境变量 ~/.bashrc 中添加 export CANDIDATE=s.h89.cn

httpx-static 配置 https 代理

webrtc 推拉流失败 80% 是 https 配置的异常
winlin 介绍 httpx-static 配置 SRS Https 代理的 视频@Bilibili
相关总结步骤如下

  1. 安装 go
    sudo apt install golang-go
  2. 配置Go环境变量,在 .bashrc 添加以下
    export GOPATH=~/go
    export GOBIN=$GOPATH/bin
    export PATH=$PATH:$GOBIN
    
  3. 下载 httpx-static
    go get github.com/ossrs/go-oryx/httpx-static
    默认源码在目录 $GOPATH/src/httpx-static 在目录 $GOPATH/bin
    配置代理命令
    sudo $GOBIN/httpx-static -https 443 -ssk key/s.h89.cn.key -ssc key/s.h89.cn.crt -p http://s.h89.cn:1985/rtc -p http://s.h89.cn:8080
    • 80443 端口需要 sudo
    • 代理 http://s.h89.cn:1985/rtchttps://s.h89.cn/rtc
  4. 启动srs
    ./objs/srs -c conf/rtc.conf
  5. webrtc推流、拉流
    地址 webrtc://s.h89.cn/live/livestream
    webrtc推流 https://s.h89.cn/players/rtc_publisher.html
    webrtc拉流 https://s.h89.cn/players/rtc_player.html
    控制台 https 无法连接,需要用 http 地址

基于SRS 配置文件支持 https

  1. http_serverhttp_api 配置 https 相关,参考如下
     listen              1935;
     max_connections     1000;
     daemon              off;
     srs_log_tank        console;
    
     http_server 
         enabled         on;
         listen          8080;
         dir             ./objs/nginx/html;
         https 
             enabled on;
             listen  8088;
             key ./key/s.h89.cn.key;
             cert ./key/s.h89.cn.crt;
         
     
    
     http_api 
         enabled         on;
         listen          1985;
         https 
             enabled on;
             listen 443;
             key ./key/s.h89.cn.key;
             cert ./key/s.h89.cn.crt;
         
     
     stats 
         network         0;
     
     rtc_server 
         enabled on;
         listen 8000;
         candidate $CANDIDATE;
     
    
     vhost __defaultVhost__ 
         rtc 
             enabled     on;
             rtc_to_rtmp on;
         
         http_remux 
             enabled     on;
             mount       [vhost]/[app]/[stream].flv;
         
         dvr 
             enabled      on;
             dvr_path     ./objs/nginx/html/[app]/[stream].[timestamp].flv;
             dvr_plan     session;
         
     
    
    
  2. 启动SRS
    用到 443端口,注意加 sudo
  3. webrtc 推流地址
    https://s.h89.cn:8088/players/rtc_publisher.html?autostart=true&app=live&stream=camera&server=s.h89.cn&port=8088&vhost=s.h89.cn&schema=https
    webrtc 拉流地址
    https://s.h89.cn:8088/players/rtc_player.html?autostart=true&app=live&stream=camera&server=s.h89.cn&port=8088&vhost=s.h89.cn&schema=https
    控制台地址
    https://s.h89.cn:8088/console/ng_index.html#/summaries?port=443&schema=https&host=s.h89.cn
    webrtc 地址
    webrtc://s.h89.cn/live/camera

android 推拉webrtc流到srs

Demo示例 https://github.com/shenbengit/WebRTC-SRS
冬季穿短裤 博文传送门如下


其它相关文档

以上是关于安卓基于SRS的Webrtc推拉流的主要内容,如果未能解决你的问题,请参考以下文章

安卓基于SRS的Webrtc推拉流

安卓基于SRS的Webrtc推拉流

开源流媒体解决方案,流媒体服务器,推拉流,直播平台,SRS,WebRTC,移动端流媒体,网络会议,优秀博客资源等分享

开源流媒体解决方案,流媒体服务器,推拉流,直播平台,SRS,WebRTC,移动端流媒体,网络会议,优秀博客资源等分享

开源流媒体解决方案,流媒体服务器,推拉流,直播平台,SRS,WebRTC,移动端流媒体,网络会议

Linux服务器搭建SRS视频推拉流