|
|
@@ -1317,6 +1317,43 @@ TraceablePeerConnection.prototype.createDataChannel = function(label, opts) {
|
|
1317
|
1317
|
return this.peerconnection.createDataChannel(label, opts);
|
|
1318
|
1318
|
};
|
|
1319
|
1319
|
|
|
|
1320
|
+/**
|
|
|
1321
|
+ * Ensures that the simulcast ssrc-group appears after any other ssrc-groups
|
|
|
1322
|
+ * in the SDP so that simulcast is properly activated.
|
|
|
1323
|
+ *
|
|
|
1324
|
+ * @param {Object} localSdp the WebRTC session description instance for
|
|
|
1325
|
+ * the local description.
|
|
|
1326
|
+ * @private
|
|
|
1327
|
+ */
|
|
|
1328
|
+TraceablePeerConnection.prototype._ensureSimulcastGroupIsLast
|
|
|
1329
|
+= function(localSdp) {
|
|
|
1330
|
+ let sdpStr = localSdp.sdp;
|
|
|
1331
|
+
|
|
|
1332
|
+ const videoStartIndex = sdpStr.indexOf('m=video');
|
|
|
1333
|
+ const simStartIndex = sdpStr.indexOf('a=ssrc-group:SIM', videoStartIndex);
|
|
|
1334
|
+ let otherStartIndex = sdpStr.lastIndexOf('a=ssrc-group');
|
|
|
1335
|
+
|
|
|
1336
|
+ if (simStartIndex === -1
|
|
|
1337
|
+ || otherStartIndex === -1
|
|
|
1338
|
+ || otherStartIndex === simStartIndex) {
|
|
|
1339
|
+ return;
|
|
|
1340
|
+ }
|
|
|
1341
|
+
|
|
|
1342
|
+ const simEndIndex = sdpStr.indexOf('\r\n', simStartIndex);
|
|
|
1343
|
+ const simStr = sdpStr.substring(simStartIndex, simEndIndex + 2);
|
|
|
1344
|
+
|
|
|
1345
|
+ sdpStr = sdpStr.replace(simStr, '');
|
|
|
1346
|
+ otherStartIndex = sdpStr.lastIndexOf('a=ssrc-group');
|
|
|
1347
|
+ const otherEndIndex = sdpStr.indexOf('\r\n', otherStartIndex);
|
|
|
1348
|
+ const sdpHead = sdpStr.slice(0, otherEndIndex);
|
|
|
1349
|
+ const simStrTrimmed = simStr.trim();
|
|
|
1350
|
+ const sdpTail = sdpStr.slice(otherEndIndex);
|
|
|
1351
|
+
|
|
|
1352
|
+ sdpStr = `${sdpHead}\r\n${simStrTrimmed}${sdpTail}`;
|
|
|
1353
|
+
|
|
|
1354
|
+ localSdp.sdp = sdpStr;
|
|
|
1355
|
+};
|
|
|
1356
|
+
|
|
1320
|
1357
|
/**
|
|
1321
|
1358
|
* Will adjust audio and video media direction in the given SDP object to
|
|
1322
|
1359
|
* reflect the current status of the {@link mediaTransferActive} flag.
|
|
|
@@ -1373,6 +1410,8 @@ TraceablePeerConnection.prototype.setLocalDescription
|
|
1373
|
1410
|
|
|
1374
|
1411
|
this._adjustLocalMediaDirection(localSdp);
|
|
1375
|
1412
|
|
|
|
1413
|
+ this._ensureSimulcastGroupIsLast(localSdp);
|
|
|
1414
|
+
|
|
1376
|
1415
|
// if we're using unified plan, transform to it first.
|
|
1377
|
1416
|
if (RTCBrowserType.usesUnifiedPlan()) {
|
|
1378
|
1417
|
localSdp = this.interop.toUnifiedPlan(localSdp);
|