但是,对于以下其他情况,接听电话的一方没有收到来电者的视频,或者双方都没有收到对方的视频:
桌面版 Safari --> Android Chrome
桌面 Safari --> IOS Safari
桌面 Safari --> 桌面 Safari
IOS Safari --> 桌面 Chrome
IOS Safari --> Android Chrome
IOS Safari --> 桌面Safari
IOS Safari --> IOS Safari。
远程视频的“静音”状态为“真”。
这是我目前的代码(我仍在努力寻找解决方案):
Caller.js
splitChunks: {
chunks(chunk) {
return chunk.name !== 'background';
},
},
Answerer.js
const peer = new Peer(idPeer, {
config: {'iceServers': [
{urls:'stun:stun1.l.google.com:19302'},
{urls:'stun:stun2.l.google.com:19302'},
{urls:'stun:stun3.l.google.com:19302'},
{urls:'stun:stun4.l.google.com:19302'},
]},
debug : 3
});
peer.on('connection', function(conn) {
clearInterval(intervalOpen);
console.log(conn)
conn.on('open', function() {
demarrerAppel()
conn.on('data', function(data) {
var newData = JSON.parse(data)
if(newData.type && newData.type == 2){
var cpt = 0;
function setDescription() {
if(call.peerConnection.iceGatheringState === "complete"){
call.peerConnection.setRemoteDescription(newData.desc).then(function(){
call.peerConnection.createAnswer({mandatory: { OfferToReceiveAudio: true, OfferToReceiveVideo: true }}).then(function(answer){
console.log(answer)
setTimeout(function(){
call.peerConnection.setLocalDescription(answer).then(function(){
var obj = {
type: "answer",
desc : call.peerConnection.localDescription
}
conn.send(JSON.stringify(obj));
})
}, 2000);
});
});
}
else{
if(cpt < 75){
setTimeout(setDescription, 200);
cpt++;
}
}
}
setDescription();
}
if(newData.options){
if(newData.options.video){
$('#video-disabled').hide();
}
else{
$('#video-disabled').css('display', 'flex');
}
if(newData.options.audio){
$('#audio-disabled').hide();
}
else{
$('#audio-disabled').css('display', 'flex');
}
}
});
conn.on('error', function(err) {
console.log(err)
});
});
});
peer.on('error',function(err){
console.log(err.type);
})
function demarrerAppel(){
optionsPartageVideo = {
video: {
width: { ideal: 1921 },
height: { ideal: 1081 }
},
audio: {
echoCancellation: true,
noiseSuppression: true,
sampleRate: 44100
}
};
navigator.mediaDevices.getUserMedia(optionsPartageVideo).then(function(stream) {
videoPrestataire = stream;
var options = {
'constraints': {
'mandatory': {
'OfferToReceiveAudio': true,
'OfferToReceiveVideo': true
},
offerToReceiveAudio: 1,
offerToReceiveVideo: 1,
}
}
call = peer.call($('#peerIdAnswerer').val(), stream, options);
video_caller.muted = true;
video_caller.srcObject = stream;
video_caller.onloadedmetadata = function(e) {
video_caller.play();
};
call.on('stream', function(remoteStream) {
video_answerer.muted = true;
video_answerer.srcObject = remoteStream;
video_answerer.onloadedmetadata = function(e) {
video_answerer.play();
};
});
call.on('close', function() {
});
}).catch(function(err) {
console.log('Failed to get local stream' ,err);
});
}
我能做什么或我应该改变什么?感谢您的帮助!