Переглянути джерело

ref(RTC) Make the remove and add track method names more generic.

Since Track effects and mute/unmute operations use the same flow, i.e., removing/adding the track from the RTCPeerConnection but not from TPC, make the names of the methods involved more generic.
release-8443
Jaya Allamsetty 3 роки тому
джерело
коміт
2682b4ecee

+ 20
- 23
JitsiConference.js Переглянути файл

@@ -1487,54 +1487,51 @@ JitsiConference.prototype._setTrackMuteStatus = function(mediaType, localTrack,
1487 1487
 };
1488 1488
 
1489 1489
 /**
1490
- * Method called by the {@link JitsiLocalTrack} (a video one) in order to add
1491
- * back the underlying WebRTC MediaStream to the PeerConnection (which has
1492
- * removed on video mute).
1493
- * @param {JitsiLocalTrack} track the local track that will be added as part of
1494
- * the unmute operation.
1495
- * @return {Promise} resolved when the process is done or rejected with a string
1496
- * which describes the error.
1490
+ * Method called by the {@link JitsiLocalTrack} in order to add the underlying MediaStream to the RTCPeerConnection.
1491
+ *
1492
+ * @param {JitsiLocalTrack} track the local track that will be added to the pc.
1493
+ * @return {Promise} resolved when the process is done or rejected with a string which describes the error.
1497 1494
  */
1498
-JitsiConference.prototype._addLocalTrackAsUnmute = function(track) {
1499
-    const addAsUnmutePromises = [];
1495
+JitsiConference.prototype._addLocalTrackToPc = function(track) {
1496
+    const addPromises = [];
1500 1497
 
1501 1498
     if (this.jvbJingleSession) {
1502
-        addAsUnmutePromises.push(this.jvbJingleSession.addTrackAsUnmute(track));
1499
+        addPromises.push(this.jvbJingleSession.addTrackToPc(track));
1503 1500
     } else {
1504
-        logger.debug('Add local MediaStream as unmute - no JVB Jingle session started yet');
1501
+        logger.debug('Add local MediaStream - no JVB Jingle session started yet');
1505 1502
     }
1506 1503
 
1507 1504
     if (this.p2pJingleSession) {
1508
-        addAsUnmutePromises.push(this.p2pJingleSession.addTrackAsUnmute(track));
1505
+        addPromises.push(this.p2pJingleSession.addTrackToPc(track));
1509 1506
     } else {
1510
-        logger.debug('Add local MediaStream as unmute - no P2P Jingle session started yet');
1507
+        logger.debug('Add local MediaStream - no P2P Jingle session started yet');
1511 1508
     }
1512 1509
 
1513
-    return Promise.allSettled(addAsUnmutePromises);
1510
+    return Promise.allSettled(addPromises);
1514 1511
 };
1515 1512
 
1516 1513
 /**
1517
- * Method called by the {@link JitsiLocalTrack} (a video one) in order to remove
1518
- * the underlying WebRTC MediaStream from the PeerConnection. The purpose of
1519
- * that is to stop sending any data and turn off the HW camera device.
1514
+ * Method called by the {@link JitsiLocalTrack} in order to remove the underlying MediaStream from the
1515
+ * RTCPeerConnection.
1516
+ *
1520 1517
  * @param {JitsiLocalTrack} track the local track that will be removed.
1521
- * @return {Promise}
1518
+ * @return {Promise} resolved when the process is done or rejected with a string which describes the error.
1522 1519
  */
1523
-JitsiConference.prototype._removeLocalTrackAsMute = function(track) {
1524
-    const removeAsMutePromises = [];
1520
+JitsiConference.prototype._removeLocalTrackFromPc = function(track) {
1521
+    const removePromises = [];
1525 1522
 
1526 1523
     if (this.jvbJingleSession) {
1527
-        removeAsMutePromises.push(this.jvbJingleSession.removeTrackAsMute(track));
1524
+        removePromises.push(this.jvbJingleSession.removeTrackFromPc(track));
1528 1525
     } else {
1529 1526
         logger.debug('Remove local MediaStream - no JVB JingleSession started yet');
1530 1527
     }
1531 1528
     if (this.p2pJingleSession) {
1532
-        removeAsMutePromises.push(this.p2pJingleSession.removeTrackAsMute(track));
1529
+        removePromises.push(this.p2pJingleSession.removeTrackFromPc(track));
1533 1530
     } else {
1534 1531
         logger.debug('Remove local MediaStream - no P2P JingleSession started yet');
1535 1532
     }
1536 1533
 
1537
-    return Promise.allSettled(removeAsMutePromises);
1534
+    return Promise.allSettled(removePromises);
1538 1535
 };
1539 1536
 
1540 1537
 /**

+ 4
- 4
modules/RTC/JitsiLocalTrack.js Переглянути файл

@@ -227,7 +227,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
227 227
         // TPC and JingleSessionPC which would contain the queue and would notify the signaling layer when local SSRCs
228 228
         // are changed. This would help to separate XMPP from the RTC module.
229 229
         return new Promise((resolve, reject) => {
230
-            this.conference._addLocalTrackAsUnmute(this)
230
+            this.conference._addLocalTrackToPc(this)
231 231
                 .then(resolve, error => reject(new Error(error)));
232 232
         });
233 233
     }
@@ -329,7 +329,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
329 329
 
330 330
             return;
331 331
         }
332
-        this.conference._removeLocalTrackAsMute(this).then(
332
+        this.conference._removeLocalTrackFromPc(this).then(
333 333
             successCallback,
334 334
             error => errorCallback(new Error(error)));
335 335
     }
@@ -863,14 +863,14 @@ export default class JitsiLocalTrack extends JitsiTrack {
863 863
 
864 864
         this._setEffectInProgress = true;
865 865
 
866
-        return conference._removeLocalTrackAsMute(this)
866
+        return conference._removeLocalTrackFromPc(this)
867 867
             .then(() => {
868 868
                 this._switchStreamEffect(effect);
869 869
                 if (this.isVideoTrack()) {
870 870
                     this.containers.forEach(cont => RTCUtils.attachMediaStream(cont, this.stream));
871 871
                 }
872 872
 
873
-                return conference._addLocalTrackAsUnmute(this);
873
+                return conference._addLocalTrackToPc(this);
874 874
             })
875 875
             .then(() => {
876 876
                 this._setEffectInProgress = false;

+ 19
- 21
modules/RTC/TraceablePeerConnection.js Переглянути файл

@@ -1748,17 +1748,16 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
1748 1748
 };
1749 1749
 
1750 1750
 /**
1751
- * Adds local track as part of the unmute operation.
1752
- * @param {JitsiLocalTrack} track the track to be added as part of the unmute operation.
1751
+ * Adds local track to the RTCPeerConnection.
1753 1752
  *
1754
- * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's
1755
- * state has changed and renegotiation is required, false if no renegotiation is needed or
1756
- * Promise is rejected when something goes wrong.
1753
+ * @param {JitsiLocalTrack} track the track to be added to the pc.
1754
+ * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's state has changed and
1755
+ * renegotiation is required, false if no renegotiation is needed or Promise is rejected when something goes wrong.
1757 1756
  */
1758
-TraceablePeerConnection.prototype.addTrackUnmute = function(track) {
1759
-    logger.info(`${this} Adding track=${track} as unmute`);
1757
+TraceablePeerConnection.prototype.addTrackToPc = function(track) {
1758
+    logger.info(`${this} Adding track=${track} to PC`);
1760 1759
 
1761
-    if (!this._assertTrackBelongs('addTrackUnmute', track)) {
1760
+    if (!this._assertTrackBelongs('addTrackToPc', track)) {
1762 1761
         // Abort
1763 1762
 
1764 1763
         return Promise.reject('Track not found on the peerconnection');
@@ -1767,7 +1766,7 @@ TraceablePeerConnection.prototype.addTrackUnmute = function(track) {
1767 1766
     const webRtcStream = track.getOriginalStream();
1768 1767
 
1769 1768
     if (!webRtcStream) {
1770
-        logger.error(`${this} Unable to add track=${track} as unmute - no WebRTC stream`);
1769
+        logger.error(`${this} Unable to add track=${track} to PC - no WebRTC stream`);
1771 1770
 
1772 1771
         return Promise.reject('Stream not found');
1773 1772
     }
@@ -1912,7 +1911,7 @@ TraceablePeerConnection.prototype.isMediaStreamInPc = function(mediaStream) {
1912 1911
  * Remove local track from this TPC.
1913 1912
  * @param {JitsiLocalTrack} localTrack the track to be removed from this TPC.
1914 1913
  *
1915
- * FIXME It should probably remove a boolean just like {@link removeTrackMute}
1914
+ * FIXME It should probably remove a boolean just like {@link removeTrackFromPc}
1916 1915
  *       The same applies to addTrack.
1917 1916
  */
1918 1917
 TraceablePeerConnection.prototype.removeTrack = function(localTrack) {
@@ -2089,19 +2088,18 @@ TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
2089 2088
 };
2090 2089
 
2091 2090
 /**
2092
- * Removes local track as part of the mute operation.
2093
- * @param {JitsiLocalTrack} localTrack the local track to be remove as part of
2094
- * the mute operation.
2095
- * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's
2096
- * state has changed and renegotiation is required, false if no renegotiation is needed or
2097
- * Promise is rejected when something goes wrong.
2091
+ * Removes local track from the RTCPeerConnection.
2092
+ *
2093
+ * @param {JitsiLocalTrack} localTrack the local track to be removed.
2094
+ * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's state has changed and
2095
+ * renegotiation is required, false if no renegotiation is needed or Promise is rejected when something goes wrong.
2098 2096
  */
2099
-TraceablePeerConnection.prototype.removeTrackMute = function(localTrack) {
2097
+TraceablePeerConnection.prototype.removeTrackFromPc = function(localTrack) {
2100 2098
     const webRtcStream = localTrack.getOriginalStream();
2101 2099
 
2102
-    this.trace('removeTrackMute', localTrack.rtcId, webRtcStream ? webRtcStream.id : null);
2100
+    this.trace('removeTrack', localTrack.rtcId, webRtcStream ? webRtcStream.id : null);
2103 2101
 
2104
-    if (!this._assertTrackBelongs('removeTrackMute', localTrack)) {
2102
+    if (!this._assertTrackBelongs('removeTrack', localTrack)) {
2105 2103
         // Abort - nothing to be done here
2106 2104
         return Promise.reject('Track not found in the peerconnection');
2107 2105
     }
@@ -2111,13 +2109,13 @@ TraceablePeerConnection.prototype.removeTrackMute = function(localTrack) {
2111 2109
     }
2112 2110
 
2113 2111
     if (webRtcStream) {
2114
-        logger.info(`${this} Removing track=${localTrack} as mute`);
2112
+        logger.info(`${this} Removing track=${localTrack} from PC`);
2115 2113
         this._removeStream(webRtcStream);
2116 2114
 
2117 2115
         return Promise.resolve(true);
2118 2116
     }
2119 2117
 
2120
-    logger.error(`${this} removeTrackMute - no WebRTC stream for track=${localTrack}`);
2118
+    logger.error(`${this} removeTrack - no WebRTC stream for track=${localTrack}`);
2121 2119
 
2122 2120
     return Promise.reject('Stream not found');
2123 2121
 };

+ 16
- 22
modules/xmpp/JingleSessionPC.js Переглянути файл

@@ -2405,16 +2405,14 @@ export default class JingleSessionPC extends JingleSession {
2405 2405
     }
2406 2406
 
2407 2407
     /**
2408
-     * Adds local track back to this session, as part of the unmute operation.
2408
+     * Adds local track back to the peerconnection associated with this session.
2409 2409
      * @param {JitsiLocalTrack} track
2410
-     * @return {Promise} a promise that will resolve once the local track is
2411
-     * added back to this session and renegotiation succeeds. Will be rejected
2412
-     * with a <tt>string</tt> that provides some error details in case something
2413
-     * goes wrong.
2410
+     * @return {Promise} a promise that will resolve once the local track is added back to this session and
2411
+     * renegotiation succeeds (if its warranted). Will be rejected with a <tt>string</tt> that provides some error
2412
+     * details in case something goes wrong.
2414 2413
      */
2415
-    addTrackAsUnmute(track) {
2416
-        return this._addRemoveTrackAsMuteUnmute(
2417
-            false /* add as unmute */, track)
2414
+    addTrackToPc(track) {
2415
+        return this._addRemoveTrack(false /* add */, track)
2418 2416
             .then(() => {
2419 2417
                 // Configure the video encodings after the track is unmuted. If the user joins the call muted and
2420 2418
                 // unmutes it the first time, all the parameters need to be configured.
@@ -2432,38 +2430,34 @@ export default class JingleSessionPC extends JingleSession {
2432 2430
      * The promise will be rejected with a <tt>string</tt> that the describes
2433 2431
      * the error if anything goes wrong.
2434 2432
      */
2435
-    removeTrackAsMute(track) {
2436
-        return this._addRemoveTrackAsMuteUnmute(
2437
-            true /* remove as mute */, track);
2433
+    removeTrackFromPc(track) {
2434
+        return this._addRemoveTrack(true /* remove */, track);
2438 2435
     }
2439 2436
 
2440 2437
     /**
2441
-     * See {@link addTrackAsUnmute} and {@link removeTrackAsMute}.
2442
-     * @param {boolean} isMute <tt>true</tt> for "remove as mute" or
2443
-     * <tt>false</tt> for "add as unmute".
2438
+     * See {@link addTrackToPc} and {@link removeTrackFromPc}.
2439
+     * @param {boolean} isRemove <tt>true</tt> for "remove" operation or <tt>false</tt> for "add" operation.
2444 2440
      * @param {JitsiLocalTrack} track the track that will be added/removed
2445 2441
      * @private
2446 2442
      */
2447
-    _addRemoveTrackAsMuteUnmute(isMute, track) {
2443
+    _addRemoveTrack(isRemove, track) {
2448 2444
         if (!track) {
2449 2445
             return Promise.reject('invalid "track" argument value');
2450 2446
         }
2451
-        const operationName = isMute ? 'removeTrackMute' : 'addTrackUnmute';
2447
+        const operationName = isRemove ? 'removeTrack' : 'addTrack';
2452 2448
         const workFunction = finishedCallback => {
2453 2449
             const tpc = this.peerconnection;
2454 2450
 
2455 2451
             if (!tpc) {
2456
-                finishedCallback(
2457
-                    `Error:  tried ${operationName} track with no active peer`
2458
-                        + 'connection');
2452
+                finishedCallback(`Error:  tried ${operationName} track with no active peer connection`);
2459 2453
 
2460 2454
                 return;
2461 2455
             }
2462 2456
             const oldLocalSDP = tpc.localDescription.sdp;
2463 2457
             const operationPromise
2464
-                = isMute
2465
-                    ? tpc.removeTrackMute(track)
2466
-                    : tpc.addTrackUnmute(track);
2458
+                = isRemove
2459
+                    ? tpc.removeTrackFromPc(track)
2460
+                    : tpc.addTrackToPc(track);
2467 2461
 
2468 2462
             operationPromise
2469 2463
                 .then(shouldRenegotiate => {

+ 12
- 15
types/auto/JitsiConference.d.ts Переглянути файл

@@ -472,23 +472,20 @@ declare class JitsiConference {
472 472
     private _setNewVideoType;
473 473
     private _setTrackMuteStatus;
474 474
     /**
475
-     * Method called by the {@link JitsiLocalTrack} (a video one) in order to add
476
-     * back the underlying WebRTC MediaStream to the PeerConnection (which has
477
-     * removed on video mute).
478
-     * @param {JitsiLocalTrack} track the local track that will be added as part of
479
-     * the unmute operation.
480
-     * @return {Promise} resolved when the process is done or rejected with a string
481
-     * which describes the error.
482
-     */
483
-    _addLocalTrackAsUnmute(track: any): Promise<any>;
484
-    /**
485
-     * Method called by the {@link JitsiLocalTrack} (a video one) in order to remove
486
-     * the underlying WebRTC MediaStream from the PeerConnection. The purpose of
487
-     * that is to stop sending any data and turn off the HW camera device.
475
+     * Method called by the {@link JitsiLocalTrack} in order to add the underlying MediaStream to the RTCPeerConnection.
476
+     *
477
+     * @param {JitsiLocalTrack} track the local track that will be added to the pc.
478
+     * @return {Promise} resolved when the process is done or rejected with a string which describes the error.
479
+     */
480
+    _addLocalTrackToPc(track: any): Promise<any>;
481
+    /**
482
+     * Method called by the {@link JitsiLocalTrack} in order to remove the underlying MediaStream from the
483
+     * RTCPeerConnection.
484
+     *
488 485
      * @param {JitsiLocalTrack} track the local track that will be removed.
489
-     * @return {Promise}
486
+     * @return {Promise} resolved when the process is done or rejected with a string which describes the error.
490 487
      */
491
-    _removeLocalTrackAsMute(track: any): Promise<any>;
488
+    _removeLocalTrackFromPc(track: any): Promise<any>;
492 489
     /**
493 490
      * Get role of the local user.
494 491
      * @returns {string} user role: 'moderator' or 'none'

+ 12
- 14
types/auto/modules/RTC/TraceablePeerConnection.d.ts Переглянути файл

@@ -504,14 +504,13 @@ export default class TraceablePeerConnection {
504 504
      */
505 505
     addTrack(track: any, isInitiator?: boolean): Promise<void>;
506 506
     /**
507
-     * Adds local track as part of the unmute operation.
508
-     * @param {JitsiLocalTrack} track the track to be added as part of the unmute operation.
507
+     * Adds local track to the RTCPeerConnection.
509 508
      *
510
-     * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's
511
-     * state has changed and renegotiation is required, false if no renegotiation is needed or
512
-     * Promise is rejected when something goes wrong.
509
+     * @param {JitsiLocalTrack} track the track to be added to the pc.
510
+     * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's state has changed and
511
+     * renegotiation is required, false if no renegotiation is needed or Promise is rejected when something goes wrong.
513 512
      */
514
-    addTrackUnmute(track: any): Promise<boolean>;
513
+    addTrackToPc(track: any): Promise<boolean>;
515 514
     private _addStream;
516 515
     /**
517 516
      * Removes WebRTC media stream from the underlying PeerConection
@@ -582,7 +581,7 @@ export default class TraceablePeerConnection {
582 581
      * Remove local track from this TPC.
583 582
      * @param {JitsiLocalTrack} localTrack the track to be removed from this TPC.
584 583
      *
585
-     * FIXME It should probably remove a boolean just like {@link removeTrackMute}
584
+     * FIXME It should probably remove a boolean just like {@link removeTrackFromPc}
586 585
      *       The same applies to addTrack.
587 586
      */
588 587
     removeTrack(localTrack: any): void;
@@ -623,14 +622,13 @@ export default class TraceablePeerConnection {
623 622
      */
624 623
     replaceTrack(oldTrack: any | null, newTrack: any | null): Promise<boolean>;
625 624
     /**
626
-     * Removes local track as part of the mute operation.
627
-     * @param {JitsiLocalTrack} localTrack the local track to be remove as part of
628
-     * the mute operation.
629
-     * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's
630
-     * state has changed and renegotiation is required, false if no renegotiation is needed or
631
-     * Promise is rejected when something goes wrong.
625
+     * Removes local track from the RTCPeerConnection.
626
+     *
627
+     * @param {JitsiLocalTrack} localTrack the local track to be removed.
628
+     * @return {Promise<boolean>} Promise that resolves to true if the underlying PeerConnection's state has changed and
629
+     * renegotiation is required, false if no renegotiation is needed or Promise is rejected when something goes wrong.
632 630
      */
633
-    removeTrackMute(localTrack: any): Promise<boolean>;
631
+    removeTrackFromPc(localTrack: any): Promise<boolean>;
634 632
     createDataChannel(label: any, opts: any): RTCDataChannel;
635 633
     private _ensureSimulcastGroupIsLast;
636 634
     private _adjustLocalMediaDirection;

+ 9
- 11
types/auto/modules/xmpp/JingleSessionPC.d.ts Переглянути файл

@@ -530,14 +530,13 @@ export default class JingleSessionPC extends JingleSession {
530 530
      */
531 531
     private _verifyNoSSRCChanged;
532 532
     /**
533
-     * Adds local track back to this session, as part of the unmute operation.
533
+     * Adds local track back to the peerconnection associated with this session.
534 534
      * @param {JitsiLocalTrack} track
535
-     * @return {Promise} a promise that will resolve once the local track is
536
-     * added back to this session and renegotiation succeeds. Will be rejected
537
-     * with a <tt>string</tt> that provides some error details in case something
538
-     * goes wrong.
535
+     * @return {Promise} a promise that will resolve once the local track is added back to this session and
536
+     * renegotiation succeeds (if its warranted). Will be rejected with a <tt>string</tt> that provides some error
537
+     * details in case something goes wrong.
539 538
      */
540
-    addTrackAsUnmute(track: any): Promise<any>;
539
+    addTrackToPc(track: any): Promise<any>;
541 540
     /**
542 541
      * Remove local track as part of the mute operation.
543 542
      * @param {JitsiLocalTrack} track the local track to be removed
@@ -546,15 +545,14 @@ export default class JingleSessionPC extends JingleSession {
546 545
      * The promise will be rejected with a <tt>string</tt> that the describes
547 546
      * the error if anything goes wrong.
548 547
      */
549
-    removeTrackAsMute(track: any): Promise<any>;
548
+    removeTrackFromPc(track: any): Promise<any>;
550 549
     /**
551
-     * See {@link addTrackAsUnmute} and {@link removeTrackAsMute}.
552
-     * @param {boolean} isMute <tt>true</tt> for "remove as mute" or
553
-     * <tt>false</tt> for "add as unmute".
550
+     * See {@link addTrackToPc} and {@link removeTrackFromPc}.
551
+     * @param {boolean} isRemove <tt>true</tt> for "remove" operation or <tt>false</tt> for "add" operation.
554 552
      * @param {JitsiLocalTrack} track the track that will be added/removed
555 553
      * @private
556 554
      */
557
-    private _addRemoveTrackAsMuteUnmute;
555
+    private _addRemoveTrack;
558 556
     /**
559 557
      * Resumes or suspends media transfer over the underlying peer connection.
560 558
      * @param {boolean} audioActive <tt>true</tt> to enable audio media

Завантаження…
Відмінити
Зберегти