Browse Source

Starts to abstract JingleSession.

master
Boris Grozev 10 years ago
parent
commit
baf720c553
3 changed files with 28 additions and 7 deletions
  1. 11
    0
      modules/xmpp/JingleSession.js
  2. 14
    3
      modules/xmpp/JingleSessionPC.js
  3. 3
    4
      modules/xmpp/strophe.jingle.js

+ 11
- 0
modules/xmpp/JingleSession.js View File

@@ -0,0 +1,11 @@
1
+/*
2
+ * JingleSession provides an API to manage a single Jingle session. We will
3
+ * have different implementations depending on the underlying interface used
4
+ * (i.e. WebRTC and ORTC) and here we hold the code common to all of them.
5
+ */
6
+function JingleSession() {
7
+    // dripping is sending trickle candidates not one-by-one
8
+    this.usedrip = true;
9
+}
10
+
11
+module.exports = JingleSession;

+ 14
- 3
modules/xmpp/JingleSessionPC.js View File

@@ -1,4 +1,5 @@
1 1
 /* jshint -W117 */
2
+var JingleSession = require("./JingleSession");
2 3
 var TraceablePeerConnection = require("./TraceablePeerConnection");
3 4
 var SDPDiffer = require("./SDPDiffer");
4 5
 var SDPUtil = require("./SDPUtil");
@@ -11,6 +12,7 @@ var SSRCReplacement = require("./LocalSSRCReplacement");
11 12
 
12 13
 // Jingle stuff
13 14
 function JingleSessionPC(me, sid, connection, service, eventEmitter) {
15
+    JingleSession.call(this, me, sid, connection, service, eventEmitter);
14 16
     this.me = me;
15 17
     this.sid = sid;
16 18
     this.connection = connection;
@@ -33,7 +35,6 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
33 35
 
34 36
     this.usetrickle = true;
35 37
     this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718
36
-    this.usedrip = false; // dripping is sending trickle candidates not one-by-one
37 38
 
38 39
     this.hadstuncandidate = false;
39 40
     this.hadturncandidate = false;
@@ -65,6 +66,17 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
65 66
     // stable and the ice connection state is connected.
66 67
     this.modifySourcesQueue.pause();
67 68
 }
69
+JingleSessionPC.prototype = JingleSession.prototype;
70
+JingleSessionPC.prototype.constructor = JingleSessionPC;
71
+
72
+
73
+JingleSessionPC.prototype.setOffer = function(offer) {
74
+    this.setRemoteDescription(offer, 'offer');
75
+};
76
+
77
+JingleSessionPC.prototype.setAnswer = function(answer) {
78
+    this.setRemoteDescription(answer, 'answer');
79
+};
68 80
 
69 81
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
70 82
     var signalingState = this.peerconnection.signalingState;
@@ -339,7 +351,6 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
339 351
                     initiator: this.initiator,
340 352
                     sid: this.sid});
341 353
             this.localSDP = new SDP(this.peerconnection.localDescription.sdp);
342
-            var self = this;
343 354
             var sendJingle = function (ssrc) {
344 355
                 if(!ssrc)
345 356
                     ssrc = {};
@@ -368,7 +379,7 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
368 379
                         JingleSessionPC.onJingleError(self.sid, error);
369 380
                     },
370 381
                     10000);
371
-            }
382
+            };
372 383
             sendJingle();
373 384
         }
374 385
         this.lasticecandidate = true;

+ 3
- 4
modules/xmpp/strophe.jingle.js View File

@@ -112,14 +112,14 @@ module.exports = function(XMPP, eventEmitter) {
112 112
 
113 113
                     sess.initiate(fromJid, false);
114 114
                     // FIXME: setRemoteDescription should only be done when this call is to be accepted
115
-                    sess.setRemoteDescription($(iq).find('>jingle'), 'offer');
115
+                    sess.setOffer($(iq).find('>jingle'));
116 116
 
117 117
                     this.sessions[sess.sid] = sess;
118 118
                     this.jid2session[sess.peerjid] = sess;
119 119
 
120 120
                     // the callback should either
121 121
                     // .sendAnswer and .accept
122
-                    // or .sendTerminate -- not necessarily synchronus
122
+                    // or .sendTerminate -- not necessarily synchronous
123 123
 
124 124
                     // TODO: do we check activecall == null?
125 125
                     this.connection.jingle.activecall = sess;
@@ -129,12 +129,11 @@ module.exports = function(XMPP, eventEmitter) {
129 129
                     // TODO: check affiliation and/or role
130 130
                     console.log('emuc data for', sess.peerjid,
131 131
                         this.connection.emuc.members[sess.peerjid]);
132
-                    sess.usedrip = true; // not-so-naive trickle ice
133 132
                     sess.sendAnswer();
134 133
                     sess.accept();
135 134
                     break;
136 135
                 case 'session-accept':
137
-                    sess.setRemoteDescription($(iq).find('>jingle'), 'answer');
136
+                    sess.setAnswer($(iq).find('>jingle'));
138 137
                     sess.accept();
139 138
                     $(document).trigger('callaccepted.jingle', [sess.sid]);
140 139
                     break;

Loading…
Cancel
Save