From 7372d12e51360001f97cd5083c6292b99d8c9e42 Mon Sep 17 00:00:00 2001 From: Pedro Beschorner Marin Date: Wed, 18 Mar 2015 16:59:26 -0300 Subject: [PATCH 1/9] Added a timeout cancel button in WebRTC audio connection --- .../main/views/WebRTCEchoTest.mxml | 86 +++++++++++++++---- 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml index 8171b1734c..63071a1e8c 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml @@ -57,8 +57,18 @@ with BigBlueButton; if not, see . private static const LOG:String = "Phone::WebRTCEchoTest - "; private static var DEFAULT_HELP_URL:String = "http://www.bigbluebutton.org/content/videos"; + + private static const TIMEOUT:Number = 30; + private static const CANCEL_BUTTON:Number = Math.round(TIMEOUT * 2 / 3); private var dotTimer:Timer; + + private var cancelTimer:Timer; + private var countdown:Number; + + [Bindable] + private var cancelButtonLabel:String = ResourceUtil.getInstance().getString('bbb.micSettings.cancel'); + private var userClosed:Boolean = false; override public function move(x:Number, y:Number):void { @@ -67,7 +77,7 @@ with BigBlueButton; if not, see . private function onCancelClicked():void { JSLog.debug(LOG + "onCancelClicked ."); - if (dotTimer) dotTimer.stop(); + stopTimers(); PopUpManager.removePopUp(this); } @@ -80,12 +90,40 @@ with BigBlueButton; if not, see . lblConnectMessage.text = lblConnectMessageMock.text = ResourceUtil.getInstance().getString('bbb.micSettings.webrtc.connecting'); dotTimer = new Timer(200, 0); dotTimer.addEventListener(TimerEvent.TIMER, dotAnimate); - dotTimer.start(); - - var testState:String = PhoneModel.getInstance().webRTCModel.state; - if (testState == Constants.DO_ECHO_TEST) { - webRTCEchoTestStarted(); - } + + cancelTimer = new Timer(1000, 0); + cancelTimer.addEventListener(TimerEvent.TIMER, timeout); + + startTimers(); + + var testState:String = PhoneModel.getInstance().webRTCModel.state; + if (testState == Constants.DO_ECHO_TEST) { + webRTCEchoTestStarted(); + } + } + + private function startTimers():void { + if (!dotTimer.running) dotTimer.start(); + if (!cancelTimer.running) { + countdown = TIMEOUT; + cancelTimer.start(); + } + } + + private function stopTimers():void { + if (dotTimer.running) dotTimer.stop(); + if (cancelTimer.running) cancelTimer.stop(); + } + + private function timeout(e:TimerEvent):void { + if (countdown > 0) { + if (!cancelButton.visible && countdown < CANCEL_BUTTON) + cancelButton.visible = true; + cancelButton.label = cancelButtonLabel + " (" + countdown.toString() + ")"; + countdown--; + } else { + noButtonClicked(); + } } private function dotAnimate(e:TimerEvent):void { @@ -122,7 +160,7 @@ with BigBlueButton; if not, see . private function webRTCEchoTestStarted():void { setCurrentState("started"); - dotTimer.stop(); + stopTimers(); } private function handleWebRTCEchoTestEndedEvent(e:WebRTCEchoTestEvent):void { @@ -132,7 +170,7 @@ with BigBlueButton; if not, see . private function webRTCEchoTestEnded():void { setCurrentState("connecting"); lblConnectMessage.text = lblConnectMessageMock.text = ResourceUtil.getInstance().getString('bbb.micSettings.webrtc.endedecho'); - if (!dotTimer.running) dotTimer.start(); + startTimers(); if (!userClosed) { onCancelClicked(); @@ -148,13 +186,13 @@ with BigBlueButton; if not, see . private function handleWebRTCEchoTestWaitingForICEEvent(e:WebRTCEchoTestEvent):void { setCurrentState("connecting"); lblConnectMessage.text = lblConnectMessageMock.text = ResourceUtil.getInstance().getString('bbb.micSettings.webrtc.waitingforice'); - if (!dotTimer.running) dotTimer.start(); + startTimers(); } private function handleWebRTCCallConnectingEvent(e:WebRTCCallEvent):void { setCurrentState("connecting"); lblConnectMessage.text = lblConnectMessageMock.text = ResourceUtil.getInstance().getString('bbb.micSettings.webrtc.connecting'); - if (!dotTimer.running) dotTimer.start(); + startTimers(); } private function handleWebRTCCallFailedEvent(e:WebRTCCallEvent):void { @@ -164,7 +202,7 @@ with BigBlueButton; if not, see . private function handleWebRTCCallWaitingForICEEvent(e:WebRTCCallEvent):void { setCurrentState("connecting"); lblConnectMessage.text = lblConnectMessageMock.text = ResourceUtil.getInstance().getString('bbb.micSettings.webrtc.waitingforice'); - if (!dotTimer.running) dotTimer.start(); + startTimers(); } private function webRTCCallStarted():void { @@ -207,13 +245,23 @@ with BigBlueButton; if not, see . - - - - - + + + + + + + + + + From 2de9adafb863740ba341c4ff0fe8f700b114b1d2 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Fri, 20 Mar 2015 17:18:29 -0300 Subject: [PATCH 2/9] change webrtc timeout to 60 seconds, and show the cancel button after 5 seconds trying to connect --- .../src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml index 63071a1e8c..ebb822a5a9 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml @@ -58,8 +58,8 @@ with BigBlueButton; if not, see . private static const LOG:String = "Phone::WebRTCEchoTest - "; private static var DEFAULT_HELP_URL:String = "http://www.bigbluebutton.org/content/videos"; - private static const TIMEOUT:Number = 30; - private static const CANCEL_BUTTON:Number = Math.round(TIMEOUT * 2 / 3); + private static const TIMEOUT:Number = 60; + private static const CANCEL_BUTTON:Number = 55; private var dotTimer:Timer; From 3c307490ef46e1891ead551fc753de5b8f302551 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Sat, 21 Mar 2015 12:38:08 -0300 Subject: [PATCH 3/9] fixed the cancel button visibility when it take a while to enable webrtc but eventually it worked, so the next time the connecting window is presented, the cancel button should be hidden again instead of remain visible to test it, apply this patch: diff --git a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js index b9b35bb..f497afa 100755 --- a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js +++ b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js @@ -33,7 +33,7 @@ function joinWebRTCVoiceConference() { BBB.webRTCConferenceCallEnded(); break; case 'started': - BBB.webRTCConferenceCallStarted(); + setTimeout(function() { BBB.webRTCConferenceCallStarted(); }, 15000); break; case 'connecting': BBB.webRTCConferenceCallConnecting(); @@ -79,7 +79,7 @@ function startWebRTCAudioTest(){ BBB.webRTCEchoTestEnded(); break; case 'started': - BBB.webRTCEchoTestStarted(); + setTimeout(function() { BBB.webRTCEchoTestStarted(); }, 15000); break; case 'connecting': BBB.webRTCEchoTestConnecting(); --- .../src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml index ebb822a5a9..03976c7241 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml @@ -103,6 +103,7 @@ with BigBlueButton; if not, see . } private function startTimers():void { + cancelButton.visible = false; if (!dotTimer.running) dotTimer.start(); if (!cancelTimer.running) { countdown = TIMEOUT; @@ -254,7 +255,7 @@ with BigBlueButton; if not, see . - Date: Thu, 26 Mar 2015 15:50:51 -0300 Subject: [PATCH 4/9] improved the way we calculate the dimension of the cancel button in the audio test dialog --- .../bigbluebutton/main/views/WebRTCEchoTest.mxml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml index 03976c7241..a9780dc9c2 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/WebRTCEchoTest.mxml @@ -100,6 +100,11 @@ with BigBlueButton; if not, see . if (testState == Constants.DO_ECHO_TEST) { webRTCEchoTestStarted(); } + + cancelButton.width = cancelButton.measureText(genCancelButtonLabel(TIMEOUT)).width + + cancelButton.getStyle("paddingRight") + + cancelButton.getStyle("paddingLeft") + + 8; // 8 is magic number } private function startTimers():void { @@ -115,12 +120,16 @@ with BigBlueButton; if not, see . if (dotTimer.running) dotTimer.stop(); if (cancelTimer.running) cancelTimer.stop(); } + + private function genCancelButtonLabel(countdown:Number):String { + return cancelButtonLabel + " (" + countdown.toString() + ")"; + } private function timeout(e:TimerEvent):void { if (countdown > 0) { if (!cancelButton.visible && countdown < CANCEL_BUTTON) cancelButton.visible = true; - cancelButton.label = cancelButtonLabel + " (" + countdown.toString() + ")"; + cancelButton.label = genCancelButtonLabel(countdown); countdown--; } else { noButtonClicked(); @@ -259,8 +268,7 @@ with BigBlueButton; if not, see . label="{cancelButtonLabel}" styleName="micSettingsWindowPlaySoundButtonStyle" click="noButtonClicked()" - toolTip="" - width="90" /> + toolTip="" /> From 51cfa5f5fa9fbf37b3da4818a79cd2b84d4480e1 Mon Sep 17 00:00:00 2001 From: Pedro Beschorner Marin Date: Thu, 16 Apr 2015 17:01:23 +0000 Subject: [PATCH 5/9] Surrounded bye so error can be caught and trigger cancel --- .../prod/lib/bbb_webrtc_bridge_sip.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js index b9b35bbe4a..d582461415 100755 --- a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js +++ b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js @@ -358,6 +358,23 @@ function make_call(username, voiceBridge, server, callback, recall) { console.log('bye event already received'); } }); + currentSession.on('cancel', function(request){ + callActive = false; + + if (currentSession) { + console.log('call canceled ' + currentSession.endTime); + + if (callPurposefullyEnded === true) { + callback({'status':'ended'}); + } else { + callback({'status':'failed', 'errorcode': 1005}); // Call ended unexpectedly + } + clearTimeout(callTimeout); + currentSession = null; + } else { + console.log('cancel event already received'); + } + }); currentSession.on('accepted', function(data){ callActive = true; console.log('BigBlueButton call accepted'); @@ -412,7 +429,12 @@ function webrtc_hangup(callback) { if (callback) { currentSession.on('bye', callback); } - currentSession.bye(); + try { + currentSession.bye(); + } catch (err) { + console.log("Forcing to cancel current session"); + currentSession.cancel(); + } } function isWebRTCAvailable() { From 5fa32ca80e6ca223d4ca7cd5d9d3939bd7dafee2 Mon Sep 17 00:00:00 2001 From: Pedro Beschorner Marin Date: Fri, 17 Apr 2015 11:17:54 -0300 Subject: [PATCH 6/9] Some cleanup --- .../resources/prod/lib/bbb_webrtc_bridge_sip.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js index d582461415..5b871696b6 100755 --- a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js +++ b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js @@ -363,12 +363,6 @@ function make_call(username, voiceBridge, server, callback, recall) { if (currentSession) { console.log('call canceled ' + currentSession.endTime); - - if (callPurposefullyEnded === true) { - callback({'status':'ended'}); - } else { - callback({'status':'failed', 'errorcode': 1005}); // Call ended unexpectedly - } clearTimeout(callTimeout); currentSession = null; } else { From 25ddb7958d457dda395284444ffd8348e2cd07f2 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Fri, 17 Apr 2015 12:24:12 -0300 Subject: [PATCH 7/9] removed the endTime since it's always null --- .../resources/prod/lib/bbb_webrtc_bridge_sip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js index 5b871696b6..d64d307e30 100755 --- a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js +++ b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js @@ -362,7 +362,7 @@ function make_call(username, voiceBridge, server, callback, recall) { callActive = false; if (currentSession) { - console.log('call canceled ' + currentSession.endTime); + console.log('call canceled'); clearTimeout(callTimeout); currentSession = null; } else { From 7dd576b0e148d415b520f09f71787f56cf0d660d Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Fri, 17 Apr 2015 13:08:34 -0300 Subject: [PATCH 8/9] fixed the issue when the user cancel webrtc, then cancel flash, then join webrtc, and the flash dialog pops up --- .../modules/phone/managers/FlashCallManager.as | 13 +++++++++++++ .../modules/phone/maps/FlashCallEventMap.mxml | 1 + 2 files changed, 14 insertions(+) diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/FlashCallManager.as b/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/FlashCallManager.as index 588a708702..e922d0194e 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/FlashCallManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/FlashCallManager.as @@ -213,6 +213,19 @@ } public function initialize():void { + JSLog.debug(LOG + "Initializing FlashCallManager, current state: " + state); + trace(LOG + "Initializing FlashCallManager, current state: " + state); + switch (state) { + case STOP_ECHO_THEN_JOIN_CONF: + // if we initialize usingFlash here, we won't be able to hang up from + // the flash connection + JSLog.debug(LOG + "Invalid state for initialize, aborting..."); + trace(LOG + "Invalid state for initialize, aborting..."); + return; + default: + break; + } + printMics(); options = new PhoneOptions(); if (options.useWebRTCIfAvailable && isWebRTCSupported()) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/phone/maps/FlashCallEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/phone/maps/FlashCallEventMap.mxml index ec5d98ef56..3106fb7b35 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/phone/maps/FlashCallEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/phone/maps/FlashCallEventMap.mxml @@ -100,6 +100,7 @@ with BigBlueButton; if not, see . + From ecf21c866447f369a05af083d730ce0e1476d3c7 Mon Sep 17 00:00:00 2001 From: Pedro Beschorner Marin Date: Fri, 24 Apr 2015 14:11:17 -0300 Subject: [PATCH 9/9] Added a timer to control ICE gathering process --- .../prod/lib/bbb_webrtc_bridge_sip.js | 1 + .../resources/prod/lib/sip.js | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js index d64d307e30..79202c6c1e 100755 --- a/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js +++ b/bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js @@ -178,6 +178,7 @@ function createUA(username, server, callback) { traceSip: true, autostart: false, userAgentString: "BigBlueButton", + iceGatheringTimeout: 5000, stunServers: "stun:stun.freeswitch.org" }; diff --git a/bigbluebutton-client/resources/prod/lib/sip.js b/bigbluebutton-client/resources/prod/lib/sip.js index 8ff731e808..5bb10e9922 100755 --- a/bigbluebutton-client/resources/prod/lib/sip.js +++ b/bigbluebutton-client/resources/prod/lib/sip.js @@ -8884,6 +8884,7 @@ UA.prototype.loadConfig = function(configuration) { userAgentString: SIP.C.USER_AGENT, // Session parameters + iceGatheringTimeout: 5000, noAnswerTimeout: 60, stunServers: ['stun:stun.l.google.com:19302'], turnServers: [], @@ -9107,6 +9108,7 @@ UA.configuration_skeleton = (function() { "hackViaTcp", // false. "hackIpInContact", //false "hackWssInTransport", //false + "iceGatheringTimeout", "instanceId", "noAnswerTimeout", // 30 seconds. "password", @@ -9288,6 +9290,15 @@ UA.configuration_check = { } }, + iceGatheringTimeout: function(iceGatheringTimeout) { + if(SIP.Utils.isDecimal(iceGatheringTimeout)) { + if (iceGatheringTimeout < 500) { + return 5000; + } + return iceGatheringTimeout; + } + }, + instanceId: function(instanceId) { if(typeof instanceId !== 'string') { return; @@ -10330,10 +10341,21 @@ var MediaHandler = function(session, options) { }; this.peerConnection.onicecandidate = function(e) { + if (self.iceGatheringTimer === undefined) { + self.iceGatheringTimer = SIP.Timers.setTimeout(function() { + self.logger.log('RTCIceGathering Timeout Triggered after '+config.iceGatheringTimeout+' micro seconds'); + self.onIceCompleted.resolve(this); + }.bind(this), config.iceGatheringTimeout); + } + if (e.candidate) { self.logger.log('ICE candidate received: '+ (e.candidate.candidate === null ? null : e.candidate.candidate.trim())); } else { - self.onIceCompleted.resolve(this); + if (self.iceGatheringTimer) { + SIP.Timers.clearTimeout(self.iceGatheringTimer); + self.iceGatheringTimer = null; + self.onIceCompleted.resolve(this); + } } };