|
@@ -40,6 +40,28 @@ export default class SDP {
|
40
|
40
|
this.removeUdpCandidates = false;
|
41
|
41
|
}
|
42
|
42
|
|
|
43
|
+ /**
|
|
44
|
+ * Adjusts the msid semantic for a remote source based on the media type and the index of the m-line.
|
|
45
|
+ * This is needed for browsers that need both the streamId and trackId to be reported in the msid attribute.
|
|
46
|
+ *
|
|
47
|
+ * @param {String} msid - The msid attribute value.
|
|
48
|
+ * @param {Number} idx - The index of the m-line in the SDP.
|
|
49
|
+ * @returns {String} - The adjusted msid semantic.
|
|
50
|
+ */
|
|
51
|
+ _adjustMsidSemantic(msid, mediaType, idx) {
|
|
52
|
+ if (mediaType === MediaType.AUDIO || !browser.isChromiumBased() || browser.isEngineVersionGreaterThan(116)) {
|
|
53
|
+ return msid;
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ const msidParts = msid.split(' ');
|
|
57
|
+
|
|
58
|
+ if (msidParts.length === 2) {
|
|
59
|
+ return msid;
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ return `${msid} ${msid}-${idx}`;
|
|
63
|
+ }
|
|
64
|
+
|
43
|
65
|
/**
|
44
|
66
|
* Updates the media and session sections of the SDP based on the raw SDP string.
|
45
|
67
|
*
|
|
@@ -95,15 +117,7 @@ export default class SDP {
|
95
|
117
|
updatedMidIndices.push(idx);
|
96
|
118
|
|
97
|
119
|
if (isAdd) {
|
98
|
|
- let updatedMsid = msid;
|
99
|
|
-
|
100
|
|
- // If the msid is not in the <stream ID> <track ID> format, create msid in that format.
|
101
|
|
- // Chrome's older versions (upto 117) expect the msid to be in this format.
|
102
|
|
- if (msid.split(' ').length !== 2
|
103
|
|
- && browser.isChromiumBased()
|
104
|
|
- && browser.isEngineVersionLessThan(117)) {
|
105
|
|
- updatedMsid = `${msid} ${msid}-${idx}`;
|
106
|
|
- }
|
|
120
|
+ const updatedMsid = this._adjustMsidSemantic(msid, mediaType, idx);
|
107
|
121
|
|
108
|
122
|
ssrcList.forEach(ssrc => {
|
109
|
123
|
this.media[idx] += `a=ssrc:${ssrc} msid:${updatedMsid}\r\n`;
|
|
@@ -259,12 +273,18 @@ export default class SDP {
|
259
|
273
|
const group = mLine.ssrcGroups?.find(g => g.ssrcs.includes(ssrcId));
|
260
|
274
|
|
261
|
275
|
if (group) {
|
|
276
|
+ if (ssrc.attribute === 'msid') {
|
|
277
|
+ ssrc.value = this._adjustMsidSemantic(ssrc.value, type, newMline.mid);
|
|
278
|
+ }
|
262
|
279
|
newMline.ssrcs.push(ssrc);
|
263
|
280
|
const otherSsrc = group.ssrcs.split(' ').find(s => s !== ssrcId);
|
264
|
281
|
|
265
|
282
|
if (otherSsrc) {
|
266
|
283
|
const otherSource = mLine.ssrcs.find(source => source.id.toString() === otherSsrc);
|
267
|
284
|
|
|
285
|
+ if (otherSource.attribute === 'msid') {
|
|
286
|
+ otherSource.value = this._adjustMsidSemantic(otherSource.value, type, newMline.mid);
|
|
287
|
+ }
|
268
|
288
|
newMline.ssrcs.push(otherSource);
|
269
|
289
|
}
|
270
|
290
|
newMline.ssrcGroups.push(group);
|
|
@@ -373,6 +393,7 @@ export default class SDP {
|
373
|
393
|
let sdp = '';
|
374
|
394
|
const sctp = transport.find(`>sctpmap[xmlns='${XEP.SCTP_DATA_CHANNEL}']`);
|
375
|
395
|
const media = { media: desc.attr('media') };
|
|
396
|
+ const mid = content.attr('name');
|
376
|
397
|
|
377
|
398
|
media.port = '9';
|
378
|
399
|
if (content.attr('senders') === 'rejected') {
|
|
@@ -445,7 +466,7 @@ export default class SDP {
|
445
|
466
|
sdp += `a=${MediaDirection.SENDRECV}\r\n`;
|
446
|
467
|
break;
|
447
|
468
|
}
|
448
|
|
- sdp += `a=mid:${content.attr('name')}\r\n`;
|
|
469
|
+ sdp += `a=mid:${mid}\r\n`;
|
449
|
470
|
|
450
|
471
|
// <description><rtcp-mux/></description>
|
451
|
472
|
// see http://code.google.com/p/libjingle/issues/detail?id=309 -- no spec though
|
|
@@ -516,6 +537,9 @@ export default class SDP {
|
516
|
537
|
value = SDPUtil.filterSpecialChars(value);
|
517
|
538
|
sourceStr += `a=ssrc:${ssrc} ${name}`;
|
518
|
539
|
|
|
540
|
+ if (name === 'msid') {
|
|
541
|
+ value = this._adjustMsidSemantic(value, media.media, mid);
|
|
542
|
+ }
|
519
|
543
|
if (value && value.length) {
|
520
|
544
|
sourceStr += `:${value}`;
|
521
|
545
|
}
|