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 5b09b921ee79..f05567c97929 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 @@ -7,6 +7,8 @@ import org.bigbluebutton.common.messages.DeskShareEndedEventMessage; import org.bigbluebutton.common.messages.DeskShareViewerJoinedEventMessage; import org.bigbluebutton.common.messages.DeskShareViewerLeftEventMessage; +import org.bigbluebutton.common.messages.DeskShareStartRecordingEventMessage; +import org.bigbluebutton.common.messages.DeskShareStopRecordingEventMessage; import org.bigbluebutton.common.messages.MessagingConstants; import org.bigbluebutton.core.api.IBigBlueButtonInGW; @@ -28,7 +30,7 @@ public void handleMessage(String pattern, String channel, String message) { if (header.has("name")) { String messageName = header.get("name").getAsString(); - if (DeskShareStartedEventMessage.DESK_SHARE_STARTED_MESSAGE.equals(messageName)) { + if (DeskShareStartedEventMessage.DESKSHARE_STARTED_MESSAGE.equals(messageName)) { DeskShareStartedEventMessage msg = DeskShareStartedEventMessage.fromJson(message); // // TODO } else if (DeskShareEndedEventMessage.DESK_SHARE_ENDED_MESSAGE.equals(messageName)) { @@ -40,6 +42,14 @@ public void handleMessage(String pattern, String channel, String message) { } else if (DeskShareViewerLeftEventMessage.DESK_SHARE_VIEWER_LEFT_MESSAGE.equals(messageName)) { DeskShareViewerLeftEventMessage msg = DeskShareViewerLeftEventMessage.fromJson(message); // // TODO + } else if (DeskShareStartRecordingEventMessage.DESKSHARE_START_RECORDING_MESSAGE.equals(messageName)) { + DeskShareStartRecordingEventMessage msg = DeskShareStartRecordingEventMessage.fromJson(message); +// // TODO + System.out.println("^^^^^^^START REC^^^^^^"); + } else if (DeskShareStopRecordingEventMessage.DESKSHARE_STOP_RECORDING_MESSAGE.equals(messageName)) { + DeskShareStopRecordingEventMessage msg = DeskShareStopRecordingEventMessage.fromJson(message); +// // TODO + System.out.println("^^^^^^^STOP REC^^^^^^"); } } } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java index ab304cbec337..b7bba87052c4 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java @@ -24,6 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import org.bigbluebutton.freeswitch.voice.events.DeskShareRecordingEvent; import org.bigbluebutton.freeswitch.voice.events.DeskShareStartedEvent; import org.bigbluebutton.freeswitch.voice.events.DeskShareEndedEvent; import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; @@ -102,6 +103,11 @@ public void run() { DeskShareViewerLeftEvent evt = (DeskShareViewerLeftEvent) event; System.out.println("************** FreeswitchConferenceEventListener DeskShareViewerLeftEvent"); vcs.deskShareViewerLeft(evt.getRoom(), evt.getCallerIdNum(), evt.getCallerIdName()); + } else if (event instanceof DeskShareRecordingEvent) { + System.out.println("******** RECORDING******\n\n\n\n\n FreeswitchConferenceEventListener "); + DeskShareRecordingEvent evt = (DeskShareRecordingEvent) event; + System.out.println("************** FreeswitchConferenceEventListener DeskShareRecordingEvent"); + vcs.deskShareRecording(evt.getRoom(), evt.getRecordingFilename(), evt.getRecord(), evt.getTimestamp()); } } }; diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java index 0709740d67a5..8228e304eaab 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java @@ -12,5 +12,6 @@ void userJoinedVoiceConf(String voiceConfId, String voiceUserId, String userId, void deskShareEnded(String voiceConfId, String callerIdNum, String callerIdName); void deskShareViewerJoined(String voiceConfId, String callerIdNum, String callerIdName); void deskShareViewerLeft(String voiceConfId, String callerIdNum, String callerIdName); + void deskShareRecording(String room, String recordingFilename, boolean record, String timestamp); } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/DeskShareRecordingEvent.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/DeskShareRecordingEvent.java new file mode 100644 index 000000000000..b7b3d49ac24b --- /dev/null +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/DeskShareRecordingEvent.java @@ -0,0 +1,51 @@ +/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2015 BigBlueButton Inc. and by respective authors (see below). +* +* This program is free software; you can redistribute it and/or modify it under the +* terms of the GNU Lesser General Public License as published by the Free Software +* Foundation; either version 3.0 of the License, or (at your option) any later +* version. +* +* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along +* with BigBlueButton; if not, see . +* +*/ +package org.bigbluebutton.freeswitch.voice.events; + +public class DeskShareRecordingEvent extends VoiceConferenceEvent { + + private String timestamp; + private String filename; + private boolean record; + + public DeskShareRecordingEvent(String room, boolean record) { + super(room); + this.record = record; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public void setRecordingFilename(String filename) { + this.filename = filename; + } + + public String getTimestamp() { + return timestamp; + } + + public String getRecordingFilename() { + return filename; + } + + public boolean getRecord() { + return record; + } +} diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java index 517fb257f72e..23a3f8457630 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java @@ -25,6 +25,7 @@ import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.BroadcastConferenceCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.DeskShareRecordCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectAllUsersCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectUserCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.MuteUserCommand; @@ -143,5 +144,13 @@ public void record(RecordConferenceCommand rcc) { EslMessage response = c.sendSyncApiCommand(rcc.getCommand(), rcc.getCommandArgs()); rcc.handleResponse(response, conferenceEventListener); } - } + } + + public void record(DeskShareRecordCommand dsrc) { + Client c = manager.getESLClient(); + if (c.canSend()) { + EslMessage response = c.sendSyncApiCommand(dsrc.getCommand(), dsrc.getCommandArgs()); + dsrc.handleResponse(response, conferenceEventListener); + } + } } \ No newline at end of file diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ESLEventListener.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ESLEventListener.java index 40acb8f9bd03..d00a0aab4fe4 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ESLEventListener.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ESLEventListener.java @@ -8,9 +8,11 @@ import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; import org.bigbluebutton.freeswitch.voice.events.DeskShareEndedEvent; +import org.bigbluebutton.freeswitch.voice.events.DeskShareRecordingEvent; import org.bigbluebutton.freeswitch.voice.events.DeskShareStartedEvent; import org.bigbluebutton.freeswitch.voice.events.DeskShareViewerJoinedEvent; import org.bigbluebutton.freeswitch.voice.events.DeskShareViewerLeftEvent; +import org.bigbluebutton.freeswitch.voice.events.VoiceConferenceEvent; import org.bigbluebutton.freeswitch.voice.events.VoiceStartRecordingEvent; import org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent; import org.bigbluebutton.freeswitch.voice.events.VoiceUserLeftEvent; @@ -177,32 +179,49 @@ public void conferenceEventThreadRun(String uniqueId, String confName, int confS //@Override public void conferenceEventRecord(String uniqueId, String confName, int confSize, EslEvent event) { - String action = event.getEventHeaders().get("Action"); - - if(action == null) { + String action = event.getEventHeaders().get("Action"); + + if(action == null) { return; } - - System.out.println("Handling conferenceEventRecord " + action); - - if (action.equals(START_RECORDING_EVENT)) { - VoiceStartRecordingEvent sre = new VoiceStartRecordingEvent(confName, true); - sre.setRecordingFilename(getRecordFilenameFromEvent(event)); - sre.setTimestamp(genTimestamp().toString()); - - System.out.println("Voice conference recording started. file=[" + getRecordFilenameFromEvent(event) + "], conf=[" + confName + "]"); - - conferenceEventListener.handleConferenceEvent(sre); - } else if (action.equals(STOP_RECORDING_EVENT)) { - VoiceStartRecordingEvent srev = new VoiceStartRecordingEvent(confName, false); - srev.setRecordingFilename(getRecordFilenameFromEvent(event)); - srev.setTimestamp(genTimestamp().toString()); - - System.out.println("Voice conference recording stopped. file=[" + getRecordFilenameFromEvent(event) + "], conf=[" + confName + "]"); - conferenceEventListener.handleConferenceEvent(srev); - } else { - System.out.println("Processing UNKNOWN conference Action " + action + "]"); - } + + System.out.println("Handling conferenceEventRecord " + action); + + if (action.equals(START_RECORDING_EVENT)) { + if (confName.endsWith(DESKSHARE_CONFERENCE_NAME_LABEL)){ + DeskShareRecordingEvent dssre = new DeskShareRecordingEvent(confName, true); + dssre.setRecordingFilename(getRecordFilenameFromEvent(event)); + dssre.setTimestamp(genTimestamp().toString()); + System.out.println("DeskShare conference recording started. file=[" + + getRecordFilenameFromEvent(event) + "], conf=[" + confName + "]"); + conferenceEventListener.handleConferenceEvent( (VoiceConferenceEvent)dssre); + } else { + VoiceStartRecordingEvent sre = new VoiceStartRecordingEvent(confName, true); + sre.setRecordingFilename(getRecordFilenameFromEvent(event)); + sre.setTimestamp(genTimestamp().toString()); + System.out.println("Voice conference recording started. file=[" + + getRecordFilenameFromEvent(event) + "], conf=[" + confName + "]"); + conferenceEventListener.handleConferenceEvent(sre); + } + } else if (action.equals(STOP_RECORDING_EVENT)) { + if (confName.endsWith(DESKSHARE_CONFERENCE_NAME_LABEL)){ + DeskShareRecordingEvent dssre = new DeskShareRecordingEvent(confName, false); + dssre.setRecordingFilename(getRecordFilenameFromEvent(event)); + dssre.setTimestamp(genTimestamp().toString()); + System.out.println("DeskShare conference recording stopped. file=[" + + getRecordFilenameFromEvent(event) + "], conf=[" + confName + "]"); + conferenceEventListener.handleConferenceEvent( (VoiceConferenceEvent)dssre); + } else { + VoiceStartRecordingEvent sre = new VoiceStartRecordingEvent(confName, false); + sre.setRecordingFilename(getRecordFilenameFromEvent(event)); + sre.setTimestamp(genTimestamp().toString()); + System.out.println("Voice conference recording stopped. file=[" + + getRecordFilenameFromEvent(event) + "], conf=[" + confName + "]"); + conferenceEventListener.handleConferenceEvent(sre); + } + } else { + System.out.println("Processing UNKNOWN conference Action " + action + "]"); + } } private Long genTimestamp() { 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 e8a4e11ecf5f..2ad5e8dbfe58 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 @@ -1,7 +1,7 @@ /** * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ * -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). +* Copyright (c) 2015 BigBlueButton Inc. and by respective authors (see below). * * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -24,7 +24,9 @@ import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; + import org.bigbluebutton.freeswitch.voice.freeswitch.actions.BroadcastConferenceCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.DeskShareRecordCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectAllUsersCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectUserCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.FreeswitchCommand; @@ -33,68 +35,74 @@ import org.bigbluebutton.freeswitch.voice.freeswitch.actions.RecordConferenceCommand; public class FreeswitchApplication { - + private static final int SENDERTHREADS = 1; private static final Executor msgSenderExec = Executors.newFixedThreadPool(SENDERTHREADS); private static final Executor runExec = Executors.newFixedThreadPool(SENDERTHREADS); private BlockingQueue messages = new LinkedBlockingQueue(); - + private final ConnectionManager manager; - + private final String USER = "0"; /* not used for now */ - + private volatile boolean sendMessages = false; - + public FreeswitchApplication(ConnectionManager manager) { this.manager = manager; } - - private void queueMessage(FreeswitchCommand command) { - try { - messages.offer(command, 5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public void getAllUsers(String voiceConfId) { - GetAllUsersCommand prc = new GetAllUsersCommand(voiceConfId, USER); - queueMessage(prc); - } - - public void muteUser(String voiceConfId, String voiceUserId, Boolean mute) { - MuteUserCommand mpc = new MuteUserCommand(voiceConfId, voiceUserId, mute, USER); - queueMessage(mpc); - } - - public void eject(String voiceConfId, String voiceUserId) { - EjectUserCommand mpc = new EjectUserCommand(voiceConfId, voiceUserId, USER); - queueMessage(mpc); - } - - public void ejectAll(String voiceConfId) { - EjectAllUsersCommand mpc = new EjectAllUsersCommand(voiceConfId, USER); - queueMessage(mpc); - } - - private Long genTimestamp() { - return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); - } - - public void startRecording(String voiceConfId, String meetingid){ - String RECORD_DIR = "/var/freeswitch/meetings"; - String voicePath = RECORD_DIR + File.separatorChar + meetingid + "-" + genTimestamp() + ".wav"; - - RecordConferenceCommand rcc = new RecordConferenceCommand(voiceConfId, USER, true, voicePath); - queueMessage(rcc); - } - - public void stopRecording(String voiceConfId, String meetingid, String voicePath){ - RecordConferenceCommand rcc = new RecordConferenceCommand(voiceConfId, USER, false, voicePath); - queueMessage(rcc); - } + + private void queueMessage(FreeswitchCommand command) { + try { + messages.offer(command, 5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void getAllUsers(String voiceConfId) { + GetAllUsersCommand prc = new GetAllUsersCommand(voiceConfId, USER); + queueMessage(prc); + } + public void muteUser(String voiceConfId, String voiceUserId, Boolean mute) { + MuteUserCommand mpc = new MuteUserCommand(voiceConfId, voiceUserId, mute, USER); + queueMessage(mpc); + } + + public void eject(String voiceConfId, String voiceUserId) { + EjectUserCommand mpc = new EjectUserCommand(voiceConfId, voiceUserId, USER); + queueMessage(mpc); + } + + public void ejectAll(String voiceConfId) { + EjectAllUsersCommand mpc = new EjectAllUsersCommand(voiceConfId, USER); + queueMessage(mpc); + } + + private Long genTimestamp() { + return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); + } + + public void startRecording(String voiceConfId, String meetingid){ + String RECORD_DIR = "/var/freeswitch/meetings"; + String voicePath = RECORD_DIR + File.separatorChar + meetingid + "-" + genTimestamp() + ".wav"; + + RecordConferenceCommand rcc = new RecordConferenceCommand(voiceConfId, USER, true, voicePath); + queueMessage(rcc); + } + + public void stopRecording(String voiceConfId, String meetingid, String voicePath){ + RecordConferenceCommand rcc = new RecordConferenceCommand(voiceConfId, USER, false, voicePath); + 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______"); + queueMessage(dsrc); + } + private void sendMessageToFreeswitch(final FreeswitchCommand command) { Runnable task = new Runnable() { public void run() { @@ -117,15 +125,18 @@ public void run() { manager.ejectAll(cmd); } else if (command instanceof RecordConferenceCommand) { manager.record((RecordConferenceCommand) command); + } else if (command instanceof DeskShareRecordCommand) { + System.out.println("Sending DeskShareRecordCommand for conference = [" + command.getRoom() + "]"); + manager.record((DeskShareRecordCommand)command); } else if (command instanceof BroadcastConferenceCommand) { manager.broadcast((BroadcastConferenceCommand) command); - } + } } }; - - runExec.execute(task); + + runExec.execute(task); } - + public void start() { sendMessages = true; Runnable sender = new Runnable() { @@ -134,18 +145,17 @@ public void run() { FreeswitchCommand message; try { message = messages.take(); - sendMessageToFreeswitch(message); + sendMessageToFreeswitch(message); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } } }; - msgSenderExec.execute(sender); + msgSenderExec.execute(sender); } - + public void stop() { sendMessages = false; } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/DeskShareRecordCommand.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/DeskShareRecordCommand.java new file mode 100644 index 000000000000..b98cdf01fd64 --- /dev/null +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/DeskShareRecordCommand.java @@ -0,0 +1,51 @@ +/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2015 BigBlueButton Inc. and by respective authors (see below). +* +* This program is free software; you can redistribute it and/or modify it under the +* terms of the GNU Lesser General Public License as published by the Free Software +* Foundation; either version 3.0 of the License, or (at your option) any later +* version. +* +* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along +* with BigBlueButton; if not, see . +* +*/ +package org.bigbluebutton.freeswitch.voice.freeswitch.actions; + +import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; +import org.freeswitch.esl.client.transport.message.EslMessage; + +public class DeskShareRecordCommand extends FreeswitchCommand { + + private String recordPath; + private boolean record; + // TODO add + + public DeskShareRecordCommand(String room, String requesterId, boolean record, String recordPath){ + super(room, requesterId); + this.recordPath = recordPath; + this.record = record; + } + + + @Override + public String getCommandArgs() { + String action = "norecord"; + if (record) + action = "record"; + + System.out.println("\n\n\n\n\n DESKSHARE RECORD " + record + "\n\n\n\n"); + return SPACE + getRoom() + SPACE + action + SPACE + recordPath; + } + + public void handleResponse(EslMessage response, ConferenceEventListener eventListener) { + //Test for Known Conference + System.out.println("\n\n\n\n\nLALALALLALA\n\n\n\n"); + } +} diff --git a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala index 7d859e62fd0e..86cd8b05f46b 100755 --- a/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala +++ b/akka-bbb-fsesl/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala @@ -2,7 +2,17 @@ package org.bigbluebutton.freeswitch import org.bigbluebutton.freeswitch.voice.IVoiceConferenceService import org.bigbluebutton.endpoint.redis.RedisPublisher -import org.bigbluebutton.common.messages._ +import org.bigbluebutton.common.messages.VoiceConfRecordingStartedMessage +import org.bigbluebutton.common.messages.UserJoinedVoiceConfMessage +import org.bigbluebutton.common.messages.UserLeftVoiceConfMessage +import org.bigbluebutton.common.messages.UserMutedInVoiceConfMessage +import org.bigbluebutton.common.messages.UserTalkingInVoiceConfMessage +import org.bigbluebutton.common.messages.DeskShareStartedEventMessage +import org.bigbluebutton.common.messages.DeskShareEndedEventMessage +import org.bigbluebutton.common.messages.DeskShareViewerJoinedEventMessage +import org.bigbluebutton.common.messages.DeskShareViewerLeftEventMessage +import org.bigbluebutton.common.messages.DeskShareStartRecordingEventMessage +import org.bigbluebutton.common.messages.DeskShareStopRecordingEventMessage class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceService { @@ -65,4 +75,17 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer val msg = new DeskShareViewerLeftEventMessage(voiceConfId, callerIdNum, callerIdName) sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) } + + def deskShareRecording(voiceConfId: String, recordingFilename: String, record: Boolean, timestamp: String) { + if (record) { + println("******** FreeswitchConferenceService received deskShareRecording - start") + val msg = new DeskShareStartRecordingEventMessage(voiceConfId, recordingFilename, timestamp) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) + } else { + println("******** FreeswitchConferenceService received deskShareRecording - stop") + val msg = new DeskShareStopRecordingEventMessage(voiceConfId, recordingFilename, timestamp) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) + } + } + } \ No newline at end of file diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartRecordingEventMessage.java b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartRecordingEventMessage.java new file mode 100644 index 000000000000..46b93e45e72b --- /dev/null +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartRecordingEventMessage.java @@ -0,0 +1,63 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class DeskShareStartRecordingEventMessage { + public static final String DESKSHARE_START_RECORDING_MESSAGE = "deskshare_start_recording_message"; + public static final String VERSION = "0.0.1"; + + public static final String CONFERENCE_NAME = "conference_name"; + public static final String FILENAME = "filename"; + public static final String TIMESTAMP = "timestamp"; + + public final String conferenceName; + public final String filename; + public final String timestamp; + + public DeskShareStartRecordingEventMessage(String conferenceName, String filename, String timestamp) { + this.conferenceName = conferenceName; + this.filename = filename; + this.timestamp = timestamp; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(CONFERENCE_NAME, conferenceName); + payload.put(FILENAME, filename); + payload.put(TIMESTAMP, timestamp); + + java.util.HashMap header = MessageBuilder.buildHeader(DESKSHARE_START_RECORDING_MESSAGE, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static DeskShareStartRecordingEventMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (DESKSHARE_START_RECORDING_MESSAGE.equals(messageName)) { + if (payload.has(CONFERENCE_NAME) + && payload.has(TIMESTAMP) + && payload.has(FILENAME)) { + String conferenceName = payload.get(CONFERENCE_NAME).getAsString(); + String filename = payload.get(FILENAME).getAsString(); + String timestamp = payload.get(TIMESTAMP).getAsString(); + + return new DeskShareStartRecordingEventMessage(conferenceName, filename, timestamp); + } + } + } + } + return null; + + } +} diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartedEventMessage.java b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartedEventMessage.java index bbd9898176e7..bcbae95e4b53 100644 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartedEventMessage.java +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStartedEventMessage.java @@ -6,7 +6,7 @@ public class DeskShareStartedEventMessage { - public static final String DESK_SHARE_STARTED_MESSAGE = "desk_share_started_message"; + public static final String DESKSHARE_STARTED_MESSAGE = "deskshare_start_message"; public static final String VERSION = "0.0.1"; public static final String CONFERENCE_NAME = "conference_name"; @@ -29,7 +29,7 @@ public String toJson() { payload.put(CALLER_ID_NAME, callerIdName); payload.put(CALLER_ID, callerId); - java.util.HashMap header = MessageBuilder.buildHeader(DESK_SHARE_STARTED_MESSAGE, VERSION, null); + java.util.HashMap header = MessageBuilder.buildHeader(DESKSHARE_STARTED_MESSAGE, VERSION, null); return MessageBuilder.buildJson(header, payload); } @@ -44,7 +44,7 @@ public static DeskShareStartedEventMessage fromJson(String message) { if (header.has("name")) { String messageName = header.get("name").getAsString(); - if (DESK_SHARE_STARTED_MESSAGE.equals(messageName)) { + if (DESKSHARE_STARTED_MESSAGE.equals(messageName)) { if (payload.has(CONFERENCE_NAME) && payload.has(CALLER_ID) && payload.has(CALLER_ID_NAME)) { diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStopRecordingEventMessage.java b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStopRecordingEventMessage.java new file mode 100644 index 000000000000..d6c825153a61 --- /dev/null +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/DeskShareStopRecordingEventMessage.java @@ -0,0 +1,63 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class DeskShareStopRecordingEventMessage { + public static final String DESKSHARE_STOP_RECORDING_MESSAGE = "deskshare_stop_recording_message"; + public static final String VERSION = "0.0.1"; + + public static final String CONFERENCE_NAME = "conference_name"; + public static final String FILENAME = "filename"; + public static final String TIMESTAMP = "timestamp"; + + public final String conferenceName; + public final String filename; + public final String timestamp; + + public DeskShareStopRecordingEventMessage(String conferenceName, String filename, String timestamp) { + this.conferenceName = conferenceName; + this.filename = filename; + this.timestamp = timestamp; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(CONFERENCE_NAME, conferenceName); + payload.put(FILENAME, filename); + payload.put(TIMESTAMP, timestamp); + + java.util.HashMap header = MessageBuilder.buildHeader(DESKSHARE_STOP_RECORDING_MESSAGE, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static DeskShareStopRecordingEventMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (DESKSHARE_STOP_RECORDING_MESSAGE.equals(messageName)) { + if (payload.has(CONFERENCE_NAME) + && payload.has(TIMESTAMP) + && payload.has(FILENAME)) { + String conferenceName = payload.get(CONFERENCE_NAME).getAsString(); + String filename = payload.get(FILENAME).getAsString(); + String timestamp = payload.get(TIMESTAMP).getAsString(); + + return new DeskShareStopRecordingEventMessage(conferenceName, filename, timestamp); + } + } + } + } + return null; + + } +}