浏览代码

Starts to abstract JingleSession.

master
Boris Grozev 10 年前
父节点
当前提交
baf720c553
共有 3 个文件被更改,包括 28 次插入7 次删除
  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 查看文件

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 查看文件

1
 /* jshint -W117 */
1
 /* jshint -W117 */
2
+var JingleSession = require("./JingleSession");
2
 var TraceablePeerConnection = require("./TraceablePeerConnection");
3
 var TraceablePeerConnection = require("./TraceablePeerConnection");
3
 var SDPDiffer = require("./SDPDiffer");
4
 var SDPDiffer = require("./SDPDiffer");
4
 var SDPUtil = require("./SDPUtil");
5
 var SDPUtil = require("./SDPUtil");
11
 
12
 
12
 // Jingle stuff
13
 // Jingle stuff
13
 function JingleSessionPC(me, sid, connection, service, eventEmitter) {
14
 function JingleSessionPC(me, sid, connection, service, eventEmitter) {
15
+    JingleSession.call(this, me, sid, connection, service, eventEmitter);
14
     this.me = me;
16
     this.me = me;
15
     this.sid = sid;
17
     this.sid = sid;
16
     this.connection = connection;
18
     this.connection = connection;
33
 
35
 
34
     this.usetrickle = true;
36
     this.usetrickle = true;
35
     this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718
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
     this.hadstuncandidate = false;
39
     this.hadstuncandidate = false;
39
     this.hadturncandidate = false;
40
     this.hadturncandidate = false;
65
     // stable and the ice connection state is connected.
66
     // stable and the ice connection state is connected.
66
     this.modifySourcesQueue.pause();
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
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
81
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
70
     var signalingState = this.peerconnection.signalingState;
82
     var signalingState = this.peerconnection.signalingState;
339
                     initiator: this.initiator,
351
                     initiator: this.initiator,
340
                     sid: this.sid});
352
                     sid: this.sid});
341
             this.localSDP = new SDP(this.peerconnection.localDescription.sdp);
353
             this.localSDP = new SDP(this.peerconnection.localDescription.sdp);
342
-            var self = this;
343
             var sendJingle = function (ssrc) {
354
             var sendJingle = function (ssrc) {
344
                 if(!ssrc)
355
                 if(!ssrc)
345
                     ssrc = {};
356
                     ssrc = {};
368
                         JingleSessionPC.onJingleError(self.sid, error);
379
                         JingleSessionPC.onJingleError(self.sid, error);
369
                     },
380
                     },
370
                     10000);
381
                     10000);
371
-            }
382
+            };
372
             sendJingle();
383
             sendJingle();
373
         }
384
         }
374
         this.lasticecandidate = true;
385
         this.lasticecandidate = true;

+ 3
- 4
modules/xmpp/strophe.jingle.js 查看文件

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

正在加载...
取消
保存