Commit 386c2b90 authored by Dele Olajide's avatar Dele Olajide Committed by dele

Rayo plugin - work in progress

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13768 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4330588a
...@@ -80,6 +80,34 @@ body { ...@@ -80,6 +80,34 @@ body {
-ms-filter: progid:DXImageTransform.Microsoft.Shadow(Color=rgba(0, 0, 0, 0.2),Direction=135,Strength=5); } -ms-filter: progid:DXImageTransform.Microsoft.Shadow(Color=rgba(0, 0, 0, 0.2),Direction=135,Strength=5); }
#callStatus.active .callerName:before { #callStatus.active .callerName:before {
content: "On Call: "; } content: "On Call: "; }
#callStatus.busy {
background-color: #bbbbbb;
background-image: rgba(255, 255, 255, 0.3);
background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(50, 50, 50, 0.1));
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(255, 255, 255, 0.3)), color-stop(1, rgba(50, 50, 50, 0.1)));
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='$top', EndColorStr='$bottom');
border-top: 2px solid white;
border-bottom: 2px solid #bbbbbb;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 3px 5px;
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 3px 5px;
box-shadow: rgba(0, 0, 0, 0.2) 0 3px 5px;
-ms-filter: progid:DXImageTransform.Microsoft.Shadow(Color=rgba(0, 0, 0, 0.2),Direction=135,Strength=5); }
#callStatus.busy .callerName:before {
content: "Busy: "; }
#callStatus.conferenced {
background-color: #74e0ff;
background-image: rgba(255, 255, 255, 0.3);
background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(50, 50, 50, 0.1));
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(255, 255, 255, 0.3)), color-stop(1, rgba(50, 50, 50, 0.1)));
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='$top', EndColorStr='$bottom');
border-top: 2px solid white;
border-bottom: 2px solid #bbbbbb;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 3px 5px;
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 3px 5px;
box-shadow: rgba(0, 0, 0, 0.2) 0 3px 5px;
-ms-filter: progid:DXImageTransform.Microsoft.Shadow(Color=rgba(0, 0, 0, 0.2),Direction=135,Strength=5); }
#callStatus.conferenced .callerName:before {
content: "Conferenced: "; }
#callStatus.inactive { #callStatus.inactive {
background-color: white; background-color: white;
background-image: rgba(255, 255, 255, 0.3); background-image: rgba(255, 255, 255, 0.3);
......
...@@ -59,6 +59,18 @@ ...@@ -59,6 +59,18 @@
}], }],
timer: true timer: true
}, },
busy: {
buttons: [{
cls: 'busy',
label: 'Join Call'
}],
},
conferenced: {
buttons: [{
cls: 'leave',
label: 'Leave Call'
}],
},
inactive: { inactive: {
buttons: [], buttons: [],
clearUser: true, clearUser: true,
...@@ -109,8 +121,14 @@ ...@@ -109,8 +121,14 @@
CandyBar.prototype.getStates = function () { CandyBar.prototype.getStates = function () {
return Object.keys(this.states); return Object.keys(this.states);
}; };
CandyBar.prototype.getState = function () {
return this.state;
};
CandyBar.prototype.setState = function (state) { CandyBar.prototype.setState = function (state) {
this.state = state;
if (!this.dom) return this; if (!this.dom) return this;
var buttons = this.dom.querySelectorAll('button'), var buttons = this.dom.querySelectorAll('button'),
callActionsEl = this.dom.querySelector('.callActions'), callActionsEl = this.dom.querySelector('.callActions'),
...@@ -208,6 +226,16 @@ ...@@ -208,6 +226,16 @@
self.call.answer(); self.call.answer();
} }
}; };
self.join = function () {
if (self.call) {
self.call.join();
}
};
self.leave = function () {
if (self.call) {
self.call.leave();
}
};
self.cancel = function () { self.cancel = function () {
if (self.call) { if (self.call) {
self.call.hangup(); self.call.hangup();
......
...@@ -46,8 +46,17 @@ ...@@ -46,8 +46,17 @@
} else if (window.dialer.getCallLabel() == "Hangup") { } else if (window.dialer.getCallLabel() == "Hangup") {
window.candybar.call.hangup(); window.candybar.call.hangup();
} else { } else if (window.dialer.getCallLabel() == "Answer") {
window.candybar.call.answer(); window.candybar.call.answer();
} else if (window.dialer.getCallLabel() == "Join") {
window.candybar.call.join();
} else if (window.dialer.getCallLabel() == "Leave") {
window.candybar.call.leave();
} else {
console.error('bad call state');
} }
} }
}); });
...@@ -187,6 +196,15 @@ ...@@ -187,6 +196,15 @@
stopTone(); stopTone();
}, },
onBusy: function(callId, headers) {
//console.log('onBusy ' + callId);
//console.log(headers);
window.candybar.setState('busy');
window.dialer.setCallLabel('Join');
stopTone();
},
onRing: function(callId, headers) { onRing: function(callId, headers) {
//console.log('onRing ' + callId); //console.log('onRing ' + callId);
//console.log(headers); //console.log(headers);
...@@ -195,12 +213,15 @@ ...@@ -195,12 +213,15 @@
startTone("ringback-uk"); startTone("ringback-uk");
}, },
onJoin: function(jid, mixer) { onJoin: function(callId, jid, mixer) {
//console.log('onJoin ' + jid + " " + mixer); //console.log('onJoin ' + jid + " " + mixer + " " + callId);
window.candybar.setState('conferenced');
window.dialer.setCallLabel('Leave');
}, },
onUnjoin: function(jid, mixer) { onUnjoin: function(callId, jid, mixer) {
//console.log('onUnjoin ' + jid + " " + mixer); console.log('onUnjoin ' + jid + " " + mixer + " " + callId);
}, },
onError: function(e) { onError: function(e) {
...@@ -225,6 +246,7 @@ ...@@ -225,6 +246,7 @@
window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, { window.connection.rayo.dial("xmpp:" + window.connection.jid, sipUri, {
codec_name: "PCMU", codec_name: "PCMU",
/* group_name: "12345678" */
}); });
window.candybar.setUser({ window.candybar.setUser({
......
...@@ -72,7 +72,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -72,7 +72,7 @@ Strophe.addConnectionPlugin('rayo',
digit: function(callId, key) digit: function(callId, key)
{ {
//console.log("digit " + callId + " " + key); //console.log("Rayo plugin digit " + callId + " " + key);
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});
...@@ -87,6 +87,26 @@ Strophe.addConnectionPlugin('rayo', ...@@ -87,6 +87,26 @@ Strophe.addConnectionPlugin('rayo',
}); });
}, },
join: function(mixer, headers)
{
//console.log('Rayo plugin join ' + mixer);
//console.log(headers)
if (this._isOffhook()) this._onhook();
this._offhook(mixer, headers, function()
{
});
},
leave: function(mixer)
{
//console.log('Rayo plugin leave ' + mixer);
this._onhook();
},
answer: function(callId, mixer, headers) answer: function(callId, mixer, headers)
{ {
//console.log('Rayo plugin accept ' + callId + " " + mixer); //console.log('Rayo plugin accept ' + callId + " " + mixer);
...@@ -94,7 +114,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -94,7 +114,7 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
//if (this._isOffhook()) this._onhook(); if (this._isOffhook()) this._onhook();
this._offhook(mixer, headers, function() this._offhook(mixer, headers, function()
{ {
...@@ -125,7 +145,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -125,7 +145,7 @@ Strophe.addConnectionPlugin('rayo',
}); });
}); });
}); });
}, },
dial: function(from, to, headers) dial: function(from, to, headers)
{ {
...@@ -175,8 +195,10 @@ Strophe.addConnectionPlugin('rayo', ...@@ -175,8 +195,10 @@ Strophe.addConnectionPlugin('rayo',
{ {
that.callbacks.onAccept( that.callbacks.onAccept(
{ {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
join: function() {that.join(mixer, headers);},
leave: function() {that.leave(mixer);},
from: from, from: from,
to: to, to: to,
...@@ -302,7 +324,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -302,7 +324,7 @@ Strophe.addConnectionPlugin('rayo',
that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"})); that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"}));
that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"})); that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"}));
action(); if (action) action();
}); });
}, function (error) { }, function (error) {
...@@ -334,8 +356,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -334,8 +356,8 @@ Strophe.addConnectionPlugin('rayo',
_handlePresence: function(presence) _handlePresence: function(presence)
{ {
//console.log('Rayo plugin handlePresence'); console.log('Rayo plugin handlePresence');
//console.log(presence); console.log(presence);
var that = this; var that = this;
var from = $(presence).attr('from'); var from = $(presence).attr('from');
...@@ -375,6 +397,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -375,6 +397,8 @@ Strophe.addConnectionPlugin('rayo',
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
answer: function() {that.answer(callId, mixer, headers);}, answer: function() {that.answer(callId, mixer, headers);},
join: function() {that.join(mixer, headers);},
leave: function() {that.leave(mixer);},
from: callFrom, from: callFrom,
to: callTo, to: callTo,
...@@ -409,16 +433,19 @@ Strophe.addConnectionPlugin('rayo', ...@@ -409,16 +433,19 @@ Strophe.addConnectionPlugin('rayo',
}) })
$(presence).find('joined').each(function() $(presence).find('joined').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId); var jid = Strophe.unescapeNode(callId);
var mixer = $(this).attr('mixer-name');
if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1)
if (jid == that._connection.jid)
{ {
if (that.callbacks && that.callbacks.onJoin) that.callbacks.onJoin(jid, $(this).attr('mixer-name')); if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
} }
if (that.callbacks && that.callbacks.onJoin) that.callbacks.onJoin(callId, jid, mixer);
} }
}); });
...@@ -428,20 +455,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -428,20 +455,14 @@ Strophe.addConnectionPlugin('rayo',
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId); var jid = Strophe.unescapeNode(callId);
var mixer = $(this).attr('mixer-name');
if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1) if (jid == that._connection.jid)
{ {
if (that.callbacks && that.callbacks.onUnjoin) that.callbacks.onUnjoin(jid, $(this).attr('mixer-name')); if (that.callbacks && that.callbacks.onHook) that.callbacks.onHook();
} else {
if (callId.indexOf("rayo-incoming-") == 0)
{
that._onhook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
} }
if (that.callbacks && that.callbacks.onUnjoin) that.callbacks.onUnjoin(callId, jid, mixer);
} }
}); });
...@@ -450,7 +471,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -450,7 +471,7 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onSpeaking) that.callbacks.onSpeaking(callId, headers); //if (that.callbacks && that.callbacks.onSpeaking) that.callbacks.onSpeaking(callId, headers);
} }
}); });
...@@ -459,7 +480,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -459,7 +480,7 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.offSpeaking) that.callbacks.offSpeaking(callId, headers); //if (that.callbacks && that.callbacks.offSpeaking) that.callbacks.offSpeaking(callId, headers);
} }
}); });
...@@ -477,13 +498,31 @@ Strophe.addConnectionPlugin('rayo', ...@@ -477,13 +498,31 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId);
if (headers['call_protocol'] == "WebRtc") var busy = false;
if (jid.indexOf('@') > -1 && jid.indexOf('/') > -1)
{ {
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook(); if (headers.call_action == "join")
{
busy = jid != that._connection.jid;
} else {
busy = jid == that._connection.jid;
}
}
if (busy)
{
if (that.callbacks && that.callbacks.onHook) that.callbacks.onHook();
if (that.callbacks && that.callbacks.onBusy) that.callbacks.onBusy(callId, headers);
} else { } else {
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers); if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers);
} }
} }
......
...@@ -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 {
/* /*
......
...@@ -431,6 +431,8 @@ public class RayoComponent extends AbstractComponent ...@@ -431,6 +431,8 @@ public class RayoComponent extends AbstractComponent
if (callJID != null) // XMPP call if (callJID != null) // XMPP call
{ {
headers.put("call_protocol", "XMPP"); headers.put("call_protocol", "XMPP");
headers.put("call_owner", callJID.toString());
headers.put("call_action", "join");
try { try {
Presence presence1 = new Presence(); //to caller Presence presence1 = new Presence(); //to caller
...@@ -439,12 +441,6 @@ public class RayoComponent extends AbstractComponent ...@@ -439,12 +441,6 @@ public class RayoComponent extends AbstractComponent
presence1.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers))); presence1.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence1); sendPacket(presence1);
Presence presence2 = new Presence(); //to called
presence2.setFrom(iq.getTo());
presence2.setTo(iq.getFrom());
presence2.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence2);
RelayChannel channel = plugin.getRelayChannel(callId); RelayChannel channel = plugin.getRelayChannel(callId);
if (channel != null) if (channel != null)
...@@ -461,12 +457,6 @@ public class RayoComponent extends AbstractComponent ...@@ -461,12 +457,6 @@ public class RayoComponent extends AbstractComponent
} else { } else {
callHandler = CallHandler.findCall(callId); // SIP call; callHandler = CallHandler.findCall(callId); // SIP call;
Presence presence = new Presence(); //to called
presence.setFrom(iq.getTo());
presence.setTo(iq.getFrom());
presence.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence);
} }
if (callHandler != null) if (callHandler != null)
...@@ -525,27 +515,23 @@ public class RayoComponent extends AbstractComponent ...@@ -525,27 +515,23 @@ public class RayoComponent extends AbstractComponent
{ {
Log.info("RayoComponent handleHangupCommand found callhandler " + callId); Log.info("RayoComponent handleHangupCommand found callhandler " + callId);
CallHandler.hangup(callId, "User requested call termination"); CallParticipant cp = callHandler.getCallParticipant();
} else { try {
reply.setError(PacketError.Condition.item_not_found); ConferenceManager conferenceManager = ConferenceManager.findConferenceManager(cp.getConferenceId());
}
try { Log.info("RayoComponent handleHangupCommand one person left, cancel call " + conferenceManager.getMemberList().size());
JID otherParty = getJID(callId);
if (otherParty != null) if (conferenceManager.getMemberList().size() <= 2)
{ {
Log.info("RayoComponent handleHangupCommand found other party " + otherParty); CallHandler.hangup(callId, "User requested call termination");
}
Presence presence1 = new Presence(); } catch (Exception e) {}
presence1.setFrom(iq.getTo());
presence1.setTo(otherParty);
presence1.getElement().add(rayoProvider.toXML(new EndEvent(null, null)));
sendPacket(presence1);
}
} catch (Exception e) { } } else {
reply.setError(PacketError.Condition.item_not_found);
}
return reply; return reply;
} }
...@@ -700,7 +686,6 @@ public class RayoComponent extends AbstractComponent ...@@ -700,7 +686,6 @@ public class RayoComponent extends AbstractComponent
cp.setCallOwner(handsetId); cp.setCallOwner(handsetId);
cp.setMediaPreference("PCMU/8000/1"); cp.setMediaPreference("PCMU/8000/1");
cp.setProtocol("SIP"); cp.setProtocol("SIP");
cp.setCallId(callId);
cp.setDisplayName(callerName); cp.setDisplayName(callerName);
cp.setPhoneNumber(to); cp.setPhoneNumber(to);
cp.setName(calledName); cp.setName(calledName);
...@@ -754,9 +739,6 @@ public class RayoComponent extends AbstractComponent ...@@ -754,9 +739,6 @@ public class RayoComponent extends AbstractComponent
reply.setError(PacketError.Condition.item_not_found); reply.setError(PacketError.Condition.item_not_found);
return reply; return reply;
} }
// tag conf with group name
ConferenceManager.setDisplayName(channel.getHandset().mixer, destination.getNode());
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
reply.setError(PacketError.Condition.item_not_found); reply.setError(PacketError.Condition.item_not_found);
...@@ -987,7 +969,9 @@ public class RayoComponent extends AbstractComponent ...@@ -987,7 +969,9 @@ public class RayoComponent extends AbstractComponent
username, false); username, false);
try { try {
cp.setConferenceId(mixer); cp.setConferenceId(mixer);
cp.setCallId(mixer);
cp.setStartTimestamp(System.currentTimeMillis()); cp.setStartTimestamp(System.currentTimeMillis());
String recording = mixer + "-" + cp.getStartTimestamp() + ".au"; String recording = mixer + "-" + cp.getStartTimestamp() + ".au";
conferenceManager.recordConference(true, recording, "au"); conferenceManager.recordConference(true, recording, "au");
Config.createCallRecord(cp.getDisplayName(), recording, cp.getPhoneNumber(), cp.getStartTimestamp(), 0, "dialed") ; Config.createCallRecord(cp.getDisplayName(), recording, cp.getPhoneNumber(), cp.getStartTimestamp(), 0, "dialed") ;
...@@ -1053,14 +1037,10 @@ public class RayoComponent extends AbstractComponent ...@@ -1053,14 +1037,10 @@ public class RayoComponent extends AbstractComponent
sendPacket(presence); sendPacket(presence);
} else if ("200 ESTABLISHED".equals(callState)) { } else if ("200 ESTABLISHED".equals(callState)) {
presence.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence);
} else if ("299 ENDED".equals(callState)) { } else if ("299 ENDED".equals(callState)) {
presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("HANGUP"), headers)));
sendPacket(presence);
finishCallRecord(cp);
} }
} else if ("250 STARTED SPEAKING".equals(myEvent)) { } else if ("250 STARTED SPEAKING".equals(myEvent)) {
...@@ -1140,7 +1120,7 @@ public class RayoComponent extends AbstractComponent ...@@ -1140,7 +1120,7 @@ public class RayoComponent extends AbstractComponent
presence.setFrom(callId + "@rayo." + getDomain()); presence.setFrom(callId + "@rayo." + getDomain());
presence.setTo(new JID(name)); presence.setTo(new JID(name));
presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("ERROR"), null))); presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("ERROR"), null)));
sendPacket(presence); //sendPacket(presence);
} }
public void terminated(String name, String callId) public void terminated(String name, String callId)
...@@ -1151,7 +1131,7 @@ public class RayoComponent extends AbstractComponent ...@@ -1151,7 +1131,7 @@ public class RayoComponent extends AbstractComponent
presence.setFrom(callId + "@rayo." + getDomain()); presence.setFrom(callId + "@rayo." + getDomain());
presence.setTo(new JID(name)); presence.setTo(new JID(name));
presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("HANGUP"), null))); presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("HANGUP"), null)));
sendPacket(presence); //sendPacket(presence);
} }
public void sendPacket(Packet packet) public void sendPacket(Packet packet)
...@@ -1175,6 +1155,8 @@ public class RayoComponent extends AbstractComponent ...@@ -1175,6 +1155,8 @@ public class RayoComponent extends AbstractComponent
{ {
Log.info("RayoComponent notifyConferenceMonitors looking for call " + conferenceEvent.getCallId() + " " + conferenceEvent.getMemberCount()); Log.info("RayoComponent notifyConferenceMonitors looking for call " + conferenceEvent.getCallId() + " " + conferenceEvent.getMemberCount());
ConferenceManager conferenceManager = ConferenceManager.findConferenceManager(conferenceEvent.getConferenceId());
CallHandler callHandler = CallHandler.findCall(conferenceEvent.getCallId()); CallHandler callHandler = CallHandler.findCall(conferenceEvent.getCallId());
if (callHandler != null) if (callHandler != null)
...@@ -1185,13 +1167,15 @@ public class RayoComponent extends AbstractComponent ...@@ -1185,13 +1167,15 @@ public class RayoComponent extends AbstractComponent
if (callParticipant != null) if (callParticipant != null)
{ {
Log.info("RayoComponent notifyConferenceMonitors found owner " + callParticipant.getCallOwner()); int memberCount = conferenceManager.getMemberList().size();
Log.info("RayoComponent notifyConferenceMonitors found owner " + callParticipant.getCallOwner() + " " + memberCount);
String groupName = ConferenceManager.getDisplayName(conferenceEvent.getConferenceId()); String groupName = ConferenceManager.getDisplayName(conferenceEvent.getConferenceId());
if (groupName == null) if (groupName == null)
{ {
routeJoinEvent(callParticipant.getCallOwner(), callParticipant, conferenceEvent); routeJoinEvent(callParticipant.getCallOwner(), callParticipant, conferenceEvent, memberCount, groupName);
} else { } else {
...@@ -1203,23 +1187,16 @@ public class RayoComponent extends AbstractComponent ...@@ -1203,23 +1187,16 @@ public class RayoComponent extends AbstractComponent
for (ClientSession session : sessions) for (ClientSession session : sessions)
{ {
routeJoinEvent(memberJID.toString(), callParticipant, conferenceEvent); routeJoinEvent(memberJID.toString(), callParticipant, conferenceEvent, memberCount, groupName);
} }
} }
} }
} }
} }
try { if (conferenceManager.getMemberList().size() == 0) {
ConferenceManager conferenceManager = ConferenceManager.findConferenceManager(conferenceEvent.getConferenceId()); conferenceManager.recordConference(false, null, null);
conferenceManager.endConference(conferenceEvent.getConferenceId());
if (conferenceManager.getMemberList().size() == 0) {
conferenceManager.recordConference(false, null, null);
conferenceManager.endConference(conferenceEvent.getConferenceId());
}
} catch (Exception e) {
//e.printStackTrace();
} }
} }
...@@ -1230,25 +1207,57 @@ public class RayoComponent extends AbstractComponent ...@@ -1230,25 +1207,57 @@ public class RayoComponent extends AbstractComponent
} }
} }
private void routeJoinEvent(String callee, CallParticipant callParticipant, ConferenceEvent conferenceEvent) private void routeJoinEvent(String callee, CallParticipant callParticipant, ConferenceEvent conferenceEvent, int memberCount, String groupName)
{ {
Log.info( "RayoComponent routeJoinEvent " + callee);
Presence presence = new Presence(); Presence presence = new Presence();
presence.setFrom(conferenceEvent.getCallId() + "@rayo." + getDomain()); presence.setFrom(conferenceEvent.getCallId() + "@rayo." + getDomain());
presence.setTo(callee); presence.setTo(callee);
if (conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT)) Map<String, String> headers = callParticipant.getHeaders();
headers.put("call_owner", callParticipant.getCallOwner());
headers.put("call_id", conferenceEvent.getCallId());
headers.put("call_action", conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT) ? "leave" : "join");
headers.put("call_protocol", callParticipant.getProtocol());
headers.put("mixer_name", conferenceEvent.getConferenceId());
headers.put("group_name", groupName);
if (memberCount > 2) // conferencing state
{ {
UnjoinedEvent event = new UnjoinedEvent(null, conferenceEvent.getConferenceId(), JoinDestinationType.MIXER); if (conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT))
presence.getElement().add(rayoProvider.toXML(event)); {
UnjoinedEvent event = new UnjoinedEvent(null, conferenceEvent.getConferenceId(), JoinDestinationType.MIXER);
presence.getElement().add(rayoProvider.toXML(event));
finishCallRecord(callParticipant); } else {
JoinedEvent event = new JoinedEvent(null, conferenceEvent.getConferenceId(), JoinDestinationType.MIXER);
presence.getElement().add(rayoProvider.toXML(event));
}
} else { sendPacket(presence);
JoinedEvent event = new JoinedEvent(null, conferenceEvent.getConferenceId(), JoinDestinationType.MIXER);
presence.getElement().add(rayoProvider.toXML(event));
}
sendPacket(presence); } else { // caller with callee only
if (memberCount == 2) // callee
{
presence.getElement().add(rayoProvider.toXML(new AnsweredEvent(null, headers)));
sendPacket(presence);
} else {
if (conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT))
{
presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("HANGUP"), headers)));
sendPacket(presence);
finishCallRecord(callParticipant);
}
}
}
} }
......
...@@ -72,7 +72,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -72,7 +72,7 @@ Strophe.addConnectionPlugin('rayo',
digit: function(callId, key) digit: function(callId, key)
{ {
//console.log("digit " + callId + " " + key); //console.log("Rayo plugin digit " + callId + " " + key);
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});
...@@ -87,6 +87,26 @@ Strophe.addConnectionPlugin('rayo', ...@@ -87,6 +87,26 @@ Strophe.addConnectionPlugin('rayo',
}); });
}, },
join: function(mixer, headers)
{
//console.log('Rayo plugin join ' + mixer);
//console.log(headers)
if (this._isOffhook()) this._onhook();
this._offhook(mixer, headers, function()
{
});
},
leave: function(mixer)
{
//console.log('Rayo plugin leave ' + mixer);
this._onhook();
},
answer: function(callId, mixer, headers) answer: function(callId, mixer, headers)
{ {
//console.log('Rayo plugin accept ' + callId + " " + mixer); //console.log('Rayo plugin accept ' + callId + " " + mixer);
...@@ -94,7 +114,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -94,7 +114,7 @@ Strophe.addConnectionPlugin('rayo',
var that = this; var that = this;
//if (this._isOffhook()) this._onhook(); if (this._isOffhook()) this._onhook();
this._offhook(mixer, headers, function() this._offhook(mixer, headers, function()
{ {
...@@ -125,7 +145,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -125,7 +145,7 @@ Strophe.addConnectionPlugin('rayo',
}); });
}); });
}); });
}, },
dial: function(from, to, headers) dial: function(from, to, headers)
{ {
...@@ -175,8 +195,10 @@ Strophe.addConnectionPlugin('rayo', ...@@ -175,8 +195,10 @@ Strophe.addConnectionPlugin('rayo',
{ {
that.callbacks.onAccept( that.callbacks.onAccept(
{ {
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
join: function() {that.join(mixer, headers);},
leave: function() {that.leave(mixer);},
from: from, from: from,
to: to, to: to,
...@@ -302,7 +324,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -302,7 +324,7 @@ Strophe.addConnectionPlugin('rayo',
that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"})); that.pc2.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayRemotePort + " typ host generation 0"}));
that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"})); that.pc1.addIceCandidate(new RTCIceCandidate({sdpMLineIndex: "0", candidate: "a=candidate:3707591233 1 udp 2113937151 " + that.relayHost + " " + that.relayLocalPort + " typ host generation 0"}));
action(); if (action) action();
}); });
}, function (error) { }, function (error) {
...@@ -334,8 +356,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -334,8 +356,8 @@ Strophe.addConnectionPlugin('rayo',
_handlePresence: function(presence) _handlePresence: function(presence)
{ {
//console.log('Rayo plugin handlePresence'); console.log('Rayo plugin handlePresence');
//console.log(presence); console.log(presence);
var that = this; var that = this;
var from = $(presence).attr('from'); var from = $(presence).attr('from');
...@@ -375,6 +397,8 @@ Strophe.addConnectionPlugin('rayo', ...@@ -375,6 +397,8 @@ Strophe.addConnectionPlugin('rayo',
digit: function(tone) {that.digit(callId, tone);}, digit: function(tone) {that.digit(callId, tone);},
hangup: function() {that.hangup(callId);}, hangup: function() {that.hangup(callId);},
answer: function() {that.answer(callId, mixer, headers);}, answer: function() {that.answer(callId, mixer, headers);},
join: function() {that.join(mixer, headers);},
leave: function() {that.leave(mixer);},
from: callFrom, from: callFrom,
to: callTo, to: callTo,
...@@ -409,16 +433,19 @@ Strophe.addConnectionPlugin('rayo', ...@@ -409,16 +433,19 @@ Strophe.addConnectionPlugin('rayo',
}) })
$(presence).find('joined').each(function() $(presence).find('joined').each(function()
{ {
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId); var jid = Strophe.unescapeNode(callId);
var mixer = $(this).attr('mixer-name');
if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1)
if (jid == that._connection.jid)
{ {
if (that.callbacks && that.callbacks.onJoin) that.callbacks.onJoin(jid, $(this).attr('mixer-name')); if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
} }
if (that.callbacks && that.callbacks.onJoin) that.callbacks.onJoin(callId, jid, mixer);
} }
}); });
...@@ -428,20 +455,14 @@ Strophe.addConnectionPlugin('rayo', ...@@ -428,20 +455,14 @@ Strophe.addConnectionPlugin('rayo',
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId); var jid = Strophe.unescapeNode(callId);
var mixer = $(this).attr('mixer-name');
if (jid.indexOf("@") > -1 && jid.indexOf("/") > -1) if (jid == that._connection.jid)
{ {
if (that.callbacks && that.callbacks.onUnjoin) that.callbacks.onUnjoin(jid, $(this).attr('mixer-name')); if (that.callbacks && that.callbacks.onHook) that.callbacks.onHook();
} else {
if (callId.indexOf("rayo-incoming-") == 0)
{
that._onhook();
if (that.callbacks && that.callbacks.onEnd) that.callbacks.onEnd(callId, headers);
}
} }
if (that.callbacks && that.callbacks.onUnjoin) that.callbacks.onUnjoin(callId, jid, mixer);
} }
}); });
...@@ -450,7 +471,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -450,7 +471,7 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.onSpeaking) that.callbacks.onSpeaking(callId, headers); //if (that.callbacks && that.callbacks.onSpeaking) that.callbacks.onSpeaking(callId, headers);
} }
}); });
...@@ -459,7 +480,7 @@ Strophe.addConnectionPlugin('rayo', ...@@ -459,7 +480,7 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
if (that.callbacks && that.callbacks.offSpeaking) that.callbacks.offSpeaking(callId, headers); //if (that.callbacks && that.callbacks.offSpeaking) that.callbacks.offSpeaking(callId, headers);
} }
}); });
...@@ -477,13 +498,31 @@ Strophe.addConnectionPlugin('rayo', ...@@ -477,13 +498,31 @@ Strophe.addConnectionPlugin('rayo',
if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE) if ($(this).attr('xmlns') == Strophe.NS.RAYO_CORE)
{ {
var callId = Strophe.getNodeFromJid(from); var callId = Strophe.getNodeFromJid(from);
var jid = Strophe.unescapeNode(callId);
if (headers['call_protocol'] == "WebRtc") var busy = false;
if (jid.indexOf('@') > -1 && jid.indexOf('/') > -1)
{ {
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook(); if (headers.call_action == "join")
{
busy = jid != that._connection.jid;
} else {
busy = jid == that._connection.jid;
}
}
if (busy)
{
if (that.callbacks && that.callbacks.onHook) that.callbacks.onHook();
if (that.callbacks && that.callbacks.onBusy) that.callbacks.onBusy(callId, headers);
} else { } else {
if (that.callbacks && that.callbacks.offHook) that.callbacks.offHook();
if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers); if (that.callbacks && that.callbacks.onAnswer) that.callbacks.onAnswer(callId, headers);
} }
} }
......
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