- start converting voice messages

This commit is contained in:
Richard Alam 2015-05-27 21:06:44 +00:00
parent c083c14135
commit 9d020b0e7d
20 changed files with 866 additions and 25 deletions

View File

@ -42,7 +42,7 @@ public class BigBlueButtonApplication extends MultiThreadedApplicationAdapter {
private RecorderApplication recorderApplication;
private ConnectionInvokerService connInvokerService;
private IBigBlueButtonInGW bbbGW, red5InGW;
private IBigBlueButtonInGW red5InGW;
private final String APP = "BBB";
private final String CONN = "RED5-";
@ -273,10 +273,6 @@ public class BigBlueButtonApplication extends MultiThreadedApplicationAdapter {
this.connInvokerService = connInvokerService;
}
public void setBigBlueButtonInGW(IBigBlueButtonInGW bbbGW) {
this.bbbGW = bbbGW;
}
public void setRed5InGW(IBigBlueButtonInGW red5InGW) {
this.red5InGW = red5InGW;
}

View File

@ -7,14 +7,19 @@ import org.bigbluebutton.core.api.IBigBlueButtonInGW;
import org.bigbluebutton.red5.pub.messages.AssignPresenterRequestMessage;
import org.bigbluebutton.red5.pub.messages.GetUsersRequestMessage;
import org.bigbluebutton.red5.pub.messages.MessagingConstants;
import org.bigbluebutton.red5.sub.messages.BroadcastLayoutMessage;
import org.bigbluebutton.red5.sub.messages.BroadcastLayoutRequestMessage;
import org.bigbluebutton.red5.sub.messages.EjectUserFromMeetingRequestMessage;
import org.bigbluebutton.red5.sub.messages.EjectUserFromVoiceRequestMessage;
import org.bigbluebutton.red5.sub.messages.GetCurrentLayoutRequestMessage;
import org.bigbluebutton.red5.sub.messages.GetRecordingStatusRequestMessage;
import org.bigbluebutton.red5.sub.messages.InitAudioSettingsMessage;
import org.bigbluebutton.red5.sub.messages.InitPermissionsSettingMessage;
import org.bigbluebutton.red5.sub.messages.IsMeetingMutedRequestMessage;
import org.bigbluebutton.red5.sub.messages.LockLayoutRequestMessage;
import org.bigbluebutton.red5.sub.messages.LockMuteUserRequestMessage;
import org.bigbluebutton.red5.sub.messages.MuteAllExceptPresenterRequestMessage;
import org.bigbluebutton.red5.sub.messages.MuteAllRequestMessage;
import org.bigbluebutton.red5.sub.messages.MuteUserRequestMessage;
import org.bigbluebutton.red5.sub.messages.SetRecordingStatusRequestMessage;
import org.bigbluebutton.red5.sub.messages.SetUserStatusRequestMessage;
import org.bigbluebutton.red5.sub.messages.UserLeavingMessage;
@ -98,6 +103,25 @@ public class ParticipantsListener implements MessageHandler{
case GetCurrentLayoutRequestMessage.GET_CURRENT_LAYOUT_REQUEST:
processGetCurrentLayoutRequestMessage(message);
break;
case MuteAllExceptPresenterRequestMessage.MUTE_ALL_EXCEPT_PRESENTER_REQUEST:
processMuteAllExceptPresenterRequestMessage(message);
break;
case MuteAllRequestMessage.MUTE_ALL_REQUEST:
processMuteAllRequestMessage(message);
break;
case IsMeetingMutedRequestMessage.IS_MEETING_MUTED_REQUEST:
processIsMeetingMutedRequestMessage(message);
break;
case MuteUserRequestMessage.MUTE_USER_REQUEST:
processMuteUserRequestMessage(message);
break;
case LockMuteUserRequestMessage.LOCK_MUTE_USER_REQUEST:
processLockMuteUserRequestMessage(message);
break;
case EjectUserFromVoiceRequestMessage.EJECT_USER_FROM_VOICE_REQUEST:
processEjectUserFromVoiceRequestMessage(message);
break;
}
}
}
@ -215,4 +239,46 @@ public class ParticipantsListener implements MessageHandler{
bbbInGW.getCurrentLayout(msg.meetingId, msg.userId);
}
}
private void processMuteAllExceptPresenterRequestMessage(String message) {
MuteAllExceptPresenterRequestMessage msg = MuteAllExceptPresenterRequestMessage.fromJson(message);
if (msg != null) {
bbbInGW.muteAllExceptPresenter(msg.meetingId, msg.requesterId, msg.mute);
}
}
private void processMuteAllRequestMessage(String message) {
MuteAllRequestMessage msg = MuteAllRequestMessage.fromJson(message);
if (msg != null) {
bbbInGW.muteAllUsers(msg.meetingId, msg.requesterId, msg.mute);
}
}
private void processIsMeetingMutedRequestMessage(String message) {
IsMeetingMutedRequestMessage msg = IsMeetingMutedRequestMessage.fromJson(message);
if (msg != null) {
bbbInGW.isMeetingMuted(msg.meetingId, msg.requesterId);
}
}
private void processMuteUserRequestMessage(String message) {
MuteUserRequestMessage msg = MuteUserRequestMessage.fromJson(message);
if (msg != null) {
bbbInGW.muteUser(msg.meetingId, msg.requesterId, msg.userId, msg.mute);
}
}
private void processLockMuteUserRequestMessage(String message) {
LockMuteUserRequestMessage msg = LockMuteUserRequestMessage.fromJson(message);
if (msg != null) {
bbbInGW.lockMuteUser(msg.meetingId, msg.requesterId, msg.userId, msg.lock);
}
}
private void processEjectUserFromVoiceRequestMessage(String message) {
EjectUserFromVoiceRequestMessage msg = EjectUserFromVoiceRequestMessage.fromJson(message);
if (msg != null) {
bbbInGW.ejectUserFromVoice(msg.meetingId, msg.userId, msg.requesterId);
}
}
}

View File

@ -31,6 +31,7 @@ public class VoiceService {
private static Logger log = Red5LoggerFactory.getLogger( VoiceService.class, "bigbluebutton" );
private IBigBlueButtonInGW bbbInGW;
private IBigBlueButtonInGW red5InGW;
public void setBigBlueButtonInGW(IBigBlueButtonInGW inGW) {
bbbInGW = inGW;
@ -59,20 +60,20 @@ public class VoiceService {
String meetingID = Red5.getConnectionLocal().getScope().getName();
String requesterID = getBbbSession().getInternalUserID();
Boolean muteAll = (Boolean) msg.get("mute");
bbbInGW.muteAllExceptPresenter(meetingID, requesterID, muteAll);
red5InGW.muteAllExceptPresenter(meetingID, requesterID, muteAll);
}
public void muteAllUsers(Map<String, Object> msg) {
String meetingID = Red5.getConnectionLocal().getScope().getName();
String requesterID = getBbbSession().getInternalUserID();
Boolean mute = (Boolean) msg.get("mute");
bbbInGW.muteAllUsers(meetingID, requesterID, mute);
red5InGW.muteAllUsers(meetingID, requesterID, mute);
}
public void isRoomMuted(){
String meetingID = Red5.getConnectionLocal().getScope().getName();
String requesterID = getBbbSession().getInternalUserID();
bbbInGW.isMeetingMuted(meetingID, requesterID);
red5InGW.isMeetingMuted(meetingID, requesterID);
}
// not sure if this is used
@ -82,7 +83,7 @@ public class VoiceService {
String meetingID = Red5.getConnectionLocal().getScope().getName();
String requesterID = getBbbSession().getInternalUserID();
bbbInGW.muteUser(meetingID, requesterID, userid, mute);
red5InGW.muteUser(meetingID, requesterID, userid, mute);
}
public void lockMuteUser(Map<String, Object> msg) {
@ -91,18 +92,22 @@ public class VoiceService {
String meetingID = Red5.getConnectionLocal().getScope().getName();
String requesterID = getBbbSession().getInternalUserID();
bbbInGW.lockMuteUser(meetingID, requesterID, userid, lock);
red5InGW.lockMuteUser(meetingID, requesterID, userid, lock);
}
public void ejectUserFromVoice(Map<String, Object> msg) {
String userId = (String) msg.get("userId");
String meetingID = Red5.getConnectionLocal().getScope().getName();
String ejectedBy = getBbbSession().getInternalUserID();
bbbInGW.ejectUserFromVoice(meetingID, userId, ejectedBy);
red5InGW.ejectUserFromVoice(meetingID, userId, ejectedBy);
}
private BigBlueButtonSession getBbbSession() {
return (BigBlueButtonSession) Red5.getConnectionLocal().getAttribute(Constants.SESSION);
}
public void setRed5InGW(IBigBlueButtonInGW red5InGW) {
this.red5InGW = red5InGW;
}
}

View File

@ -11,11 +11,17 @@ import org.bigbluebutton.red5.pubsub.messages.RequestWhiteboardAnnotationHistory
import org.bigbluebutton.red5.pubsub.messages.SendWhiteboardAnnotationRequestMessage;
import org.bigbluebutton.red5.sub.messages.BroadcastLayoutRequestMessage;
import org.bigbluebutton.red5.sub.messages.EjectUserFromMeetingRequestMessage;
import org.bigbluebutton.red5.sub.messages.EjectUserFromVoiceRequestMessage;
import org.bigbluebutton.red5.sub.messages.GetCurrentLayoutRequestMessage;
import org.bigbluebutton.red5.sub.messages.GetRecordingStatusRequestMessage;
import org.bigbluebutton.red5.sub.messages.InitAudioSettingsMessage;
import org.bigbluebutton.red5.sub.messages.InitPermissionsSettingMessage;
import org.bigbluebutton.red5.sub.messages.IsMeetingMutedRequestMessage;
import org.bigbluebutton.red5.sub.messages.LockLayoutRequestMessage;
import org.bigbluebutton.red5.sub.messages.LockMuteUserRequestMessage;
import org.bigbluebutton.red5.sub.messages.MuteAllExceptPresenterRequestMessage;
import org.bigbluebutton.red5.sub.messages.MuteAllRequestMessage;
import org.bigbluebutton.red5.sub.messages.MuteUserRequestMessage;
import org.bigbluebutton.red5.sub.messages.SetRecordingStatusRequestMessage;
import org.bigbluebutton.red5.sub.messages.SetUserStatusRequestMessage;
import org.bigbluebutton.red5.sub.messages.UserLeavingMessage;
@ -23,6 +29,7 @@ import org.bigbluebutton.red5.sub.messages.UserLoweredHandMessage;
import org.bigbluebutton.red5.sub.messages.UserRaisedHandMessage;
import org.bigbluebutton.red5.sub.messages.UserShareWebcamRequestMessage;
import org.bigbluebutton.red5.sub.messages.UserUnshareWebcamRequestMessage;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -231,40 +238,42 @@ public class Red5BBBInGw implements IBigBlueButtonInGW {
@Override
public void muteAllExceptPresenter(String meetingID, String requesterID,
Boolean mute) {
// TODO Auto-generated method stub
MuteAllExceptPresenterRequestMessage msg = new MuteAllExceptPresenterRequestMessage(meetingID, requesterID, mute);
sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson());
}
@Override
public void muteAllUsers(String meetingID, String requesterID, Boolean mute) {
// TODO Auto-generated method stub
MuteAllRequestMessage msg = new MuteAllRequestMessage(meetingID, requesterID, mute);
sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson());
}
@Override
public void isMeetingMuted(String meetingID, String requesterID) {
// TODO Auto-generated method stub
IsMeetingMutedRequestMessage msg = new IsMeetingMutedRequestMessage(meetingID, requesterID);
sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson());
}
@Override
public void muteUser(String meetingID, String requesterID, String userID,
Boolean mute) {
// TODO Auto-generated method stub
MuteUserRequestMessage msg = new MuteUserRequestMessage(meetingID, requesterID, userID, mute);
sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson());
}
@Override
public void lockMuteUser(String meetingID, String requesterID,
String userID, Boolean lock) {
// TODO Auto-generated method stub
LockMuteUserRequestMessage msg = new LockMuteUserRequestMessage(meetingID, requesterID, userID, lock);
sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson());
}
@Override
public void ejectUserFromVoice(String meetingID, String userId,
String ejectedBy) {
// TODO Auto-generated method stub
EjectUserFromVoiceRequestMessage msg = new EjectUserFromVoiceRequestMessage(meetingID, ejectedBy, userId);
sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson());
}

View File

@ -0,0 +1,25 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
import java.util.Set;
public class MessageDistributor {
private ReceivedMessageHandler handler;
private Set<MessageHandler> listeners;
public void setMessageListeners(Set<MessageHandler> listeners) {
this.listeners = listeners;
}
public void setMessageHandler(ReceivedMessageHandler handler) {
this.handler = handler;
if (handler != null) {
handler.setMessageDistributor(this);
}
}
public void notifyListeners(String pattern, String channel, String message) {
for (MessageHandler listener : listeners) {
listener.handleMessage(pattern, channel, message);
}
}
}

View File

@ -0,0 +1,23 @@
/**
* 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.pubsub.redis;
public interface MessageHandler {
void handleMessage(String pattern, String channel, String message);
}

View File

@ -0,0 +1,92 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.bigbluebutton.red5.pub.messages.MessagingConstants;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPubSub;
public class MessageReceiver {
private static Logger log = Red5LoggerFactory.getLogger(MessageReceiver.class, "bigbluebutton");
private ReceivedMessageHandler handler;
private JedisPool redisPool;
private volatile boolean receiveMessage = false;
private final Executor msgReceiverExec = Executors.newSingleThreadExecutor();
public void stop() {
receiveMessage = false;
}
public void start() {
log.info("Ready to receive messages from Redis pubsub.");
try {
receiveMessage = true;
final Jedis jedis = redisPool.getResource();
Runnable messageReceiver = new Runnable() {
public void run() {
if (receiveMessage) {
jedis.psubscribe(new PubSubListener(),
MessagingConstants.FROM_BBB_APPS_PATTERN);
}
}
};
msgReceiverExec.execute(messageReceiver);
} catch (Exception e) {
log.error("Error subscribing to channels: " + e.getMessage());
}
}
public void setRedisPool(JedisPool redisPool){
this.redisPool = redisPool;
}
public void setMessageHandler(ReceivedMessageHandler handler) {
this.handler = handler;
}
private class PubSubListener extends JedisPubSub {
public PubSubListener() {
super();
}
@Override
public void onMessage(String channel, String message) {
// Not used.
}
@Override
public void onPMessage(String pattern, String channel, String message) {
handler.handleMessage(pattern, channel, message);
}
@Override
public void onPSubscribe(String pattern, int subscribedChannels) {
log.debug("Subscribed to the pattern: " + pattern);
}
@Override
public void onPUnsubscribe(String pattern, int subscribedChannels) {
// Not used.
}
@Override
public void onSubscribe(String channel, int subscribedChannels) {
// Not used.
}
@Override
public void onUnsubscribe(String channel, int subscribedChannels) {
// Not used.
}
}
}

View File

@ -0,0 +1,74 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class MessageSender {
private static Logger log = Red5LoggerFactory.getLogger(MessageSender.class, "bigbluebutton");
private JedisPool redisPool;
private volatile boolean sendMessage = false;
private final Executor msgSenderExec = Executors.newSingleThreadExecutor();
private final Executor runExec = Executors.newSingleThreadExecutor();
private BlockingQueue<MessageToSend> messages = new LinkedBlockingQueue<MessageToSend>();
public void stop() {
sendMessage = false;
}
public void start() {
log.info("Redis message publisher starting!");
try {
sendMessage = true;
Runnable messageSender = new Runnable() {
public void run() {
while (sendMessage) {
try {
MessageToSend msg = messages.take();
publish(msg.getChannel(), msg.getMessage());
} catch (InterruptedException e) {
log.warn("Failed to get message from queue.");
}
}
}
};
msgSenderExec.execute(messageSender);
} catch (Exception e) {
log.error("Error subscribing to channels: " + e.getMessage());
}
}
public void send(String channel, String message) {
MessageToSend msg = new MessageToSend(channel, message);
messages.add(msg);
}
private void publish(final String channel, final String message) {
Runnable task = new Runnable() {
public void run() {
Jedis jedis = redisPool.getResource();
try {
jedis.publish(channel, message);
} catch(Exception e){
log.warn("Cannot publish the message to redis", e);
} finally {
redisPool.returnResource(jedis);
}
}
};
runExec.execute(task);
}
public void setRedisPool(JedisPool redisPool){
this.redisPool = redisPool;
}
}

View File

@ -0,0 +1,19 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
public class MessageToSend {
private final String channel;
private final String message;
public MessageToSend(String channel, String message) {
this.channel = channel;
this.message = message;
}
public String getChannel() {
return channel;
}
public String getMessage() {
return message;
}
}

View File

@ -0,0 +1,28 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
public class ReceivedMessage {
private final String pattern;
private final String channel;
private final String message;
public ReceivedMessage(String pattern, String channel, String message) {
this.pattern = pattern;
this.channel = channel;
this.message = message;
}
public String getPattern() {
return pattern;
}
public String getChannel() {
return channel;
}
public String getMessage() {
return message;
}
}

View File

@ -0,0 +1,72 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
public class ReceivedMessageHandler {
private static Logger log = Red5LoggerFactory.getLogger(ReceivedMessageHandler.class, "bigbluebutton");
private BlockingQueue<ReceivedMessage> receivedMessages = new LinkedBlockingQueue<ReceivedMessage>();
private volatile boolean processMessage = false;
private final Executor msgProcessorExec = Executors.newSingleThreadExecutor();
private final Executor runExec = Executors.newSingleThreadExecutor();
private MessageDistributor handler;
public void stop() {
processMessage = false;
}
public void start() {
log.info("Ready to handle messages from Redis pubsub!");
try {
processMessage = true;
Runnable messageProcessor = new Runnable() {
public void run() {
while (processMessage) {
try {
ReceivedMessage msg = receivedMessages.take();
processMessage(msg);
} catch (InterruptedException e) {
log.warn("Error while taking received message from queue.");
}
}
}
};
msgProcessorExec.execute(messageProcessor);
} catch (Exception e) {
log.error("Error subscribing to channels: " + e.getMessage());
}
}
private void processMessage(final ReceivedMessage msg) {
Runnable task = new Runnable() {
public void run() {
if (handler != null) {
handler.notifyListeners(msg.getPattern(), msg.getChannel(), msg.getMessage());
} else {
log.info("No listeners interested in messages from Redis!");
}
}
};
runExec.execute(task);
}
public void handleMessage(String pattern, String channel, String message) {
ReceivedMessage rm = new ReceivedMessage(pattern, channel, message);
receivedMessages.add(rm);
}
public void setMessageDistributor(MessageDistributor h) {
this.handler = h;
}
}

View File

@ -0,0 +1,46 @@
package org.bigbluebutton.freeswitch.pubsub.redis;
import org.bigbluebutton.conference.meeting.messaging.red5.ConnectionInvokerService;
import org.bigbluebutton.red5.client.MeetingClientMessageSender;
import org.bigbluebutton.red5.client.PresentationClientMessageSender;
import org.bigbluebutton.red5.client.UserClientMessageSender;
import org.bigbluebutton.red5.pub.messages.MessagingConstants;
import org.bigbluebutton.red5.client.ChatClientMessageSender;
import org.bigbluebutton.red5.client.WhiteboardClientMessageSender;
public class RedisPubSubMessageHandler implements MessageHandler {
private ConnectionInvokerService service;
private UserClientMessageSender userMessageSender;
private MeetingClientMessageSender meetingMessageSender;
private ChatClientMessageSender chatMessageSender;
private PresentationClientMessageSender presentationMessageSender;
private WhiteboardClientMessageSender whiteboardMessageSender;
public void setConnectionInvokerService(ConnectionInvokerService s) {
this.service = s;
userMessageSender = new UserClientMessageSender(service);
meetingMessageSender = new MeetingClientMessageSender(service);
chatMessageSender = new ChatClientMessageSender(service);
presentationMessageSender = new PresentationClientMessageSender(service);
whiteboardMessageSender = new WhiteboardClientMessageSender(service);
}
@Override
public void handleMessage(String pattern, String channel, String message) {
if (channel.equalsIgnoreCase(MessagingConstants.FROM_CHAT_CHANNEL)) {
chatMessageSender.handleChatMessage(message);
} else if (channel.equalsIgnoreCase(MessagingConstants.FROM_PRESENTATION_CHANNEL)) {
presentationMessageSender.handlePresentationMessage(message);
} else if (channel.equalsIgnoreCase(MessagingConstants.FROM_MEETING_CHANNEL)) {
meetingMessageSender.handleMeetingMessage(message);
} else if (channel.equalsIgnoreCase(MessagingConstants.FROM_USERS_CHANNEL)) {
userMessageSender.handleUsersMessage(message);
} else if (channel.equalsIgnoreCase(MessagingConstants.FROM_WHITEBOARD_CHANNEL)) {
System.out.println("the message FROM_WHITEBOARD_CHANNEL is:"+message);
whiteboardMessageSender.handleWhiteboardMessage(message);
}
}
}

View File

@ -0,0 +1,63 @@
package org.bigbluebutton.red5.sub.messages;
import java.util.HashMap;
import org.bigbluebutton.red5.pub.messages.MessageBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class EjectUserFromVoiceRequestMessage implements ISubscribedMessage {
public static final String EJECT_USER_FROM_VOICE_REQUEST = "eject_user_from_voice_request_message";
public static final String VERSION = "0.0.1";
public static final String MEETING_ID = "meeting_id";
public static final String REQUESTER_ID = "requester_id";
public static final String USER_ID = "user_id";
public final String meetingId;
public final String requesterId;
public final String userId;
public EjectUserFromVoiceRequestMessage(String meetingId, String requesterId, String userId) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.userId = userId;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
payload.put(USER_ID, userId);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(EJECT_USER_FROM_VOICE_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static EjectUserFromVoiceRequestMessage 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 (EJECT_USER_FROM_VOICE_REQUEST.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)
&& payload.has(USER_ID)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
String userId = payload.get(USER_ID).getAsString();
return new EjectUserFromVoiceRequestMessage(id, requesterId, userId);
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,57 @@
package org.bigbluebutton.red5.sub.messages;
import java.util.HashMap;
import org.bigbluebutton.red5.pub.messages.MessageBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class IsMeetingMutedRequestMessage implements ISubscribedMessage {
public static final String IS_MEETING_MUTED_REQUEST = "is_meeting_muted_request_message";
public static final String VERSION = "0.0.1";
public static final String MEETING_ID = "meeting_id";
public static final String REQUESTER_ID = "requester_id";
public final String meetingId;
public final String requesterId;
public IsMeetingMutedRequestMessage(String meetingId, String requesterId) {
this.meetingId = meetingId;
this.requesterId = requesterId;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(IS_MEETING_MUTED_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static IsMeetingMutedRequestMessage 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 (IS_MEETING_MUTED_REQUEST.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
return new IsMeetingMutedRequestMessage(id, requesterId);
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,70 @@
package org.bigbluebutton.red5.sub.messages;
import java.util.HashMap;
import org.bigbluebutton.red5.pub.messages.Constants;
import org.bigbluebutton.red5.pub.messages.MessageBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class LockMuteUserRequestMessage implements ISubscribedMessage {
public static final String LOCK_MUTE_USER_REQUEST = "lock_mute_user_request_message";
public static final String VERSION = "0.0.1";
public static final String MEETING_ID = "meeting_id";
public static final String REQUESTER_ID = "requester_id";
public static final String USER_ID = "user_id";
public static final String LOCK = "lock";
public final String meetingId;
public final String requesterId;
public final String userId;
public final Boolean lock;
public LockMuteUserRequestMessage(String meetingId, String requesterId, String userId, Boolean lock) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.userId = userId;
this.lock = lock;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
payload.put(USER_ID, userId);
payload.put(LOCK, lock);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(LOCK_MUTE_USER_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static LockMuteUserRequestMessage 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 (LOCK_MUTE_USER_REQUEST.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)
&& payload.has(USER_ID)
&& payload.has(LOCK)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
String userId = payload.get(USER_ID).getAsString();
Boolean lock = payload.get(LOCK).getAsBoolean();
return new LockMuteUserRequestMessage(id, requesterId, userId, lock);
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,64 @@
package org.bigbluebutton.red5.sub.messages;
import java.util.HashMap;
import org.bigbluebutton.red5.pub.messages.Constants;
import org.bigbluebutton.red5.pub.messages.MessageBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class MuteAllExceptPresenterRequestMessage implements ISubscribedMessage {
public static final String MUTE_ALL_EXCEPT_PRESENTER_REQUEST = "mute_all_except_presenter_request_message";
public static final String VERSION = "0.0.1";
public static final String MEETING_ID = "meeting_id";
public static final String REQUESTER_ID = "requester_id";
public static final String MUTE = "mute";
public final String meetingId;
public final String requesterId;
public final Boolean mute;
public MuteAllExceptPresenterRequestMessage(String meetingId, String requesterId, Boolean mute) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.mute = mute;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
payload.put(MUTE, mute);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(MUTE_ALL_EXCEPT_PRESENTER_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static MuteAllExceptPresenterRequestMessage 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 (MUTE_ALL_EXCEPT_PRESENTER_REQUEST.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)
&& payload.has(MUTE)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
Boolean mute = payload.get(MUTE).getAsBoolean();
return new MuteAllExceptPresenterRequestMessage(id, requesterId, mute);
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,64 @@
package org.bigbluebutton.red5.sub.messages;
import java.util.HashMap;
import org.bigbluebutton.red5.pub.messages.Constants;
import org.bigbluebutton.red5.pub.messages.MessageBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class MuteAllRequestMessage implements ISubscribedMessage {
public static final String MUTE_ALL_REQUEST = "mute_all_request_message";
public static final String VERSION = "0.0.1";
public static final String MEETING_ID = "meeting_id";
public static final String REQUESTER_ID = "requester_id";
public static final String MUTE = "mute";
public final String meetingId;
public final String requesterId;
public final Boolean mute;
public MuteAllRequestMessage(String meetingId, String requesterId, Boolean mute) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.mute = mute;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
payload.put(MUTE, mute);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(MUTE_ALL_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static MuteAllRequestMessage 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 (MUTE_ALL_REQUEST.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)
&& payload.has(MUTE)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
Boolean mute = payload.get(MUTE).getAsBoolean();
return new MuteAllRequestMessage(id, requesterId, mute);
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,70 @@
package org.bigbluebutton.red5.sub.messages;
import java.util.HashMap;
import org.bigbluebutton.red5.pub.messages.Constants;
import org.bigbluebutton.red5.pub.messages.MessageBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class MuteUserRequestMessage implements ISubscribedMessage {
public static final String MUTE_USER_REQUEST = "mute_user_request_message";
public static final String VERSION = "0.0.1";
public static final String MEETING_ID = "meeting_id";
public static final String REQUESTER_ID = "requester_id";
public static final String USER_ID = "user_id";
public static final String MUTE = "mute";
public final String meetingId;
public final String requesterId;
public final String userId;
public final Boolean mute;
public MuteUserRequestMessage(String meetingId, String requesterId, String userId, Boolean mute) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.userId = userId;
this.mute = mute;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
payload.put(USER_ID, userId);
payload.put(MUTE, mute);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(MUTE_USER_REQUEST, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static MuteUserRequestMessage 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 (MUTE_USER_REQUEST.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)
&& payload.has(USER_ID)
&& payload.has(MUTE)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
String userId = payload.get(USER_ID).getAsString();
Boolean mute = payload.get(MUTE).getAsBoolean();
return new MuteUserRequestMessage(id, requesterId, userId, mute);
}
}
}
}
return null;
}
}

View File

@ -30,6 +30,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<beans:bean id="voice.service" class="org.bigbluebutton.conference.service.voice.VoiceService">
<beans:property name="bigBlueButtonInGW" ref="bbbInGW"/>
<beans:property name="red5InGW" ref="red5BbbInGW"/>
</beans:bean>
<beans:bean id="voiceMessageListener" class="org.bigbluebutton.conference.service.voice.VoiceMessageListener">

View File

@ -60,9 +60,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<property name="connInvokerService">
<ref bean="connInvokerService"/>
</property>
<property name="bigBlueButtonInGW">
<ref bean="bbbInGW"/>
</property>
<property name="red5InGW">
<ref bean="red5BbbInGW"/>
</property>