Browse Source

ref(JingleSessionPC) Do not renegotiate on every local source change.

Instead rely on the 'negotiationneeded' event fired by the browser for JVB connection. This makes local source changes faster even if the modification queue is backed up.
tags/v0.0.2
Jaya Allamsetty 4 years ago
parent
commit
012c38769d
2 changed files with 17 additions and 15 deletions
  1. 7
    9
      modules/RTC/TraceablePeerConnection.js
  2. 10
    6
      modules/xmpp/JingleSessionPC.js

+ 7
- 9
modules/RTC/TraceablePeerConnection.js View File

@@ -1972,20 +1972,18 @@ TraceablePeerConnection.prototype.findSenderForTrack = function(track) {
1972 1972
  * <tt>oldTrack</tt> with a null <tt>newTrack</tt> effectively just removes
1973 1973
  * <tt>oldTrack</tt>
1974 1974
  *
1975
- * @param {JitsiLocalTrack|null} oldTrack - The current track in use to be
1976
- * replaced
1977
- * @param {JitsiLocalTrack|null} newTrack - The new track to use
1978
- * @returns {Promise<boolean>} - If the promise resolves with true,
1979
- * renegotiation will be needed. Otherwise no renegotiation is needed.
1975
+ * @param {JitsiLocalTrack|null} oldTrack - The current track in use to be replaced on the pc.
1976
+ * @param {JitsiLocalTrack|null} newTrack - The new track to be used.
1977
+ *
1978
+ * @returns {Promise<boolean>} - If the promise resolves with true, renegotiation will be needed.
1979
+ * Otherwise no renegotiation is needed.
1980 1980
  */
1981 1981
 TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
1982 1982
     if (this._usesUnifiedPlan) {
1983 1983
         logger.debug(`${this} TPC.replaceTrack using unified plan`);
1984 1984
 
1985
-        return this.tpcUtils.replaceTrack(oldTrack, newTrack)
1986
-
1987
-            // Renegotiate when SDP is used for simulcast munging or when in p2p mode.
1988
-            .then(() => (this.isSimulcastOn() && browser.usesSdpMungingForSimulcast()) || this.isP2P);
1985
+        // Renegotiate only in the case of P2P. We rely on 'negotiationeeded' to be fired for JVB.
1986
+        return this.tpcUtils.replaceTrack(oldTrack, newTrack).then(() => this.isP2P);
1989 1987
     }
1990 1988
 
1991 1989
     logger.debug(`${this} TPC.replaceTrack using plan B`);

+ 10
- 6
modules/xmpp/JingleSessionPC.js View File

@@ -599,20 +599,24 @@ export default class JingleSessionPC extends JingleSession {
599 599
             const state = this.peerconnection.signalingState;
600 600
             const remoteDescription = this.peerconnection.remoteDescription;
601 601
 
602
-            if (this.usesUnifiedPlan && state === 'stable'
603
-                && remoteDescription && typeof remoteDescription.sdp === 'string') {
604
-                logger.debug(`${this} onnegotiationneeded fired on ${this.peerconnection} in state: ${state}`);
602
+            if (this.usesUnifiedPlan
603
+                && !this.isP2P
604
+                && state === 'stable'
605
+                && remoteDescription
606
+                && typeof remoteDescription.sdp === 'string') {
607
+                logger.info(`${this} onnegotiationneeded fired on ${this.peerconnection}`);
608
+
605 609
                 const workFunction = finishedCallback => {
606 610
                     const oldSdp = new SDP(this.peerconnection.localDescription.sdp);
607 611
 
608 612
                     this._renegotiate()
613
+                        .then(() => this.peerconnection.configureSenderVideoEncodings())
609 614
                         .then(() => {
610 615
                             const newSdp = new SDP(this.peerconnection.localDescription.sdp);
611 616
 
612 617
                             this.notifyMySSRCUpdate(oldSdp, newSdp);
613
-                            finishedCallback();
614
-                        },
615
-                        finishedCallback /* will be called with en error */);
618
+                        })
619
+                        .then(() => finishedCallback(), error => finishedCallback(error));
616 620
                 };
617 621
 
618 622
                 this.modificationQueue.push(

Loading…
Cancel
Save