- voice messages

This commit is contained in:
Richard Alam 2015-05-27 22:01:47 +00:00
parent 811f0e4537
commit e05a7e4fcf
4 changed files with 134 additions and 25 deletions

View File

@ -30,32 +30,8 @@ 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;
}
/*
private Map<Integer, Map> arrayListToMap(ArrayList<Participant> alp) {
log.debug("Converting arraylist to Map " + alp.size());
Map<Integer, Map> result = new HashMap();
for (Participant p : alp) {
Map<String, Object> pmap = new HashMap();
pmap.put("participant", p.getId());
pmap.put("name", p.getName());
pmap.put("muted", p.isMuted());
pmap.put("talking", p.isTalking());
log.debug("[" + p.getId() + "," + p.getName() + "," + p.isMuted() + "," + p.isTalking() + "]");
result.put(p.getId(), pmap);
}
return result;
}
*/
public void muteAllUsersExceptPresenter(Map<String, Object> msg) {
String meetingID = Red5.getConnectionLocal().getScope().getName();
String requesterID = getBbbSession().getInternalUserID();

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 IsMeetingMutedReplyMessage implements ISubscribedMessage {
public static final String IS_MEETING_MUTED_REPLY = "is_meeting_muted_reply_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 MUTED = "muted";
public final String meetingId;
public final String requesterId;
public final Boolean muted;
public IsMeetingMutedReplyMessage(String meetingId, String requesterId, Boolean muted) {
this.meetingId = meetingId;
this.requesterId = requesterId;
this.muted = muted;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(MEETING_ID, meetingId);
payload.put(REQUESTER_ID, requesterId);
payload.put(MUTED, muted);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(IS_MEETING_MUTED_REPLY, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static IsMeetingMutedReplyMessage 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_REPLY.equals(messageName)) {
if (payload.has(MEETING_ID)
&& payload.has(REQUESTER_ID)
&& payload.has(MUTED)) {
String id = payload.get(MEETING_ID).getAsString();
String requesterId = payload.get(REQUESTER_ID).getAsString();
Boolean muted = payload.get(MUTED).getAsBoolean();
return new IsMeetingMutedReplyMessage(id, requesterId, muted);
}
}
}
}
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 MuteVoiceUserRequestMessage 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 MuteVoiceUserRequestMessage(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 MuteVoiceUserRequestMessage 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 MuteVoiceUserRequestMessage(id, requesterId, userId, mute);
}
}
}
}
return null;
}
}

View File

@ -104,7 +104,7 @@ class BigBlueButtonActor(val system: ActorSystem, outGW: MessageOutGateway) exte
meetings -= msg.meetingID
log.info("Kick everyone out on meeting id[" + msg.meetingID + "].")
outGW.send(new EndAndKickAll(msg.meetingID, m.recorded))
outGW.send(new DisconnectAllUsers(msg.meetingID))
log.info("Destroyed meeting id[" + msg.meetingID + "].")
outGW.send(new MeetingDestroyed(msg.meetingID))
}