【网络通信 -- 直播】SRS -- 基于 SRS 的通话环境搭建
【1】安装配置 GO 环境
下载 GO 相关环境软件包
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
设置 GO 相关环境变量
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
确认 GO 相关环境的正确性
命令 : which go
结果 : /usr/local/go/bin/go
命令 : go env
结果 :
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0
-fdebug-prefix-map=/tmp/go-build3030606881=/tmp/go-build -gno-record-gcc-switches"
【2】编译启动 SRS 相关服务
【2.1】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
- rtc.conf 配置文件示例
listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
http_api {
enabled on;
listen 1985;
}
stats {
network 0;
}
rtc_server {
enabled on;
# Listen at udp://8000
listen 8000;
#
# The $CANDIDATE means fetch from env, if not configed, use * as default.
#
# The * means retrieving server IP automatically, from all network interfaces,
# @see https://github.com/ossrs/srs/wiki/v4_CN_RTCWiki#config-candidate
candidate 116.62.236.165; # 给定候选的 IP 地址
}
vhost __defaultVhost__ {
rtc {
enabled on;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
}
}
【2.2】SRS 信令服务
cd 3rdparty/signaling
make
./objs/signaling
【2.3】SRS Web 服务器
cd 3rdparty/httpx-static
make
./objs/httpx-static -http 80 -https 443 -ssk /home/CopperSun/cert/server.key \
-ssc /home/CopperSun/cert/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/
【3】基于 SRS 测试通话
【3.1】生成证书
生成 server.key
openssl genrsa -out server.key 2048
生成 server.crt
openssl req -new -x509 -key server.key -out server.crt -days 3650
【3.2】进入测试页面
进入测试页面,网址 : https://116.62.236.165/demos/
参考与致谢
本博客为博主的学习实践总结,并参考了众多博主的博文,在此表示感谢,博主若有不足之处,请批评指正。
【3】【GO 开发系列 -- 基础】GO 开发环境搭建(Linux)