Pārlūkot izejas kodu

ref(JingleSessionPC): detach from room.options

The options are coming from the config anyway.
master
paweldomas 7 gadus atpakaļ
vecāks
revīzija
e4bc78422c

+ 3
- 4
JitsiConference.js Parādīt failu

@@ -1587,7 +1587,7 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(
1587 1587
             value: now
1588 1588
         }));
1589 1589
     try {
1590
-        jingleSession.initialize(false /* initiator */, this.room, this.rtc);
1590
+        jingleSession.initialize(this.room, this.rtc, this.options.config);
1591 1591
     } catch (error) {
1592 1592
         GlobalOnErrorHandler.callErrorHandler(error);
1593 1593
     }
@@ -2332,8 +2332,7 @@ JitsiConference.prototype._acceptP2PIncomingCall = function(
2332 2332
     // Accept the offer
2333 2333
     this.p2pJingleSession = jingleSession;
2334 2334
 
2335
-    this.p2pJingleSession.initialize(
2336
-        false /* initiator */, this.room, this.rtc);
2335
+    this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2337 2336
 
2338 2337
     logger.info('Starting CallStats for P2P connection...');
2339 2338
 
@@ -2634,7 +2633,7 @@ JitsiConference.prototype._startP2PSession = function(remoteJid) {
2634 2633
     logger.info(
2635 2634
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2636 2635
 
2637
-    this.p2pJingleSession.initialize(true /* initiator */, this.room, this.rtc);
2636
+    this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2638 2637
 
2639 2638
     logger.info('Starting CallStats for P2P connection...');
2640 2639
 

+ 21
- 7
modules/xmpp/JingleSession.js Parādīt failu

@@ -23,6 +23,8 @@ export default class JingleSession {
23 23
      * the PeerConnection onCreateAnswer/Offer as defined by the WebRTC.
24 24
      * @param {Object} iceConfig the ICE servers config object as defined by
25 25
      * the WebRTC. Passed to the PeerConnection's constructor.
26
+     * @param {boolean} isInitiator indicates if it will be the side which
27
+     * initiates the session.
26 28
      */
27 29
     constructor(
28 30
             sid,
@@ -30,7 +32,8 @@ export default class JingleSession {
30 32
             remoteJid,
31 33
             connection,
32 34
             mediaConstraints,
33
-            iceConfig) {
35
+            iceConfig,
36
+            isInitiator) {
34 37
         this.sid = sid;
35 38
         this.localJid = localJid;
36 39
         this.remoteJid = remoteJid;
@@ -38,6 +41,17 @@ export default class JingleSession {
38 41
         this.mediaConstraints = mediaConstraints;
39 42
         this.iceConfig = iceConfig;
40 43
 
44
+        /**
45
+         * Indicates whether this instance is an initiator or an answerer of
46
+         * the Jingle session.
47
+         * @type {boolean}
48
+         */
49
+        this.isInitiator = isInitiator;
50
+
51
+        this.initiator = this.isInitiator ? this.localJid : this.remoteJid;
52
+
53
+        this.responder = this.isInitiator ? this.remoteJid : this.localJid;
54
+
41 55
         /**
42 56
          * Whether to use dripping or not. Dripping is sending trickle
43 57
          * candidates not one-by-one.
@@ -72,12 +86,13 @@ export default class JingleSession {
72 86
 
73 87
     /**
74 88
      * Prepares this object to initiate a session.
75
-     * @param {boolean} isInitiator whether we will be the Jingle initiator.
76 89
      * @param {ChatRoom} room the chat room for the conference associated with
77 90
      * this session
78 91
      * @param {RTC} rtc the RTC service instance
92
+     * @param {object} options - the options, see implementing class's
93
+     * {@link #doInitialize} description for more details.
79 94
      */
80
-    initialize(isInitiator, room, rtc) {
95
+    initialize(room, rtc, options) {
81 96
         if (this.state !== null) {
82 97
             const errmsg
83 98
                 = `attempt to initiate on session ${this.sid}
@@ -89,17 +104,16 @@ export default class JingleSession {
89 104
         this.room = room;
90 105
         this.rtc = rtc;
91 106
         this.state = JingleSessionState.PENDING;
92
-        this.initiator = isInitiator ? this.localJid : this.remoteJid;
93
-        this.responder = isInitiator ? this.remoteJid : this.localJid;
94
-        this.doInitialize();
107
+        this.doInitialize(options);
95 108
     }
96 109
 
97 110
     /**
98 111
      * The implementing class finishes initialization here. Called at the end of
99 112
      * {@link initialize}.
113
+     * @param {Object} options - The options specific to the implementing class.
100 114
      * @protected
101 115
      */
102
-    doInitialize() {} // eslint-disable-line no-empty-function
116
+    doInitialize(options) { } // eslint-disable-line no-unused-vars, no-empty-function, max-len
103 117
 
104 118
     /* eslint-disable no-unused-vars, no-empty-function */
105 119
 

+ 62
- 53
modules/xmpp/JingleSessionPC.js Parādīt failu

@@ -36,6 +36,31 @@ const IQ_TIMEOUT = 10000;
36 36
  */
37 37
 const DEFAULT_MAX_STATS = 300;
38 38
 
39
+/**
40
+ * @typedef {Object} JingleSessionPCOptions
41
+ * @property {Object} abTesting - A/B testing related options (ask George).
42
+ * @property {boolean} abTesting.enableSuspendVideoTest - enables the suspend
43
+ * video test ?(ask George).
44
+ * @property {boolean} disableH264 - Described in the config.js[1].
45
+ * @property {boolean} disableRtx - Described in the config.js[1].
46
+ * @property {boolean} disableSimulcast - Described in the config.js[1].
47
+ * @property {boolean} enableLayerSuspension - Described in the config.js[1].
48
+ * @property {boolean} failICE - it's an option used in the tests. Set to
49
+ * <tt>true</tt> to block any real candidates and make the ICE fail.
50
+ * @property {boolean} gatherStats - Described in the config.js[1].
51
+ * @property {object} p2p - Peer to peer related options (FIXME those could be
52
+ * fetched from config.p2p on the upper level).
53
+ * @property {boolean} p2p.disableH264 - Described in the config.js[1].
54
+ * @property {boolean} p2p.preferH264 - Described in the config.js[1].
55
+ * @property {boolean} preferH264 - Described in the config.js[1].
56
+ * @property {Object} testing - Testing and/or experimental options.
57
+ * @property {boolean} testing.enableFirefoxSimulcast - Described in the
58
+ * config.js[1].
59
+ * @property {boolean} webrtcIceUdpDisable - Described in the config.js[1].
60
+ * @property {boolean} webrtcIceTcpDisable - Described in the config.js[1].
61
+ *
62
+ * [1]: https://github.com/jitsi/jitsi-meet/blob/master/config.js
63
+ */
39 64
 /**
40 65
  *
41 66
  */
@@ -82,16 +107,8 @@ export default class JingleSessionPC extends JingleSession {
82 107
      * @param {boolean} isP2P indicates whether this instance is
83 108
      * meant to be used in a direct, peer to peer connection or <tt>false</tt>
84 109
      * if it's a JVB connection.
85
-     * @param {boolean} isInitiator indicates whether or not we are the side
86
-     * which sends the 'session-initiate'.
87
-     * @param {object} options a set of config options
88
-     * @param {boolean} options.webrtcIceUdpDisable <tt>true</tt> to block UDP
89
-     * candidates.
90
-     * @param {boolean} options.webrtcIceTcpDisable <tt>true</tt> to block TCP
91
-     * candidates.
92
-     * @param {boolean} options.failICE it's an option used in the tests. Set to
93
-     * <tt>true</tt> to block any real candidates and make the ICE fail.
94
-     *
110
+     * @param {boolean} isInitiator indicates if it will be the side which
111
+     * initiates the session.
95 112
      * @constructor
96 113
      *
97 114
      * @implements {SignalingLayer}
@@ -104,10 +121,11 @@ export default class JingleSessionPC extends JingleSession {
104 121
             mediaConstraints,
105 122
             iceConfig,
106 123
             isP2P,
107
-            isInitiator,
108
-            options) {
124
+            isInitiator) {
109 125
         super(
110
-            sid, localJid, remoteJid, connection, mediaConstraints, iceConfig);
126
+            sid,
127
+            localJid,
128
+            remoteJid, connection, mediaConstraints, iceConfig, isInitiator);
111 129
 
112 130
         /**
113 131
          * Stores result of {@link window.performance.now()} at the time when
@@ -169,13 +187,6 @@ export default class JingleSessionPC extends JingleSession {
169 187
         this.lasticecandidate = false;
170 188
         this.closed = false;
171 189
 
172
-        /**
173
-         * Indicates whether this instance is an initiator or an answerer of
174
-         * the Jingle session.
175
-         * @type {boolean}
176
-         */
177
-        this.isInitiator = isInitiator;
178
-
179 190
         /**
180 191
          * Indicates whether or not this <tt>JingleSessionPC</tt> is used in
181 192
          * a peer to peer type of session.
@@ -190,16 +201,6 @@ export default class JingleSessionPC extends JingleSession {
190 201
          */
191 202
         this.signalingLayer = new SignalingLayerImpl();
192 203
 
193
-        this.webrtcIceUdpDisable = Boolean(options.webrtcIceUdpDisable);
194
-        this.webrtcIceTcpDisable = Boolean(options.webrtcIceTcpDisable);
195
-
196
-        /**
197
-         * Flag used to enforce ICE failure through the URL parameter for
198
-         * the automatic testing purpose.
199
-         * @type {boolean}
200
-         */
201
-        this.failICE = Boolean(options.failICE);
202
-
203 204
         this.modificationQueue
204 205
             = async.queue(this._processQueueTasks.bind(this), 1);
205 206
 
@@ -242,32 +243,41 @@ export default class JingleSessionPC extends JingleSession {
242 243
     }
243 244
 
244 245
     /**
245
-     *
246
+     * @inheritDoc
247
+     * @param {JingleSessionPCOptions} options  - a set of config options.
246 248
      */
247
-    doInitialize() {
249
+    doInitialize(options) {
250
+        this.failICE = Boolean(options.failICE);
248 251
         this.lasticecandidate = false;
252
+        this.options = options;
249 253
 
250
-        // True if reconnect is in progress
254
+        /**
255
+         * {@code true} if reconnect is in progress.
256
+         * @type {boolean}
257
+         */
251 258
         this.isReconnect = false;
252 259
 
253
-        // Set to true if the connection was ever stable
260
+        /**
261
+         * Set to {@code true} if the connection was ever stable
262
+         * @type {boolean}
263
+         */
254 264
         this.wasstable = false;
265
+        this.webrtcIceUdpDisable = Boolean(options.webrtcIceUdpDisable);
266
+        this.webrtcIceTcpDisable = Boolean(options.webrtcIceTcpDisable);
255 267
 
256
-        const pcOptions = { disableRtx: this.room.options.disableRtx };
268
+        const pcOptions = { disableRtx: options.disableRtx };
257 269
 
258
-        if (this.room.options.gatherStats) {
270
+        if (options.gatherStats) {
259 271
             pcOptions.maxstats = DEFAULT_MAX_STATS;
260 272
         }
261 273
 
262 274
         if (this.isP2P) {
263 275
             // simulcast needs to be disabled for P2P (121) calls
264 276
             pcOptions.disableSimulcast = true;
265
-            pcOptions.disableH264
266
-                = this.room.options.p2p && this.room.options.p2p.disableH264;
267
-            pcOptions.preferH264
268
-                = this.room.options.p2p && this.room.options.p2p.preferH264;
277
+            pcOptions.disableH264 = options.p2p && options.p2p.disableH264;
278
+            pcOptions.preferH264 = options.p2p && options.p2p.preferH264;
269 279
 
270
-            const abtestSuspendVideo = this._abtestSuspendVideoEnabled();
280
+            const abtestSuspendVideo = this._abtestSuspendVideoEnabled(options);
271 281
 
272 282
             if (typeof abtestSuspendVideo !== 'undefined') {
273 283
                 pcOptions.abtestSuspendVideo = abtestSuspendVideo;
@@ -275,15 +285,12 @@ export default class JingleSessionPC extends JingleSession {
275 285
         } else {
276 286
             // H264 does not support simulcast, so it needs to be disabled.
277 287
             pcOptions.disableSimulcast
278
-                = this.room.options.disableSimulcast
279
-                    || (this.room.options.preferH264
280
-                            && !this.room.options.disableH264);
281
-            pcOptions.preferH264 = this.room.options.preferH264;
288
+                = options.disableSimulcast
289
+                    || (options.preferH264 && !options.disableH264);
290
+            pcOptions.preferH264 = options.preferH264;
282 291
             pcOptions.enableFirefoxSimulcast
283
-                = this.room.options.testing
284
-                    && this.room.options.testing.enableFirefoxSimulcast;
285
-            pcOptions.enableLayerSuspension
286
-                = this.room.options.enableLayerSuspension;
292
+                = options.testing && options.testing.enableFirefoxSimulcast;
293
+            pcOptions.enableLayerSuspension = options.enableLayerSuspension;
287 294
         }
288 295
 
289 296
         this.peerconnection
@@ -480,7 +487,7 @@ export default class JingleSessionPC extends JingleSession {
480 487
         // The signaling layer will bind it's listeners at this point
481 488
         this.signalingLayer.setChatRoom(this.room);
482 489
 
483
-        if (!this.isP2P && this.room.options.enableLayerSuspension) {
490
+        if (!this.isP2P && options.enableLayerSuspension) {
484 491
             // If this is the bridge session, we'll listen for
485 492
             // IS_SELECTED_CHANGED events and notify the peer connection
486 493
             this.rtc.addListener(RTCEvents.IS_SELECTED_CHANGED,
@@ -953,6 +960,8 @@ export default class JingleSessionPC extends JingleSession {
953 960
                         `Error renegotiating after setting new remote ${
954 961
                             this.isInitiator ? 'answer: ' : 'offer: '}${error}`,
955 962
                         newRemoteSdp);
963
+
964
+                    // FIXME remove static method - there's no need
956 965
                     JingleSessionPC.onJingleFatalError(this, error);
957 966
                     finishedCallback(error);
958 967
                 });
@@ -2240,10 +2249,10 @@ export default class JingleSessionPC extends JingleSession {
2240 2249
      * If the A/B test for suspend video is disabled according to the room's
2241 2250
      * configuration, returns undefined. Otherwise returns a boolean which
2242 2251
      * indicates whether the suspend video option should be enabled or disabled.
2252
+     * @param {JingleSessionPCOptions} options - The config options.
2243 2253
      */
2244
-    _abtestSuspendVideoEnabled() {
2245
-        if (!this.room.options.abTesting
2246
-            || !this.room.options.abTesting.enableSuspendVideoTest) {
2254
+    _abtestSuspendVideoEnabled({ abTesting }) {
2255
+        if (!abTesting || !abTesting.enableSuspendVideoTest) {
2247 2256
             return;
2248 2257
         }
2249 2258
 

+ 2
- 4
modules/xmpp/strophe.jingle.js Parādīt failu

@@ -162,8 +162,7 @@ class JingleConnectionPlugin extends ConnectionPlugin {
162 162
                     this.mediaConstraints,
163 163
                     isP2P ? this.p2pIceConfig : this.jvbIceConfig,
164 164
                     isP2P,
165
-                    /* initiator */ false,
166
-                    this.xmpp.options);
165
+                    /* initiator */ false);
167 166
 
168 167
             this.sessions[sess.sid] = sess;
169 168
 
@@ -264,8 +263,7 @@ class JingleConnectionPlugin extends ConnectionPlugin {
264 263
                 this.mediaConstraints,
265 264
                 this.p2pIceConfig,
266 265
                 /* P2P */ true,
267
-                /* initiator */ true,
268
-                this.xmpp.options);
266
+                /* initiator */ true);
269 267
 
270 268
         this.sessions[sess.sid] = sess;
271 269
 

Notiek ielāde…
Atcelt
Saglabāt