Skip to content

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

Continues to separate JingleSessionPC.

Boris Grozevf52b1380ee13
diff --git a/modules/xmpp/JingleSession.js b/modules/xmpp/JingleSession.js
index b69b6fbc4f..1b40a9d85d 100644
--- a/modules/xmpp/JingleSession.js
+++ b/modules/xmpp/JingleSession.js
@@ -3,9 +3,125 @@
* 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
+function JingleSession(me, sid, connection, service, eventEmitter) {
+ /**
+ * Our JID.
+ */
+ this.me = me;
+
+ /**
+ * The Jingle session identifier.
+ */
+ this.sid = sid;
+
+ /**
+ * The XMPP connection.
+ */
+ this.connection = connection;
+
+ /**
+ * The XMPP service.
+ */
+ this.service = service;
+
+ /**
+ * The event emitter.
+ */
+ this.eventEmitter = eventEmitter;
+
+ /**
+ * Whether to use dripping or not. Dripping is sending trickle candidates
+ * not one-by-one.
+ * Note: currently we do not support 'false'.
+ */
this.usedrip = true;
+
+ /**
+ * When dripping is used, stores ICE candidates which are to be sent.
+ */
+ this.drip_container = [];
+
+ // Media constraints. Is this WebRTC only?
+ this.media_constraints = null;
+
+ // ICE servers config (RTCConfiguration?).
+ this.ice_config = {};
}
+/**
+ * Prepares this object to initiate a session.
+ * @param peerjid the JID of the remote peer.
+ * @param isInitiator whether we will be the Jingle initiator.
+ * @param media_constraints
+ * @param ice_config
+ */
+JingleSession.prototype.initialize = function(peerjid, isInitiator,
+ media_constraints, ice_config) {
+ this.media_constraints = media_constraints;
+ this.ice_config = ice_config;
+
+ if (this.state !== null) {
+ console.error('attempt to initiate on session ' + this.sid +
+ 'in state ' + this.state);
+ return;
+ }
+ this.state = 'pending';
+ this.initiator = isInitiator ? this.me : peerjid;
+ this.responder = !isInitiator ? this.me : peerjid;
+ this.peerjid = peerjid;
+
+ this.doInitialize();
+};
+
+/**
+ * Finishes initialization.
+ */
+JingleSession.prototype.doInitialize = function() {};
+
+/**
+ * Adds the ICE candidates found in the 'contents' array as remote candidates?
+ * Note: currently only used on transport-info
+ */
+JingleSession.prototype.addIceCandidates = function(contents) {};
+
+/**
+ * Handles an 'add-source' event.
+ *
+ * @param contents an array of Jingle 'content' elements.
+ */
+JingleSession.prototype.addSources = function(contents) {};
+
+/**
+ * Handles a 'remove-source' event.
+ *
+ * @param contents an array of Jingle 'content' elements.
+ */
+JingleSession.prototype.removeSources = function(contents) {};
+
+/**
+ * Terminates this Jingle session (stops sending media and closes the streams?)
+ */
+JingleSession.prototype.terminate = function() {};
+
+/**
+ * Sends a Jingle session-terminate message to the peer and terminates the
+ * session.
+ * @param reason
+ * @param text
+ */
+JingleSession.prototype.sendTerminate = function(reason, text) {};
+
+/**
+ * Handles an offer from the remote peer (prepares to accept a session).
+ * @param jingle the 'jingle' XML element.
+ */
+JingleSession.prototype.setOffer = function(jingle) {};
+
+/**
+ * Handles an answer from the remote peer (prepares to accept a session).
+ * @param jingle the 'jingle' XML element.
+ */
+JingleSession.prototype.setAnswer = function(jingle) {};
+
+
module.exports = JingleSession;
diff --git a/modules/xmpp/JingleSessionPC.js b/modules/xmpp/JingleSessionPC.js
index 74e2259c37..72da5b1c34 100644
--- a/modules/xmpp/JingleSessionPC.js
+++ b/modules/xmpp/JingleSessionPC.js
@@ -13,25 +13,14 @@ 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;
this.initiator = null;
this.responder = null;
- this.isInitiator = null;
this.peerjid = null;
this.state = null;
this.localSDP = null;
this.remoteSDP = null;
this.relayedStreams = [];
- this.startTime = null;
- this.stopTime = null;
- this.media_constraints = null;
this.pc_constraints = null;
- this.ice_config = {};
- this.drip_container = [];
- this.service = service;
- this.eventEmitter = eventEmitter;
this.usetrickle = true;
this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718
@@ -88,25 +77,15 @@ JingleSessionPC.prototype.updateModifySourcesQueue = function() {
}
};
-JingleSessionPC.prototype.initiate = function (peerjid, isInitiator) {
+JingleSessionPC.prototype.doInitialize = function () {
var self = this;
- if (this.state !== null) {
- console.error('attempt to initiate on session ' + this.sid +
- 'in state ' + this.state);
- return;
- }
- this.isInitiator = isInitiator;
- this.state = 'pending';
- this.initiator = isInitiator ? this.me : peerjid;
- this.responder = !isInitiator ? this.me : peerjid;
- this.peerjid = peerjid;
+
this.hadstuncandidate = false;
this.hadturncandidate = false;
this.lasticecandidate = false;
this.isreconnect = false;
- this.peerconnection
- = new TraceablePeerConnection(
+ this.peerconnection = new TraceablePeerConnection(
this.connection.jingle.ice_config,
this.connection.jingle.pc_constraints,
this);
@@ -147,7 +126,6 @@ JingleSessionPC.prototype.initiate = function (peerjid, isInitiator) {
self.updateModifySourcesQueue();
switch (self.peerconnection.iceConnectionState) {
case 'connected':
- self.startTime = new Date();
// Informs interested parties that the connection has been restored.
if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
@@ -157,7 +135,6 @@ JingleSessionPC.prototype.initiate = function (peerjid, isInitiator) {
break;
case 'disconnected':
self.isreconnect = true;
- self.stopTime = new Date();
// Informs interested parties that the connection has been interrupted.
if (self.peerconnection.signalingState === 'stable')
self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
diff --git a/modules/xmpp/strophe.jingle.js b/modules/xmpp/strophe.jingle.js
index 4c46963621..f1adc5f6bf 100644
--- a/modules/xmpp/strophe.jingle.js
+++ b/modules/xmpp/strophe.jingle.js
@@ -110,7 +110,7 @@ module.exports = function(XMPP, eventEmitter) {
sess.pc_constraints = this.pc_constraints;
sess.ice_config = this.ice_config;
- sess.initiate(fromJid, false);
+ sess.initialize(fromJid, false);
// FIXME: setRemoteDescription should only be done when this call is to be accepted
sess.setOffer($(iq).find('>jingle'));
@@ -200,7 +200,7 @@ module.exports = function(XMPP, eventEmitter) {
sess.pc_constraints = this.pc_constraints;
sess.ice_config = this.ice_config;
- sess.initiate(peerjid, true);
+ sess.initialize(peerjid, true);
this.sessions[sess.sid] = sess;
this.jid2session[sess.peerjid] = sess;
sess.sendOffer();