From 87b4306e7fa7ec6b36d6ca8143a41ca7d227d658 Mon Sep 17 00:00:00 2001 From: Gustavo Trott <gustavO@trott.com.br> Date: Thu, 10 Jan 2019 21:22:14 -0200 Subject: [PATCH] Add tryGenerateIceCandidates to verify and ask media permission if necessary --- .../imports/utils/safari-webrtc.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/bigbluebutton-html5/imports/utils/safari-webrtc.js b/bigbluebutton-html5/imports/utils/safari-webrtc.js index 652e4b840e..685be90f71 100644 --- a/bigbluebutton-html5/imports/utils/safari-webrtc.js +++ b/bigbluebutton-html5/imports/utils/safari-webrtc.js @@ -10,19 +10,37 @@ export function canGenerateIceCandidates() { if(countIceCandidates) return; if (e.candidate) { countIceCandidates++; - resolve(true); + resolve(); } } - + pc.onicegatheringstatechange = function(e) { - if(e.currentTarget.iceGatheringState == 'complete' && countIceCandidates == 0) reject(true); + if(e.currentTarget.iceGatheringState == 'complete' && countIceCandidates == 0) reject(); } setTimeout(function(){ - if(!countIceCandidates) reject(true); + if(!countIceCandidates) reject(); }, 3000); p = pc.createOffer({offerToReceiveVideo: true}); p.then( answer => {pc.setLocalDescription(answer) ; } ) }); }; + +export function tryGenerateIceCandidates() { + return new Promise((resolve, reject) => { + canGenerateIceCandidates().then(ok => { + resolve(); + }).catch(e => { + navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(function (stream) { + canGenerateIceCandidates().then(ok => { + resolve(); + }).catch(e => { + reject(); + }); + }).catch(e => { + reject(); + }); + }); + }); +}; \ No newline at end of file -- GitLab