From e388173f1f2f08f1b1e15fdb35162095c88c23c4 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Fri, 19 Jan 2018 08:38:55 -0800 Subject: [PATCH] - bw mon determine connection type --- .../core/services/BandwidthMonitor.as | 51 +++++++++++++------ .../bwcheck/app/BandwidthDetectionApp.as | 41 +++++++++++++-- 2 files changed, 72 insertions(+), 20 deletions(-) mode change 100644 => 100755 bigbluebutton-client/src/org/bigbluebutton/core/services/BandwidthMonitor.as diff --git a/bigbluebutton-client/src/org/bigbluebutton/core/services/BandwidthMonitor.as b/bigbluebutton-client/src/org/bigbluebutton/core/services/BandwidthMonitor.as old mode 100644 new mode 100755 index a9b330ef31..5038b47714 --- a/bigbluebutton-client/src/org/bigbluebutton/core/services/BandwidthMonitor.as +++ b/bigbluebutton-client/src/org/bigbluebutton/core/services/BandwidthMonitor.as @@ -25,7 +25,11 @@ package org.bigbluebutton.core.services 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.model.BandwidthMonOptions; import org.bigbluebutton.main.model.NetworkStatsData; + import org.bigbluebutton.util.ConnUtil; import org.red5.flash.bwcheck.ClientServerBandwidth; import org.red5.flash.bwcheck.ServerClientBandwidth; import org.red5.flash.bwcheck.events.BandwidthDetectEvent; @@ -35,8 +39,6 @@ package org.bigbluebutton.core.services public static const INTERVAL_BETWEEN_CHECKS:int = 30000; // in ms private static var _instance:BandwidthMonitor = null; - private var _serverURL:String = "localhost"; - private var _serverApplication:String = "video"; private var _clientServerService:String = "checkBandwidthUp"; private var _serverClientService:String = "checkBandwidth"; private var _pendingClientToServer:Boolean; @@ -83,26 +85,43 @@ package org.bigbluebutton.core.services } return _instance; } - - public function set serverURL(url:String):void { - if (_nc.connected) - _nc.close(); - _serverURL = url; - } - - public function set serverApplication(app:String):void { - if (_nc.connected) - _nc.close(); - _serverApplication = app; - } - + public function start():void { connect(); } private function connect():void { if (!_nc.connected && !_connecting) { - _nc.connect("rtmp://" + _serverURL + "/" + _serverApplication); + var bwMonOption:BandwidthMonOptions = Options.getOptions(BandwidthMonOptions) as BandwidthMonOptions; + + var pattern:RegExp = /(?P.+):\/\/(?P.+)/; + var result:Array = pattern.exec(bwMonOption.server); + + var bwMonUrl: String; + var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS; + if (BBB.initConnectionManager().isTunnelling) { + var tunnelProtocol: String = ConnUtil.RTMPT; + + if (useRTMPS) { + _nc.proxyType = ConnUtil.PROXY_NONE; + tunnelProtocol = ConnUtil.RTMPS; + } + + + bwMonUrl = tunnelProtocol + "://" + result.server + "/" + bwMonOption.application; + trace("******* BW MON CONNECT tunnel = TRUE " + "url=" + bwMonUrl); + } else { + var nativeProtocol: String = ConnUtil.RTMP; + if (useRTMPS) { + _nc.proxyType = ConnUtil.PROXY_BEST; + nativeProtocol = ConnUtil.RTMPS; + } + + bwMonUrl = nativeProtocol + "://" + result.server + "/" + bwMonOption.application; + trace("******* BBB MON CONNECT tunnel = FALSE " + "url=" + bwMonUrl); + } + + _nc.connect(bwMonUrl); _connecting = true; } } diff --git a/bigbluebutton-client/src/org/red5/flash/bwcheck/app/BandwidthDetectionApp.as b/bigbluebutton-client/src/org/red5/flash/bwcheck/app/BandwidthDetectionApp.as index 4ce74b00b8..d18d270927 100755 --- a/bigbluebutton-client/src/org/red5/flash/bwcheck/app/BandwidthDetectionApp.as +++ b/bigbluebutton-client/src/org/red5/flash/bwcheck/app/BandwidthDetectionApp.as @@ -7,6 +7,10 @@ package org.red5.flash.bwcheck.app import mx.core.Application; import org.bigbluebutton.common.LogUtil; + import org.bigbluebutton.core.BBB; + import org.bigbluebutton.core.Options; + import org.bigbluebutton.core.model.BandwidthMonOptions; + import org.bigbluebutton.util.ConnUtil; import org.red5.flash.bwcheck.ClientServerBandwidth; import org.red5.flash.bwcheck.ServerClientBandwidth; import org.red5.flash.bwcheck.events.BandwidthDetectEvent; @@ -17,7 +21,7 @@ package org.red5.flash.bwcheck.app private var _serverApplication:String = ""; private var _clientServerService:String = ""; private var _serverClientService:String = ""; - + private var bwMonOption: BandwidthMonOptions; private var nc:NetConnection; public function BandwidthDetectionApp() @@ -47,12 +51,41 @@ package org.red5.flash.bwcheck.app public function connect():void { + bwMonOption = Options.getOptions(BandwidthMonOptions) as BandwidthMonOptions; + + var pattern:RegExp = /(?P.+):\/\/(?P.+)/; + var result:Array = pattern.exec(bwMonOption.server); + + var bwMonUrl: String; + nc = new NetConnection(); - nc.proxyType = "best"; - nc.objectEncoding = flash.net.ObjectEncoding.AMF0; + + var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS; + if (BBB.initConnectionManager().isTunnelling) { + var tunnelProtocol: String = ConnUtil.RTMPT; + + if (useRTMPS) { + nc.proxyType = ConnUtil.PROXY_NONE; + tunnelProtocol = ConnUtil.RTMPS; + } + + bwMonUrl = tunnelProtocol + "://" + result.server + "/" + bwMonOption.application; + trace("******* BW MON CONNECT tunnel = TRUE " + "url=" + bwMonUrl); + } else { + var nativeProtocol: String = ConnUtil.RTMP; + if (useRTMPS) { + nc.proxyType = ConnUtil.PROXY_BEST; + nativeProtocol = ConnUtil.RTMPS; + } + + bwMonUrl = nativeProtocol + "://" + result.server + "/" + bwMonOption.application; + trace("******* BBB MON CONNECT tunnel = FALSE " + "url=" + bwMonUrl); + } + + nc.objectEncoding = flash.net.ObjectEncoding.AMF3; nc.client = this; nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus); - nc.connect("rtmp://" + _serverURL + "/" + _serverApplication); + nc.connect(bwMonUrl); }