ソースを参照

ref(JingleSessionPC): detach from room.options

The options are coming from the config anyway.
tags/v0.0.2
paweldomas 7年前
コミット
e4bc78422c

+ 3
- 4
JitsiConference.js ファイルの表示

1587
             value: now
1587
             value: now
1588
         }));
1588
         }));
1589
     try {
1589
     try {
1590
-        jingleSession.initialize(false /* initiator */, this.room, this.rtc);
1590
+        jingleSession.initialize(this.room, this.rtc, this.options.config);
1591
     } catch (error) {
1591
     } catch (error) {
1592
         GlobalOnErrorHandler.callErrorHandler(error);
1592
         GlobalOnErrorHandler.callErrorHandler(error);
1593
     }
1593
     }
2332
     // Accept the offer
2332
     // Accept the offer
2333
     this.p2pJingleSession = jingleSession;
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
     logger.info('Starting CallStats for P2P connection...');
2337
     logger.info('Starting CallStats for P2P connection...');
2339
 
2338
 
2634
     logger.info(
2633
     logger.info(
2635
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
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
     logger.info('Starting CallStats for P2P connection...');
2638
     logger.info('Starting CallStats for P2P connection...');
2640
 
2639
 

+ 21
- 7
modules/xmpp/JingleSession.js ファイルの表示

23
      * the PeerConnection onCreateAnswer/Offer as defined by the WebRTC.
23
      * the PeerConnection onCreateAnswer/Offer as defined by the WebRTC.
24
      * @param {Object} iceConfig the ICE servers config object as defined by
24
      * @param {Object} iceConfig the ICE servers config object as defined by
25
      * the WebRTC. Passed to the PeerConnection's constructor.
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
     constructor(
29
     constructor(
28
             sid,
30
             sid,
30
             remoteJid,
32
             remoteJid,
31
             connection,
33
             connection,
32
             mediaConstraints,
34
             mediaConstraints,
33
-            iceConfig) {
35
+            iceConfig,
36
+            isInitiator) {
34
         this.sid = sid;
37
         this.sid = sid;
35
         this.localJid = localJid;
38
         this.localJid = localJid;
36
         this.remoteJid = remoteJid;
39
         this.remoteJid = remoteJid;
38
         this.mediaConstraints = mediaConstraints;
41
         this.mediaConstraints = mediaConstraints;
39
         this.iceConfig = iceConfig;
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
          * Whether to use dripping or not. Dripping is sending trickle
56
          * Whether to use dripping or not. Dripping is sending trickle
43
          * candidates not one-by-one.
57
          * candidates not one-by-one.
72
 
86
 
73
     /**
87
     /**
74
      * Prepares this object to initiate a session.
88
      * Prepares this object to initiate a session.
75
-     * @param {boolean} isInitiator whether we will be the Jingle initiator.
76
      * @param {ChatRoom} room the chat room for the conference associated with
89
      * @param {ChatRoom} room the chat room for the conference associated with
77
      * this session
90
      * this session
78
      * @param {RTC} rtc the RTC service instance
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
         if (this.state !== null) {
96
         if (this.state !== null) {
82
             const errmsg
97
             const errmsg
83
                 = `attempt to initiate on session ${this.sid}
98
                 = `attempt to initiate on session ${this.sid}
89
         this.room = room;
104
         this.room = room;
90
         this.rtc = rtc;
105
         this.rtc = rtc;
91
         this.state = JingleSessionState.PENDING;
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
      * The implementing class finishes initialization here. Called at the end of
111
      * The implementing class finishes initialization here. Called at the end of
99
      * {@link initialize}.
112
      * {@link initialize}.
113
+     * @param {Object} options - The options specific to the implementing class.
100
      * @protected
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
     /* eslint-disable no-unused-vars, no-empty-function */
118
     /* eslint-disable no-unused-vars, no-empty-function */
105
 
119
 

+ 62
- 53
modules/xmpp/JingleSessionPC.js ファイルの表示

36
  */
36
  */
37
 const DEFAULT_MAX_STATS = 300;
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
      * @param {boolean} isP2P indicates whether this instance is
107
      * @param {boolean} isP2P indicates whether this instance is
83
      * meant to be used in a direct, peer to peer connection or <tt>false</tt>
108
      * meant to be used in a direct, peer to peer connection or <tt>false</tt>
84
      * if it's a JVB connection.
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
      * @constructor
112
      * @constructor
96
      *
113
      *
97
      * @implements {SignalingLayer}
114
      * @implements {SignalingLayer}
104
             mediaConstraints,
121
             mediaConstraints,
105
             iceConfig,
122
             iceConfig,
106
             isP2P,
123
             isP2P,
107
-            isInitiator,
108
-            options) {
124
+            isInitiator) {
109
         super(
125
         super(
110
-            sid, localJid, remoteJid, connection, mediaConstraints, iceConfig);
126
+            sid,
127
+            localJid,
128
+            remoteJid, connection, mediaConstraints, iceConfig, isInitiator);
111
 
129
 
112
         /**
130
         /**
113
          * Stores result of {@link window.performance.now()} at the time when
131
          * Stores result of {@link window.performance.now()} at the time when
169
         this.lasticecandidate = false;
187
         this.lasticecandidate = false;
170
         this.closed = false;
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
          * Indicates whether or not this <tt>JingleSessionPC</tt> is used in
191
          * Indicates whether or not this <tt>JingleSessionPC</tt> is used in
181
          * a peer to peer type of session.
192
          * a peer to peer type of session.
190
          */
201
          */
191
         this.signalingLayer = new SignalingLayerImpl();
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
         this.modificationQueue
204
         this.modificationQueue
204
             = async.queue(this._processQueueTasks.bind(this), 1);
205
             = async.queue(this._processQueueTasks.bind(this), 1);
205
 
206
 
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
         this.lasticecandidate = false;
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
         this.isReconnect = false;
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
         this.wasstable = false;
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
             pcOptions.maxstats = DEFAULT_MAX_STATS;
271
             pcOptions.maxstats = DEFAULT_MAX_STATS;
260
         }
272
         }
261
 
273
 
262
         if (this.isP2P) {
274
         if (this.isP2P) {
263
             // simulcast needs to be disabled for P2P (121) calls
275
             // simulcast needs to be disabled for P2P (121) calls
264
             pcOptions.disableSimulcast = true;
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
             if (typeof abtestSuspendVideo !== 'undefined') {
282
             if (typeof abtestSuspendVideo !== 'undefined') {
273
                 pcOptions.abtestSuspendVideo = abtestSuspendVideo;
283
                 pcOptions.abtestSuspendVideo = abtestSuspendVideo;
275
         } else {
285
         } else {
276
             // H264 does not support simulcast, so it needs to be disabled.
286
             // H264 does not support simulcast, so it needs to be disabled.
277
             pcOptions.disableSimulcast
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
             pcOptions.enableFirefoxSimulcast
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
         this.peerconnection
296
         this.peerconnection
480
         // The signaling layer will bind it's listeners at this point
487
         // The signaling layer will bind it's listeners at this point
481
         this.signalingLayer.setChatRoom(this.room);
488
         this.signalingLayer.setChatRoom(this.room);
482
 
489
 
483
-        if (!this.isP2P && this.room.options.enableLayerSuspension) {
490
+        if (!this.isP2P && options.enableLayerSuspension) {
484
             // If this is the bridge session, we'll listen for
491
             // If this is the bridge session, we'll listen for
485
             // IS_SELECTED_CHANGED events and notify the peer connection
492
             // IS_SELECTED_CHANGED events and notify the peer connection
486
             this.rtc.addListener(RTCEvents.IS_SELECTED_CHANGED,
493
             this.rtc.addListener(RTCEvents.IS_SELECTED_CHANGED,
953
                         `Error renegotiating after setting new remote ${
960
                         `Error renegotiating after setting new remote ${
954
                             this.isInitiator ? 'answer: ' : 'offer: '}${error}`,
961
                             this.isInitiator ? 'answer: ' : 'offer: '}${error}`,
955
                         newRemoteSdp);
962
                         newRemoteSdp);
963
+
964
+                    // FIXME remove static method - there's no need
956
                     JingleSessionPC.onJingleFatalError(this, error);
965
                     JingleSessionPC.onJingleFatalError(this, error);
957
                     finishedCallback(error);
966
                     finishedCallback(error);
958
                 });
967
                 });
2240
      * If the A/B test for suspend video is disabled according to the room's
2249
      * If the A/B test for suspend video is disabled according to the room's
2241
      * configuration, returns undefined. Otherwise returns a boolean which
2250
      * configuration, returns undefined. Otherwise returns a boolean which
2242
      * indicates whether the suspend video option should be enabled or disabled.
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
             return;
2256
             return;
2248
         }
2257
         }
2249
 
2258
 

+ 2
- 4
modules/xmpp/strophe.jingle.js ファイルの表示

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

読み込み中…
キャンセル
保存