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 { ...@@ -44,6 +44,7 @@ public class ColibriProvider extends BaseProvider {
private Object buildColibriCommand(Element element) throws URISyntaxException private Object buildColibriCommand(Element element) throws URISyntaxException
{ {
String action = element.attributeValue("action");
String videobridge = element.attributeValue("videobridge"); String videobridge = element.attributeValue("videobridge");
String localRTPPort = element.attributeValue("localrtpport"); String localRTPPort = element.attributeValue("localrtpport");
String localRTCPPort = element.attributeValue("localrtcpport"); String localRTCPPort = element.attributeValue("localrtcpport");
...@@ -51,12 +52,22 @@ public class ColibriProvider extends BaseProvider { ...@@ -51,12 +52,22 @@ public class ColibriProvider extends BaseProvider {
String remoteRTCPPort = element.attributeValue("remotertcpport"); String remoteRTCPPort = element.attributeValue("remotertcpport");
String codec = element.attributeValue("codec"); 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; return command;
} }
// Object -> XML // Object -> XML
// ================================================================================ // ================================================================================
......
...@@ -530,12 +530,14 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -530,12 +530,14 @@ public class PluginImpl implements Plugin, PropertyEventListener
private class ColibriIQHandler extends IQHandler implements MUCEventListener private class ColibriIQHandler extends IQHandler implements MUCEventListener
{ {
private ConcurrentHashMap<String, FocusAgent> sessions; private ConcurrentHashMap<String, FocusAgent> sessions;
private ConcurrentHashMap<String, JID> registry;
private MultiUserChatManager mucManager; private MultiUserChatManager mucManager;
public ColibriIQHandler() public ColibriIQHandler()
{ {
super("Rayo: XEP 0327 - Colibri"); super("Rayo: XEP 0327 - Colibri");
sessions = new ConcurrentHashMap<String, FocusAgent>(); sessions = new ConcurrentHashMap<String, FocusAgent>();
registry = new ConcurrentHashMap<String, JID>();
MUCEventDispatcher.addListener(this); MUCEventDispatcher.addListener(this);
mucManager = XMPPServer.getInstance().getMultiUserChatManager(); mucManager = XMPPServer.getInstance().getMultiUserChatManager();
...@@ -552,6 +554,8 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -552,6 +554,8 @@ public class PluginImpl implements Plugin, PropertyEventListener
final Element element = iq.getChildElement(); final Element element = iq.getChildElement();
IQ reply = null; IQ reply = null;
JID from = iq.getFrom();
String fromId = from.toString();
Object object = colibriProvider.fromXML(element); Object object = colibriProvider.fromXML(element);
...@@ -559,6 +563,16 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -559,6 +563,16 @@ public class PluginImpl implements Plugin, PropertyEventListener
ColibriCommand command = (ColibriCommand) object; ColibriCommand command = (ColibriCommand) object;
reply = handleColibriCommand(command, iq); 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 { } else {
reply = IQ.createResultIQ(iq); reply = IQ.createResultIQ(iq);
reply.setError(PacketError.Condition.not_allowed); reply.setError(PacketError.Condition.not_allowed);
...@@ -646,33 +660,34 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -646,33 +660,34 @@ public class PluginImpl implements Plugin, PropertyEventListener
*/ */
public void occupantJoined(JID roomJID, JID user, String nickname) 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)) } else {
{ focusAgent = new FocusAgent(focusAgentName, roomJID);
focusAgent = sessions.get(focusAgentName); 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.createColibriChannel(participant);
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);
} }
/** /**
* *
...@@ -680,17 +695,18 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -680,17 +695,18 @@ public class PluginImpl implements Plugin, PropertyEventListener
*/ */
public void occupantLeft(JID roomJID, JID user) public void occupantLeft(JID roomJID, JID user)
{ {
//MUCRoom mucRoom = mucManager.getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode()); if (registry.containsKey(user.toString()))
{
Log.info("ColibriIQHandler occupantLeft " + roomJID + " " + user); Log.info("ColibriIQHandler occupantLeft " + roomJID + " " + user);
String focusAgentName = "jitsi.videobridge." + roomJID.getNode(); String focusAgentName = "jitsi.videobridge." + roomJID.getNode();
if (sessions.containsKey(focusAgentName)) if (sessions.containsKey(focusAgentName))
{ {
FocusAgent focusAgent = sessions.get(focusAgentName); FocusAgent focusAgent = sessions.get(focusAgentName);
focusAgent.removeColibriChannel(user); focusAgent.removeColibriChannel(user);
}
} }
} }
/** /**
......
...@@ -5,6 +5,6 @@ var config = { ...@@ -5,6 +5,6 @@ var config = {
bridge: 'jitsi-videobridge.' + window.location.hostname // FIXME: use XEP-0030 bridge: 'jitsi-videobridge.' + window.location.hostname // FIXME: use XEP-0030
}, },
useNicks: false, useNicks: false,
useWebsockets: true, useWebsockets: false,
bosh: window.location.protocol + "//" + window.location.host + '/http-bind/' // FIXME: use xep-0156 for that bosh: window.location.protocol + "//" + window.location.host + '/http-bind/' // FIXME: use xep-0156 for that
}; };
...@@ -77,6 +77,7 @@ $(document).ready(function () ...@@ -77,6 +77,7 @@ $(document).ready(function ()
{ {
console.log('connected'); console.log('connected');
connection.send($pres()); connection.send($pres());
registerRayoEvents();
getConstraints(['audio', 'video'], '720'); getConstraints(['audio', 'video'], '720');
getUserMedia(); getUserMedia();
...@@ -89,6 +90,7 @@ $(document).ready(function () ...@@ -89,6 +90,7 @@ $(document).ready(function ()
$(window).bind('beforeunload', function () $(window).bind('beforeunload', function ()
{ {
if (connection && connection.connected) { if (connection && connection.connected) {
unregisterRayoEvents();
connection.disconnect(); connection.disconnect();
} }
}); });
...@@ -173,6 +175,32 @@ $(document).bind('remotestreamadded.rayo', function(event, data, sid) ...@@ -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() function setupRTC()
{ {
var RTC = null; 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