我正在创建一个应用程序,该应用程序将使用 WebRTC 将摄像头视频共享到多个对等连接。服务器只是为用户提供一个房间,房间内的所有用户都会看到摄像头的视频。唯一不工作的是 onicecandidate 没有触发,因此无法建立对等连接。
我为每个新用户创建新的对等连接。一切看起来都很好(广播员和观众可以交换消息:1)当观众加入房间时,广播员创建新的对等连接,创建报价,设置本地描述,并将其发送给新观众。2)新观众将设置远程描述,创建答案,设置本地描述并将答案发送回广播公司。3)广播可以接收应答,设置远程描述,但我不能创建冰候选。
为什么 RTCPeerConnection.oniceccandidate 不触发?
"use strict";
// config
//Acess camera from the http://localhost:2013 is allowed because it is considered a safe environment
//Acess camera from the http://192.168.10.7:2013 is considered a non secure environment (therefore require https)
//var serverIP = "http://192.168.10.7:2013";
//var serverIP = "https://172.21.2.197:2013";
//var serverIP = "https://172.20.10.12:2013";
var serverIP = "https://localhost:2013";
// RTCPeerConnection Options
var server = {
// Uses Google's STUN server
iceServers: [{
"url": "stun:stun.xten.com"
},
{
// Use my TURN server …Run Code Online (Sandbox Code Playgroud)