SRS4.0 WebRTC一对一通话环境搭建与逻辑分析(转载)

辑分析

参考:https://blog.csdn.net/m0_60259116/article/details/124691647

11.1环境搭建

11.1.1. 安装go语⾔环境

1.在Go语⾔官⽹找到对应的安装包(Downloads - The Go Programming Language

2.下载和解析(使用的是阿里云的Ubuntu系统):

cd /usr/local/

wget https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz --no-check-certificate

tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz

3.需要配置 GOROOT 和 PATH环境变量,在/etc/profile中配置。

 vim /etc/profile

 

# 将环境变量添加到/etc/profile⽂件末尾。

export GOROOT=/usr/local/go

export PATH=$PATH:$GOROOT/bin:$GOBIN

4.然后使用 source /etc/profile 命令使配置文件生效,就可以在任意⽬录使用Go语言命令。

   source /etc/profile

5.执行go version可以查看安装go是否成功。

11.1.2. 编译和启动srs

git clone -b v4.0.123 https://gitee.com/winlinvip/srs.oschina.git

srs.4.0.123

cd srs.4.0.123/trunk

./configure

make

./objs/srs -c conf/rtc.conf

11.1.3. 编译和启动信令服务器

1.进行srs/trunk目录下。

cd 3rdparty/signaling

make

./objs/signaling

 

11.1.4. 编译和启动web服务器

1.需要server.crt和server.key,如果没有则⽤openssl⽣成。

2.进入srs/trunk/3rdparty/httpx-static目录,执行:

# ⽣成 server.key

openssl genrsa -out server.key 2048

 

# ⽣成 server.crt

openssl req -new -x509 -key server.key -out server.crt -days 3650

3.编译和启动web服务器

cd 3rdparty/httpx-static

make

./objs/httpx-static -http 80 -https 443 -ssk server.key -ssc server.crt \

-proxy http://127.0.0.1:1989/sig -proxy http://127.0.0.1:1985/rtc \

-proxy http://127.0.0.1:8080/

 

11.1.5. 进入测试页面

1.打开demo地址

https://localhost/demos/

https://192.168.145.128/demos/  #公网ip

 

2.输入Room和Display就可以进行1对1通话

 

11.2. SRS4.0 WebRTC1对1通话逻辑分析

按F12打开一对一通话http页面源码,在 one2one.html?autostart=true&room=fbe219e 中可以看到,“开始通话”按钮id是btn_start,当点击按钮后,执行startDemo函数。

posted @ 2024-07-24 14:30  泽良_小涛  阅读(1)  评论(0编辑  收藏  举报