Makes utility for webrtc capabilities
This commit is contained in:
parent
c08f9d4d7b
commit
f5650b1d16
@ -39,6 +39,7 @@ package org.bigbluebutton.modules.screenshare.managers
|
||||
import org.bigbluebutton.modules.screenshare.utils.BrowserCheck;
|
||||
import org.bigbluebutton.modules.screenshare.events.DeskshareToolbarEvent;
|
||||
import org.bigbluebutton.modules.screenshare.events.ShareStartedEvent;
|
||||
import org.bigbluebutton.modules.screenshare.utils.WebRTCScreenshareUtility;
|
||||
|
||||
public class WebRTCDeskshareManager {
|
||||
private static const LOGGER:ILogger = getClassLogger(WebRTCDeskshareManager);
|
||||
@ -162,76 +163,44 @@ package org.bigbluebutton.modules.screenshare.managers
|
||||
sharing = false;
|
||||
}
|
||||
|
||||
private function canIUseVertoOnThisBrowser(newOnWebRTCBrokeFailure:Function = null, newOnNoWebRTCFailure:Function = null, newOnSuccess:Function = null):void {
|
||||
LOGGER.debug("DeskshareManager::canIUseVertoOnThisBrowser");
|
||||
var options:ScreenshareOptions = new ScreenshareOptions();
|
||||
options.parseOptions();
|
||||
var onNoWebRTCFailure:Function, onWebRTCBrokeFailure:Function, onSuccess:Function;
|
||||
/* When WebRTC DS cannot be used. Marks usingWebRTC as false,
|
||||
sends out fall back to java command
|
||||
*/
|
||||
private function cannotUseWebRTC (message:String):void {
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent - falling back to java");
|
||||
usingWebRTC = false;
|
||||
// send out event to fallback to Java
|
||||
globalDispatcher.dispatchEvent(new UseJavaModeCommand());
|
||||
};
|
||||
|
||||
onNoWebRTCFailure = (newOnNoWebRTCFailure != null) ? newOnNoWebRTCFailure : function(message:String):void {
|
||||
usingWebRTC = false;
|
||||
// send out event to fallback to Java
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent - falling back to java");
|
||||
globalDispatcher.dispatchEvent(new UseJavaModeCommand());
|
||||
return;
|
||||
};
|
||||
/* When WebRTC is supported in the browser, theres an extension key,
|
||||
but not configured properly (no extension for example)
|
||||
*/
|
||||
private function webRTCWorksButNotConfigured (message:String):void {
|
||||
publishWindowManager.openWindow();
|
||||
globalDispatcher.dispatchEvent(new WebRTCPublishWindowChangeState(WebRTCPublishWindowChangeState.DISPLAY_INSTALL));
|
||||
}
|
||||
|
||||
onWebRTCBrokeFailure = (newOnWebRTCBrokeFailure != null) ? newOnWebRTCBrokeFailure : function(message:String):void {
|
||||
publishWindowManager.openWindow();
|
||||
globalDispatcher.dispatchEvent(new WebRTCPublishWindowChangeState(WebRTCPublishWindowChangeState.DISPLAY_INSTALL));
|
||||
};
|
||||
|
||||
onSuccess = (newOnSuccess != null) ? newOnSuccess : function(message:String):void {
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent onSuccess");
|
||||
usingWebRTC = true;
|
||||
startWebRTCDeskshare();
|
||||
};
|
||||
|
||||
if (options.tryWebRTCFirst && BrowserCheck.isWebRTCSupported() && BrowserCheck.isHttps()) {
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent WebRTC Supported");
|
||||
if (BrowserCheck.isFirefox()) {
|
||||
onSuccess("Firefox, lets try");
|
||||
} else {
|
||||
if (chromeExtensionKey != null) {
|
||||
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent chrome extension link exists - ");
|
||||
if (ExternalInterface.available) {
|
||||
|
||||
var success2:Function = function(exists:Boolean):void {
|
||||
ExternalInterface.addCallback("success2", null);
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent inside onSuccess2");
|
||||
if (exists) {
|
||||
LOGGER.debug("Chrome Extension exists");
|
||||
onSuccess("worked");
|
||||
} else {
|
||||
onWebRTCBrokeFailure("No Chrome Extension");
|
||||
LOGGER.debug("no chrome extension");
|
||||
}
|
||||
};
|
||||
ExternalInterface.addCallback("success2", success2);
|
||||
ExternalInterface.call("checkChromeExtInstalled", "success2", chromeExtensionKey);
|
||||
}
|
||||
} else {
|
||||
onNoWebRTCFailure("No chromeExtensionKey in config.xml");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onNoWebRTCFailure("Web browser doesn't support WebRTC");
|
||||
return;
|
||||
}
|
||||
/* WebRTC is supported and everything is configured properly (extension exists),
|
||||
attempt to share
|
||||
*/
|
||||
private function webRTCWorksAndConfigured (message:String):void {
|
||||
LOGGER.debug("WebRTCDeskshareManager::webRTCWorksAndConfigured");
|
||||
usingWebRTC = true;
|
||||
startWebRTCDeskshare();
|
||||
}
|
||||
|
||||
/*handle start sharing event*/
|
||||
public function handleStartSharingEvent():void {
|
||||
LOGGER.debug("WebRTCDeskshareManager::handleStartSharingEvent");
|
||||
|
||||
if (WebRTCAudioStatus.getInstance().getDidWebRTCAudioFail()) {
|
||||
usingWebRTC = false;
|
||||
globalDispatcher.dispatchEvent(new UseJavaModeCommand());
|
||||
return;
|
||||
usingWebRTC = false;
|
||||
globalDispatcher.dispatchEvent(new UseJavaModeCommand());
|
||||
return;
|
||||
}
|
||||
|
||||
canIUseVertoOnThisBrowser();
|
||||
WebRTCScreenshareUtility.canIUseVertoOnThisBrowser(cannotUseWebRTC, webRTCWorksButNotConfigured, webRTCWorksAndConfigured);
|
||||
}
|
||||
|
||||
public function handleShareWindowCloseEvent():void {
|
||||
@ -288,7 +257,7 @@ package org.bigbluebutton.modules.screenshare.managers
|
||||
var dispatcher:Dispatcher = new Dispatcher();
|
||||
dispatcher.dispatchEvent(new WebRTCViewStreamEvent(WebRTCViewStreamEvent.START));
|
||||
}
|
||||
|
||||
|
||||
/*public function handleIsSharingScreenEvent(event: IsSharingScreenEvent):void {*/
|
||||
public function handleIsSharingScreenEvent():void {
|
||||
if (UsersUtil.amIPresenter()) {
|
||||
|
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
*
|
||||
* Copyright (c) 2017 BigBlueButton Inc. and by respective authors (see below).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along
|
||||
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.bigbluebutton.modules.screenshare.utils
|
||||
{
|
||||
import flash.external.ExternalInterface;
|
||||
import org.as3commons.logging.api.ILogger;
|
||||
import org.as3commons.logging.api.getClassLogger;
|
||||
import org.bigbluebutton.modules.screenshare.utils.BrowserCheck;
|
||||
import org.bigbluebutton.modules.screenshare.model.ScreenshareOptions;
|
||||
|
||||
public class WebRTCScreenshareUtility {
|
||||
private static const LOGGER:ILogger = getClassLogger(WebRTCScreenshareUtility);
|
||||
public static var chromeExtensionKey:String = null;
|
||||
public static var extensionLink:String = null;
|
||||
|
||||
public static function canIUseVertoOnThisBrowser (cannotUseWebRTC:Function, webRTCWorksButNotConfigured:Function, webRTCWorksAndConfigured:Function):void {
|
||||
LOGGER.debug("WebRTCScreenshareUtility::canIUseVertoOnThisBrowser");
|
||||
|
||||
if (!ExternalInterface.available) {
|
||||
cannotUseWebRTC("No ExternalInterface");
|
||||
return;
|
||||
}
|
||||
|
||||
// https is required for verto and for peripheral sharing
|
||||
/*if (!BrowserCheck.isHttps()) {
|
||||
cannotUseWebRTC("Requires Https");
|
||||
return;
|
||||
}*/
|
||||
|
||||
var options:ScreenshareOptions = new ScreenshareOptions();
|
||||
options.parseOptions();
|
||||
|
||||
// fail if you dont want to try webrtc first
|
||||
if (!options.tryWebRTCFirst) {
|
||||
cannotUseWebRTC("not supposed to try WebRTC first (config.xml)");
|
||||
return;
|
||||
}
|
||||
|
||||
// webrtc isnt even supported
|
||||
if (!BrowserCheck.isWebRTCSupported()) {
|
||||
cannotUseWebRTC("Web browser doesn't support WebRTC");
|
||||
return;
|
||||
}
|
||||
|
||||
// if theres no extension link-- users cant download-- fail
|
||||
if (options.chromeExtensionLink == null || options.chromeExtensionLink == "") {
|
||||
cannotUseWebRTC("No extensionLink in config.xml");
|
||||
return;
|
||||
}
|
||||
|
||||
WebRTCScreenshareUtility.extensionLink = options.chromeExtensionLink;
|
||||
|
||||
// if its firefox go ahead and let verto handle it
|
||||
if (BrowserCheck.isFirefox()) {
|
||||
webRTCWorksAndConfigured("Firefox, lets try");
|
||||
return;
|
||||
|
||||
// if its chrome we need to check for the extension
|
||||
} else if (BrowserCheck.isChrome()) {
|
||||
WebRTCScreenshareUtility.chromeExtensionKey = options.chromeExtensionKey;
|
||||
|
||||
// if theres no key we cannot connect to the extension-- fail
|
||||
if (WebRTCScreenshareUtility.chromeExtensionKey == null || WebRTCScreenshareUtility.chromeExtensionKey == "") {
|
||||
cannotUseWebRTC("No chromeExtensionKey in config.xml");
|
||||
return;
|
||||
}
|
||||
|
||||
// connect to the verto code to attempt a connection with the extension
|
||||
var onSuccess:Function = function(exists:Boolean):void {
|
||||
// clear the check callback
|
||||
ExternalInterface.addCallback("onSuccess", null);
|
||||
|
||||
if (exists) {
|
||||
LOGGER.debug("Chrome Extension exists");
|
||||
webRTCWorksAndConfigured("worked");
|
||||
} else {
|
||||
webRTCWorksButNotConfigured("No Chrome Extension");
|
||||
LOGGER.debug("no chrome extension");
|
||||
}
|
||||
};
|
||||
|
||||
// add the callback
|
||||
ExternalInterface.addCallback("onSuccess", onSuccess);
|
||||
// check if the extension exists
|
||||
ExternalInterface.call("checkChromeExtInstalled", "onSuccess", WebRTCScreenshareUtility.chromeExtensionKey);
|
||||
} else {
|
||||
cannotUseWebRTC("Web browser doesn't support WebRTC");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user