From 0261a5e2b89048982e8c0572c669fd1e4b9a2d16 Mon Sep 17 00:00:00 2001 From: Richard Alam <ritzalam@gmail.com> Date: Mon, 21 Oct 2019 14:29:52 -0700 Subject: [PATCH] - send users and recordings in one message --- .../core/running/MeetingActor.scala | 7 ++ .../FreeswitchConferenceEventListener.java | 11 +- .../voice/IVoiceConferenceService.java | 66 +++++++--- .../freeswitch/voice/events/ConfMember.java | 28 +++++ .../voice/events/ConfRecording.java | 11 ++ .../VoiceConfRunningAndRecordingEvent.java | 9 +- .../voice/events/VoiceUserJoinedEvent.java | 10 +- .../voice/events/VoiceUserStatusEvent.java | 76 ------------ .../voice/events/VoiceUsersStatusEvent.java | 35 ++++++ .../actions/ConferenceCheckRecordCommand.java | 11 +- .../actions/GetUsersStatusCommand.java | 36 ++++-- .../freeswitch/response/ConferenceMember.java | 20 +++ .../XMLResponseConferenceListParser.java | 19 ++- .../freeswitch/VoiceConferenceService.scala | 115 +++++++++++++++--- .../common2/msgs/VoiceConfMsgs.scala | 20 ++- 15 files changed, 328 insertions(+), 146 deletions(-) create mode 100755 akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfMember.java create mode 100755 akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfRecording.java delete mode 100755 akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserStatusEvent.java create mode 100755 akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUsersStatusEvent.java diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala index d8281b6b0c..6f6789827b 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala @@ -763,5 +763,12 @@ class MeetingActor( def handleUserStatusVoiceConfEvtMsg(msg: UserStatusVoiceConfEvtMsg): Unit = { println("************* RECEIVED UserStatusVoiceConfEvtMsg *************") + msg.body.confUsers foreach { cm => + println("user " + cm.callerIdName) + } + + msg.body.confRecordings foreach { cr => + println("rec = " + cr.recordPath) + } } } 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 126b0d6603..0d165a9a5c 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 @@ -56,7 +56,7 @@ public class FreeswitchConferenceEventListener implements ConferenceEventListene if (event instanceof VoiceUserJoinedEvent) { VoiceUserJoinedEvent evt = (VoiceUserJoinedEvent) event; vcs.userJoinedVoiceConf(evt.getRoom(), evt.getVoiceUserId(), evt.getUserId(), evt.getCallerIdName(), - evt.getCallerIdNum(), evt.getMuted(), evt.getSpeaking(), evt.getAvatarURL()); + evt.getCallerIdNum(), evt.getMuted(), evt.getSpeaking(), evt.getCallingWith()); } else if (event instanceof VoiceConfRunningEvent) { VoiceConfRunningEvent evt = (VoiceConfRunningEvent) event; vcs.voiceConfRunning(evt.getRoom(), evt.isRunning()); @@ -96,11 +96,10 @@ public class FreeswitchConferenceEventListener implements ConferenceEventListene + ",rec=" + evt.recording); } - vcs.voiceConfRunningAndRecording(evt.getRoom(), evt.running, evt.recording); - } else if (event instanceof VoiceUserStatusEvent) { - VoiceUserStatusEvent evt = (VoiceUserStatusEvent) event; - vcs.voiceUserStatus(evt.getRoom(), evt.getVoiceUserId(), evt.getUserId(), evt.getCallerIdName(), - evt.getCallerIdNum(), evt.getMuted(), evt.getSpeaking(), evt.getAvatarURL()); + vcs.voiceConfRunningAndRecording(evt.getRoom(), evt.running, evt.recording, evt.confRecordings); + } else if (event instanceof VoiceUsersStatusEvent) { + VoiceUsersStatusEvent evt = (VoiceUsersStatusEvent) event; + vcs.voiceUsersStatus(evt.getRoom(), evt.confMembers, evt.confRecordings); } } 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 e1e5757140..e916924939 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 @@ -1,32 +1,68 @@ package org.bigbluebutton.freeswitch.voice; +import org.bigbluebutton.freeswitch.voice.events.ConfMember; +import org.bigbluebutton.freeswitch.voice.events.ConfRecording; + public interface IVoiceConferenceService { - void voiceConfRecordingStarted(String voiceConfId, String recordStream, Boolean recording, String timestamp); + void voiceConfRecordingStarted(String voiceConfId, + String recordStream, + Boolean recording, + String timestamp); - void voiceConfRunning(String voiceConfId, Boolean running); + void voiceConfRunning(String voiceConfId, + Boolean running); - void userJoinedVoiceConf(String voiceConfId, String voiceUserId, String userId, String callerIdName, - String callerIdNum, Boolean muted, Boolean speaking, String avatarURL); + void userJoinedVoiceConf(String voiceConfId, + String voiceUserId, + String userId, + String callerIdName, + String callerIdNum, + Boolean muted, + Boolean speaking, + String avatarURL); - void voiceUserStatus(String voiceConfId, String voiceUserId, String userId, String callerIdName, - String callerIdNum, Boolean muted, Boolean speaking, String avatarURL); + void voiceUsersStatus(String voiceConfId, + java.util.List<ConfMember> confMembers, + java.util.List<ConfRecording> confRecordings); - void userLeftVoiceConf(String voiceConfId, String voiceUserId); + void userLeftVoiceConf(String voiceConfId, + String voiceUserId); - void userLockedInVoiceConf(String voiceConfId, String voiceUserId, Boolean locked); + void userLockedInVoiceConf(String voiceConfId, + String voiceUserId, + Boolean locked); - void userMutedInVoiceConf(String voiceConfId, String voiceUserId, Boolean muted); + void userMutedInVoiceConf(String voiceConfId, + String voiceUserId, + Boolean muted); - void userTalkingInVoiceConf(String voiceConfId, String voiceUserId, Boolean talking); + void userTalkingInVoiceConf(String voiceConfId, + String voiceUserId, + Boolean talking); - void deskShareStarted(String voiceConfId, String callerIdNum, String callerIdName); + void deskShareStarted(String voiceConfId, + String callerIdNum, + String callerIdName); - void deskShareEnded(String voiceConfId, String callerIdNum, String callerIdName); + void deskShareEnded(String voiceConfId, + String callerIdNum, + String callerIdName); - void deskShareRTMPBroadcastStarted(String room, String streamname, Integer videoWidth, Integer videoHeight, String timestamp); + void deskShareRTMPBroadcastStarted(String room, + String streamname, + Integer videoWidth, + Integer videoHeight, + String timestamp); - void deskShareRTMPBroadcastStopped(String room, String streamname, Integer videoWidth, Integer videoHeight, String timestamp); + void deskShareRTMPBroadcastStopped(String room, + String streamname, + Integer videoWidth, + Integer videoHeight, + String timestamp); - void voiceConfRunningAndRecording(String room, Boolean isRunning, Boolean isRecording); + void voiceConfRunningAndRecording(String room, + Boolean isRunning, + Boolean isRecording, + java.util.List<ConfRecording> confRecording); } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfMember.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfMember.java new file mode 100755 index 0000000000..2470355c8b --- /dev/null +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfMember.java @@ -0,0 +1,28 @@ +package org.bigbluebutton.freeswitch.voice.events; + +public class ConfMember { + public final String voiceUserId; + public final String callerIdNum; + public final String callerIdName; + public final Boolean muted; + public final Boolean speaking; + public final Boolean locked = false; + public final String userId; + public final String callingWith; + + public ConfMember(String userId, + String voiceUserId, + String callerIdNum, + String callerIdName, + Boolean muted, + Boolean speaking, + String callingWith) { + this.userId = userId; + this.voiceUserId = voiceUserId; + this.callerIdName = callerIdName; + this.callerIdNum = callerIdNum; + this.muted = muted; + this.speaking = speaking; + this.callingWith = callingWith; + } +} diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfRecording.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfRecording.java new file mode 100755 index 0000000000..aef7ed88f3 --- /dev/null +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/ConfRecording.java @@ -0,0 +1,11 @@ +package org.bigbluebutton.freeswitch.voice.events; + +public class ConfRecording { + public final String recordingPath; + public final Long recordingStartTime; + + public ConfRecording(String recordingPath, Long recordingStartTime) { + this.recordingPath = recordingPath; + this.recordingStartTime = recordingStartTime; + } +} diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceConfRunningAndRecordingEvent.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceConfRunningAndRecordingEvent.java index 0d3332c55c..ebf0aab925 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceConfRunningAndRecordingEvent.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceConfRunningAndRecordingEvent.java @@ -17,15 +17,22 @@ */ package org.bigbluebutton.freeswitch.voice.events; +import java.util.List; + public class VoiceConfRunningAndRecordingEvent extends VoiceConferenceEvent { public final boolean running; public final boolean recording; + public final List<ConfRecording> confRecordings; - public VoiceConfRunningAndRecordingEvent(String room, boolean running, boolean recording) { + public VoiceConfRunningAndRecordingEvent(String room, + boolean running, + boolean recording, + List<ConfRecording> confRecordings) { super(room); this.running = running; this.recording = recording; + this.confRecordings = confRecordings; } } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserJoinedEvent.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserJoinedEvent.java index 7ac8f398e7..cb06948176 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserJoinedEvent.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserJoinedEvent.java @@ -27,11 +27,11 @@ public class VoiceUserJoinedEvent extends VoiceConferenceEvent { private final Boolean speaking; private final Boolean locked = false; private final String userId; - private final String avatarURL; + private final String callingWith; public VoiceUserJoinedEvent(String userId, String voiceUserId, String room, String callerIdNum, String callerIdName, - Boolean muted, Boolean speaking, String avatarURL) { + Boolean muted, Boolean speaking, String callingWith) { super(room); this.userId = userId; this.voiceUserId = voiceUserId; @@ -39,7 +39,7 @@ public class VoiceUserJoinedEvent extends VoiceConferenceEvent { this.callerIdNum = callerIdNum; this.muted = muted; this.speaking = speaking; - this.avatarURL = avatarURL; + this.callingWith = callingWith; } public String getUserId() { @@ -70,7 +70,7 @@ public class VoiceUserJoinedEvent extends VoiceConferenceEvent { return locked; } - public String getAvatarURL() { - return avatarURL; + public String getCallingWith() { + return callingWith; } } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserStatusEvent.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserStatusEvent.java deleted file mode 100755 index db1559aced..0000000000 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUserStatusEvent.java +++ /dev/null @@ -1,76 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2012 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 <http://www.gnu.org/licenses/>. -* -*/ -package org.bigbluebutton.freeswitch.voice.events; - -public class VoiceUserStatusEvent extends VoiceConferenceEvent { - - private final String voiceUserId; - private final String callerIdNum; - private final String callerIdName; - private final Boolean muted; - private final Boolean speaking; - private final Boolean locked = false; - private final String userId; - private final String avatarURL; - - public VoiceUserStatusEvent(String userId, String voiceUserId, String room, - String callerIdNum, String callerIdName, - Boolean muted, Boolean speaking, String avatarURL) { - super(room); - this.userId = userId; - this.voiceUserId = voiceUserId; - this.callerIdName = callerIdName; - this.callerIdNum = callerIdNum; - this.muted = muted; - this.speaking = speaking; - this.avatarURL = avatarURL; - } - - public String getUserId() { - return userId; - } - - public String getVoiceUserId() { - return voiceUserId; - } - - public String getCallerIdNum() { - return callerIdNum; - } - - public String getCallerIdName() { - return callerIdName; - } - - public Boolean getMuted() { - return muted; - } - - public Boolean getSpeaking() { - return speaking; - } - - public Boolean isLocked() { - return locked; - } - - public String getAvatarURL() { - return avatarURL; - } -} diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUsersStatusEvent.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUsersStatusEvent.java new file mode 100755 index 0000000000..eb674d7d80 --- /dev/null +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/events/VoiceUsersStatusEvent.java @@ -0,0 +1,35 @@ +/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2012 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 <http://www.gnu.org/licenses/>. +* +*/ +package org.bigbluebutton.freeswitch.voice.events; + +import java.util.List; + +public class VoiceUsersStatusEvent extends VoiceConferenceEvent { + + public final List<ConfMember> confMembers; + public final List<ConfRecording> confRecordings; + + public VoiceUsersStatusEvent(String room, List<ConfMember> confMembers, + List<ConfRecording> confRecordings) { + super(room); + this.confMembers = confMembers; + this.confRecordings = confRecordings; + } + +} diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/ConferenceCheckRecordCommand.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/ConferenceCheckRecordCommand.java index b9c648a743..47a7edf2dd 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/ConferenceCheckRecordCommand.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/ConferenceCheckRecordCommand.java @@ -1,6 +1,7 @@ package org.bigbluebutton.freeswitch.voice.freeswitch.actions; import org.apache.commons.lang3.StringUtils; +import org.bigbluebutton.freeswitch.voice.events.ConfRecording; import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; import org.bigbluebutton.freeswitch.voice.events.VoiceConfRunningAndRecordingEvent; import org.bigbluebutton.freeswitch.voice.freeswitch.response.ConferenceMember; @@ -15,7 +16,9 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; public class ConferenceCheckRecordCommand extends FreeswitchCommand { private static Logger log = LoggerFactory.getLogger(ConferenceCheckRecordCommand.class); @@ -31,6 +34,7 @@ public class ConferenceCheckRecordCommand extends FreeswitchCommand { } public void handleResponse(EslMessage response, ConferenceEventListener eventListener) { + List<ConfRecording> confRecordings = new ArrayList<ConfRecording>(); String firstLine = response.getBodyLines().get(0); //log.info("Check conference first line response: " + firstLine); @@ -38,7 +42,7 @@ public class ConferenceCheckRecordCommand extends FreeswitchCommand { if(!firstLine.startsWith("<?xml")) { //log.info("Conference is not running and recording {}.", room); VoiceConfRunningAndRecordingEvent voiceConfRunningAndRecordingEvent = - new VoiceConfRunningAndRecordingEvent(getRoom(), false, false); + new VoiceConfRunningAndRecordingEvent(getRoom(), false, false, confRecordings); eventListener.handleConferenceEvent(voiceConfRunningAndRecordingEvent); return; } @@ -63,6 +67,7 @@ public class ConferenceCheckRecordCommand extends FreeswitchCommand { ByteArrayInputStream bs = new ByteArrayInputStream(responseBody.getBytes()); sp.parse(bs, confXML); + Integer numUsers = confXML.getConferenceList().size(); if (numUsers > 0) { //log.info("Check conference response: " + responseBody); @@ -75,12 +80,14 @@ public class ConferenceCheckRecordCommand extends FreeswitchCommand { } else if ("recording_node".equals(member.getMemberType())) { recording = true; + ConfRecording confRecording = new ConfRecording(member.getRecordPath(), member.getRecordStartTime()); + confRecordings.add(confRecording); } } } VoiceConfRunningAndRecordingEvent voiceConfRunningAndRecordingEvent = - new VoiceConfRunningAndRecordingEvent(getRoom(), running, recording); + new VoiceConfRunningAndRecordingEvent(getRoom(), running, recording, confRecordings); eventListener.handleConferenceEvent(voiceConfRunningAndRecordingEvent); }catch(SAXException se) { diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java index 33fde35207..cbfeeed54c 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetUsersStatusCommand.java @@ -1,10 +1,7 @@ package org.bigbluebutton.freeswitch.voice.freeswitch.actions; import org.apache.commons.lang3.StringUtils; -import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; -import org.bigbluebutton.freeswitch.voice.events.VoiceConfRunningAndRecordingEvent; -import org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent; -import org.bigbluebutton.freeswitch.voice.events.VoiceUserStatusEvent; +import org.bigbluebutton.freeswitch.voice.events.*; import org.bigbluebutton.freeswitch.voice.freeswitch.response.ConferenceMember; import org.bigbluebutton.freeswitch.voice.freeswitch.response.XMLResponseConferenceListParser; import org.freeswitch.esl.client.transport.message.EslMessage; @@ -17,6 +14,8 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -65,6 +64,9 @@ public class GetUsersStatusCommand extends FreeswitchCommand { if (numUsers > 0) { log.info("Check user status response: " + responseBody); + List<ConfMember> confMembers = new ArrayList<ConfMember>(); + List<ConfRecording> confRecordings = new ArrayList<ConfRecording>(); + for (ConferenceMember member : confXML.getConferenceList()) { if ("caller".equals(member.getMemberType())) { String callerId = member.getCallerId(); @@ -85,19 +87,27 @@ public class GetUsersStatusCommand extends FreeswitchCommand { + ",muted=" + member.getMuted() + ",talking=" + member.getSpeaking()); - VoiceUserStatusEvent pj = new VoiceUserStatusEvent(voiceUserId, member.getId().toString(), confXML.getConferenceRoom(), - callerId, callerIdName, member.getMuted(), member.getSpeaking(), "none"); - eventListener.handleConferenceEvent(pj); + //VoiceUsersStatusEvent pj = new VoiceUsersStatusEvent(voiceUserId, member.getId().toString(), confXML.getConferenceRoom(), + // callerId, callerIdName, member.getMuted(), member.getSpeaking(), "none"); + //eventListener.handleConferenceEvent(pj); + + ConfMember confMember = new ConfMember(voiceUserId, + member.getId().toString(), + callerId, callerIdName, + member.getMuted(), + member.getSpeaking(), + "none"); + confMembers.add(confMember); } else if ("recording_node".equals(member.getMemberType())) { - + ConfRecording confRecording = new ConfRecording(member.getRecordPath(), member.getRecordStartTime()); + confRecordings.add(confRecording); } } - } - - //VoiceConfRunningAndRecordingEvent voiceConfRunningAndRecordingEvent = - // new VoiceConfRunningAndRecordingEvent(getRoom(), running, recording); - //eventListener.handleConferenceEvent(voiceConfRunningAndRecordingEvent); + VoiceUsersStatusEvent voiceUsersStatusEvent = + new VoiceUsersStatusEvent(getRoom(), confMembers, confRecordings); + eventListener.handleConferenceEvent(voiceUsersStatusEvent); + } }catch(SAXException se) { log.error("Cannot parse response. ", se); }catch(ParserConfigurationException pce) { diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/ConferenceMember.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/ConferenceMember.java index c30bc4f738..2133b73542 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/ConferenceMember.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/ConferenceMember.java @@ -34,6 +34,10 @@ public class ConferenceMember { protected Integer lastTalking; protected String memberType; + // For recording + protected String recordPath; + protected Long recordStartTime; + public Integer getId() { return memberId; } @@ -97,4 +101,20 @@ public class ConferenceMember { public String getMemberType() { return memberType; } + + public void setRecordPath(String path) { + this.recordPath = path; + } + + public String getRecordPath() { + return recordPath; + } + + public void setRecordStartTime(Long recordStartTime) { + this.recordStartTime = recordStartTime; + } + + public Long getRecordStartTime() { + return recordStartTime; + } } diff --git a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/XMLResponseConferenceListParser.java b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/XMLResponseConferenceListParser.java index 2d2ce32a54..29e9ec1756 100755 --- a/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/XMLResponseConferenceListParser.java +++ b/akka-bbb-fsesl/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/response/XMLResponseConferenceListParser.java @@ -145,17 +145,28 @@ public class XMLResponseConferenceListParser extends DefaultHandler { }else if (qName.equalsIgnoreCase("caller_id_number")) { tempMember.setCallerId(tempVal); }else if (qName.equalsIgnoreCase("join_time")) { - try { - tempMember.setJoinTime(Integer.parseInt(tempVal)); - } catch(NumberFormatException nfe) { - + if (tempMember.getMemberType().equalsIgnoreCase("caller")) { + try { + tempMember.setJoinTime(Integer.parseInt(tempVal)); + } catch(NumberFormatException nfe) { + + } + } else if (tempMember.getMemberType().equalsIgnoreCase("recording_node")) { + try { + tempMember.setRecordStartTime(Long.parseLong(tempVal)); + } catch(NumberFormatException nfe) { + + } } + }else if (qName.equalsIgnoreCase("last_talking")) { try { tempMember.setLastTalking(Integer.parseInt(tempVal)); } catch(NumberFormatException nfe) { } + } else if (qName.equalsIgnoreCase("record_path")) { + tempMember.setRecordPath(tempVal); } } } 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 5e42a0ca95..fd8d53c7c7 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 @@ -1,16 +1,24 @@ package org.bigbluebutton.freeswitch +import scala.collection.JavaConverters._ import org.bigbluebutton.SystemConfiguration +import org.bigbluebutton.common2.msgs import org.bigbluebutton.freeswitch.voice.IVoiceConferenceService import org.bigbluebutton.common2.msgs._ import org.bigbluebutton.common2.util.JsonUtil import org.bigbluebutton.common2.redis.RedisPublisher +import org.bigbluebutton.freeswitch.voice.events.{ ConfMember, ConfRecording } class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceService with SystemConfiguration { val FROM_VOICE_CONF_SYSTEM_CHAN = "bigbluebutton:from-voice-conf:system" - def voiceConfRunningAndRecording(voiceConfId: String, isRunning: java.lang.Boolean, isRecording: java.lang.Boolean) { + def voiceConfRunningAndRecording( + voiceConfId: String, + isRunning: java.lang.Boolean, + isRecording: java.lang.Boolean, + confRecording: java.util.List[ConfRecording] + ) { val header = BbbCoreVoiceConfHeader(CheckRunningAndRecordingVoiceConfEvtMsg.NAME, voiceConfId) val body = CheckRunningAndRecordingVoiceConfEvtMsgBody(voiceConfId, isRunning.booleanValue(), isRecording.booleanValue()) val envelope = BbbCoreEnvelope(CheckRunningAndRecordingVoiceConfEvtMsg.NAME, Map("voiceConf" -> voiceConfId)) @@ -22,7 +30,12 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer sender.publish(fromVoiceConfRedisChannel, json) } - def voiceConfRecordingStarted(voiceConfId: String, recordStream: String, recording: java.lang.Boolean, timestamp: String) { + def voiceConfRecordingStarted( + voiceConfId: String, + recordStream: String, + recording: java.lang.Boolean, + timestamp: String + ) { val header = BbbCoreVoiceConfHeader(RecordingStartedVoiceConfEvtMsg.NAME, voiceConfId) val body = RecordingStartedVoiceConfEvtMsgBody(voiceConfId, recordStream, recording.booleanValue(), timestamp) val envelope = BbbCoreEnvelope(RecordingStartedVoiceConfEvtMsg.NAME, Map("voiceConf" -> voiceConfId)) @@ -35,7 +48,10 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def voiceConfRunning(voiceConfId: String, running: java.lang.Boolean): Unit = { + def voiceConfRunning( + voiceConfId: String, + running: java.lang.Boolean + ): Unit = { val header = BbbCoreVoiceConfHeader(VoiceConfRunningEvtMsg.NAME, voiceConfId) val body = VoiceConfRunningEvtMsgBody(voiceConfId, running.booleanValue()) val envelope = BbbCoreEnvelope(VoiceConfRunningEvtMsg.NAME, Map("voiceConf" -> voiceConfId)) @@ -47,12 +63,32 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer sender.publish(fromVoiceConfRedisChannel, json) } - def voiceUserStatus(voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String, - callerIdNum: String, muted: java.lang.Boolean, talking: java.lang.Boolean, avatarURL: String) { + def voiceUsersStatus( + voiceConfId: String, + confMembers: java.util.List[ConfMember], + confRecording: java.util.List[ConfRecording] + ) { + val users: scala.collection.mutable.ListBuffer[ConfVoiceUser] = new scala.collection.mutable.ListBuffer[ConfVoiceUser]() + confMembers forEach { cm => + users += ConfVoiceUser( + cm.voiceUserId, + cm.userId, + cm.callerIdName, + cm.callerIdNum, + cm.muted, + cm.speaking, + cm.callingWith, + "freeswitch" + ) + } + + val recs: scala.collection.mutable.ListBuffer[ConfVoiceRecording] = new scala.collection.mutable.ListBuffer[ConfVoiceRecording]() + confRecording forEach { cr => + recs += ConfVoiceRecording(cr.recordingPath, cr.recordingStartTime) + } val header = BbbCoreVoiceConfHeader(UserStatusVoiceConfEvtMsg.NAME, voiceConfId) - val body = UserStatusVoiceConfEvtMsgBody(voiceConfId, voiceUserId, userId, callerIdName, callerIdNum, - muted.booleanValue(), talking.booleanValue(), avatarURL, "freeswitch") + val body = UserStatusVoiceConfEvtMsgBody(voiceConfId, users.toVector, recs.toVector) val envelope = BbbCoreEnvelope(UserStatusVoiceConfEvtMsg.NAME, Map("voiceConf" -> voiceConfId)) val msg = new UserStatusVoiceConfEvtMsg(header, body) @@ -63,12 +99,20 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def userJoinedVoiceConf(voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String, - callerIdNum: String, muted: java.lang.Boolean, talking: java.lang.Boolean, avatarURL: String) { + def userJoinedVoiceConf( + voiceConfId: String, + voiceUserId: String, + userId: String, + callerIdName: String, + callerIdNum: String, + muted: java.lang.Boolean, + talking: java.lang.Boolean, + callingWith: String + ) { val header = BbbCoreVoiceConfHeader(UserJoinedVoiceConfEvtMsg.NAME, voiceConfId) val body = UserJoinedVoiceConfEvtMsgBody(voiceConfId, voiceUserId, userId, callerIdName, callerIdNum, - muted.booleanValue(), talking.booleanValue(), avatarURL) + muted.booleanValue(), talking.booleanValue(), callingWith) val envelope = BbbCoreEnvelope(UserJoinedVoiceConfEvtMsg.NAME, Map("voiceConf" -> voiceConfId)) val msg = new UserJoinedVoiceConfEvtMsg(header, body) @@ -79,7 +123,10 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def userLeftVoiceConf(voiceConfId: String, voiceUserId: String) { + def userLeftVoiceConf( + voiceConfId: String, + voiceUserId: String + ) { val header = BbbCoreVoiceConfHeader(UserLeftVoiceConfEvtMsg.NAME, voiceConfId) val body = UserLeftVoiceConfEvtMsgBody(voiceConfId, voiceUserId) @@ -93,11 +140,19 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def userLockedInVoiceConf(voiceConfId: String, voiceUserId: String, locked: java.lang.Boolean) { + def userLockedInVoiceConf( + voiceConfId: String, + voiceUserId: String, + locked: java.lang.Boolean + ) { } - def userMutedInVoiceConf(voiceConfId: String, voiceUserId: String, muted: java.lang.Boolean) { + def userMutedInVoiceConf( + voiceConfId: String, + voiceUserId: String, + muted: java.lang.Boolean + ) { val header = BbbCoreVoiceConfHeader(UserMutedInVoiceConfEvtMsg.NAME, voiceConfId) val body = UserMutedInVoiceConfEvtMsgBody(voiceConfId, voiceUserId, muted.booleanValue()) @@ -111,7 +166,11 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def userTalkingInVoiceConf(voiceConfId: String, voiceUserId: String, talking: java.lang.Boolean) { + def userTalkingInVoiceConf( + voiceConfId: String, + voiceUserId: String, + talking: java.lang.Boolean + ) { val header = BbbCoreVoiceConfHeader(UserTalkingInVoiceConfEvtMsg.NAME, voiceConfId) val body = UserTalkingInVoiceConfEvtMsgBody(voiceConfId, voiceUserId, talking.booleanValue()) @@ -125,7 +184,11 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def deskShareStarted(voiceConfId: String, callerIdNum: String, callerIdName: String) { + def deskShareStarted( + voiceConfId: String, + callerIdNum: String, + callerIdName: String + ) { val header = BbbCoreVoiceConfHeader(ScreenshareStartedVoiceConfEvtMsg.NAME, voiceConfId) val body = ScreenshareStartedVoiceConfEvtMsgBody(voiceConf = voiceConfId, screenshareConf = voiceConfId, @@ -139,7 +202,11 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer sender.publish(fromVoiceConfRedisChannel, json) } - def deskShareEnded(voiceConfId: String, callerIdNum: String, callerIdName: String) { + def deskShareEnded( + voiceConfId: String, + callerIdNum: String, + callerIdName: String + ) { val header = BbbCoreVoiceConfHeader(ScreenshareStoppedVoiceConfEvtMsg.NAME, voiceConfId) val body = ScreenshareStoppedVoiceConfEvtMsgBody(voiceConf = voiceConfId, screenshareConf = voiceConfId, @@ -153,7 +220,13 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer sender.publish(fromVoiceConfRedisChannel, json) } - def deskShareRTMPBroadcastStarted(voiceConfId: String, streamname: String, vw: java.lang.Integer, vh: java.lang.Integer, timestamp: String) { + def deskShareRTMPBroadcastStarted( + voiceConfId: String, + streamname: String, + vw: java.lang.Integer, + vh: java.lang.Integer, + timestamp: String + ) { val header = BbbCoreVoiceConfHeader(ScreenshareRtmpBroadcastStartedVoiceConfEvtMsg.NAME, voiceConfId) val body = ScreenshareRtmpBroadcastStartedVoiceConfEvtMsgBody(voiceConf = voiceConfId, screenshareConf = voiceConfId, @@ -169,7 +242,13 @@ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceSer } - def deskShareRTMPBroadcastStopped(voiceConfId: String, streamname: String, vw: java.lang.Integer, vh: java.lang.Integer, timestamp: String) { + def deskShareRTMPBroadcastStopped( + voiceConfId: String, + streamname: String, + vw: java.lang.Integer, + vh: java.lang.Integer, + timestamp: String + ) { val header = BbbCoreVoiceConfHeader(ScreenshareRtmpBroadcastStoppedVoiceConfEvtMsg.NAME, voiceConfId) val body = ScreenshareRtmpBroadcastStoppedVoiceConfEvtMsgBody(voiceConf = voiceConfId, screenshareConf = voiceConfId, diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/VoiceConfMsgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/VoiceConfMsgs.scala index 1d196bbb0c..83f90ead4d 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/VoiceConfMsgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/VoiceConfMsgs.scala @@ -271,7 +271,12 @@ case class CheckRunningAndRecordingVoiceConfEvtMsg( header: BbbCoreVoiceConfHeader, body: CheckRunningAndRecordingVoiceConfEvtMsgBody ) extends VoiceStandardMsg -case class CheckRunningAndRecordingVoiceConfEvtMsgBody(voiceConf: String, isRunning: Boolean, isRecording: Boolean) +case class CheckRunningAndRecordingVoiceConfEvtMsgBody( + voiceConf: String, + isRunning: Boolean, + isRecording: Boolean, + confRecordings: Vector[ConfVoiceRecording] +) /** * Sent to FS to get status of users in voice conference. @@ -291,11 +296,14 @@ case class UserStatusVoiceConfEvtMsg( header: BbbCoreVoiceConfHeader, body: UserStatusVoiceConfEvtMsgBody ) extends VoiceStandardMsg -case class UserStatusVoiceConfEvtMsgBody(voiceConf: String, voiceUserId: String, intId: String, - callerIdName: String, callerIdNum: String, muted: Boolean, - talking: Boolean, callingWith: String, - calledInto: String // freeswitch, kms - ) +case class UserStatusVoiceConfEvtMsgBody(voiceConf: String, confUsers: Vector[ConfVoiceUser], + confRecordings: Vector[ConfVoiceRecording]) +case class ConfVoiceUser(voiceUserId: String, intId: String, + callerIdName: String, callerIdNum: String, muted: Boolean, + talking: Boolean, callingWith: String, + calledInto: String // freeswitch, kms + ) +case class ConfVoiceRecording(recordPath: String, recordStartTime: Long) /** * Received from FS that user joined voice conference. -- GitLab