- determine screenshare connection type

This commit is contained in:
Richard Alam 2018-01-19 12:16:47 -08:00
parent 9d660bb4b5
commit e789d1440d
12 changed files with 130 additions and 157 deletions

View File

@ -41,7 +41,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
private static const LOGGER:ILogger = getClassLogger(ScreenshareModule);
private var _moduleName:String = "Desk Share";
private var _attributes:Object;
private var globalDispatcher:Dispatcher = new Dispatcher();;
@ -53,35 +52,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
return _moduleName;
}
public function get uri():String{
return _attributes.uri;
}
public function get username():String{
return _attributes.username;
}
public function get mode():String{
if (_attributes.mode == null){
_attributes.mode = "LIVE";
LOGGER.debug("Setting DeskShare mode: " + _attributes.mode);
}
LOGGER.debug("DeskShare mode: " + _attributes.mode);
return _attributes.mode;
}
public function get userid():Number{
return _attributes.userid as Number;
}
public function get role():String{
return _attributes.userrole as String;
}
public function start(attributes:Object):void{
LOGGER.debug("desk share attr: " + attributes.username);
_attributes = attributes;
var startEvent:ModuleEvent = new ModuleEvent(ModuleEvent.START);
startEvent.module = this;
globalDispatcher.dispatchEvent(startEvent);
@ -93,27 +66,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
globalDispatcher.dispatchEvent(stopEvent);
}
public function getRoom():String{
return _attributes.room;
}
public function getRed5ServerUri():String{
return _attributes.uri;
}
public function getCaptureServerUri():String{
var uri:String = _attributes.uri;
uri = uri.split("/")[2];
return uri;
}
public function tunnel():Boolean {
if (_attributes.protocol == "RTMPT") {
LOGGER.debug("Use tunneling for desktop sharing");
return true;
}
return false;
}
]]>
</fx:Script>

View File

@ -72,7 +72,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
logoutURL = p.getParameter("LOGOUTURL");
host = p.getParameter("HOST");
room = p.getParameter("ROOM");
service.connect(host, room);
service.connect();
cursor.graphics.lineStyle(6, 0xFF0000, 0.6);
cursor.graphics.drawCircle(0,0,3);

View File

@ -29,9 +29,7 @@ package org.bigbluebutton.main.model.users
import flash.net.ObjectEncoding;
import flash.net.Responder;
import flash.utils.Timer;
import mx.utils.ObjectUtil;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.BBB;
@ -44,7 +42,6 @@ package org.bigbluebutton.main.model.users
import org.bigbluebutton.core.events.TokenValidReconnectEvent;
import org.bigbluebutton.core.managers.ReconnectionManager;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.core.services.BandwidthMonitor;
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.main.events.InvalidAuthTokenEvent;
import org.bigbluebutton.main.model.options.ApplicationOptions;
@ -415,7 +412,7 @@ package org.bigbluebutton.main.model.users
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<server>.+)\/(?P<app>.+)/;
var result:Array = pattern.exec(appURL);
var uri:String = appURL + "/" + intMeetingId;
var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS;
if (BBB.initConnectionManager().isTunnelling) {
@ -467,15 +464,14 @@ package org.bigbluebutton.main.model.users
recorded, extUserId,
intUserId, muteOnStart,
guest, authToken);
} catch(e:ArgumentError) {
// Invalid parameters.
switch (e.errorID) {
case 2004 :
LOGGER.debug("Error! Invalid server location: {0}", [uri]);
LOGGER.debug("Error! Invalid server location: {0}", [bbbAppsUrl]);
break;
default :
LOGGER.debug("UNKNOWN Error! Invalid server location: {0}", [uri]);
LOGGER.debug("UNKNOWN Error! Invalid server location: {0}", [bbbAppsUrl]);
break;
}
}

View File

@ -46,11 +46,11 @@ package org.bigbluebutton.modules.screenshare.managers {
if (shareWindow != null) shareWindow.stopSharing();
}
public function startSharing(uri:String, room:String, tunnel:Boolean):void {
public function startSharing():void {
LOGGER.debug("DS:PublishWindowManager::opening desk share window");
if (shareWindow == null) {
shareWindow = new ScreensharePublishWindow();
shareWindow.initWindow(service.getConnection(), uri, room, tunnel);
shareWindow.initWindow(service.getConnection());
shareWindow.visible = true;
openWindow(shareWindow);
}

View File

@ -152,7 +152,7 @@ package org.bigbluebutton.modules.screenshare.managers {
if (force || (options.tryWebRTCFirst && !BrowserCheck.isWebRTCSupported()) || !options.tryWebRTCFirst) {
usingJava = true;
publishWindowManager.startSharing(module.getCaptureServerUri(), module.getRoom(), BBB.initConnectionManager().isTunnelling);
publishWindowManager.startSharing();
sharing = true;
service.requestShareToken();
} else {
@ -200,7 +200,7 @@ package org.bigbluebutton.modules.screenshare.managers {
public function handleStartSharingEvent():void {
//toolbarButtonManager.disableToolbarButton();
toolbarButtonManager.startedSharing();
publishWindowManager.startSharing(module.getCaptureServerUri(), module.getRoom(), module.tunnel());
publishWindowManager.startSharing();
sharing = true;
}

View File

@ -34,12 +34,12 @@ package org.bigbluebutton.modules.screenshare.managers
private var viewWindow:WebRTCDesktopViewWindow;
private var shareWindow:WebRTCDesktopPublishWindow;
private var service:WebRTCDeskshareService;
private var isViewing:Boolean = false;
private var globalDispatcher:Dispatcher;
public function WebRTCViewerWindowManager(service:WebRTCDeskshareService) {
this.service = service;
globalDispatcher = new Dispatcher();
}

View File

@ -21,6 +21,9 @@ package org.bigbluebutton.modules.screenshare.model {
public class ScreenshareOptions extends Options {
[Bindable]
public var uri: String = "";
[Bindable]
public var showButton:Boolean = true;

View File

@ -18,8 +18,7 @@
*/
package org.bigbluebutton.modules.screenshare.services {
import com.asfusion.mate.events.Dispatcher;
import flash.net.NetConnection;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.UsersUtil;
@ -39,9 +38,7 @@ package org.bigbluebutton.modules.screenshare.services {
private var module:ScreenshareModule;
private var dispatcher:Dispatcher;
private var uri:String;
private var room:String;
private var sender:MessageSender;
private var receiver:MessageReceiver;
@ -52,19 +49,14 @@ package org.bigbluebutton.modules.screenshare.services {
public function handleStartModuleEvent(module:ScreenshareModule):void {
LOGGER.debug("Screenshare Module starting");
this.module = module;
connect(module.uri, module.getRoom());
connect();
}
public function connect(uri:String, room:String):void {
this.uri = uri;
this.room = room;
LOGGER.debug("Screenshare Service connecting to " + uri);
conn = new Connection(room);
public function connect():void {
conn = new Connection();
sender = new MessageSender(conn);
receiver = new MessageReceiver(conn);
conn.setURI(uri);
conn.connect();
}

View File

@ -37,13 +37,10 @@ package org.bigbluebutton.modules.screenshare.services
private var sender:MessageSender;
private var uri:String;
private var room:String;
public function WebRTCDeskshareService() {
this.dispatcher = new Dispatcher();
red5conn = new Connection(room);
red5conn = new Connection();
sender = new MessageSender(red5conn);
sender.queryForScreenshare();
}
@ -51,14 +48,8 @@ package org.bigbluebutton.modules.screenshare.services
public function handleStartModuleEvent(module:ScreenshareModule):void {
LOGGER.debug("Deskshare Module starting");
this.module = module;
connect(module.uri, module.getRoom());
}
public function connect(uri:String, room:String):void {
this.uri = uri;
this.room = room;
LOGGER.debug("Deskshare Service connecting to {0}", [uri]);
}
public function getConnection():NetConnection{
return red5conn.getConnection();

View File

@ -19,62 +19,79 @@
package org.bigbluebutton.modules.screenshare.services.red5 {
import com.asfusion.mate.events.Dispatcher;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.managers.ReconnectionManager;
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.modules.screenshare.events.ViewStreamEvent;
import org.bigbluebutton.modules.screenshare.model.ScreenshareModel;
import org.bigbluebutton.modules.screenshare.model.ScreenshareOptions;
import org.bigbluebutton.util.ConnUtil;
public class Connection {
private static const LOGGER:ILogger = getClassLogger(Connection);
private var netConnection:NetConnection;
private var uri:String;
private var responder:Responder;
private var width:Number;
private var height:Number;
private var meetingId:String;
private var dispatcher:Dispatcher = new Dispatcher();
private var _messageListeners:Array = new Array();
private var logoutOnUserCommand:Boolean = false;
private var reconnecting:Boolean = false;
public function Connection(meetingId:String) {
this.meetingId = meetingId;
}
private var ssAppUrl: String = null;
public function connect():void {
var isTunnelling:Boolean = BBB.initConnectionManager().isTunnelling;
if (isTunnelling) {
uri = uri.replace(/rtmp:/gi, "rtmpt:");
}
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF3;
netConnection = new NetConnection();
netConnection.proxyType = "best";
netConnection = new NetConnection();
netConnection.objectEncoding = ObjectEncoding.AMF3;
var options: ScreenshareOptions = Options.getOptions(ScreenshareOptions) as ScreenshareOptions;
var appURL: String = options.uri;
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<server>.+)\/(?P<app>.+)/;
var result:Array = pattern.exec(appURL);
var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS;
if (BBB.initConnectionManager().isTunnelling) {
var tunnelProtocol: String = ConnUtil.RTMPT;
if (useRTMPS) {
netConnection.proxyType = ConnUtil.PROXY_NONE;
tunnelProtocol = ConnUtil.RTMPS;
}
ssAppUrl = tunnelProtocol + "://" + result.server + "/" + result.app + "/" + UsersUtil.getInternalMeetingID();
trace("******* SCREENSHARE CONNECT tunnel = TRUE " + "url=" + ssAppUrl);
} else {
var nativeProtocol: String = ConnUtil.RTMP;
if (useRTMPS) {
netConnection.proxyType = ConnUtil.PROXY_BEST;
nativeProtocol = ConnUtil.RTMPS;
}
ssAppUrl = nativeProtocol + "://" + result.server + "/" + result.app + "/" + UsersUtil.getInternalMeetingID();
trace("******* SCREENSHARE CONNECT tunnel = FALSE " + "url=" + ssAppUrl);
}
netConnection.client = this;
netConnection.addEventListener( NetStatusEvent.NET_STATUS , netStatusHandler);
netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
// uri may include internal meetingId if we are reconnecting
var internalMeetingID:String = UsersUtil.getInternalMeetingID();
if (uri.indexOf(internalMeetingID) == -1) {
uri = uri + "/" + internalMeetingID;
}
LOGGER.debug("Connecting to uri=[{0}]", [uri]);
netConnection.connect(uri);
LOGGER.debug("Connecting to uri=[{0}]", [ssAppUrl]);
netConnection.connect(ssAppUrl);
}
@ -215,11 +232,7 @@ package org.bigbluebutton.modules.screenshare.services.red5 {
// LOGGER.error(status);
}, message);
}
public function setURI(p_URI:String):void {
uri = p_URI;
}
public function onBWCheck(... rest):Number {
return 0;
}
@ -234,7 +247,7 @@ package org.bigbluebutton.modules.screenshare.services.red5 {
private function sendUserIdToServer():void {
var message:Object = new Object();
message["meetingId"] = meetingId;
message["meetingId"] = UsersUtil.getInternalMeetingID();
message["userId"] = UsersUtil.getMyUserID();
sendMessage("screenshare.setUserId", function(result:String):void { // On successful result
@ -250,7 +263,7 @@ package org.bigbluebutton.modules.screenshare.services.red5 {
}
private function netStatusHandler(event:NetStatusEvent):void {
LOGGER.debug("Connected to [" + uri + "]. [" + event.info.code + "]");
LOGGER.debug("Connected to [" + ssAppUrl + "]. [" + event.info.code + "]");
var ce:ConnectionEvent;
switch (event.info.code) {
@ -332,11 +345,11 @@ package org.bigbluebutton.modules.screenshare.services.red5 {
}
public function connectionFailedHandler(e:ConnectionEvent):void {
LOGGER.error("connection failed to " + uri + " with message " + e.toString());
LOGGER.error("connection failed to " + ssAppUrl + " with message " + e.toString());
}
public function connectionRejectedHandler(e:ConnectionEvent):void {
LOGGER.error("connection rejected " + uri + " with message " + e.toString());
LOGGER.error("connection rejected " + ssAppUrl + " with message " + e.toString());
}
}

View File

@ -49,32 +49,33 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.common.events.LocaleChangeEvent;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.managers.ReconnectionManager;
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.main.events.MadePresenterEvent;
import org.bigbluebutton.main.events.ShortcutEvent;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.screenshare.events.RequestToPauseSharing;
import org.bigbluebutton.modules.screenshare.events.RequestToRestartSharing;
import org.bigbluebutton.modules.screenshare.events.RequestToStopSharing;
import org.bigbluebutton.modules.screenshare.events.ScreenSharePausedEvent;
import org.bigbluebutton.modules.screenshare.events.ShareStartEvent;
import org.bigbluebutton.modules.screenshare.events.ShareStoppedEvent;
import org.bigbluebutton.modules.screenshare.events.ShareWindowEvent;
import org.bigbluebutton.modules.screenshare.events.StartShareRequestSuccessEvent;
import org.bigbluebutton.modules.screenshare.events.StopSharingButtonEvent;
import org.bigbluebutton.modules.screenshare.events.ViewStreamEvent;
import org.bigbluebutton.modules.screenshare.model.ScreenshareModel;
import org.bigbluebutton.modules.screenshare.model.ScreenshareOptions;
import org.bigbluebutton.modules.screenshare.services.red5.Connection;
import org.bigbluebutton.util.i18n.ResourceUtil;
import com.asfusion.mate.events.Dispatcher;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.common.events.LocaleChangeEvent;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.managers.ReconnectionManager;
import org.bigbluebutton.main.events.BBBEvent;
import org.bigbluebutton.main.events.MadePresenterEvent;
import org.bigbluebutton.main.events.ShortcutEvent;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.screenshare.events.RequestToPauseSharing;
import org.bigbluebutton.modules.screenshare.events.RequestToRestartSharing;
import org.bigbluebutton.modules.screenshare.events.RequestToStopSharing;
import org.bigbluebutton.modules.screenshare.events.ScreenSharePausedEvent;
import org.bigbluebutton.modules.screenshare.events.ShareStartEvent;
import org.bigbluebutton.modules.screenshare.events.ShareStoppedEvent;
import org.bigbluebutton.modules.screenshare.events.ShareWindowEvent;
import org.bigbluebutton.modules.screenshare.events.StartShareRequestSuccessEvent;
import org.bigbluebutton.modules.screenshare.events.StopSharingButtonEvent;
import org.bigbluebutton.modules.screenshare.events.ViewStreamEvent;
import org.bigbluebutton.modules.screenshare.model.ScreenshareModel;
import org.bigbluebutton.modules.screenshare.model.ScreenshareOptions;
import org.bigbluebutton.modules.screenshare.services.red5.Connection;
import org.bigbluebutton.util.i18n.ResourceUtil;
private static const LOGGER:ILogger = getClassLogger(ScreensharePublishWindow);
@ -84,9 +85,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
private static const VID_WIDTH_PAD:Number = 6;
private var connection:Connection;
private var uri:String;
private var room:String;
private var tunnel:Boolean = false;
private var sharingFullScreen:Boolean = false;
private var streaming:Boolean = false;
@ -137,7 +135,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
focusManager.setFocus(titleBarOverlay);
if (tunnel) {
if (BBB.initConnectionManager().isTunnelling) {
helpInfoBox.visible = helpInfoBox.includeInLayout = false;
previewBox.visible = previewBox.includeInLayout = false;
tunnelBox.visible = tunnelBox.includeInLayout = true;
@ -188,11 +186,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/
public function resetWidthAndHeight():void{/* do nothing */}
public function initWindow(connection:Connection, uri:String, room:String, tunnel:Boolean):void {
public function initWindow(connection:Connection):void {
this.connection = connection;
this.uri = uri;
this.room = room;
this.tunnel = tunnel;
}
private function handleStartShareRequestSuccessEvent(event:StartShareRequestSuccessEvent):void {
@ -258,10 +253,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
startBtn.enabled = false;
var shareStartEvent:ShareStartEvent = new ShareStartEvent();
dispatchEvent(shareStartEvent);
startSharing(connection.getConnection(), uri, room, fullScreen);
startSharing(connection.getConnection(), fullScreen);
}
private function startSharing(connection:NetConnection, uri:String, room:String, fullScreen:Boolean):void {
private function startSharing(connection:NetConnection, fullScreen:Boolean):void {
var captureX:Number = 0;
var captureY:Number = 0;
sharingFullScreen = fullScreen;

View File

@ -47,12 +47,15 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.common.IBbbModuleWindow;
import org.bigbluebutton.common.events.LocaleChangeEvent;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.screenshare.events.ViewStreamEvent;
import org.bigbluebutton.modules.screenshare.events.ViewWindowEvent;
import org.bigbluebutton.modules.screenshare.model.ScreenshareOptions;
import org.bigbluebutton.modules.screenshare.services.red5.WebRTCConnectionEvent;
import org.bigbluebutton.util.ConnUtil;
import org.bigbluebutton.util.i18n.ResourceUtil;
public static const LOG:String = "Deskshare::DesktopViewWindow - ";
@ -130,13 +133,41 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
public function connect(rtmpUrl: String):void {
nc = new NetConnection();
nc.proxyType = "best";
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<serverAndApp>.+)/;
var result:Array = pattern.exec(rtmpUrl);
var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS;
var ssAppUrl: String = null;
if (BBB.initConnectionManager().isTunnelling) {
var tunnelProtocol: String = ConnUtil.RTMPT;
if (useRTMPS) {
nc.proxyType = ConnUtil.PROXY_NONE;
tunnelProtocol = ConnUtil.RTMPS;
}
ssAppUrl = tunnelProtocol + "://" + result.serverAndApp;
trace("******* WEBRTC SSHARE CONNECT tunnel = TRUE " + "url=" + ssAppUrl);
} else {
var nativeProtocol: String = ConnUtil.RTMP;
if (useRTMPS) {
nc.proxyType = ConnUtil.PROXY_BEST;
nativeProtocol = ConnUtil.RTMPS;
}
ssAppUrl = nativeProtocol + "://" + result.serverAndApp;
trace("******* WEBRTC SSHARE CONNECT tunnel = FALSE " + "url=" + ssAppUrl);
}
nc.objectEncoding = ObjectEncoding.AMF3;
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
nc.connect(rtmpUrl);
nc.connect(ssAppUrl);
}
public function connectionSuccessHandler():void{