Bladeren bron

feat(p2p): refactor p2p configuration options

Also add a preferH264 option for P2P.
master
Saúl Ibarra Corretgé 7 jaren geleden
bovenliggende
commit
d762b06b4b
3 gewijzigde bestanden met toevoegingen van 16 en 8 verwijderingen
  1. 8
    6
      JitsiConference.js
  2. 4
    1
      modules/xmpp/JingleSessionPC.js
  3. 4
    1
      modules/xmpp/xmpp.js

+ 8
- 6
JitsiConference.js Bestand weergeven

@@ -45,14 +45,14 @@ const logger = getLogger(__filename);
45 45
  * @param {number} [options.config.avgRtpStatsN=15] how many samples are to be
46 46
  * collected by {@link AvgRTPStatsReporter}, before arithmetic mean is
47 47
  * calculated and submitted to the analytics module.
48
- * @param {boolean} [options.config.enableP2P] when set to <tt>true</tt>
48
+ * @param {boolean} [options.config.p2p.enabled] when set to <tt>true</tt>
49 49
  * the peer to peer mode will be enabled. It means that when there are only 2
50 50
  * participants in the conference an attempt to make direct connection will be
51 51
  * made. If the connection succeeds the conference will stop sending data
52 52
  * through the JVB connection and will use the direct one instead.
53
- * @param {number} [options.config.backToP2PDelay=5] a delay given in seconds,
54
- * before the conference switches back to P2P, after the 3rd participant has
55
- * left the room.
53
+ * @param {number} [options.config.p2p.backToP2PDelay=5] a delay given in
54
+ * seconds, before the conference switches back to P2P, after the 3rd
55
+ * participant has left the room.
56 56
  * @param {number} [options.config.channelLastN=-1] The requested amount of
57 57
  * videos are going to be delivered after the value is in effect. Set to -1 for
58 58
  * unlimited or all available videos.
@@ -151,7 +151,8 @@ export default function JitsiConference(options) {
151 151
      */
152 152
     this.deferredStartP2PTask = null;
153 153
 
154
-    const delay = parseInt(options.config.backToP2PDelay, 10);
154
+    const delay
155
+        = parseInt(options.config.p2p && options.config.p2p.backToP2PDelay, 10);
155 156
 
156 157
     /**
157 158
      * A delay given in seconds, before the conference switches back to P2P
@@ -2298,7 +2299,8 @@ JitsiConference.prototype._suspendMediaTransferForJvbConnection = function() {
2298 2299
  * @private
2299 2300
  */
2300 2301
 JitsiConference.prototype._maybeStartOrStopP2P = function(userLeftEvent) {
2301
-    if (!this.options.config.enableP2P || !RTCBrowserType.isP2PSupported()) {
2302
+    if (!(RTCBrowserType.isP2PSupported()
2303
+            && this.options.config.p2p && this.options.config.p2p.enabled)) {
2302 2304
         logger.info('Auto P2P disabled');
2303 2305
 
2304 2306
         return;

+ 4
- 1
modules/xmpp/JingleSessionPC.js Bestand weergeven

@@ -244,7 +244,10 @@ export default class JingleSessionPC extends JingleSession {
244 244
                 {
245 245
                     disableSimulcast: this.room.options.disableSimulcast,
246 246
                     disableRtx: this.room.options.disableRtx,
247
-                    preferH264: this.room.options.preferH264
247
+                    preferH264: this.isP2P
248
+                        ? this.room.options.p2p
249
+                            && this.room.options.p2p.preferH264
250
+                        : this.room.options.preferH264
248 251
                 });
249 252
 
250 253
         this.peerconnection.onicecandidate = ev => {

+ 4
- 1
modules/xmpp/xmpp.js Bestand weergeven

@@ -443,8 +443,11 @@ export default class XMPP extends Listenable {
443 443
      *
444 444
      */
445 445
     _initStrophePlugins() {
446
+        const p2pStunServers = this.options.p2p
447
+            && this.options.p2p.enabled && this.options.p2p.stunServers;
448
+
446 449
         initEmuc(this);
447
-        initJingle(this, this.eventEmitter, this.options.p2pStunServers);
450
+        initJingle(this, this.eventEmitter, p2pStunServers);
448 451
         initStropheUtil();
449 452
         initPing(this);
450 453
         initRayo();

Laden…
Annuleren
Opslaan