From 3b91a08efdfe5333598ef00309a23eca4681dc24 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Sat, 26 Jan 2013 21:31:47 +0000 Subject: [PATCH] - publish deskshare streams in the app context so that context isn't removed when last user disconnects --- bigbluebutton-client/src/DeskShareModule.mxml | 4 +- .../src/DeskshareStandalone.mxml | 6 ++- .../deskshare/services/DeskshareService.as | 53 ++++++++++--------- .../server/ScreenVideoBroadcastStream.java | 45 ++++++++-------- .../server/red5/DeskshareApplication.scala | 36 +++++++------ .../server/stream/DeskshareService.scala | 4 +- 6 files changed, 78 insertions(+), 70 deletions(-) diff --git a/bigbluebutton-client/src/DeskShareModule.mxml b/bigbluebutton-client/src/DeskShareModule.mxml index cbfb72de69d0..596d2bed9fe9 100755 --- a/bigbluebutton-client/src/DeskShareModule.mxml +++ b/bigbluebutton-client/src/DeskShareModule.mxml @@ -51,9 +51,7 @@ } public function get uri():String{ - if (_attributes.mode == "PLAYBACK") - return _attributes.uri + "/" + _attributes.playbackRoom; - return _attributes.uri + "/" + _attributes.room; + return _attributes.uri; } public function get username():String{ diff --git a/bigbluebutton-client/src/DeskshareStandalone.mxml b/bigbluebutton-client/src/DeskshareStandalone.mxml index 1e95319b60a5..014a9c5ab421 100755 --- a/bigbluebutton-client/src/DeskshareStandalone.mxml +++ b/bigbluebutton-client/src/DeskshareStandalone.mxml @@ -71,7 +71,7 @@ logoutURL = p.getParameter("LOGOUTURL"); host = p.getParameter("HOST"); room = p.getParameter("ROOM"); - service.connect(host+"/"+room); + service.connect(host, room); cursor.graphics.lineStyle(6, 0xFF0000, 0.6); cursor.graphics.drawCircle(0,0,3); @@ -141,6 +141,10 @@ } private function onUpdateCursorEvent(event:CursorEvent):void { + + return; + + if (cursor == null) return; // cursor.x = ((event.x/video.videoWidth)) * videoHolder.width; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as index 35da4d863b79..22d0a5e0ce8e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/deskshare/services/DeskshareService.as @@ -18,10 +18,12 @@ */ package org.bigbluebutton.modules.deskshare.services { - import com.asfusion.mate.events.Dispatcher; + import com.asfusion.mate.events.Dispatcher; + import flash.net.NetConnection; import flash.net.Responder; - import flash.net.SharedObject; + import flash.net.SharedObject; + import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.main.events.RecordStatusEvent; import org.bigbluebutton.modules.deskshare.events.AppletStartedEvent; @@ -47,7 +49,8 @@ package org.bigbluebutton.modules.deskshare.services private var width:Number; private var height:Number; private var uri:String; - + private var room:String; + public function DeskshareService() { this.dispatcher = new Dispatcher(); @@ -56,12 +59,13 @@ package org.bigbluebutton.modules.deskshare.services public function handleStartModuleEvent(module:DeskShareModule):void { LogUtil.debug("Deskshare Module starting"); this.module = module; - connect(module.uri); + connect(module.uri, module.getRoom()); } - public function connect(uri:String):void { + public function connect(uri:String, room:String):void { this.uri = uri; - LogUtil.debug("Deskshare Service connecting to " + uri); + this.room = room; + trace("Deskshare Service connecting to " + uri); conn = new Connection(); conn.addEventListener(Connection.SUCCESS, connectionSuccessHandler); conn.addEventListener(Connection.FAILED, connectionFailedHandler); @@ -74,17 +78,17 @@ package org.bigbluebutton.modules.deskshare.services if (result != null && (result.publishing as Boolean)){ width = result.width as Number; height = result.height as Number; - LogUtil.debug("Desk Share stream is streaming [" + width + "," + height + "]"); + trace("Desk Share stream is streaming [" + width + "," + height + "]"); var event:ViewStreamEvent = new ViewStreamEvent(ViewStreamEvent.START); event.videoWidth = width; event.videoHeight = height; dispatcher.dispatchEvent(event); } else { - LogUtil.debug("No deskshare stream being published"); + trace("No deskshare stream being published"); } }, function(status:Object):void{ - LogUtil.error("Error while trying to call remote mathod on server"); + trace("Error while trying to call remote mathod on server"); } ); } @@ -94,13 +98,14 @@ package org.bigbluebutton.modules.deskshare.services } private function connectionSuccessHandler(e:ConnectionEvent):void{ - LogUtil.debug("Successully connection to " + uri); - nc = conn.getConnection(); - deskSO = SharedObject.getRemote("deskSO", uri, false); - deskSO.client = this; - deskSO.connect(nc); + trace("Successully connection to " + uri); + nc = conn.getConnection(); + var deskSOName:String = room + "-deskSO"; + deskSO = SharedObject.getRemote(deskSOName, uri, false); + deskSO.client = this; + deskSO.connect(nc); - checkIfStreamIsPublishing(); + checkIfStreamIsPublishing(room); } public function getConnection():NetConnection{ @@ -127,7 +132,7 @@ package org.bigbluebutton.modules.deskshare.services * */ public function appletStarted(videoWidth:Number, videoHeight:Number):void{ - LogUtil.debug("Got applet started"); + trace("Got applet started"); var event:AppletStartedEvent = new AppletStartedEvent(); event.videoWidth = videoWidth; event.videoHeight = videoHeight; @@ -147,7 +152,7 @@ package org.bigbluebutton.modules.deskshare.services } public function sendStartedViewingNotification():void{ - LogUtil.debug("Sending start viewing to server"); + trace("Sending start viewing to server"); nc.call("deskshare.startedToViewStream", null); } @@ -157,7 +162,7 @@ package org.bigbluebutton.modules.deskshare.services * */ public function startViewing(videoWidth:Number, videoHeight:Number):void{ - LogUtil.debug("startViewing invoked by server"); + trace("startViewing invoked by server"); var event:ViewStreamEvent = new ViewStreamEvent(ViewStreamEvent.START); event.videoWidth = videoWidth; @@ -170,11 +175,11 @@ package org.bigbluebutton.modules.deskshare.services * */ public function sendStopViewingNotification():void{ - LogUtil.debug("Sending stop viewing notification to other clients."); + trace("Sending stop viewing notification to other clients."); try{ deskSO.send("stopViewing"); } catch(e:Error){ - LogUtil.error("could not send stop viewing notification"); + trace("could not send stop viewing notification"); } } @@ -191,7 +196,7 @@ package org.bigbluebutton.modules.deskshare.services * */ public function stopViewing():void{ - LogUtil.debug("Received dekskshareStreamStopped"); + trace("Received dekskshareStreamStopped"); dispatcher.dispatchEvent(new ViewStreamEvent(ViewStreamEvent.STOP)); } @@ -214,9 +219,9 @@ package org.bigbluebutton.modules.deskshare.services * This method is useful for clients which have joined a room where somebody is already publishing * */ - private function checkIfStreamIsPublishing():void{ - LogUtil.debug("checking if desk share stream is publishing"); - nc.call("deskshare.checkIfStreamIsPublishing", responder); + private function checkIfStreamIsPublishing(room:String):void{ + trace("checking if desk share stream is publishing"); + nc.call("deskshare.checkIfStreamIsPublishing", responder, room); } public function calculateEncodingDimensions(captureWidth:Number, captureHeight:Number):void{ diff --git a/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/ScreenVideoBroadcastStream.java b/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/ScreenVideoBroadcastStream.java index 82edc8e39263..633f0dad6d28 100755 --- a/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/ScreenVideoBroadcastStream.java +++ b/deskshare/app/src/main/java/org/bigbluebutton/deskshare/server/ScreenVideoBroadcastStream.java @@ -65,7 +65,7 @@ public class ScreenVideoBroadcastStream implements IBroadcastStream, IProvider, public ScreenVideoBroadcastStream(String name) { publishedStreamName = name; livePipe = null; - log.trace("name: {}", name); + log.debug("name: {}", name); // we want to create a video codec when we get our // first video packet. @@ -74,22 +74,22 @@ public ScreenVideoBroadcastStream(String name) { } public IProvider getProvider() { - log.trace("getProvider()"); + log.debug("getProvider()"); return this; } public String getPublishedName() { - log.trace("getPublishedName()"); + log.debug("getPublishedName()"); return publishedStreamName; } public String getSaveFilename() { - log.trace("getSaveFilename()"); + log.debug("getSaveFilename()"); throw new Error("unimplemented method"); } public void addStreamListener(IStreamListener listener) { - log.trace("addStreamListener(listener: {})", listener); + log.debug("addStreamListener(listener: {})", listener); streamListeners.add(listener); } @@ -99,23 +99,23 @@ public Collection getStreamListeners() { } public void removeStreamListener(IStreamListener listener) { - log.trace("removeStreamListener({})", listener); + log.debug("removeStreamListener({})", listener); streamListeners.remove(listener); } public void saveAs(String filePath, boolean isAppend) throws IOException, ResourceNotFoundException, ResourceExistException { - log.trace("saveAs(filepath:{}, isAppend:{})", filePath, isAppend); + log.debug("saveAs(filepath:{}, isAppend:{})", filePath, isAppend); throw new Error("unimplemented method"); } public void setPublishedName(String name) { - log.trace("setPublishedName(name:{})", name); + log.debug("setPublishedName(name:{})", name); publishedStreamName = name; } public void close() { - log.trace("close()"); + log.debug("close()"); } public IStreamCodecInfo getCodecInfo() { @@ -125,7 +125,7 @@ public IStreamCodecInfo getCodecInfo() { } public String getName() { - log.trace("getName(): {}", publishedStreamName); + log.debug("getName(): {}", publishedStreamName); // for now, just return the published name return publishedStreamName; } @@ -135,30 +135,29 @@ public void setScope(IScope scope) { } public IScope getScope() { - log.trace("getScope(): {}", scope); + log.debug("getScope(): {}", scope); return scope; } public void start() { - log.trace("start()"); + log.debug("start()"); } public void stop() { - log.trace("stop"); + log.debug("stop"); } public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { - log.trace("onOOBControlMessage"); + log.debug("onOOBControlMessage"); } public void onPipeConnectionEvent(PipeConnectionEvent event) { - log.trace("onPipeConnectionEvent(event:{})", event); + log.debug("onPipeConnectionEvent(event:{})", event); switch (event.getType()) { case PipeConnectionEvent.PROVIDER_CONNECT_PUSH: - log.trace("PipeConnectionEvent.PROVIDER_CONNECT_PUSH"); - if (event.getProvider() == this && (event.getParamMap() == null - || !event.getParamMap().containsKey("record"))) { - log.trace("Creating a live pipe"); + log.debug("PipeConnectionEvent.PROVIDER_CONNECT_PUSH"); + if (event.getProvider() == this && (event.getParamMap() == null || !event.getParamMap().containsKey("record"))) { + log.debug("Creating a live pipe"); System.out.println("Creating a live pipe"); this.livePipe = (IPipe) event.getSource(); } @@ -166,21 +165,21 @@ public void onPipeConnectionEvent(PipeConnectionEvent event) { case PipeConnectionEvent.PROVIDER_DISCONNECT: log.trace("PipeConnectionEvent.PROVIDER_DISCONNECT"); if (this.livePipe == event.getSource()) { - log.trace("PipeConnectionEvent.PROVIDER_DISCONNECT - this.mLivePipe = null;"); + log.debug("PipeConnectionEvent.PROVIDER_DISCONNECT - this.mLivePipe = null;"); System.out.println("PipeConnectionEvent.PROVIDER_DISCONNECT - this.mLivePipe = null;"); this.livePipe = null; } break; case PipeConnectionEvent.CONSUMER_CONNECT_PUSH: - log.trace("PipeConnectionEvent.CONSUMER_CONNECT_PUSH"); + log.debug("PipeConnectionEvent.CONSUMER_CONNECT_PUSH"); System.out.println("PipeConnectionEvent.CONSUMER_CONNECT_PUSH"); break; case PipeConnectionEvent.CONSUMER_DISCONNECT: - log.trace("PipeConnectionEvent.CONSUMER_DISCONNECT"); + log.debug("PipeConnectionEvent.CONSUMER_DISCONNECT"); System.out.println("PipeConnectionEvent.CONSUMER_DISCONNECT"); break; default: - log.trace("PipeConnectionEvent default"); + log.debug("PipeConnectionEvent default"); System.out.println("PipeConnectionEvent default"); break; } diff --git a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/red5/DeskshareApplication.scala b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/red5/DeskshareApplication.scala index cf1fc48477ba..32b824e26bd6 100755 --- a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/red5/DeskshareApplication.scala +++ b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/red5/DeskshareApplication.scala @@ -121,20 +121,22 @@ class DeskshareApplication(streamManager: StreamManager, deskShareServer: DeskSh return Some(roomScope) } - private def getRoomSharedObject(roomScope:IScope):Option[ISharedObject] = { + private def getRoomSharedObject(roomScope:IScope, name:String):Option[ISharedObject] = { + var soName:String = name + "-deskSO"; + if (roomScope == null) { logger.error("DeskshareApplication: Cannot get shared object because room scope is null.") return None } logger.debug("DeskshareApplication: Getting shared object.") - var deskSO:ISharedObject = getSharedObject(roomScope, "deskSO") + var deskSO:ISharedObject = getSharedObject(roomScope, soName) logger.debug("DeskshareApplication: Got shared object.") if (deskSO == null) { logger.debug("DeskshareApplication: Creating shared object.") - if (createSharedObject(roomScope, "deskSO", false)) { + if (createSharedObject(roomScope, soName, false)) { logger.debug("DeskshareApplication: Created shared object. Getting shared object.") - deskSO = getSharedObject(roomScope, "deskSO") + deskSO = getSharedObject(roomScope, soName) } else { logger.error("DeskshareApplication: Failed to create shared object for room") // println ("Failed to create shared object") @@ -147,17 +149,17 @@ class DeskshareApplication(streamManager: StreamManager, deskShareServer: DeskSh } def createDeskshareClient(name: String): Option[RtmpClientAdapter] = { - getRoomScope(name) match { - case None => logger.error("DeskshareApplication: Failed to get room scope for [ %s ] ", name) - case Some(roomScope) => { - getRoomSharedObject(roomScope) match { + // getRoomScope(name) match { +// case None => logger.error("DeskshareApplication: Failed to get room scope for [ %s ] ", name) +// case Some(roomScope) => { + getRoomSharedObject(appScope, name) match { case None => logger.error("DeskshareApplication:: Failed to get shared object for room [ %s ]",name) case Some(deskSO) => { logger.debug("DeskshareApplication: Creating RtmpClientAdapter") return Some(new RtmpClientAdapter(deskSO)) } - } - } +// } +// } } return None @@ -166,18 +168,18 @@ class DeskshareApplication(streamManager: StreamManager, deskShareServer: DeskSh def createScreenVideoBroadcastStream(name: String): Option[ScreenVideoBroadcastStream] = { logger.debug("DeskshareApplication: Creating ScreenVideoBroadcastStream") - getRoomScope(name) match { - case None => logger.error("Failed to get room scope %s", name) - case Some(roomScope) => { - getRoomSharedObject(roomScope) match { +// getRoomScope(name) match { +// case None => logger.error("Failed to get room scope %s", name) +// case Some(roomScope) => { + getRoomSharedObject(appScope, name) match { case None => logger.error("Failed to get shared object for room %s",name) case Some(deskSO) => { logger.debug("DeskshareApplication: Creating Broadcast Stream for room [ %s ]", name) - return createBroadcastStream(name, roomScope) + return createBroadcastStream(name, appScope) } } - } - } +// } +// } return None } diff --git a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala index 467cf94e5969..348db4c7c521 100755 --- a/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala +++ b/deskshare/app/src/main/scala/org/bigbluebutton/deskshare/server/stream/DeskshareService.scala @@ -29,8 +29,8 @@ import net.lag.logging.Logger class DeskshareService(streamManager: StreamManager, sessionGateway: SessionManagerGateway) { private val log = Logger.get - def checkIfStreamIsPublishing(): HashMap[String, Any] = { - val room: String = Red5.getConnectionLocal().getScope().getName(); + def checkIfStreamIsPublishing(room:String): HashMap[String, Any] = { +// val room: String = Red5.getConnectionLocal().getScope().getName(); log.debug("Checking if %s is streaming.", room) var publishing = false var width = 0