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

Jitsi Videobridge: Started work on incoming SIP audio participants

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@14014 b35dd754-fafc-0310-a699-88a17e54d16e
parent b1fcad6a
...@@ -142,16 +142,14 @@ public class CallSession ...@@ -142,16 +142,14 @@ public class CallSession
public String jabberLocal; public String jabberLocal;
private PluginImpl.FocusAgent focusAgent; private PluginImpl.FocusAgent focusAgent;
private JID owner;
private String callId; private String callId;
public CallSession(MediaStream mediaStream, String host, JID owner, PluginImpl.FocusAgent focusAgent, String callId) public CallSession(MediaStream mediaStream, String host, PluginImpl.FocusAgent focusAgent, String callId)
{ {
Log.info("CallSession creation " + host); Log.info("CallSession creation " + host);
this.mediaStream = mediaStream; this.mediaStream = mediaStream;
this.owner = owner;
this.focusAgent = focusAgent; this.focusAgent = focusAgent;
this.callId = callId; this.callId = callId;
...@@ -181,7 +179,7 @@ public class CallSession ...@@ -181,7 +179,7 @@ public class CallSession
try try
{ {
mediaStream.stop(); mediaStream.stop();
focusAgent.inviteEvent(false, callId, owner); focusAgent.inviteEvent(false, callId);
} }
finally finally
{ {
...@@ -811,7 +809,7 @@ public class CallSession ...@@ -811,7 +809,7 @@ public class CallSession
} }
} }
focusAgent.inviteEvent(true, callId, owner); focusAgent.inviteEvent(true, callId);
} }
catch (Exception e) catch (Exception e)
{ {
......
...@@ -59,6 +59,9 @@ import javax.sip.message.Response; ...@@ -59,6 +59,9 @@ import javax.sip.message.Response;
import org.slf4j.*; import org.slf4j.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.jitsi.videobridge.openfire.*;
/** /**
* Handles incoming sip requests/responses * Handles incoming sip requests/responses
* *
...@@ -228,11 +231,12 @@ public class VideoBridgeSipListener implements SipListener ...@@ -228,11 +231,12 @@ public class VideoBridgeSipListener implements SipListener
if (th.getTag() == null) if (th.getTag() == null)
{ {
Log.info("[[SIP]] New Subscription, sending add request to user"); Log.info("[[SIP]] New Subscription, sending add request to user");
/*
sub = new SipSubscription(req); sub = new SipSubscription(req);
//sub.localTag = ((ToHeader) res.getHeader(ToHeader.NAME)).getTag(); //sub.localTag = ((ToHeader) res.getHeader(ToHeader.NAME)).getTag();
((ToHeader) res.getHeader(ToHeader.NAME)).setTag(sub.localTag); ((ToHeader) res.getHeader(ToHeader.NAME)).setTag(sub.localTag);
SipSubscriptionManager.addWatcher(dest, sub); SipSubscriptionManager.addWatcher(dest, sub);
/*
JID destination = UriMappings.toJID(dest); JID destination = UriMappings.toJID(dest);
JID source = new JID(src + "@" + host); JID source = new JID(src + "@" + host);
...@@ -454,17 +458,16 @@ public class VideoBridgeSipListener implements SipListener ...@@ -454,17 +458,16 @@ public class VideoBridgeSipListener implements SipListener
{ {
if (evt.getDialog() == null) if (evt.getDialog() == null)
{ {
Log.info("[[SIP]] Got initial invite!");
FromHeader fh = (FromHeader) req.getHeader("From"); FromHeader fh = (FromHeader) req.getHeader("From");
URI ruri = req.getRequestURI(); String from = ((SipURI) fh.getAddress().getURI()).getUser();
String src = ((SipURI) fh.getAddress().getURI()).getUser(); URI ruri = req.getRequestURI();
String dest = ((SipURI) ruri).getUser(); String dest = ((SipURI) ruri).getUser();
/*
JID destination = UriMappings.toJID(dest); ToHeader th = (ToHeader) req.getHeader("To");
if (destination != null) String to = ((SipURI) th.getAddress().getURI()).getUser();
{
Log.debug("[[SIP]] Attempting to send to destination: " + destination.toString()); Log.info("[[SIP]] Got initial invite! " + from + " " + to + " " + dest);
ServerTransaction trans; ServerTransaction trans;
if (evt.getServerTransaction() == null) if (evt.getServerTransaction() == null)
...@@ -477,19 +480,20 @@ public class VideoBridgeSipListener implements SipListener ...@@ -477,19 +480,20 @@ public class VideoBridgeSipListener implements SipListener
} }
Dialog dialog = SipService.sipProvider.getNewDialog(trans); Dialog dialog = SipService.sipProvider.getNewDialog(trans);
Session sess = SessionManager.findCreateSession(host, destination); CallSession cs = PluginImpl.findCreateSession(from, to, dest);
CallSession cs = new CallSession();
if (cs != null)
{
Log.info("[[SIP]] created call session : [[" + cs.internalCallId + "]]"); Log.info("[[SIP]] created call session : [[" + cs.internalCallId + "]]");
cs.parseInvite(req, dialog, trans); cs.parseInvite(req, dialog, trans);
dialog.setApplicationData(cs); dialog.setApplicationData(cs);
if (sess.startCall(cs, src, dest))
{
Response res = SipService.messageFactory.createResponse(Response.RINGING, req); Response res = SipService.messageFactory.createResponse(Response.RINGING, req);
trans.sendResponse(res); trans.sendResponse(res);
SipService.acceptCall(cs);
return; return;
} }
}
*/
} else { } else {
// SIP RE-INVITE (dumbstart implementation, ignores timers, etc) // SIP RE-INVITE (dumbstart implementation, ignores timers, etc)
Log.info("[[SIP]] Got a re-invite!"); Log.info("[[SIP]] Got a re-invite!");
...@@ -587,6 +591,21 @@ public class VideoBridgeSipListener implements SipListener ...@@ -587,6 +591,21 @@ public class VideoBridgeSipListener implements SipListener
return; return;
} }
} }
else if (req.getMethod().equals(Request.REGISTER))
{
Response res = SipService.messageFactory.createResponse(Response.OK, req);
if (evt.getServerTransaction() == null)
{
ServerTransaction tx = ((SipProvider) evt.getSource()).getNewServerTransaction(req);
tx.sendResponse(res);
}
else
{
evt.getServerTransaction().sendResponse(res);
}
return;
}
else if (req.getMethod().equals(Request.ACK)) else if (req.getMethod().equals(Request.ACK))
{ {
......
...@@ -84,6 +84,7 @@ import org.ifsoft.rtp.*; ...@@ -84,6 +84,7 @@ import org.ifsoft.rtp.*;
*/ */
public class PluginImpl implements Plugin, PropertyEventListener public class PluginImpl implements Plugin, PropertyEventListener
{ {
private static ConcurrentHashMap<String, FocusAgent> sessions;
/** /**
* SIP registration status. * SIP registration status.
*/ */
...@@ -199,7 +200,7 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -199,7 +200,7 @@ public class PluginImpl implements Plugin, PropertyEventListener
/** /**
* *
*/ */
private ComponentImpl componentImpl; private static ComponentImpl componentImpl;
public void destroyPlugin() public void destroyPlugin()
...@@ -648,19 +649,64 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -648,19 +649,64 @@ public class PluginImpl implements Plugin, PropertyEventListener
* *
* *
*/ */
public Videobridge getVideoBridge() public static Videobridge getVideoBridge()
{ {
return componentImpl.getVideoBridge(); return componentImpl.getVideoBridge();
} }
/** /**
*
*
*/
public static CallSession findCreateSession(String from, String to, String destination)
{
CallSession session = null;
String hostname = XMPPServer.getInstance().getServerInfo().getHostname();
String focusAgentName = "jitsi.videobridge." + to;
if (sessions.containsKey(focusAgentName))
{
FocusAgent focus = sessions.get(focusAgentName);
if (focus.callSessions.containsKey(from))
{
session = focus.callSessions.get(from);
} else {
Conference conference = null;
String focusJid = XMPPServer.getInstance().createJID(focusAgentName, focusAgentName).toString();
if (focus.focusId != null)
{
conference = getVideoBridge().getConference(focus.focusId, focusJid);
}
if (conference != null)
{
MediaService mediaService = LibJitsi.getMediaService();
MediaStream mediaStream = mediaService.createMediaStream(null, org.jitsi.service.neomedia.MediaType.AUDIO, mediaService.createSrtpControl(SrtpControlType.MIKEY));
mediaStream.setName("rayo-" + System.currentTimeMillis());
mediaStream.setSSRCFactory(focus.ssrcFactory);
mediaStream.setDevice(conference.getOrCreateContent("audio").getMixer());
session = new CallSession(mediaStream, hostname, focus, from);
focus.callSessions.put(to, session);
session.jabberRemote = to;
session.jabberLocal = from;
}
}
}
return session;
}
/*
* *
* *
*/ */
private class ColibriIQHandler extends IQHandler implements MUCEventListener private class ColibriIQHandler extends IQHandler implements MUCEventListener
{ {
private ConcurrentHashMap<String, FocusAgent> sessions;
private ConcurrentHashMap<String, JID> registry; private ConcurrentHashMap<String, JID> registry;
private ConcurrentHashMap<String, Participant> pending; private ConcurrentHashMap<String, Participant> pending;
private MultiUserChatManager mucManager; private MultiUserChatManager mucManager;
...@@ -1196,20 +1242,22 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -1196,20 +1242,22 @@ public class PluginImpl implements Plugin, PropertyEventListener
private SessionPacketRouter router; private SessionPacketRouter router;
private String focusName; private String focusName;
private JID roomJid; private JID roomJid;
private String focusId = null;
private int count = 0; private int count = 0;
private LocalClientSession session; private LocalClientSession session;
private String domainName = XMPPServer.getInstance().getServerInfo().getXMPPDomain(); private String domainName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
private Recorder recorder = null; private Recorder recorder = null;
private AudioMixingPushBufferDataSource outDataSource; private AudioMixingPushBufferDataSource outDataSource;
private SSRCFactoryImpl ssrcFactory = new SSRCFactoryImpl();
private long initialLocalSSRC; public String focusId = null;
public SSRCFactoryImpl ssrcFactory = new SSRCFactoryImpl();
public ConcurrentHashMap<String, Participant> users = new ConcurrentHashMap<String, Participant>(); public ConcurrentHashMap<String, Participant> users = new ConcurrentHashMap<String, Participant>();
public ConcurrentHashMap<String, Participant> ids = new ConcurrentHashMap<String, Participant>(); public ConcurrentHashMap<String, Participant> ids = new ConcurrentHashMap<String, Participant>();
public ConcurrentHashMap<String, Element> ssrcs = new ConcurrentHashMap<String, Element>(); public ConcurrentHashMap<String, Element> ssrcs = new ConcurrentHashMap<String, Element>();
public ConcurrentHashMap<String, CallSession> callSessions = new ConcurrentHashMap<String, CallSession>(); public ConcurrentHashMap<String, CallSession> callSessions = new ConcurrentHashMap<String, CallSession>();
private long initialLocalSSRC = ssrcFactory.doGenerateSSRC() & 0xFFFFFFFFL;
/** /**
* *
* *
...@@ -1491,7 +1539,7 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -1491,7 +1539,7 @@ public class PluginImpl implements Plugin, PropertyEventListener
* *
* *
*/ */
public void inviteEvent(boolean accepted, String callId, JID owner) public void inviteEvent(boolean accepted, String callId)
{ {
Presence presence = new Presence(); Presence presence = new Presence();
presence.setFrom(XMPPServer.getInstance().createJID(focusName, focusName)); presence.setFrom(XMPPServer.getInstance().createJID(focusName, focusName));
...@@ -1572,9 +1620,7 @@ public class PluginImpl implements Plugin, PropertyEventListener ...@@ -1572,9 +1620,7 @@ public class PluginImpl implements Plugin, PropertyEventListener
mediaStream.setSSRCFactory(ssrcFactory); mediaStream.setSSRCFactory(ssrcFactory);
mediaStream.setDevice(conference.getOrCreateContent("audio").getMixer()); mediaStream.setDevice(conference.getOrCreateContent("audio").getMixer());
initialLocalSSRC = ssrcFactory.doGenerateSSRC() & 0xFFFFFFFFL; CallSession cs = new CallSession(mediaStream, hostname, this, toUri.toString());
CallSession cs = new CallSession(mediaStream, hostname, reply.getTo(), this, toUri.toString());
callSessions.put(toUri.toString(), cs); callSessions.put(toUri.toString(), cs);
cs.jabberRemote = to; cs.jabberRemote = to;
......
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