From 5d2a78a5ce6eb227c4fafe5d6f691a168588ea5b Mon Sep 17 00:00:00 2001 From: Augusto Bennemann Date: Tue, 28 Nov 2017 17:31:36 -0200 Subject: [PATCH] HTML5 video iOS support --- .../ui/components/video-dock/component.jsx | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx b/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx index 47232fb938..42edf9f741 100644 --- a/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx @@ -87,11 +87,15 @@ export default class VideoDock extends Component { const webRtcPeer = this.state.webRtcPeers[parsedMessage.cameraId]; if (webRtcPeer !== null) { - webRtcPeer.addIceCandidate(parsedMessage.candidate, (err) => { - if (err) { - return log('error', `Error adding candidate: ${err}`); - } - }); + if (webRtcPeer.didSDPAnswered) { + webRtcPeer.addIceCandidate(parsedMessage.candidate, (err) => { + if (err) { + return log('error', `Error adding candidate: ${err}`); + } + }); + } else { + webRtcPeer.iceQueue.push(parsedMessage.candidate); + } } else { log('error', ' [ICE] Message arrived before webRtcPeer?'); } @@ -119,13 +123,23 @@ export default class VideoDock extends Component { that.sendMessage(message); }; + var videoConstraints = {}; + if (!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) { // Custom constraints for Safari + videoConstraints = { + width: {min:320, max:640}, + height: {min:240, max:480} + } + } else { + videoConstraints = { + width: {min: 320, ideal: 320}, + height: {min: 240, ideal:240}, + frameRate: {min: 5, ideal: 10} + }; + } + const options = { mediaConstraints: { audio: false, - video: { - width: {min: 320, ideal: 320}, - height: {min: 240, ideal:240}, - frameRate: { min: 5, ideal: 10} - } + video: videoConstraints }, onicecandidate: onIceCandidate, }; @@ -143,6 +157,7 @@ export default class VideoDock extends Component { options.remoteVideo.height = 90; options.remoteVideo.autoplay = true; options.remoteVideo.playsinline = true; + options.remoteVideo.muted = true; document.getElementById('webcamArea').appendChild(options.remoteVideo); } @@ -154,6 +169,9 @@ export default class VideoDock extends Component { return; } + this.didSDPAnswered = false; + this.iceQueue = []; + if (shareWebcam) { that.state.sharedWebcam = that.state.webRtcPeers[id]; that.state.myId = id; @@ -173,6 +191,15 @@ export default class VideoDock extends Component { }; that.sendMessage(message); }); + while (this.iceQueue.length) { + var candidate = this.iceQueue.shift(); + this.addIceCandidate(candidate, (err) => { + if (err) { + return console.error(`Error adding candidate: ${err}`); + } + }); + } + this.didSDPAnswered = true; }); }