jiti-meet/modules/xmpp/JingleSession.js

128 lines
3.2 KiB
JavaScript
Raw Normal View History

2015-08-03 18:32:29 +00:00
/*
* 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.
*/
2015-08-10 21:37:12 +00:00
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'.
*/
2015-08-03 18:32:29 +00:00
this.usedrip = true;
2015-08-10 21:37:12 +00:00
/**
* 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 = {};
2015-08-03 18:32:29 +00:00
}
2015-08-10 21:37:12 +00:00
/**
* 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) {};
2015-08-03 18:32:29 +00:00
module.exports = JingleSession;