Fix bug show black video on Safari when using kurento-utils.js
I'm developing a video call system using Kurento as Media Server. The latest Kurento version said that they already support Safari but it did not work in my case :(
After a day searching, I found a reason and solution:
Safari does not support generateOffer with offerToReceiveAudio: true
To fix it, you have to extend WebRtcPeer.js to modify some line of codes in generateOffer method or hard code. Go to generateOffer method and use this block code:
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
if (constraints.offerToReceiveAudio) {
pc.addTransceiver('audio');
}
if (constraints.offerToReceiveVideo) {
pc.addTransceiver('video');
}
}
Please note that this issue occurred only on Safari, Chrome & Firefox works well so we need to check the block code above only run when browser is Safari.