Skip to content

Commit

Permalink
- publish deskshare streams in the app context so that context isn't…
Browse files Browse the repository at this point in the history
… removed when last user disconnects
  • Loading branch information
ritzalam committed Jan 26, 2013
1 parent 2429d13 commit 3b91a08
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 70 deletions.
4 changes: 1 addition & 3 deletions bigbluebutton-client/src/DeskShareModule.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 5 additions & 1 deletion bigbluebutton-client/src/DeskshareStandalone.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -141,6 +141,10 @@
}
private function onUpdateCursorEvent(event:CursorEvent):void {
return;
if (cursor == null) return;
// cursor.x = ((event.x/video.videoWidth)) * videoHolder.width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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");
}
);
}
Expand All @@ -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{
Expand All @@ -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;
Expand All @@ -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);
}

Expand All @@ -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;
Expand All @@ -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");
}
}

Expand All @@ -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));
}

Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}

Expand All @@ -99,23 +99,23 @@ public Collection<IStreamListener> 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() {
Expand All @@ -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;
}
Expand All @@ -135,52 +135,51 @@ 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();
}
break;
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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
}
Expand Down
Loading

0 comments on commit 3b91a08

Please sign in to comment.