Merge pull request #675 from ritzalam/reconnect-to-bbb-video

Reconnect to bbb video
This commit is contained in:
Richard Alam 2015-06-30 15:58:15 -04:00
commit fb94468edf
6 changed files with 76 additions and 42 deletions

View File

@ -24,21 +24,17 @@ package org.bigbluebutton.modules.videoconf.business
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.events.TimerEvent;
import flash.media.H264Level;
import flash.media.H264Profile;
import flash.media.H264VideoStreamSettings;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.system.Capabilities;
import mx.collections.ArrayCollection;
import flash.utils.Timer;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.managers.UserManager;
import org.bigbluebutton.main.model.users.BBBUser;
import org.bigbluebutton.main.model.users.events.StreamStartedEvent;
import org.bigbluebutton.modules.videoconf.events.ConnectedEvent;
import org.bigbluebutton.modules.videoconf.events.StartBroadcastEvent;
import org.bigbluebutton.modules.videoconf.model.VideoConfOptions;
@ -46,6 +42,8 @@ package org.bigbluebutton.modules.videoconf.business
public class VideoProxy
{
public static const LOG:String = "VideoProxy - ";
public var videoOptions:VideoConfOptions;
private var nc:NetConnection;
@ -53,6 +51,10 @@ package org.bigbluebutton.modules.videoconf.business
private var _url:String;
private var camerasPublishing:Object = new Object();
private var connected:Boolean = false;
private var reconnect:Boolean = false;
private var reconnecting:Boolean = false;
private var autoReconnectTimer:Timer = new Timer(1000, 1);
private function parseOptions():void {
videoOptions = new VideoConfOptions();
@ -70,7 +72,10 @@ package org.bigbluebutton.modules.videoconf.business
nc.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
}
public function reconnectWhenDisconnected(connect:Boolean):void {
reconnect = connect;
}
public function connect():void {
@ -78,25 +83,39 @@ package org.bigbluebutton.modules.videoconf.business
}
private function onAsyncError(event:AsyncErrorEvent):void{
trace("VIDEO WEBCAM onAsyncError");
}
private function onIOError(event:NetStatusEvent):void{
trace("VIDEO WEBCAM onIOError");
}
private function onConnectedToVideoApp():void{
var dispatcher:Dispatcher = new Dispatcher();
dispatcher.dispatchEvent(new ConnectedEvent(ConnectedEvent.VIDEO_CONNECTED));
dispatcher.dispatchEvent(new ConnectedEvent(reconnecting));
reconnecting = false;
}
private function onNetStatus(event:NetStatusEvent):void{
trace("[" + event.info.code + "] for [" + _url + "]");
switch(event.info.code){
case "NetConnection.Connect.Success":
connected = true;
//ns = new NetStream(nc);
onConnectedToVideoApp();
break;
case "NetStream.Play.Failed":
disconnect();
break;
case "NetStream.Play.Stop":
disconnect();
break;
case "NetConnection.Connect.Closed":
disconnect();
break;
default:
LogUtil.debug("[" + event.info.code + "] for [" + _url + "]");
trace("[" + event.info.code + "] for [" + _url + "]");
connected = false;
break;
}
@ -110,7 +129,7 @@ package org.bigbluebutton.modules.videoconf.business
}
public function startPublishing(e:StartBroadcastEvent):void{
var ns:NetStream = new NetStream(nc);
ns = new NetStream(nc);
ns.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus );
ns.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
ns.addEventListener( AsyncErrorEvent.ASYNC_ERROR, onAsyncError );
@ -181,6 +200,18 @@ package org.bigbluebutton.modules.videoconf.business
trace("VideoProxy:: disconnecting from Video application");
stopAllBroadcasting();
if (nc != null) nc.close();
if (reconnect) {
var reconnectTimer:Timer = new Timer(1000, 1);
reconnectTimer.addEventListener("timer", reconnectTimerHandler);
reconnectTimer.start();
}
}
private function reconnectTimerHandler(event:TimerEvent):void {
trace(LOG + "rtmptRetryTimerHandler: " + event);
reconnecting = true;
connect();
}
public function onBWCheck(... rest):Number {

View File

@ -24,9 +24,12 @@ package org.bigbluebutton.modules.videoconf.events
{
public static const VIDEO_CONNECTED:String = "connected to video app event";
public function ConnectedEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false)
public var reconnection:Boolean = false;
public function ConnectedEvent(reconnection:Boolean)
{
super(type, bubbles, cancelable);
super(VIDEO_CONNECTED, true, false);
this.reconnection = reconnection;
}
}
}

View File

@ -39,7 +39,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.modules.videoconf.events.StopShareCameraRequestEvent;
import org.bigbluebutton.modules.videoconf.events.VideoModuleStartEvent;
import org.bigbluebutton.modules.videoconf.events.VideoModuleStopEvent;
import org.bigbluebutton.modules.videoconf.events.WebRTCWebcamRequestEvent;
]]>
</mx:Script>
@ -58,7 +57,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
</EventHandlers>
<EventHandlers type="{ConnectAppEvent.CONNECT_VIDEO_APP}">
<MethodInvoker generator="{VideoEventMapDelegate}" method="connectToVideoApp" />
<MethodInvoker generator="{VideoEventMapDelegate}" method="connectToVideoApp"/>
</EventHandlers>
<EventHandlers type="{ShareCameraRequestEvent.SHARE_CAMERA_REQUEST}">
@ -111,7 +110,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
</EventHandlers>
<EventHandlers type="{ConnectedEvent.VIDEO_CONNECTED}">
<MethodInvoker generator="{VideoEventMapDelegate}" method="connectedToVideoApp" />
<MethodInvoker generator="{VideoEventMapDelegate}" method="connectedToVideoApp" arguments="{event}"/>
</EventHandlers>
<EventHandlers type="{ClosePublishWindowEvent.CLOSE_PUBLISH_WINDOW}">

View File

@ -153,9 +153,8 @@ package org.bigbluebutton.modules.videoconf.maps
}
private function addToolbarButton():void{
LogUtil.debug("****************** Adding toolbar button. presenter?=[" + UsersUtil.amIPresenter() + "]");
if (proxy.videoOptions.showButton) {
if (proxy.videoOptions.showButton) {
displayToolbarButton();
var event:ToolbarButtonEvent = new ToolbarButtonEvent(ToolbarButtonEvent.ADD);
@ -284,6 +283,7 @@ package org.bigbluebutton.modules.videoconf.maps
public function connectToVideoApp():void {
proxy = new VideoProxy(uri);
proxy.reconnectWhenDisconnected(true);
proxy.connect();
}
@ -423,6 +423,7 @@ package org.bigbluebutton.modules.videoconf.maps
public function stopModule():void {
trace("VideoEventMapDelegate:: stopping video module");
closeAllWindows();
proxy.reconnectWhenDisconnected(false);
proxy.disconnect();
}
@ -455,13 +456,18 @@ package org.bigbluebutton.modules.videoconf.maps
}
}
public function connectedToVideoApp():void{
public function connectedToVideoApp(event: ConnectedEvent):void{
trace("VideoEventMapDelegate:: [" + me + "] Connected to video application.");
_ready = true;
if (event.reconnection) {
closeAllWindows()
} else {
addToolbarButton();
openWebcamWindows();
}
}
public function handleCameraSetting(event:BBBEvent):void {
var cameraIndex:int = event.payload.cameraIndex;
var videoProfile:VideoProfile = event.payload.videoProfile;

View File

@ -40,13 +40,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<mx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import mx.controls.Menu;
import mx.events.MenuEvent;
import mx.styles.StyleManager;
import mx.styles.IStyleManager2;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.core.events.LockControlEvent;
import org.bigbluebutton.core.managers.UserManager;
import org.bigbluebutton.main.events.BBBEvent;
@ -54,9 +51,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.main.model.users.BBBUser;
import org.bigbluebutton.main.model.users.Conference;
import org.bigbluebutton.main.views.MainToolbar;
import org.bigbluebutton.modules.videoconf.events.ClosePublishWindowEvent;
import org.bigbluebutton.modules.videoconf.events.ShareCameraRequestEvent;
import org.bigbluebutton.modules.videoconf.events.StopBroadcastEvent;
import org.bigbluebutton.modules.videoconf.events.StopShareCameraRequestEvent;
import org.bigbluebutton.util.i18n.ResourceUtil;

View File

@ -50,11 +50,11 @@ class UrlMappings {
}
"/api/getMeetings"(controller:"api") {
action = [GET:'getMeetingsHandler']
action = [GET:'getMeetingsHandler', POST:'getMeetingsHandler']
}
"/api/getRecordings"(controller:"api") {
action = [GET:'getRecordingsHandler']
action = [GET:'getRecordingsHandler', POST:'getRecordingsHandler']
}
"/$controller/$action?/$id?(.${format})?"{