Permalink
Browse files

- update broadcast module to work on master

  • Loading branch information...
1 parent 39953cf commit cbcd54cd7bb72b6807d01dae1216c9dd7cc6db51 @ritzalam ritzalam committed Dec 21, 2012
@@ -0,0 +1,33 @@
+package org.bigbluebutton.conference;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.red5.server.api.Red5;
+
+public class BigBlueButtonService {
+ private ConnectionInvokerService connInvokerService;
+
+ public void sendMessage(HashMap<String, Object> params) {
+
+ Map<String, Object> messageToSend = new HashMap<String, Object>();
+
+ for (Iterator<String> it = params.keySet().iterator(); it.hasNext();) {
+ String key = it.next();
+ messageToSend.put(key, params.get(key));
+ }
+
+ ClientMessage m = new ClientMessage(ClientMessage.BROADCAST, getMeetingId(), (String) params.get("messageID"), messageToSend);
+ connInvokerService.sendMessage(m);
+ }
+
+ private String getMeetingId(){
+ return Red5.getConnectionLocal().getScope().getName();
+ }
+
+ public void setConnInvokerService(ConnectionInvokerService connInvokerService) {
+ this.connInvokerService = connInvokerService;
+ }
+
+}
@@ -12,7 +12,11 @@
<property name="messagingService" ref="messagingService"></property>
<property name="conversionUpdatesMessageListener" ref="conversionUpdatesMessageListener"></property>
</bean>
-
+
+ <bean id="bigbluebutton.service" class="org.bigbluebutton.conference.BigBlueButtonService">
+ <property name="connInvokerService"> <ref bean="connInvokerService"/></property>
+ </bean>
+
<bean id="participantsHandler" class="org.bigbluebutton.conference.service.participants.ParticipantsHandler">
<property name="participantsApplication"> <ref local="participantsApplication"/></property>
<property name="recorderApplication"> <ref local="recorderApplication"/></property>
@@ -110,6 +110,17 @@
enableEdit="true"
/>
+ <module name="BroadcastModule" url="http://HOST/client/BroadcastModule.swf?v=VERSION"
+ uri="rtmp://HOST/bigbluebutton"
+ streamsUri="http://HOST/streams.xml"
+ position="absolute"
+ width="600"
+ height="400"
+ x="40"
+ y="40"
+ dependsOn="ViewersModule"
+ />
+
<!-- new module in development:
<module name="DynamicInfoModule" url="http://HOST/client/DynamicInfoModule.swf?v=VERSION"
uri="rtmp://HOST/bigbluebutton"
@@ -0,0 +1,12 @@
+package org.bigbluebutton.modules.broadcast.events
+{
+ import flash.events.Event;
+
+ public class PlayStreamEvent extends Event
+ {
+ public function PlayStreamEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ super(type, bubbles, cancelable);
+ }
+ }
+}
@@ -43,7 +43,7 @@ package org.bigbluebutton.modules.broadcast.managers
LogUtil.debug("BroadcastModule Start");
dispatcher = new Dispatcher();
if (broadcastWindow == null){
- LogUtil.debug("*** Opening BroadcastModule Window");
+ trace("*** Opening BroadcastModule Window");
var opt:BroadcastOptions = new BroadcastOptions();
broadcastWindow = new BroadcastWindow();
@@ -58,7 +58,7 @@ package org.bigbluebutton.modules.broadcast.managers
dispatcher.dispatchEvent(e);
streamService.queryAvailableStreams(options.streamsUri);
} else {
- LogUtil.debug("*** Not Opening BroadcastModule Window");
+ trace("*** Not Opening BroadcastModule Window");
}
sendWhatIsTheCurrentStreamRequest();
@@ -79,10 +79,12 @@ package org.bigbluebutton.modules.broadcast.managers
}
public function playVideo(index:int):void {
+ trace("BroadcastModule::playVideo [" + streams.streamUrls[index] + "],[" + streams.streamIds[index] + "],[" + streams.streamNames[index] + "]");
broadcastService.playStream(streams.streamUrls[index], streams.streamIds[index], streams.streamNames[index]);
}
public function stopVideo():void {
+ trace("BroadcastModule::stopVideo");
broadcastService.stopStream();
}
@@ -91,18 +93,18 @@ package org.bigbluebutton.modules.broadcast.managers
}
public function handleWhatIsTheCurrentStreamRequest(event:BBBEvent):void {
- LogUtil.debug("Received " + event.payload["messageId"] );
+ trace("Received " + event.payload["messageID"] );
var isPresenter:Boolean = UserManager.getInstance().getConference().amIPresenter();
if (isPresenter && curStream != null) {
broadcastService.sendWhatIsTheCurrentStreamReply(event.payload["requestedBy"], curStream.getStreamId());
}
}
public function handleWhatIsTheCurrentStreamReply(event:BBBEvent):void {
- LogUtil.debug("Received " + event.payload["messageId"] );
+ trace("Received " + event.payload["messageID"] );
var amIRequester:Boolean = UserManager.getInstance().getConference().amIThisUser(event.payload["requestedBy"]);
if (amIRequester) {
- var streamId:String = event.payload["streamId"];
+ var streamId:String = event.payload["streamID"];
var info:Object = streams.getStreamNameAndUrl(streamId);
if (info != null) {
playStream(info["url"], streamId, info["name"]);
@@ -118,12 +120,12 @@ package org.bigbluebutton.modules.broadcast.managers
}
public function handlePlayStreamRequest(event:BBBEvent):void {
- LogUtil.debug("Received " + event.payload["messageId"]);
- playStream(event.payload["uri"], event.payload["streamId"], event.payload["streamName"]);
+ trace("Received " + event.payload["messageID"]);
+ playStream(event.payload["uri"], event.payload["streamID"], event.payload["streamName"]);
}
public function handleStopStreamRequest(event:BBBEvent):void {
- LogUtil.debug("Received " + event.payload["messageId"]);
+ trace("Received " + event.payload["messageID"]);
stopPlayingStream();
}
@@ -24,13 +24,15 @@
xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
- import com.asfusion.mate.events.Dispatcher;
-
- import mx.events.FlexEvent;
-
- import org.bigbluebutton.main.events.MadePresenterEvent;
- import org.bigbluebutton.modules.broadcast.managers.BroadcastManager;
- import org.bigbluebutton.modules.broadcast.services.BroadcastService;
+ import com.asfusion.mate.events.Dispatcher;
+
+ import mx.events.FlexEvent;
+
+ import org.bigbluebutton.main.events.MadePresenterEvent;
+ import org.bigbluebutton.modules.broadcast.managers.BroadcastManager;
+ import org.bigbluebutton.modules.broadcast.services.BroadcastService;
+ import org.bigbluebutton.modules.broadcast.services.MessageReceiver;
+ import org.bigbluebutton.modules.broadcast.services.MessageSender;
]]>
</mx:Script>
@@ -51,22 +53,32 @@
<MethodInvoker generator="{BroadcastManager}" method="handleSwitchToViewerMode" />
</EventHandlers>
- <EventHandlers type="playBroadcastStream">
+ <EventHandlers type="BroadcastPlayStreamCommand">
<MethodInvoker generator="{BroadcastManager}" method="handlePlayStreamRequest" arguments="{event}"/>
</EventHandlers>
- <EventHandlers type="stopBroadcastStream">
+ <EventHandlers type="BroadcastStopStreamCommand">
<MethodInvoker generator="{BroadcastManager}" method="handleStopStreamRequest" arguments="{event}"/>
</EventHandlers>
- <EventHandlers type="whatIsTheCurrentStreamRequest">
+ <EventHandlers type="BroadcastWhatIsTheCurrentStreamRequest">
<MethodInvoker generator="{BroadcastManager}" method="handleWhatIsTheCurrentStreamRequest" arguments="{event}"/>
</EventHandlers>
- <EventHandlers type="whatIsTheCurrentStreamReply">
+ <EventHandlers type="BroadcastWhatIsTheCurrentStreamReply">
<MethodInvoker generator="{BroadcastManager}" method="handleWhatIsTheCurrentStreamReply" arguments="{event}"/>
</EventHandlers>
+
+<!--
+ <Injectors target="{BroadcastService}">
+ <ObjectBuilder generator="{MessageSender}" cache="global"/>
+ <PropertyInjector targetKey="receiver" source="{MessageReceiver}"/>
+ <PropertyInjector targetKey="sender" source="{MessageSender}"/>
+ </Injectors>
-
-
+ <Injectors target="{MessageReceiver}">
+ <PropertyInjector targetKey="dispatcher" source="{scope.dispatcher}"/>
+ </Injectors>
+-->
+
</EventMap>
@@ -0,0 +1,9 @@
+package org.bigbluebutton.modules.broadcast.models
+{
+ public class BroadcastModel
+ {
+ public function BroadcastModel()
+ {
+ }
+ }
+}
@@ -2,49 +2,35 @@ package org.bigbluebutton.modules.broadcast.services
{
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.managers.UserManager;
- import org.bigbluebutton.core.model.Connection;
- public class BroadcastService {
- public function playStream(uri:String, streamId:String, streamName:String):void {
- var conn:Connection = BBB.initConnectionManager().getConnection("bbb");
- if (conn != null) {
- var message:Object = new Object();
- message["messageId"] = "playBroadcastStream";
- message["uri"] = uri;
- message["streamId"] = streamId;
- message["streamName"] = streamName;
- conn.sendMessage(message);
- }
+ public class BroadcastService {
+ private var sender:MessageSender;
+ private var receiver:MessageReceiver;
+
+ public function BroadcastService() {
+ sender = new MessageSender();
+ receiver = new MessageReceiver();
+ }
+
+ public function playStream(uri:String, streamID:String, streamName:String):void {
+ trace("BroadcastService::playStream");
+ if (sender == null) {
+ trace("SENDER is NULL!!!!");
+ }
+ sender.playStream(uri, streamID, streamName);
}
public function stopStream():void {
- var conn:Connection = BBB.initConnectionManager().getConnection("bbb");
- if (conn != null) {
- var message:Object = new Object();
- message["messageId"] = "stopBroadcastStream";
- conn.sendMessage(message);
- }
+ trace("BroadcastService::stopStream");
+ sender.stopStream();
}
public function sendWhatIsTheCurrentStreamRequest():void {
- var conn:Connection = BBB.initConnectionManager().getConnection("bbb");
- if (conn != null) {
- var message:Object = new Object();
- message["messageId"] = "whatIsTheCurrentStreamRequest";
- message["requestedBy"] = UserManager.getInstance().getConference().getMyUserId();
- conn.sendMessage(message);
- }
+ sender.sendWhatIsTheCurrentStreamRequest();
}
- public function sendWhatIsTheCurrentStreamReply(requestedByUserid:Number, streamId:String):void {
- var conn:Connection = BBB.initConnectionManager().getConnection("bbb");
- if (conn != null) {
- var message:Object = new Object();
- message["messageId"] = "whatIsTheCurrentStreamReply";
- message["requestedBy"] = requestedByUserid;
- message["streamId"] = streamId;
- conn.sendMessage(message);
- }
+ public function sendWhatIsTheCurrentStreamReply(requestedByUserID:Number, streamID:String):void {
+ sender.sendWhatIsTheCurrentStreamReply(requestedByUserID, streamID);
}
}
}
@@ -0,0 +1,72 @@
+package org.bigbluebutton.modules.broadcast.services
+{
+ import com.asfusion.mate.events.Dispatcher;
+
+ import org.bigbluebutton.core.BBB;
+ import org.bigbluebutton.main.events.BBBEvent;
+ import org.bigbluebutton.main.model.users.IMessageListener;
+
+ public class MessageReceiver implements IMessageListener
+ {
+ private var dispatcher:Dispatcher;
+
+ public function MessageReceiver() {
+ dispatcher = new Dispatcher();
+ BBB.initConnectionManager().addMessageListener(this);
+ }
+
+ public function onMessage(messageName:String, message:Object):void {
+ trace("Broadcast: received message " + messageName);
+
+ switch (messageName) {
+ case "BroadcastPlayStreamCommand":
+ handleBroadcastPlayStreamCommand(message);
+ break;
+ case "BroadcastStopStreamCommand":
+ handleBroadcastStopStreamCommand(message);
+ break;
+ case "BroadcastWhatIsTheCurrentStreamRequest":
+ handleBroadcastWhatIsTheCurrentStreamRequest(message);
+ break;
+ case "BroadcastWhatIsTheCurrentStreamReply":
+ handleBroadcastWhatIsTheCurrentStreamReply(message);
+ break;
+ default:
+ // LogUtil.warn("Cannot handle message [" + messageName + "]");
+ }
+ }
+
+ private function handleBroadcastPlayStreamCommand(message:Object):void {
+ var event:BBBEvent = new BBBEvent("BroadcastPlayStreamCommand");
+ event.payload["messageID"] = "BroadcastPlayStreamCommand";
+ event.payload["uri"] = message.uri;
+ event.payload["streamID"] = message.streamID;
+ event.payload["streamName"] = message.streamName;
+
+ dispatcher.dispatchEvent(event);
+ }
+
+ private function handleBroadcastStopStreamCommand(messsage:Object):void {
+ var event:BBBEvent = new BBBEvent("BroadcastStopStreamCommand");
+ event.payload["messageID"] = "BroadcastStopStreamCommand";
+ dispatcher.dispatchEvent(event);
+ }
+
+ private function handleBroadcastWhatIsTheCurrentStreamRequest(message:Object):void {
+ var event:BBBEvent = new BBBEvent("BroadcastWhatIsTheCurrentStreamRequest");
+ event.payload["messageID"] = "BroadcastWhatIsTheCurrentStreamRequest";
+ event.payload["requestedBy"] = message.requestedByUserID;
+
+ dispatcher.dispatchEvent(event);
+ }
+
+ private function handleBroadcastWhatIsTheCurrentStreamReply(message:Object):void {
+ var event:BBBEvent = new BBBEvent("BroadcastWhatIsTheCurrentStreamReply");
+ event.payload["messageID"] = "BroadcastWhatIsTheCurrentStreamReply";
+ event.payload["requestedBy"] = message.requestedByUserID;
+ event.payload["streamID"] = message.streamID;
+
+ dispatcher.dispatchEvent(event);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit cbcd54c

Please sign in to comment.