当我在Firefox中使用Kurento连接时,数据通道的readyState不会更改。对等连接正在正常工作,因为我可以发送和接收视频和音频。在chrome中,一切正常。我不知道问题是否与Kurento有关。
这是我创建两个数据通道(接收和发送)的方式
function onExistingParticipants(msg) {
peerConn = new RTCPeerConnection(pc_config);
dataChannel = peerConn.createDataChannel('send', {reliable: false});
dataChannel.binaryType = 'arraybuffer';
dataChannel.onerror = function (error) {
console.log(error);
};
dataChannel.onmessage = function (event) {
console.log('MESSAGE' ,event);
};
dataChannel.onclose = function () {
console.log('close');
};
dataChannel.onopen = function (event) {
console.log('OPEN',event);
};
window.localConnection = peerConn;
var participant = new Participant(msg.user);
participants[msg.user] = participant;
var constraints = {
audio : true,
video : {
mandatory : {
maxWidth : 320,
maxFrameRate : 15,
minFrameRate : 15
}
}
};
var video = participant.getVideoElement();
var options = {
peerConnection : peerConn ,
localVideo: video,
mediaConstraints: constraints,
onicecandidate: participant.onIceCandidate.bind(participant)
}
participant.rtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options,
function (error) {
if(error) {
return console.error(error);
}
this.generateOffer(participant.offerToReceiveVideo.bind(participant));
});
msg.data.forEach(receiveVideo);
}
function receiveVideo(sender) {
remotechannel = remotepeer.createDataChannel('receive');
remotechannel.onerror = function (error) {
console.log(error)
};
remotechannel.onmessage = messages;
remotechannel.onclose = function () {
console.log('close');
};
remotechannel.onopen = function (event) {
console.log('OPEN',event);
};
remotechannel.binaryType = 'arraybuffer';
participants[sender] = participant;
var video = participant.getVideoElement();
var options = {
peerConnection : remotepeer ,
remoteVideo: video,
onicecandidate: participant.onIceCandidate.bind(participant)
}
participant.rtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options,
function (error) {
if(error) {
return console.error(error);
}
this.generateOffer(participant.offerToReceiveVideo.bind(participant));
}
);
}
在服务器端同时进入会议室并获得用户的端点
room.pipeline.create('WebRtcEndpoint', {useDataChannels: true}, (error, webRtc) => {
....
}