Starts to abstract JingleSession.

This commit is contained in:
Boris Grozev 2015-08-03 13:32:29 -05:00
parent deaff6af5b
commit baf720c553
3 changed files with 28 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;