Browse Source

get rid of implode for remote rtx since it isn't needed (simulcast implode takes care of this). add new stripRtx method for stripping rtx from a remote offer altogether

master
brian baldino 9 years ago
parent
commit
bcdf08a34e

+ 21
- 37
modules/xmpp/RtxModifier.js View File

@@ -222,15 +222,13 @@ export default class RtxModifier {
222 222
     }
223 223
 
224 224
     /**
225
-     * Remove all reference to any rtx ssrcs that 
226
-     *  don't correspond to the primary stream.
227
-     * Must be called *after* any simulcast streams
228
-     *  have been imploded
225
+     * Strip all rtx streams from the given sdp
229 226
      * @param {string} sdpStr sdp in raw string format
227
+     * @returns {string} sdp string with all rtx streams stripped
230 228
      */
231
-    implodeRemoteRtxSsrcs (sdpStr) {
232
-        let parsedSdp = transform.parse(sdpStr);
233
-        let videoMLine = 
229
+    stripRtx (sdpStr) {
230
+        const parsedSdp = transform.parse(sdpStr);
231
+        const videoMLine = 
234 232
             parsedSdp.media.find(mLine => mLine.type === "video");
235 233
         if (videoMLine.direction === "inactive" ||
236 234
                 videoMLine.direction === "recvonly") {
@@ -238,39 +236,25 @@ export default class RtxModifier {
238 236
                 "m line is inactive or recvonly");
239 237
             return sdpStr;
240 238
         }
241
-        if (!videoMLine.ssrcGroups) {
242
-            // Nothing to do
243
-            return sdpStr;
239
+        if (!videoMLine.ssrcs) {
240
+          logger.info("RtxModifier doing nothing, no video ssrcs present");
241
+          return sdpStr;
244 242
         }
245
-
246
-        // Returns true if the given ssrc is present
247
-        //  in the mLine's ssrc list
248
-        let ssrcExists = (ssrcToFind) => {
249
-            return videoMLine.ssrcs.
250
-              find((ssrc) => ssrc.id + "" === ssrcToFind);
251
-        };
252
-        let ssrcsToRemove = [];
253
-        videoMLine.ssrcGroups.forEach(group => {
254
-            if (group.semantics === "FID") {
255
-                let primarySsrc = group.ssrcs.split(" ")[0];
256
-                let rtxSsrc = group.ssrcs.split(" ")[1];
257
-                if (!ssrcExists(primarySsrc)) {
258
-                    ssrcsToRemove.push(rtxSsrc);
259
-                }
260
-            }
243
+        const fidGroups = videoMLine.ssrcGroups
244
+            .filter(group => group.semantics === "FID");
245
+        // Remove the fid groups from the mline
246
+        videoMLine.ssrcGroups = videoMLine.ssrcGroups
247
+            .filter(group => group.semantics !== "FID");
248
+        // Get the rtx ssrcs and remove them from the mline
249
+        const ssrcsToRemove = [];
250
+        fidGroups.forEach(fidGroup => {
251
+            const groupSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
252
+            const rtxSsrc = groupSsrcs[1];
253
+            ssrcsToRemove.push(rtxSsrc);
261 254
         });
262 255
         videoMLine.ssrcs = videoMLine.ssrcs
263
-            .filter(ssrc => ssrcsToRemove.indexOf(ssrc.id + "") === -1);
264
-        videoMLine.ssrcGroups = videoMLine.ssrcGroups
265
-            .filter(group => {
266
-                let ssrcs = group.ssrcs.split(" ");
267
-                for (let i = 0; i < ssrcs.length; ++i) {
268
-                    if (ssrcsToRemove.indexOf(ssrcs[i]) !== -1) {
269
-                        return false;
270
-                    }
271
-                }
272
-                return true;
273
-            });
256
+            .filter(line => ssrcsToRemove.indexOf(line.id) === -1);
257
+        
274 258
         return transform.write(parsedSdp);
275 259
     }
276 260
 }

+ 15
- 0
modules/xmpp/RtxModifier.spec.js View File

@@ -287,6 +287,21 @@ describe ("RtxModifier", function() {
287 287
         });
288 288
       });
289 289
     });
290
+
291
+    describe("stripRtx", function() {
292
+        beforeEach(function() {
293
+            this.sdpStr = transform.write(SampleSdpStrings.rtxVideoSdp);
294
+        });
295
+        it ("should strip all rtx streams from an sdp with rtx", function() {
296
+            const newSdpStr = this.rtxModifier.stripRtx(this.sdpStr);
297
+            const newSdp = transform.parse(newSdpStr);
298
+            const fidGroups = getVideoGroups(newSdp, "FID");
299
+            expect(fidGroups.length).toEqual(0);
300
+            const videoMLine = SDPUtil.getMedia(newSdp, "video");
301
+            expect(videoMLine.ssrcs.length).toEqual(1);
302
+
303
+        });
304
+    });
290 305
 });
291 306
 
292 307
 /*eslint-enable max-len*/

+ 10
- 0
modules/xmpp/SDPUtil.js View File

@@ -443,6 +443,16 @@ var SDPUtil = {
443 443
             .split(" ")
444 444
             .map(ssrcStr => parseInt(ssrcStr));
445 445
     },
446
+
447
+    /**
448
+     * Get the mline of the given type from the given sdp
449
+     * @param {object} sdp sdp as parsed from transform.parse
450
+     * @param {string} type the type of the desired mline (e.g. "video")
451
+     * @returns {object} a media object
452
+     */
453
+    getMedia: function (sdp, type) {
454
+        return sdp.media.find(m => m.type === type);
455
+    },
446 456
 };
447 457
 
448 458
 module.exports = SDPUtil;

+ 2
- 2
modules/xmpp/TraceablePeerConnection.js View File

@@ -389,8 +389,8 @@ TraceablePeerConnection.prototype.setRemoteDescription
389 389
     description = this.simulcast.mungeRemoteDescription(description);
390 390
     this.trace('setRemoteDescription::postTransform (simulcast)', dumpSDP(description));
391 391
 
392
-    description.sdp = this.rtxModifier.implodeRemoteRtxSsrcs(description.sdp);
393
-    this.trace('setRemoteDescription::postTransform (implodeRemoteRtxSsrcs)', dumpSDP(description));
392
+    //description.sdp = this.rtxModifier.implodeRemoteRtxSsrcs(description.sdp);
393
+    //this.trace('setRemoteDescription::postTransform (implodeRemoteRtxSsrcs)', dumpSDP(description));
394 394
 
395 395
     // if we're running on FF, transform to Plan A first.
396 396
     if (RTCBrowserType.usesUnifiedPlan()) {

Loading…
Cancel
Save