Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Starts to abstract JingleSession.

Boris Grozevbaf720c553d7
diff --git a/modules/xmpp/JingleSession.js b/modules/xmpp/JingleSession.js
new file mode 100644
index 0000000000..b69b6fbc4f
--- /dev/null
+++ b/modules/xmpp/JingleSession.js
@@ -0,0 +1,11 @@
+/*
+ * JingleSession provides an API to manage a single Jingle session. We will
+ * have different implementations depending on the underlying interface used
+ * (i.e. WebRTC and ORTC) and here we hold the code common to all of them.
+ */
+function JingleSession() {
+ // dripping is sending trickle candidates not one-by-one
+ this.usedrip = true;
+}
+
+module.exports = JingleSession;
diff --git a/modules/xmpp/JingleSessionPC.js b/modules/xmpp/JingleSessionPC.js
index 5dd8a9c957..74e2259c37 100644
--- a/modules/xmpp/JingleSessionPC.js
+++ b/modules/xmpp/JingleSessionPC.js
@@ -1,4 +1,5 @@
/* jshint -W117 */
+var JingleSession = require("./JingleSession");
var TraceablePeerConnection = require("./TraceablePeerConnection");
var SDPDiffer = require("./SDPDiffer");
var SDPUtil = require("./SDPUtil");
@@ -11,6 +12,7 @@ var SSRCReplacement = require("./LocalSSRCReplacement");
// Jingle stuff
function JingleSessionPC(me, sid, connection, service, eventEmitter) {
+ JingleSession.call(this, me, sid, connection, service, eventEmitter);
this.me = me;
this.sid = sid;
this.connection = connection;
@@ -33,7 +35,6 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
this.usetrickle = true;
this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718
- this.usedrip = false; // dripping is sending trickle candidates not one-by-one
this.hadstuncandidate = false;
this.hadturncandidate = false;
@@ -65,6 +66,17 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
// stable and the ice connection state is connected.
this.modifySourcesQueue.pause();
}
+JingleSessionPC.prototype = JingleSession.prototype;
+JingleSessionPC.prototype.constructor = JingleSessionPC;
+
+
+JingleSessionPC.prototype.setOffer = function(offer) {
+ this.setRemoteDescription(offer, 'offer');
+};
+
+JingleSessionPC.prototype.setAnswer = function(answer) {
+ this.setRemoteDescription(answer, 'answer');
+};
JingleSessionPC.prototype.updateModifySourcesQueue = function() {
var signalingState = this.peerconnection.signalingState;
@@ -339,7 +351,6 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
initiator: this.initiator,
sid: this.sid});
this.localSDP = new SDP(this.peerconnection.localDescription.sdp);
- var self = this;
var sendJingle = function (ssrc) {
if(!ssrc)
ssrc = {};
@@ -368,7 +379,7 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
JingleSessionPC.onJingleError(self.sid, error);
},
10000);
- }
+ };
sendJingle();
}
this.lasticecandidate = true;
diff --git a/modules/xmpp/strophe.jingle.js b/modules/xmpp/strophe.jingle.js
index ec0e4153dd..4c46963621 100644
--- a/modules/xmpp/strophe.jingle.js
+++ b/modules/xmpp/strophe.jingle.js
@@ -112,14 +112,14 @@ module.exports = function(XMPP, eventEmitter) {
sess.initiate(fromJid, false);
// FIXME: setRemoteDescription should only be done when this call is to be accepted
- sess.setRemoteDescription($(iq).find('>jingle'), 'offer');
+ sess.setOffer($(iq).find('>jingle'));
this.sessions[sess.sid] = sess;
this.jid2session[sess.peerjid] = sess;
// the callback should either
// .sendAnswer and .accept
- // or .sendTerminate -- not necessarily synchronus
+ // or .sendTerminate -- not necessarily synchronous
// TODO: do we check activecall == null?
this.connection.jingle.activecall = sess;
@@ -129,12 +129,11 @@ module.exports = function(XMPP, eventEmitter) {
// TODO: check affiliation and/or role
console.log('emuc data for', sess.peerjid,
this.connection.emuc.members[sess.peerjid]);
- sess.usedrip = true; // not-so-naive trickle ice
sess.sendAnswer();
sess.accept();
break;
case 'session-accept':
- sess.setRemoteDescription($(iq).find('>jingle'), 'answer');
+ sess.setAnswer($(iq).find('>jingle'));
sess.accept();
$(document).trigger('callaccepted.jingle', [sess.sid]);
break;