Commit 7692b193 authored by Dele Olajide's avatar Dele Olajide Committed by dele

work-in-progress

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13758 b35dd754-fafc-0310-a699-88a17e54d16e
parent ca711647
...@@ -109,6 +109,9 @@ ...@@ -109,6 +109,9 @@
{ {
window.connection.rayo.phone( window.connection.rayo.phone(
{ {
codec_name: "PCMU",
stereo_pan: "0",
offHook: function() { offHook: function() {
$("#status").html("Off Hook"); $("#status").html("Off Hook");
}, },
...@@ -131,7 +134,7 @@ ...@@ -131,7 +134,7 @@
if (window.candybar.call == null) // ignore when user has active call if (window.candybar.call == null) // ignore when user has active call
{ {
var cli = headers['caller-name'] ? headers['caller-name']: call.from; var cli = headers.caller_name ? headers.caller_name : call.from;
window.candybar.setUser({ window.candybar.setUser({
name: cli, name: cli,
...@@ -193,7 +196,10 @@ ...@@ -193,7 +196,10 @@
if (prefix == "xmpp:") sipUri = prefix + destination + "@" + domain + "/" + destination; if (prefix == "xmpp:") sipUri = prefix + destination + "@" + domain + "/" + destination;
window.candybar.call = window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri); window.candybar.call = window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, {
codec_name: "PCMU",
});
window.candybar.setUser({ window.candybar.setUser({
name: destination, name: destination,
......
...@@ -77,9 +77,9 @@ Strophe.addConnectionPlugin('rayo', ...@@ -77,9 +77,9 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key}); var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key});
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, function(response)
{ {
if ($(response).attr('type') != "result") if ($(response).attr('type') != "result")
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure"); if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure");
...@@ -132,7 +132,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -132,7 +132,7 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var mixer = "rayo-mixer-" + Math.random().toString(36).substr(2,9); var mixer = "rayo-outgoing-" + Math.random().toString(36).substr(2,9);
var callId = "rayo-call-" + Math.random().toString(36).substr(2,9); var callId = "rayo-call-" + Math.random().toString(36).substr(2,9);
if (to.indexOf("xmpp:") == 0) if (to.indexOf("xmpp:") == 0)
...@@ -146,7 +146,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -146,7 +146,7 @@ Strophe.addConnectionPlugin('rayo',
{ {
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("dial", {xmlns: Strophe.NS.RAYO_CORE, to: to, from: from}); var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("dial", {xmlns: Strophe.NS.RAYO_CORE, to: to, from: from});
iq.c("header", {name: "call-id", value: callId}).up(); iq.c("header", {name: "call_id", value: callId}).up();
if (headers) if (headers)
{ {
...@@ -210,8 +210,11 @@ Strophe.addConnectionPlugin('rayo', ...@@ -210,8 +210,11 @@ Strophe.addConnectionPlugin('rayo',
_offhook1: function(mixer, headers, action) _offhook1: function(mixer, headers, action)
{ {
//console.log('Rayo plugin _offhook1 ' + mixer); //console.log('Rayo plugin _offhook1 ' + mixer);
var that = this; var that = this;
var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS");
that.pc1 = new webkitRTCPeerConnection(null); that.pc1 = new webkitRTCPeerConnection(null);
that.pc2 = new webkitRTCPeerConnection(null); that.pc2 = new webkitRTCPeerConnection(null);
...@@ -230,7 +233,12 @@ Strophe.addConnectionPlugin('rayo', ...@@ -230,7 +233,12 @@ Strophe.addConnectionPlugin('rayo',
that.pc1.setLocalDescription(desc); that.pc1.setLocalDescription(desc);
var sdpObj1 = WebrtcSDP.parseSDP(desc.sdp); var sdpObj1 = WebrtcSDP.parseSDP(desc.sdp);
sdpObj1.contents[0].codecs = [{clockrate: "48000", id: "111", name: "opus", channels: 2}];
if (codec == "PCMU")
sdpObj1.contents[0].codecs = [{clockrate: "8000", id: "0", name: "PCMU", channels: 1}];
else
sdpObj1.contents[0].codecs = [{clockrate: "48000", id: "111", name: "opus", channels: 2}];
var sdp = WebrtcSDP.buildSDP(sdpObj1); var sdp = WebrtcSDP.buildSDP(sdpObj1);
//console.log(sdp); //console.log(sdp);
that.cryptoSuite = sdpObj1.contents[0].crypto['crypto-suite']; that.cryptoSuite = sdpObj1.contents[0].crypto['crypto-suite'];
...@@ -257,8 +265,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -257,8 +265,8 @@ Strophe.addConnectionPlugin('rayo',
//console.log('Rayo plugin _offhook2 ' + this.cryptoSuite + " " + this.localCrypto + " " + this.remoteCrypto + " " + mixer); //console.log('Rayo plugin _offhook2 ' + this.cryptoSuite + " " + this.localCrypto + " " + this.remoteCrypto + " " + mixer);
var that = this; var that = this;
var stereo = (headers && headers.stereo) ? headers.stereo : "0"; var stereo = (headers && headers.stereo_pan) ? headers.stereo_pan : (that.callbacks.stereo_pan ? that.callbacks.stereo_pan : "0");
var codec = (headers && headers.codec) ? headers.codec : "OPUS"; var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS");
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer}); var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer});
...@@ -346,7 +354,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -346,7 +354,7 @@ Strophe.addConnectionPlugin('rayo',
var callTo = $(this).attr('to'); var callTo = $(this).attr('to');
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var mixer = headers['mixer-name'] var mixer = headers['mixer_name']
var call = { var call = {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
...@@ -396,7 +404,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -396,7 +404,14 @@ Strophe.addConnectionPlugin('rayo',
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from);
if (callId.indexOf("rayo-incoming-") == 0)
{
that._onhook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
} }
}); });
...@@ -433,7 +448,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -433,7 +448,7 @@ Strophe.addConnectionPlugin('rayo',
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
if (headers['call-protocol'] == "WebRtc") if (headers['call_protocol'] == "WebRtc")
{ {
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook(); if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
......
...@@ -23,12 +23,6 @@ ...@@ -23,12 +23,6 @@
package com.sun.voip.server; package com.sun.voip.server;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.JID;
import com.sun.voip.CallParticipant; import com.sun.voip.CallParticipant;
import com.sun.voip.CallState; import com.sun.voip.CallState;
import com.sun.voip.CallEvent; import com.sun.voip.CallEvent;
...@@ -40,6 +34,9 @@ import java.io.IOException; ...@@ -40,6 +34,9 @@ import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketException; import java.net.SocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.text.ParseException; import java.text.ParseException;
...@@ -48,6 +45,8 @@ import java.util.Collection; ...@@ -48,6 +45,8 @@ import java.util.Collection;
import org.voicebridge.Application; import org.voicebridge.Application;
import org.voicebridge.Config; import org.voicebridge.Config;
import org.ifsoft.rayo.RayoComponent;
/** /**
* Handle an incoming call. The call is placed into a temporary conference. * Handle an incoming call. The call is placed into a temporary conference.
...@@ -109,38 +108,12 @@ public class IncomingCallHandler extends CallHandler ...@@ -109,38 +108,12 @@ public class IncomingCallHandler extends CallHandler
System.out.println("Incoming SIP, call " + cp); System.out.println("Incoming SIP, call " + cp);
Collection<ClientSession> sessions = SessionManager.getInstance().getSessions(); if (RayoComponent.self.routeIncomingSIP(cp))
boolean foundUser = false;
for (ClientSession session : sessions)
{ {
try{
String userId = session.getAddress().getNode();
if (cp.getToPhoneNumber().equals(userId))
{
System.out.println("Incoming SIP, call route to user " + userId);
foundUser = true;
break;
}
} catch (Exception e) { }
}
if (foundUser) // send this call to conf with username and invite user to join with Jingle RTMP
{
String sid = "incoming-" + String.valueOf(System.currentTimeMillis());
cp.setConferenceId(sid);
haveIncomingConferenceId = true; haveIncomingConferenceId = true;
CallEvent callEvent = new CallEvent(CallEvent.STATE_CHANGED); } else {
callEvent.setCallState(new CallState(CallState.INCOMING)); // conf bridge
callEvent.setInfo(cp.getPhoneNumber());
callEvent.setCallId(sid);
sendCallEventNotification(callEvent);
} else { // conf bridge
if (Config.getInstance().getConferenceExten().equals(cp.getToPhoneNumber())) if (Config.getInstance().getConferenceExten().equals(cp.getToPhoneNumber()))
{ {
......
...@@ -369,7 +369,7 @@ public class MemberSender { ...@@ -369,7 +369,7 @@ public class MemberSender {
callHandler.getMember().adjustVolume(dataToSend, outputVolume); callHandler.getMember().adjustVolume(dataToSend, outputVolume);
} }
dataToSend = normalize(dataToSend); //dataToSend = normalize(dataToSend);
try { try {
/* /*
......
...@@ -380,8 +380,7 @@ public class SipServer implements SipListener { ...@@ -380,8 +380,7 @@ public class SipServer implements SipListener {
String from = fromHeader.getAddress().toString(); String from = fromHeader.getAddress().toString();
String to = toHeader.getAddress().toString(); String to = toHeader.getAddress().toString();
Logger.writeFile("SipServer: duplicate INVITE from " Logger.writeFile("SipServer: duplicate INVITE from " + from + " to " + to);
+ from + " to " + to);
return; return;
} }
...@@ -434,6 +433,7 @@ public class SipServer implements SipListener { ...@@ -434,6 +433,7 @@ public class SipServer implements SipListener {
* we should send back a 500 Internal Server Error * we should send back a 500 Internal Server Error
*/ */
Logger.exception("processRequest", e); Logger.exception("processRequest", e);
e.printStackTrace();
} }
} }
......
...@@ -77,9 +77,9 @@ Strophe.addConnectionPlugin('rayo', ...@@ -77,9 +77,9 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key}); var iq = $iq({to: callId + "@rayo." + this._connection.domain, from: this._connection.jid, type: "get"}).c("dtmf", {xmlns: Strophe.NS.RAYO_CORE, tones: key});
that._connection.sendIQ(iq, function(response) that._connection.sendIQ(iq, function(response)
{ {
if ($(response).attr('type') != "result") if ($(response).attr('type') != "result")
{ {
if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure"); if (that.callbacks && that.callbacks.onError) that.callbacks.onError("dtmf failure");
...@@ -132,7 +132,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -132,7 +132,7 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
var mixer = "rayo-mixer-" + Math.random().toString(36).substr(2,9); var mixer = "rayo-outgoing-" + Math.random().toString(36).substr(2,9);
var callId = "rayo-call-" + Math.random().toString(36).substr(2,9); var callId = "rayo-call-" + Math.random().toString(36).substr(2,9);
if (to.indexOf("xmpp:") == 0) if (to.indexOf("xmpp:") == 0)
...@@ -146,7 +146,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -146,7 +146,7 @@ Strophe.addConnectionPlugin('rayo',
{ {
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("dial", {xmlns: Strophe.NS.RAYO_CORE, to: to, from: from}); var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("dial", {xmlns: Strophe.NS.RAYO_CORE, to: to, from: from});
iq.c("header", {name: "call-id", value: callId}).up(); iq.c("header", {name: "call_id", value: callId}).up();
if (headers) if (headers)
{ {
...@@ -210,8 +210,11 @@ Strophe.addConnectionPlugin('rayo', ...@@ -210,8 +210,11 @@ Strophe.addConnectionPlugin('rayo',
_offhook1: function(mixer, headers, action) _offhook1: function(mixer, headers, action)
{ {
//console.log('Rayo plugin _offhook1 ' + mixer); //console.log('Rayo plugin _offhook1 ' + mixer);
var that = this; var that = this;
var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS");
that.pc1 = new webkitRTCPeerConnection(null); that.pc1 = new webkitRTCPeerConnection(null);
that.pc2 = new webkitRTCPeerConnection(null); that.pc2 = new webkitRTCPeerConnection(null);
...@@ -230,7 +233,12 @@ Strophe.addConnectionPlugin('rayo', ...@@ -230,7 +233,12 @@ Strophe.addConnectionPlugin('rayo',
that.pc1.setLocalDescription(desc); that.pc1.setLocalDescription(desc);
var sdpObj1 = WebrtcSDP.parseSDP(desc.sdp); var sdpObj1 = WebrtcSDP.parseSDP(desc.sdp);
sdpObj1.contents[0].codecs = [{clockrate: "48000", id: "111", name: "opus", channels: 2}];
if (codec == "PCMU")
sdpObj1.contents[0].codecs = [{clockrate: "8000", id: "0", name: "PCMU", channels: 1}];
else
sdpObj1.contents[0].codecs = [{clockrate: "48000", id: "111", name: "opus", channels: 2}];
var sdp = WebrtcSDP.buildSDP(sdpObj1); var sdp = WebrtcSDP.buildSDP(sdpObj1);
//console.log(sdp); //console.log(sdp);
that.cryptoSuite = sdpObj1.contents[0].crypto['crypto-suite']; that.cryptoSuite = sdpObj1.contents[0].crypto['crypto-suite'];
...@@ -257,8 +265,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -257,8 +265,8 @@ Strophe.addConnectionPlugin('rayo',
//console.log('Rayo plugin _offhook2 ' + this.cryptoSuite + " " + this.localCrypto + " " + this.remoteCrypto + " " + mixer); //console.log('Rayo plugin _offhook2 ' + this.cryptoSuite + " " + this.localCrypto + " " + this.remoteCrypto + " " + mixer);
var that = this; var that = this;
var stereo = (headers && headers.stereo) ? headers.stereo : "0"; var stereo = (headers && headers.stereo_pan) ? headers.stereo_pan : (that.callbacks.stereo_pan ? that.callbacks.stereo_pan : "0");
var codec = (headers && headers.codec) ? headers.codec : "OPUS"; var codec = (headers && headers.codec_name) ? headers.codec_name : (that.callbacks.codec_name ? that.callbacks.codec_name : "OPUS");
var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer}); var iq = $iq({to: "rayo." + that._connection.domain, from: that._connection.jid, type: "get"}).c("offhook", {xmlns: Strophe.NS.RAYO_HANDSET, cryptoSuite: that.cryptoSuite, localCrypto: that.localCrypto, remoteCrypto: that.remoteCrypto, codec: codec, stereo: stereo, mixer: mixer});
...@@ -346,7 +354,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -346,7 +354,7 @@ Strophe.addConnectionPlugin('rayo',
var callTo = $(this).attr('to'); var callTo = $(this).attr('to');
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var mixer = headers['mixer-name'] var mixer = headers['mixer_name']
var call = { var call = {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
...@@ -396,7 +404,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -396,7 +404,14 @@ Strophe.addConnectionPlugin('rayo',
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from);
if (callId.indexOf("rayo-incoming-") == 0)
{
that._onhook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
} }
}); });
...@@ -433,7 +448,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -433,7 +448,7 @@ Strophe.addConnectionPlugin('rayo',
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
if (headers['call-protocol'] == "WebRtc") if (headers['call_protocol'] == "WebRtc")
{ {
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook(); if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
......
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