1、coturn
前文已编译好了coturn https://xue-fei.blog.csdn.net/article/details/155945401
配置文件 turnserver.conf
# 监听地址和端口 listening-port=3478 tls-listening-port=5349 listening-ip=0.0.0.0 # 你的公网 IP(必须!用于 NAT 穿透) external-ip=x.x.x.x relay-ip=0.0.0.0 # 认证方式(静态用户名/密码) user=xx:xx # Realm(必须设置,可任意域名) realm=default-realm # 启用 TURN 中继(关键!) fingerprint lt-cred-mech # 日志(可选) log-file=.\turn.log verbose # WebRTC 媒体中继端口范围(必须!) min-port=49152 max-port=65535启动
turnserver.exe -c turnserver.conf2、WebApp
下载WebApp源码 https://codeload.github.com/Unity-Technologies/UnityRenderStreaming/zip/refs/tags/3.1.0-exp.9
编译过程看这里 https://xue-fei.blog.csdn.net/article/details/135345064
需要修改的地方 WebApp\client\public\js\config.js
import {getServers} from "./icesettings.js"; export async function getServerConfig() { const protocolEndPoint = location.origin + '/config'; const createResponse = await fetch(protocolEndPoint); return await createResponse.json(); } export function getRTCConfiguration() { let config = {}; config.sdpSemantics = 'unified-plan'; //注释掉这行 //config.iceServers = getServers(); config.iceServers = [{ urls: ['stun:stun.l.google.com:19302'] }, { urls: ['turn:x.x.x.x:3478?transport=tcp'], username: 'xx', credential: 'xx' } ]; return config; }启动
webserver.exe -p 90903、Unity工程设置
SignalingManager 修改URL和ICEServers
4、服务器端口号设置
放开3748/3749的udp和tcp
放开32355/65535的udp和tcp