侧边栏壁纸
博主头像
JavaLYG 博主等级

行动起来,活在当下

  • 累计撰写 38 篇文章
  • 累计创建 13 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

SRS推流1对1视频通话signaling信令服务器和httpx-static代理服务器的安装启动

liuyg
2025-03-20 / 0 评论 / 0 点赞 / 10 阅读 / 0 字 / 正在检测是否收录...

背景

在公司安排的音视频项目中,选用了SRS方案

在测试WebRTC推流和拉流中 /players/whip.html 和 /players/whep.html 都没有问题

在/demos/one2one.html中,wss一直连接失败,最终发现需要signaling和httpx-static

官网提到signaling和httpx-static都是一笔带过😂百度过程比较复杂,终于找到解决方案

参考8、SRS4.0源代码分析之WebRTC环境彻底搭建_srs4.0多人通话原理-CSDN博客

版本

SRS版本:6.0.134

解决方案

1. 安装Go

# 下载最新Go语言包(以1.21.4为例)
wget https://dl.google.com/go/go1.21.4.linux-amd64.tar.gz

# 解压到系统目录
sudo tar -C /usr/local -xzf go1.21.4.linux-amd64.tar.gz

# 设置环境变量
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
source ~/.bashrc
# 检查Go版本
go version
# 应输出:go version go1.21.4 linux/amd64

# 检查gofmt是否可用
which gofmt
# 应输出:/usr/local/go/bin/gofmt

2. 编译安装运行signaling

signaling目录在:srs/trunk/3rdparty/signaling

我在是root下安装,所以下面命令均为按照root目录安装:

cd /root/srs/trunk/3rdparty/signaling && make
# 安装完成后运行
nohup ./objs/signaling >/dev/null 2>&1 & 

3. 编译安装运行httpx-static

httpx-static目录在/srs/trunk/3rdparty/httpx-static

我在是root下安装,所以下面命令均为按照root目录安装:

cd /root/srs/trunk/3rdparty/httpx-static && make
# 安装完成后运行
# 下面需要替换“证书.key”和“证书.pem”
nohup ./objs/httpx-static -http 80 -https 443 -ssk /root/srs/trunk/conf/证书.key -ssc /root/srs/trunk/conf/证书.pem     -proxy http://127.0.0.1:1989/sig -proxy http://127.0.0.1:1985/rtc     -proxy http://127.0.0.1:8080/  > /dev/null 2>&1 &

总结

SRS中WebRTC音视频通话的测试demo,如果需要用到one2one通话,就需要安装signaling和httpx-static模块

httpx-static代理的端口和下面srs.conf配置的端口是相通的,如果需要修改端口,就需要修改代理的端口

附一份srs.conf

# main config for srs.
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
#srs_log_tank        file;
#srs_log_file        ./objs/srs.log;
daemon              on;

http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
    https {
        enabled on;
        listen 8088;
        key ./conf/证书.key;
        cert ./conf/证书.pem;
    }
}


stats {
    network         0;
}

http_api {
    enabled         on;
    listen          1985;
    crossdomain     on;
    https {
        enabled on;
        crossdomain on;
        listen 1990;
        key ./conf/证书.key;
        cert ./conf/证书.pem;
    }
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    protocol udp;
    candidate 你自己的服务器物理ip;
}
vhost 域名 {
    hls {
        enabled         on;
    }
    rtc {
        enabled     on;   
        nack on;
        twcc on;
        stun_timeout 30;
        dtls_role passive;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc off;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp off;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    play{
        gop_cache_max_frames 2500;
    }
}

效果图

0
srs

评论区