diff --git a/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/DeskShareMessageReceiver.java b/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/DeskShareMessageReceiver.java index a8fe39329c..0a017b0f0d 100644 --- a/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/DeskShareMessageReceiver.java +++ b/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/DeskShareMessageReceiver.java @@ -35,9 +35,11 @@ public class DeskShareMessageReceiver implements MessageHandler { if (DeskShareStartedEventMessage.DESKSHARE_STARTED_MESSAGE.equals(messageName)) { DeskShareStartedEventMessage msg = DeskShareStartedEventMessage.fromJson(message); + System.out.println("^^^^^^^DESKSHARE STARTED^^^^^^"); bbbGW.deskShareStarted(msg.conferenceName, msg.callerId, msg.callerIdName); } else if (DeskShareStoppedEventMessage.DESK_SHARE_STOPPED_MESSAGE.equals(messageName)) { DeskShareStoppedEventMessage msg = DeskShareStoppedEventMessage.fromJson(message); + System.out.println("^^^^^^^DESKSHARE STOPPED^^^^^^"); bbbGW.deskShareStopped(msg.conferenceName, msg.callerId, msg.callerIdName); } // else if (DeskShareViewerJoinedEventMessage.DESK_SHARE_VIEWER_JOINED_MESSAGE.equals(messageName)) { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala index 78486517d0..23f2c12998 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala @@ -52,6 +52,11 @@ class BigBlueButtonActor(val system: ActorSystem, outGW: MessageOutGateway, voic } private def findMeetingWithVoiceConfId(voiceConfId: String): Option[RunningMeeting] = { + // println("searching meeeting with voiceConfId=" + voiceConfId) + // meetings.values.find(m => { + // println("^^^^^^" + m.mProps.voiceBridge) + // m.mProps.voiceBridge == voiceConfId + // }) meetings.values.find(m => m.mProps.voiceBridge == voiceConfId) } @@ -275,7 +280,10 @@ class BigBlueButtonActor(val system: ActorSystem, outGW: MessageOutGateway, voic var originalConfId = msg.conferenceName.replace(DESKSHARE_CONFERENCE_NAME_SUFFIX, "") println("originalConfId=" + originalConfId) findMeetingWithVoiceConfId(originalConfId) foreach { m => - m.actorRef ! msg + { + println("FOREACH" + m.toString()) + m.actorRef ! msg + } } } else { println("\n\n\nERROR in handleDeskShareStartedMessage in BBBActor \n\n\n") @@ -284,7 +292,28 @@ class BigBlueButtonActor(val system: ActorSystem, outGW: MessageOutGateway, voic } private def handleDeskShareStoppedRequest(msg: DeskShareStoppedRequest) { - //TODO + + println("DeskShareStoppedRequest in BBBActor") + val DESKSHARE_CONFERENCE_NAME_SUFFIX = "-DESKSHARE" + // find in which meeting .... + + println("\n\n\n\nBBBActor: handleDeskShareStoppedRequest\n\n\n\n") + println(msg.conferenceName) + println(msg.callerId) + println(msg.callerIdName) + + if (msg.conferenceName.endsWith(DESKSHARE_CONFERENCE_NAME_SUFFIX)) { + var originalConfId = msg.conferenceName.replace(DESKSHARE_CONFERENCE_NAME_SUFFIX, "") + println("originalConfId=" + originalConfId) + findMeetingWithVoiceConfId(originalConfId) foreach { m => + { + println("FOREACH" + m.toString()) + m.actorRef ! msg + } + } + } else { + println("\n\n\nERROR in handleDeskShareStoppedMessage in BBBActor \n\n\n") + } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala index 31dc0b2fb4..a1546a0387 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala @@ -62,10 +62,14 @@ class MeetingActor(val mProps: MeetingProperties, val outGW: MessageOutGateway) handleUserTalkingInVoiceConfMessage(msg) case msg: VoiceConfRecordingStartedMessage => handleVoiceConfRecordingStartedMessage(msg) - case msg: DeskShareRecordingStartedRequest => - handleDeskShareRecordingStartedRequest(msg) - case msg: DeskShareRecordingStoppedRequest => - handleDeskShareRecordingStoppedRequest(msg) + // case msg: DeskShareRecordingStartedRequest => + // handleDeskShareRecordingStartedRequest(msg) + // case msg: DeskShareRecordingStoppedRequest => + // handleDeskShareRecordingStoppedRequest(msg) + case msg: DeskShareStartedRequest => + handleDeskShareStartedRequest(msg) + case msg: DeskShareStoppedRequest => + handleDeskShareStoppedRequest(msg) case msg: UserJoining => handleUserJoin(msg) case msg: UserLeaving => @@ -231,7 +235,7 @@ class MeetingActor(val mProps: MeetingProperties, val outGW: MessageOutGateway) } def handleMonitorNumberOfWebUsers() { - println("BACK TIMER") + // println("BACK TIMER") if (users.numWebUsers == 0 && meetingModel.lastWebUserLeftOn > 0) { if (timeNowInMinutes - meetingModel.lastWebUserLeftOn > 2) { log.info("MonitorNumberOfWebUsers empty for meeting [" + mProps.meetingID + "]. Ejecting all users from voice.") @@ -305,45 +309,39 @@ class MeetingActor(val mProps: MeetingProperties, val outGW: MessageOutGateway) // If the meeting is recorded, tell FS to record video private def handleDeskShareStartedRequest(msg: DeskShareStartedRequest) { - //TODO - println("\n\n\nMeetingActor-handleDeskShareStartedRequest-start\n") + println("\n\n\nMeetingActor-handleDeskShareStartedRequest\n") println("isRecording=" + meetingModel.isRecording()) - println("\n\n\nMeetingActor-handleDeskShareStartedRequest-end\n") if (meetingModel.isRecording()) { println("IS RECORDING") - // outGW.send(new DeskShareStartRecording())//TODO + val timestamp = System.currentTimeMillis().toString() + // val filepath = "/var/freeswitch/meetings/" + mProps.meetingID + "-" + timestamp + ".mp4" + val filepath = "/home/debian/" + mProps.meetingID + "-" + timestamp + ".mp4" + meetingModel.recordingStarted() + meetingModel.setVoiceRecordingFilename(filepath) + outGW.send(new DeskShareStartRecording(msg.conferenceName, filepath, timestamp)) } else { println("IS NOT RECORDING") } - // if (mProps.allowStartStopRecording && meetingModel.isRecording() != msg.recording) { - // if (msg.recording) { - // meetingModel.recordingStarted() - // } else { - // meetingModel.recordingStopped() - // } - // log.debug("Sending recording status for meeting [" + mProps.meetingID + "], recording=[" + msg.recording + "]") - // outGW.send(new RecordingStatusChanged(mProps.meetingID, mProps.recorded, msg.userId, msg.recording)) - // } - - // if (msg.recording) { - // meetingModel.setVoiceRecordingFilename(msg.recordStream) - // outGW.send(new VoiceRecordingStarted(mProps.meetingID, mProps.recorded, msg.recordStream, msg.timestamp, mProps.voiceBridge)) - // } else { - // meetingModel.setVoiceRecordingFilename("") - // outGW.send(new VoiceRecordingStopped(mProps.meetingID, mProps.recorded, msg.recordStream, msg.timestamp, mProps.voiceBridge)) - // } - - // conferenceName: String, filename: String, timestamp: String - outGW.send(new DeskShareStartedReply(msg.conferenceName, msg.callerId, msg.callerIdName)) } private def handleDeskShareStoppedRequest(msg: DeskShareStoppedRequest) { - //TODO + println("\n\n\nMeetingActor-handleDeskShareStoppedRequest\n") + println("isRecording=" + meetingModel.isRecording()) + + if (meetingModel.isRecording()) { + println("STOPPING WHEN IT IS RECORDING") + val timestamp = System.currentTimeMillis().toString() + + meetingModel.recordingStopped() + outGW.send(new DeskShareStopRecording(msg.conferenceName, meetingModel.getVoiceRecordingFilename(), timestamp)) + } else { + println("ERROR: STOP REC BUT IT WAS NOT RECORDING?!") + } } private def handleDeskShareRecordingStartedRequest(msg: DeskShareRecordingStartedRequest) { - + //TODO } private def handleDeskShareRecordingStoppedRequest(msg: DeskShareRecordingStoppedRequest) { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala index 1163f07e26..7f745a2f0b 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala @@ -113,10 +113,12 @@ case class IsWhiteboardEnabledReply(meetingID: String, recorded: Boolean, reques case class GetAllMeetingsReply(meetings: Array[MeetingInfo]) extends IOutMessage // DeskShare -case class DeskShareStartedReply(conferenceName: String, callerId: String, callerIdName: String) extends IOutMessage -case class DeskShareStoppedReply(conferenceName: String, callerId: String, callerIdName: String) extends IOutMessage -case class DeskShareRecordingStartedReply(conferenceName: String, filename: String, timestamp: String) extends IOutMessage -case class DeskShareRecordingStoppedReply(conferenceName: String, filename: String, timestamp: String) extends IOutMessage +//case class DeskShareStartedReply(conferenceName: String, callerId: String, callerIdName: String) extends IOutMessage +//case class DeskShareStoppedReply(conferenceName: String, callerId: String, callerIdName: String) extends IOutMessage +//case class DeskShareRecordingStartedReply(conferenceName: String, filename: String, timestamp: String) extends IOutMessage +//case class DeskShareRecordingStoppedReply(conferenceName: String, filename: String, timestamp: String) extends IOutMessage +case class DeskShareStartRecording(conferenceName: String, filename: String, timestamp: String) extends IOutMessage +case class DeskShareStopRecording(conferenceName: String, filename: String, timestamp: String) extends IOutMessage // Value Objects case class MeetingVO(id: String, recorded: Boolean) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/DeskShareEventRedisPublisher.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/DeskShareEventRedisPublisher.scala new file mode 100644 index 0000000000..7eeb288025 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/DeskShareEventRedisPublisher.scala @@ -0,0 +1,34 @@ +package org.bigbluebutton.core.pubsub.senders + +import org.bigbluebutton.core.api.OutMessageListener2 +import org.bigbluebutton.core.MessageSender +import org.bigbluebutton.core.api._ +import com.google.gson.Gson +import scala.collection.mutable.HashMap +import collection.JavaConverters._ +import scala.collection.JavaConversions._ +import java.util.ArrayList +import org.bigbluebutton.common.messages.MessagingConstants +import org.bigbluebutton.core.messaging.Util + +class DeskShareEventRedisPublisher(service: MessageSender) extends OutMessageListener2 { + def handleMessage(msg: IOutMessage) { + msg match { + case msg: DeskShareStartRecording => handleDeskShareStartRecording(msg) + case msg: DeskShareStopRecording => handleDeskShareStopRecording(msg) + case _ => // do nothing + } + } + + private def handleDeskShareStartRecording(msg: DeskShareStartRecording) { + println("_______handleDeskShareStartRecording____________") + val json = DeskShareMessageToJsonConverter.getDeskShareStartRecordingToJson(msg) + service.send(MessagingConstants.TO_VOICE_CONF_SYSTEM_CHAN, json) + } + + private def handleDeskShareStopRecording(msg: DeskShareStopRecording) { + println("_______handleDeskShareStopRecording____________") + val json = DeskShareMessageToJsonConverter.getDeskShareStopRecordingToJson(msg) + service.send(MessagingConstants.TO_VOICE_CONF_SYSTEM_CHAN, json) + } +} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/DeskShareMessageToJsonConverter.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/DeskShareMessageToJsonConverter.scala new file mode 100644 index 0000000000..70d7f56ee4 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/DeskShareMessageToJsonConverter.scala @@ -0,0 +1,22 @@ +package org.bigbluebutton.core.pubsub.senders + +import org.bigbluebutton.core.api._ +import org.bigbluebutton.common.messages.DeskShareStartRecordingEventMessage +import org.bigbluebutton.common.messages.DeskShareStopRecordingEventMessage + +object DeskShareMessageToJsonConverter { + + val UNKNOWN = "unknown" + + def getDeskShareStartRecordingToJson(msg: DeskShareStartRecording): String = { + println("^^^^^getDeskShareStartRecordingToJson in DeskShareMessageToJsonConverter") + val newMsg = new DeskShareStartRecordingEventMessage(msg.conferenceName, msg.filename, msg.timestamp) + newMsg.toJson() + } + + def getDeskShareStopRecordingToJson(msg: DeskShareStopRecording): String = { + println("^^^^^getDeskShareStopRecordingToJson in DeskShareMessageToJsonConverter") + val newMsg = new DeskShareStopRecordingEventMessage(msg.conferenceName, msg.filename, msg.timestamp) + newMsg.toJson() + } +} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/DeskShareEventRedisRecorder.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/DeskShareEventRedisRecorder.scala new file mode 100644 index 0000000000..7234e15837 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/DeskShareEventRedisRecorder.scala @@ -0,0 +1,21 @@ +package org.bigbluebutton.core.recorders + +import org.bigbluebutton.core.api._ +import scala.collection.JavaConversions._ +import org.bigbluebutton.core.service.recorder.RecorderApplication +import org.bigbluebutton.core.recorders.events.PublicChatRecordEvent + +class DeskShareEventRedisRecorder(recorder: RecorderApplication) extends OutMessageListener2 { + def handleMessage(msg: IOutMessage) { + msg match { + case msg: SendPublicMessageEvent => handleSendPublicMessageEvent(msg) + case _ => // do nothing + } + } + + private def handleSendPublicMessageEvent(msg: SendPublicMessageEvent) { + println("____TODO____DeskShareEventRedisRecorder") + // if (msg.recorded) { + // } + } +} diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java index cb1ba1a66e..66d3ae6761 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java @@ -1,12 +1,14 @@ package org.bigbluebutton.freeswitch.pubsub.receivers; +import org.bigbluebutton.common.messages.DeskShareStopRecordingEventMessage; import org.bigbluebutton.common.messages.EjectAllUsersFromVoiceConfRequestMessage; import org.bigbluebutton.common.messages.EjectUserFromVoiceConfRequestMessage; import org.bigbluebutton.common.messages.GetUsersFromVoiceConfRequestMessage; import org.bigbluebutton.common.messages.MuteUserInVoiceConfRequestMessage; import org.bigbluebutton.common.messages.StartRecordingVoiceConfRequestMessage; import org.bigbluebutton.common.messages.StopRecordingVoiceConfRequestMessage; +import org.bigbluebutton.common.messages.DeskShareStartRecordingEventMessage; import org.bigbluebutton.freeswitch.voice.freeswitch.FreeswitchApplication; import com.google.gson.JsonObject; @@ -55,12 +57,30 @@ public class RedisMessageReceiver { case StopRecordingVoiceConfRequestMessage.STOP_RECORD_VOICE_CONF_REQUEST: processStopRecordingVoiceConfRequestMessage(message); break; + case DeskShareStartRecordingEventMessage.DESKSHARE_START_RECORDING_MESSAGE: + processDeskShareStartRecordingEventMessage(message); + break; + case DeskShareStopRecordingEventMessage.DESKSHARE_STOP_RECORDING_MESSAGE: + processDeskShareStopRecordingEventMessage(message); + break; } } } } } - + + private void processDeskShareStartRecordingEventMessage(String json) { + System.out.println("^^^FS^processDeskShareStartRecordingEventMessage"); + DeskShareStartRecordingEventMessage msg = DeskShareStartRecordingEventMessage.fromJson(json); + fsApp.deskShareRecording(msg.conferenceName, msg.filename, true); + } + + private void processDeskShareStopRecordingEventMessage(String json) { + System.out.println("^^^FS^processDeskShareStopRecordingEventMessage"); + DeskShareStopRecordingEventMessage msg = DeskShareStopRecordingEventMessage.fromJson(json); + fsApp.deskShareRecording(msg.conferenceName, msg.filename, false); + } + private void processEjectAllVoiceUsersRequestMessage(String json) { EjectAllUsersFromVoiceConfRequestMessage msg = EjectAllUsersFromVoiceConfRequestMessage.fromJson(json); fsApp.ejectAll(msg.voiceConfId); diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java index 586de1ce1f..c125c72951 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java @@ -98,9 +98,9 @@ public class FreeswitchApplication { queueMessage(rcc); } - public void deskShareRecording(String voiceConfId, String meetingid, String filePath){ - DeskShareRecordCommand dsrc = new DeskShareRecordCommand(voiceConfId, USER, true, filePath); - System.out.println("______in FS app deskShareRecording______"); + public void deskShareRecording(String voiceConfId, String filePath, Boolean record){ + DeskShareRecordCommand dsrc = new DeskShareRecordCommand(voiceConfId, USER, record, filePath); + System.out.println("______in FS app deskShareRecording__" + dsrc.getCommand() + "____"); queueMessage(dsrc); } @@ -128,6 +128,7 @@ public class FreeswitchApplication { manager.record((RecordConferenceCommand) command); } else if (command instanceof DeskShareRecordCommand) { System.out.println("Sending DeskShareRecordCommand for conference = [" + command.getRoom() + "]"); + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$Sending DeskShareRECORDCommand for conference = [" + command.getRoom() + "]"); manager.record((DeskShareRecordCommand)command); } else if (command instanceof DeskShareBroadcastRTMPCommand) { System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$Sending DeskShareBroadcastRTMPCommand for conference = [" + command.getRoom() + "]");