|
@@ -1157,7 +1157,7 @@ TraceablePeerConnection.prototype._removeRemoteTrack = function(toBeRemoved) {
|
1157
|
1157
|
*/
|
1158
|
1158
|
TraceablePeerConnection.prototype._extractSSRCMap = function(desc) {
|
1159
|
1159
|
/**
|
1160
|
|
- * Track SSRC infos mapped by stream ID (msid) or mediaType (unfied-plan)
|
|
1160
|
+ * Track SSRC infos mapped by stream ID (msid) or mediaType (unified-plan)
|
1161
|
1161
|
* @type {Map<string,TrackSSRCInfo>}
|
1162
|
1162
|
*/
|
1163
|
1163
|
const ssrcMap = new Map();
|
|
@@ -1186,14 +1186,22 @@ TraceablePeerConnection.prototype._extractSSRCMap = function(desc) {
|
1186
|
1186
|
// For unified plan clients, only the first audio and video mlines will have ssrcs for the local sources.
|
1187
|
1187
|
// The rest of the m-lines are for the recv-only sources, one for each remote source.
|
1188
|
1188
|
if (this._usesUnifiedPlan) {
|
1189
|
|
- media = [];
|
1190
|
|
- [ MediaType.AUDIO, MediaType.VIDEO ].forEach(mediaType => {
|
1191
|
|
- const mLine = session.media.find(m => m.type === mediaType);
|
|
1189
|
+ if (FeatureFlags.isMultiStreamSupportEnabled()) {
|
|
1190
|
+ media = media.filter(mline => mline.direction === MediaDirection.SENDONLY
|
|
1191
|
+ || mline.direction === MediaDirection.SENDRECV);
|
|
1192
|
+ logger.warn(`local m-lines is ${media.length}`);
|
|
1193
|
+ } else {
|
|
1194
|
+ media = [];
|
|
1195
|
+ [ MediaType.AUDIO, MediaType.VIDEO ].forEach(mediaType => {
|
|
1196
|
+ const mLine = session.media.find(m => m.type === mediaType);
|
1192
|
1197
|
|
1193
|
|
- mLine && media.push(mLine);
|
1194
|
|
- });
|
|
1198
|
+ mLine && media.push(mLine);
|
|
1199
|
+ });
|
|
1200
|
+ }
|
1195
|
1201
|
}
|
1196
|
1202
|
|
|
1203
|
+ let index = 0;
|
|
1204
|
+
|
1197
|
1205
|
for (const mLine of media) {
|
1198
|
1206
|
if (!Array.isArray(mLine.ssrcs)) {
|
1199
|
1207
|
continue; // eslint-disable-line no-continue
|
|
@@ -1201,8 +1209,7 @@ TraceablePeerConnection.prototype._extractSSRCMap = function(desc) {
|
1201
|
1209
|
|
1202
|
1210
|
if (Array.isArray(mLine.ssrcGroups)) {
|
1203
|
1211
|
for (const group of mLine.ssrcGroups) {
|
1204
|
|
- if (typeof group.semantics !== 'undefined'
|
1205
|
|
- && typeof group.ssrcs !== 'undefined') {
|
|
1212
|
+ if (typeof group.semantics !== 'undefined' && typeof group.ssrcs !== 'undefined') {
|
1206
|
1213
|
// Parse SSRCs and store as numbers
|
1207
|
1214
|
const groupSSRCs = group.ssrcs.split(' ').map(ssrcStr => parseInt(ssrcStr, 10));
|
1208
|
1215
|
const primarySSRC = groupSSRCs[0];
|
|
@@ -1231,7 +1238,9 @@ TraceablePeerConnection.prototype._extractSSRCMap = function(desc) {
|
1231
|
1238
|
// the standard and the unified plan SDPs do not have a proper msid attribute for the sources.
|
1232
|
1239
|
// Also the ssrcs for sources do not change for Unified plan clients since RTCRtpSender#replaceTrack is
|
1233
|
1240
|
// used for switching the tracks so it is safe to use the mediaType as the key for the TrackSSRCInfo map.
|
1234
|
|
- const key = this._usesUnifiedPlan ? mLine.type : ssrc.value;
|
|
1241
|
+ const key = this._usesUnifiedPlan
|
|
1242
|
+ ? FeatureFlags.isMultiStreamSupportEnabled() ? `${mLine.type}-${index}` : mLine.type
|
|
1243
|
+ : ssrc.value;
|
1235
|
1244
|
const ssrcNumber = ssrc.id;
|
1236
|
1245
|
let ssrcInfo = ssrcMap.get(key);
|
1237
|
1246
|
|
|
@@ -1253,6 +1262,9 @@ TraceablePeerConnection.prototype._extractSSRCMap = function(desc) {
|
1253
|
1262
|
}
|
1254
|
1263
|
}
|
1255
|
1264
|
}
|
|
1265
|
+
|
|
1266
|
+ // Currently multi-stream is supported for video only.
|
|
1267
|
+ mLine.type === MediaType.VIDEO && index++;
|
1256
|
1268
|
}
|
1257
|
1269
|
|
1258
|
1270
|
return ssrcMap;
|
|
@@ -2922,7 +2934,17 @@ TraceablePeerConnection.prototype._extractPrimarySSRC = function(ssrcObj) {
|
2922
|
2934
|
*/
|
2923
|
2935
|
TraceablePeerConnection.prototype._processLocalSSRCsMap = function(ssrcMap) {
|
2924
|
2936
|
for (const track of this.localTracks.values()) {
|
2925
|
|
- const sourceIdentifier = this._usesUnifiedPlan ? track.getType() : track.storedMSID;
|
|
2937
|
+ let sourceIndex, sourceName;
|
|
2938
|
+
|
|
2939
|
+ if (FeatureFlags.isMultiStreamSupportEnabled()) {
|
|
2940
|
+ sourceName = track.getSourceName();
|
|
2941
|
+ sourceIndex = sourceName?.indexOf('-') + 2;
|
|
2942
|
+ }
|
|
2943
|
+
|
|
2944
|
+ const sourceIdentifier = this._usesUnifiedPlan
|
|
2945
|
+ ? FeatureFlags.isMultiStreamSupportEnabled() && sourceIndex
|
|
2946
|
+ ? `${track.getType()}-${sourceName.substr(sourceIndex, 1)}` : track.getType()
|
|
2947
|
+ : track.storedMSID;
|
2926
|
2948
|
|
2927
|
2949
|
if (ssrcMap.has(sourceIdentifier)) {
|
2928
|
2950
|
const newSSRC = ssrcMap.get(sourceIdentifier);
|