Commit c08c876c authored by Dele Olajide's avatar Dele Olajide Committed by dele

Jitsi Videobridge plugin - Added register/unregister actions to colibri command

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13853 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1db630d0
package com.rayo.core.verb;
public class RegisterCommand extends AbstractVerbCommand {
}
package com.rayo.core.verb;
public class UnRegisterCommand extends AbstractVerbCommand {
}
......@@ -44,6 +44,7 @@ public class ColibriProvider extends BaseProvider {
private Object buildColibriCommand(Element element) throws URISyntaxException
{
String action = element.attributeValue("action");
String videobridge = element.attributeValue("videobridge");
String localRTPPort = element.attributeValue("localrtpport");
String localRTCPPort = element.attributeValue("localrtcpport");
......@@ -51,12 +52,22 @@ public class ColibriProvider extends BaseProvider {
String remoteRTCPPort = element.attributeValue("remotertcpport");
String codec = element.attributeValue("codec");
ColibriCommand command = new ColibriCommand(videobridge, localRTPPort, localRTCPPort, remoteRTPPort, remoteRTCPPort, codec);
Object command = null;
if ("register".equals(action))
{
command = new RegisterCommand();
} else if ("unregister".equals(action)) {
command = new UnRegisterCommand();
} else if ("bridge".equals(action)) {
command = new ColibriCommand(videobridge, localRTPPort, localRTCPPort, remoteRTPPort, remoteRTCPPort, codec);
}
return command;
}
// Object -> XML
// ================================================================================
......
......@@ -530,12 +530,14 @@ public class PluginImpl implements Plugin, PropertyEventListener
private class ColibriIQHandler extends IQHandler implements MUCEventListener
{
private ConcurrentHashMap<String, FocusAgent> sessions;
private ConcurrentHashMap<String, JID> registry;
private MultiUserChatManager mucManager;
public ColibriIQHandler()
{
super("Rayo: XEP 0327 - Colibri");
sessions = new ConcurrentHashMap<String, FocusAgent>();
registry = new ConcurrentHashMap<String, JID>();
MUCEventDispatcher.addListener(this);
mucManager = XMPPServer.getInstance().getMultiUserChatManager();
......@@ -552,6 +554,8 @@ public class PluginImpl implements Plugin, PropertyEventListener
final Element element = iq.getChildElement();
IQ reply = null;
JID from = iq.getFrom();
String fromId = from.toString();
Object object = colibriProvider.fromXML(element);
......@@ -559,6 +563,16 @@ public class PluginImpl implements Plugin, PropertyEventListener
ColibriCommand command = (ColibriCommand) object;
reply = handleColibriCommand(command, iq);
} else if (object instanceof RegisterCommand) {
registry.put(fromId, from);
reply = IQ.createResultIQ(iq);
} else if (object instanceof UnRegisterCommand) {
if (registry.containsKey(fromId)) registry.remove(fromId, from);
reply = IQ.createResultIQ(iq);
} else {
reply = IQ.createResultIQ(iq);
reply.setError(PacketError.Condition.not_allowed);
......@@ -646,33 +660,34 @@ public class PluginImpl implements Plugin, PropertyEventListener
*/
public void occupantJoined(JID roomJID, JID user, String nickname)
{
//MUCRoom mucRoom = mucManager.getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode());
if (registry.containsKey(user.toString()))
{
Log.info("ColibriIQHandler occupantJoined " + roomJID + " " + user + " " + nickname);
Log.info("ColibriIQHandler occupantJoined " + roomJID + " " + user + " " + nickname);
String focusAgentName = "jitsi.videobridge." + roomJID.getNode();
String focusAgentName = "jitsi.videobridge." + roomJID.getNode();
FocusAgent focusAgent;
FocusAgent focusAgent;
Participant participant = new Participant(nickname, user);
Participant participant = new Participant(nickname, user);
if (sessions.containsKey(focusAgentName))
{
focusAgent = sessions.get(focusAgentName);
if (sessions.containsKey(focusAgentName))
{
focusAgent = sessions.get(focusAgentName);
} else {
focusAgent = new FocusAgent(focusAgentName, roomJID);
LocalClientSession session = SessionManager.getInstance().createClientSession(focusAgent, new BasicStreamID(focusAgentName + "-" + System.currentTimeMillis() ) );
focusAgent.setRouter( new SessionPacketRouter(session), session);
AuthToken authToken = new AuthToken(focusAgentName, true);
session.setAuthToken(authToken, focusAgentName);
sessions.put(focusAgentName, focusAgent);
Presence presence = new Presence();
focusAgent.getRouter().route(presence);
}
} else {
focusAgent = new FocusAgent(focusAgentName, roomJID);
LocalClientSession session = SessionManager.getInstance().createClientSession(focusAgent, new BasicStreamID(focusAgentName + "-" + System.currentTimeMillis() ) );
focusAgent.setRouter( new SessionPacketRouter(session), session);
AuthToken authToken = new AuthToken(focusAgentName, true);
session.setAuthToken(authToken, focusAgentName);
sessions.put(focusAgentName, focusAgent);
Presence presence = new Presence();
focusAgent.getRouter().route(presence);
focusAgent.createColibriChannel(participant);
}
focusAgent.createColibriChannel(participant);
}
/**
*
......@@ -680,17 +695,18 @@ public class PluginImpl implements Plugin, PropertyEventListener
*/
public void occupantLeft(JID roomJID, JID user)
{
//MUCRoom mucRoom = mucManager.getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode());
Log.info("ColibriIQHandler occupantLeft " + roomJID + " " + user);
if (registry.containsKey(user.toString()))
{
Log.info("ColibriIQHandler occupantLeft " + roomJID + " " + user);
String focusAgentName = "jitsi.videobridge." + roomJID.getNode();
String focusAgentName = "jitsi.videobridge." + roomJID.getNode();
if (sessions.containsKey(focusAgentName))
{
FocusAgent focusAgent = sessions.get(focusAgentName);
if (sessions.containsKey(focusAgentName))
{
FocusAgent focusAgent = sessions.get(focusAgentName);
focusAgent.removeColibriChannel(user);
focusAgent.removeColibriChannel(user);
}
}
}
/**
......
......@@ -5,6 +5,6 @@ var config = {
bridge: 'jitsi-videobridge.' + window.location.hostname // FIXME: use XEP-0030
},
useNicks: false,
useWebsockets: true,
useWebsockets: false,
bosh: window.location.protocol + "//" + window.location.host + '/http-bind/' // FIXME: use xep-0156 for that
};
......@@ -77,6 +77,7 @@ $(document).ready(function ()
{
console.log('connected');
connection.send($pres());
registerRayoEvents();
getConstraints(['audio', 'video'], '720');
getUserMedia();
......@@ -89,6 +90,7 @@ $(document).ready(function ()
$(window).bind('beforeunload', function ()
{
if (connection && connection.connected) {
unregisterRayoEvents();
connection.disconnect();
}
});
......@@ -173,6 +175,32 @@ $(document).bind('remotestreamadded.rayo', function(event, data, sid)
);
});
function registerRayoEvents()
{
connection.sendIQ($iq({to: connection.domain, type: 'set'}).c('colibri', {xmlns: 'urn:xmpp:rayo:colibri:1', action: 'register'}),
function (res) {
console.log('rayo colibri register set ok');
},
function (err) {
console.log('rayo colibri register got error', err);
}
);
}
function unregisterRayoEvents()
{
connection.sendIQ($iq({to: connection.domain, type: 'set'}).c('colibri', {xmlns: 'urn:xmpp:rayo:colibri:1', action: 'unregister'}),
function (res) {
console.log('rayo colibri unregister set ok');
},
function (err) {
console.log('rayo colibri unregister got error', err);
}
);
}
function setupRTC()
{
var RTC = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment