|
@@ -241,77 +241,4 @@ export default class SdpSimulcast {
|
241
|
241
|
sdp: transform.write(session)
|
242
|
242
|
});
|
243
|
243
|
}
|
244
|
|
-
|
245
|
|
- /**
|
246
|
|
- * Munges the given media description by removing the SSRCs and related FID groups for the higher layer streams.
|
247
|
|
- *
|
248
|
|
- * @param description
|
249
|
|
- * @returns
|
250
|
|
- */
|
251
|
|
- mungeRemoteDescription(description: Description) : Description {
|
252
|
|
- if (!description || !description.sdp) {
|
253
|
|
- return description;
|
254
|
|
- }
|
255
|
|
-
|
256
|
|
- const session = transform.parse(description.sdp);
|
257
|
|
-
|
258
|
|
- for (const media of session.media) {
|
259
|
|
- if (media.type !== MediaType.VIDEO) {
|
260
|
|
- continue;
|
261
|
|
- }
|
262
|
|
-
|
263
|
|
- if (media.direction !== MediaDirection.SENDONLY) {
|
264
|
|
- continue;
|
265
|
|
- }
|
266
|
|
-
|
267
|
|
- // Ignore m-lines that do not have any SSRCs or SSRC groups. These are the ones associated with remote
|
268
|
|
- // sources that have left the call. These will be recycled when a new remote source joins the call.
|
269
|
|
- if (!media.ssrcGroups?.length || !media?.ssrcs.length) {
|
270
|
|
- continue;
|
271
|
|
- }
|
272
|
|
-
|
273
|
|
- // Cache the SSRCs and the source groups.
|
274
|
|
- const mungedSsrcs = new Set(media.ssrcs.slice());
|
275
|
|
- const mungedSsrcGroups = new Set(media.ssrcGroups.slice());
|
276
|
|
- const fidGroups = media.ssrcGroups.filter(group => group.semantics === 'FID');
|
277
|
|
- const simGroup = media.ssrcGroups.find(group => group.semantics === 'SIM');
|
278
|
|
- const primarySsrc = simGroup?.ssrcs.split(' ')[0];;
|
279
|
|
-
|
280
|
|
- // When simulcast and RTX are both enabled.
|
281
|
|
- if (fidGroups.length && simGroup) {
|
282
|
|
- const fidGroup = fidGroups.find(group => group.ssrcs.includes(primarySsrc));
|
283
|
|
- const secondarySsrc = fidGroup.ssrcs.split(' ')[1];
|
284
|
|
-
|
285
|
|
- for (const ssrcGroup of media.ssrcGroups) {
|
286
|
|
- if (ssrcGroup !== fidGroup) {
|
287
|
|
- mungedSsrcGroups.delete(ssrcGroup);
|
288
|
|
- }
|
289
|
|
- }
|
290
|
|
- for (const ssrc of media.ssrcs) {
|
291
|
|
- if (ssrc.id.toString() !== primarySsrc
|
292
|
|
- && ssrc.id.toString() !== secondarySsrc) {
|
293
|
|
- mungedSsrcs.delete(ssrc);
|
294
|
|
- }
|
295
|
|
- }
|
296
|
|
-
|
297
|
|
- // When simulcast is enabled but RTX is disabled.
|
298
|
|
- } else if (simGroup) {
|
299
|
|
- mungedSsrcGroups.delete(simGroup);
|
300
|
|
-
|
301
|
|
- for (const ssrc of media.ssrcs) {
|
302
|
|
- if (ssrc.id.toString() !== primarySsrc) {
|
303
|
|
- mungedSsrcs.delete(ssrc);
|
304
|
|
- }
|
305
|
|
- }
|
306
|
|
- }
|
307
|
|
-
|
308
|
|
- media.ssrcs = Array.from(mungedSsrcs);
|
309
|
|
- media.ssrcGroups = Array.from(mungedSsrcGroups);
|
310
|
|
- }
|
311
|
|
-
|
312
|
|
- return new RTCSessionDescription ({
|
313
|
|
- type: description.type,
|
314
|
|
- sdp: transform.write(session)
|
315
|
|
- });
|
316
|
|
- }
|
317
|
244
|
}
|