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
public String jabberLocal;
private PluginImpl.FocusAgent focusAgent;
private JID owner;
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);
this.mediaStream = mediaStream;
this.owner = owner;
this.focusAgent = focusAgent;
this.callId = callId;
......@@ -181,7 +179,7 @@ public class CallSession
try
{
mediaStream.stop();
focusAgent.inviteEvent(false, callId, owner);
focusAgent.inviteEvent(false, callId);
}
finally
{
......@@ -811,7 +809,7 @@ public class CallSession
}
}
focusAgent.inviteEvent(true, callId, owner);
focusAgent.inviteEvent(true, callId);
}
catch (Exception e)
{
......
......@@ -59,6 +59,9 @@ import javax.sip.message.Response;
import org.slf4j.*;
import org.slf4j.Logger;
import org.jitsi.videobridge.openfire.*;
/**
* Handles incoming sip requests/responses
*
......@@ -228,11 +231,12 @@ public class VideoBridgeSipListener implements SipListener
if (th.getTag() == null)
{
Log.info("[[SIP]] New Subscription, sending add request to user");
/*
sub = new SipSubscription(req);
//sub.localTag = ((ToHeader) res.getHeader(ToHeader.NAME)).getTag();
((ToHeader) res.getHeader(ToHeader.NAME)).setTag(sub.localTag);
SipSubscriptionManager.addWatcher(dest, sub);
/*
JID destination = UriMappings.toJID(dest);
JID source = new JID(src + "@" + host);
......@@ -454,42 +458,42 @@ public class VideoBridgeSipListener implements SipListener
{
if (evt.getDialog() == null)
{
Log.info("[[SIP]] Got initial invite!");
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();
/*
JID destination = UriMappings.toJID(dest);
if (destination != null)
ToHeader th = (ToHeader) req.getHeader("To");
String to = ((SipURI) th.getAddress().getURI()).getUser();
Log.info("[[SIP]] Got initial invite! " + from + " " + to + " " + dest);
ServerTransaction trans;
if (evt.getServerTransaction() == null)
{
trans = ((SipProvider) evt.getSource()).getNewServerTransaction(req);
}
else
{
Log.debug("[[SIP]] Attempting to send to destination: " + destination.toString());
trans = evt.getServerTransaction();
}
ServerTransaction trans;
if (evt.getServerTransaction() == null)
{
trans = ((SipProvider) evt.getSource()).getNewServerTransaction(req);
}
else
{
trans = evt.getServerTransaction();
}
Dialog dialog = SipService.sipProvider.getNewDialog(trans);
CallSession cs = PluginImpl.findCreateSession(from, to, dest);
Dialog dialog = SipService.sipProvider.getNewDialog(trans);
Session sess = SessionManager.findCreateSession(host, destination);
CallSession cs = new CallSession();
if (cs != null)
{
Log.info("[[SIP]] created call session : [[" + cs.internalCallId + "]]");
cs.parseInvite(req, dialog, trans);
dialog.setApplicationData(cs);
if (sess.startCall(cs, src, dest))
{
Response res = SipService.messageFactory.createResponse(Response.RINGING, req);
trans.sendResponse(res);
return;
}
Response res = SipService.messageFactory.createResponse(Response.RINGING, req);
trans.sendResponse(res);
SipService.acceptCall(cs);
return;
}
*/
} else {
// SIP RE-INVITE (dumbstart implementation, ignores timers, etc)
Log.info("[[SIP]] Got a re-invite!");
......@@ -587,6 +591,21 @@ public class VideoBridgeSipListener implements SipListener
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))
{
......
......@@ -84,6 +84,7 @@ import org.ifsoft.rtp.*;
*/
public class PluginImpl implements Plugin, PropertyEventListener
{
private static ConcurrentHashMap<String, FocusAgent> sessions;
/**
* SIP registration status.
*/
......@@ -199,7 +200,7 @@ public class PluginImpl implements Plugin, PropertyEventListener
/**
*
*/
private ComponentImpl componentImpl;
private static ComponentImpl componentImpl;
public void destroyPlugin()
......@@ -648,19 +649,64 @@ public class PluginImpl implements Plugin, PropertyEventListener
*
*
*/
public Videobridge getVideoBridge()
public static Videobridge 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 ConcurrentHashMap<String, FocusAgent> sessions;
private ConcurrentHashMap<String, JID> registry;
private ConcurrentHashMap<String, Participant> pending;
private MultiUserChatManager mucManager;
......@@ -1196,20 +1242,22 @@ public class PluginImpl implements Plugin, PropertyEventListener
private SessionPacketRouter router;
private String focusName;
private JID roomJid;
private String focusId = null;
private int count = 0;
private LocalClientSession session;
private String domainName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
private Recorder recorder = null;
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> ids = new ConcurrentHashMap<String, Participant>();
public ConcurrentHashMap<String, Element> ssrcs = new ConcurrentHashMap<String, Element>();
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
*
*
*/
public void inviteEvent(boolean accepted, String callId, JID owner)
public void inviteEvent(boolean accepted, String callId)
{
Presence presence = new Presence();
presence.setFrom(XMPPServer.getInstance().createJID(focusName, focusName));
......@@ -1572,9 +1620,7 @@ public class PluginImpl implements Plugin, PropertyEventListener
mediaStream.setSSRCFactory(ssrcFactory);
mediaStream.setDevice(conference.getOrCreateContent("audio").getMixer());
initialLocalSSRC = ssrcFactory.doGenerateSSRC() & 0xFFFFFFFFL;
CallSession cs = new CallSession(mediaStream, hostname, reply.getTo(), this, toUri.toString());
CallSession cs = new CallSession(mediaStream, hostname, this, toUri.toString());
callSessions.put(toUri.toString(), cs);
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