瀏覽代碼

fix(multi-stream) Reject m-lines associated with removed sources.

We do not want the client to re-use the inactive transceivers that are associated with m-lines for removed remote tracks. Rejecting a m-line on source-remove clears it from the list of available transceivers.
release-8443
Jaya Allamsetty 3 年之前
父節點
當前提交
5e52c7254a
共有 3 個檔案被更改,包括 42 行新增19 行删除
  1. 35
    12
      modules/xmpp/JingleSessionPC.js
  2. 6
    6
      package-lock.json
  3. 1
    1
      package.json

+ 35
- 12
modules/xmpp/JingleSessionPC.js 查看文件

@@ -1885,8 +1885,10 @@ export default class JingleSessionPC extends JingleSession {
1885 1885
             lines = lines.split('\r\n');
1886 1886
             lines.pop(); // remove empty last element;
1887 1887
             if (this.usesUnifiedPlan) {
1888
+                let mid;
1889
+
1888 1890
                 lines.forEach(line => {
1889
-                    const mid = remoteSdp.media.findIndex(mLine => mLine.includes(line));
1891
+                    mid = remoteSdp.media.findIndex(mLine => mLine.includes(line));
1890 1892
 
1891 1893
                     if (mid > -1) {
1892 1894
                         remoteSdp.media[mid] = remoteSdp.media[mid].replace(`${line}\r\n`, '');
@@ -1905,6 +1907,15 @@ export default class JingleSessionPC extends JingleSession {
1905 1907
                         }
1906 1908
                     }
1907 1909
                 });
1910
+
1911
+                // Reject the m-line so that the browser removes the associated transceiver from the list of available
1912
+                // transceivers. This will prevent the client from trying to re-use these inactive transceivers when
1913
+                // additional video sources are added to the peerconnection.
1914
+                if (mid > -1 && !this.isP2P && FeatureFlags.isMultiStreamSupportEnabled()) {
1915
+                    const { media, port } = SDPUtil.parseMLine(remoteSdp.media[mid].split('\r\n')[0]);
1916
+
1917
+                    remoteSdp.media[mid] = remoteSdp.media[mid].replace(`m=${media} ${port}`, `m=${media} 0`);
1918
+                }
1908 1919
             } else {
1909 1920
                 lines.forEach(line => {
1910 1921
                     remoteSdp.media[idx] = remoteSdp.media[idx].replace(`${line}\r\n`, '');
@@ -2049,6 +2060,7 @@ export default class JingleSessionPC extends JingleSession {
2049 2060
 
2050 2061
         const replaceTracks = [];
2051 2062
         const workFunction = finishedCallback => {
2063
+            const oldLocalSDP = new SDP(this.peerconnection.localDescription.sdp);
2052 2064
             const remoteSdp = new SDP(this.peerconnection.peerconnection.remoteDescription.sdp);
2053 2065
 
2054 2066
             // Add transceivers by adding a new mline in the remote description for each track.
@@ -2056,14 +2068,33 @@ export default class JingleSessionPC extends JingleSession {
2056 2068
                 remoteSdp.addMlineForNewLocalSource(track.getType());
2057 2069
             }
2058 2070
 
2059
-            // Always initiate a responder renegotiate since the new m-line is added to remote SDP.
2060 2071
             const remoteDescription = new RTCSessionDescription({
2061 2072
                 type: 'offer',
2062 2073
                 sdp: remoteSdp.raw
2063 2074
             });
2064 2075
 
2076
+            // Always initiate a responder renegotiate since the new m-line is added to remote SDP.
2065 2077
             this._responderRenegotiate(remoteDescription)
2066
-                .then(() => finishedCallback(), error => finishedCallback(error));
2078
+                .then(() => {
2079
+                    // Replace the tracks on the newly generated transceivers.
2080
+                    for (const track of localTracks) {
2081
+                        replaceTracks.push(this.peerconnection.replaceTrack(null, track));
2082
+                    }
2083
+
2084
+                    return Promise.all(replaceTracks);
2085
+                })
2086
+
2087
+                // Trigger a renegotiation here since renegotiations are suppressed at TPC.replaceTrack for screenshare
2088
+                // tracks. This is done here so that presence for screenshare tracks is sent before signaling.
2089
+                .then(() => this._renegotiate())
2090
+                .then(() => {
2091
+                    const newLocalSDP = new SDP(this.peerconnection.localDescription.sdp);
2092
+
2093
+                    // Signal the new sources to the peer.
2094
+                    this.notifyMySSRCUpdate(oldLocalSDP, newLocalSDP);
2095
+                    finishedCallback();
2096
+                })
2097
+                .catch(error => finishedCallback(error));
2067 2098
         };
2068 2099
 
2069 2100
         return new Promise((resolve, reject) => {
@@ -2077,15 +2108,7 @@ export default class JingleSessionPC extends JingleSession {
2077 2108
                         reject(error);
2078 2109
                     } else {
2079 2110
                         logger.debug(`${this} renegotiation after addTrack executed - OK`);
2080
-
2081
-                        // Replace the tracks on the newly generated transceivers.
2082
-                        for (const track of localTracks) {
2083
-                            replaceTracks.push(this.replaceTrack(null, track));
2084
-                        }
2085
-
2086
-                        return Promise.all(replaceTracks)
2087
-                            .then(() => resolve())
2088
-                            .catch(() => reject());
2111
+                        resolve();
2089 2112
                     }
2090 2113
                 });
2091 2114
         });

+ 6
- 6
package-lock.json 查看文件

@@ -11,7 +11,7 @@
11 11
       "dependencies": {
12 12
         "@jitsi/js-utils": "2.0.0",
13 13
         "@jitsi/logger": "2.0.0",
14
-        "@jitsi/sdp-interop": "https://git@github.com/jitsi/sdp-interop#3707993863eb6c5b6d66c4a025e9dba193775bfb",
14
+        "@jitsi/sdp-interop": "https://git@github.com/jitsi/sdp-interop#dbd765c99e50a7f18bea75d0b6fb07dc58691076",
15 15
         "@jitsi/sdp-simulcast": "0.4.0",
16 16
         "async": "0.9.0",
17 17
         "base64-js": "1.3.1",
@@ -1993,8 +1993,8 @@
1993 1993
     },
1994 1994
     "node_modules/@jitsi/sdp-interop": {
1995 1995
       "version": "1.0.5",
1996
-      "resolved": "git+https://git@github.com/jitsi/sdp-interop.git#3707993863eb6c5b6d66c4a025e9dba193775bfb",
1997
-      "integrity": "sha512-gqp3Pne45vlrLUyBgfTCw58zMflNripWb2Eaj0mF++U5uk2oRoo1/GBZu2C6Z42ExHfHfhFUFR3N8/Ss2LwnVw==",
1996
+      "resolved": "git+https://git@github.com/jitsi/sdp-interop.git#dbd765c99e50a7f18bea75d0b6fb07dc58691076",
1997
+      "integrity": "sha512-4nqEqJWyRFjHM/riI0DQRNx+mgx277iK0r5LhwVAHDZDBYbLN54vYcfZ6JepcmygQiixa8jet/gLJnikdH9wzQ==",
1998 1998
       "license": "Apache-2.0",
1999 1999
       "dependencies": {
2000 2000
         "lodash.clonedeep": "4.5.0",
@@ -8279,9 +8279,9 @@
8279 8279
       "integrity": "sha512-QZE0NpI/GKRdZK0vhuyFYWr4XkCz4slihkSfy6RTszjj/YEHZKIV7yGJo6Hbs3kYI2h5v7apoy+h2WCOMumPJw=="
8280 8280
     },
8281 8281
     "@jitsi/sdp-interop": {
8282
-      "version": "git+https://git@github.com/jitsi/sdp-interop.git#3707993863eb6c5b6d66c4a025e9dba193775bfb",
8283
-      "integrity": "sha512-gqp3Pne45vlrLUyBgfTCw58zMflNripWb2Eaj0mF++U5uk2oRoo1/GBZu2C6Z42ExHfHfhFUFR3N8/Ss2LwnVw==",
8284
-      "from": "@jitsi/sdp-interop@https://git@github.com/jitsi/sdp-interop#3707993863eb6c5b6d66c4a025e9dba193775bfb",
8282
+      "version": "git+https://git@github.com/jitsi/sdp-interop.git#dbd765c99e50a7f18bea75d0b6fb07dc58691076",
8283
+      "integrity": "sha512-4nqEqJWyRFjHM/riI0DQRNx+mgx277iK0r5LhwVAHDZDBYbLN54vYcfZ6JepcmygQiixa8jet/gLJnikdH9wzQ==",
8284
+      "from": "@jitsi/sdp-interop@https://git@github.com/jitsi/sdp-interop#dbd765c99e50a7f18bea75d0b6fb07dc58691076",
8285 8285
       "requires": {
8286 8286
         "lodash.clonedeep": "4.5.0",
8287 8287
         "sdp-transform": "2.14.1"

+ 1
- 1
package.json 查看文件

@@ -18,7 +18,7 @@
18 18
   "dependencies": {
19 19
     "@jitsi/js-utils": "2.0.0",
20 20
     "@jitsi/logger": "2.0.0",
21
-    "@jitsi/sdp-interop": "https://git@github.com/jitsi/sdp-interop#3707993863eb6c5b6d66c4a025e9dba193775bfb",
21
+    "@jitsi/sdp-interop": "https://git@github.com/jitsi/sdp-interop#dbd765c99e50a7f18bea75d0b6fb07dc58691076",
22 22
     "@jitsi/sdp-simulcast": "0.4.0",
23 23
     "async": "0.9.0",
24 24
     "base64-js": "1.3.1",

Loading…
取消
儲存