我正在尝试使用 WebRTC 建立一个多方视频会议,只需要稍微澄清一下:
问)我需要为RTCPeerConnection
会议的每个成员创建一个对象还是一个对象?
例如,我目前正在为两种方式的通信做这个,效果很好......
var pc; // single peer connection instance (see startPeerConnection)
startLocalVideo(function (stream) {
//Offer Local video to Remote Server
if (stream) {
if (!pc) {
startPeerConnection();
}
if (pc) {
pc.addStream(stream);
pc.onaddstream = addRemoteStream;
pc.createOffer(function (description) {
pc.setLocalDescription(description, function () {
signal('offer', {
extension: extension,
call: currentcall,
description: description
});
}, failure);
}, function (error) {
console.log("createOffer error: " + error);
});
}
}
});
function startPeerConnection() {
pc = new RTCPeerConnection({
iceServers: [{
url: "stun:stun.l.google.com:19302"
}]
});
pc.onicecandidate = gotLocalIceCandidate;
}