|
@@ -1639,28 +1639,6 @@ TraceablePeerConnection.prototype._mungeCodecOrder = function(description) {
|
1639
|
1639
|
if (this.codecPreference.mimeType === CodecMimeType.H264 && browser.isReactNative() && this.isP2P) {
|
1640
|
1640
|
SDPUtil.stripCodec(mLine, this.codecPreference.mimeType, true /* high profile */);
|
1641
|
1641
|
}
|
1642
|
|
-
|
1643
|
|
- // Set the max bitrate here on the SDP so that the configured max. bitrate is effective
|
1644
|
|
- // as soon as the browser switches to VP9.
|
1645
|
|
- if (this.codecPreference.mimeType === CodecMimeType.VP9
|
1646
|
|
- && this.getConfiguredVideoCodec() === CodecMimeType.VP9) {
|
1647
|
|
- const bitrates = this.tpcUtils.videoBitrates.VP9 || this.tpcUtils.videoBitrates;
|
1648
|
|
- const hdBitrate = bitrates.high ? bitrates.high : HD_BITRATE;
|
1649
|
|
- const limit = Math.floor((this._isSharingScreen() ? HD_BITRATE : hdBitrate) / 1000);
|
1650
|
|
-
|
1651
|
|
- // Use only the HD bitrate for now as there is no API available yet for configuring
|
1652
|
|
- // the bitrates on the individual SVC layers.
|
1653
|
|
- mLine.bandwidth = [ {
|
1654
|
|
- type: 'AS',
|
1655
|
|
- limit
|
1656
|
|
- } ];
|
1657
|
|
- } else {
|
1658
|
|
- // Clear the bandwidth limit in SDP when VP9 is no longer the preferred codec.
|
1659
|
|
- // This is needed on react native clients as react-native-webrtc returns the
|
1660
|
|
- // SDP that the application passed instead of returning the SDP off the native side.
|
1661
|
|
- // This line automatically gets cleared on web on every renegotiation.
|
1662
|
|
- mLine.bandwidth = undefined;
|
1663
|
|
- }
|
1664
|
1642
|
} else {
|
1665
|
1643
|
SDPUtil.stripCodec(mLine, this.codecPreference.mimeType);
|
1666
|
1644
|
}
|
|
@@ -2344,6 +2322,74 @@ TraceablePeerConnection.prototype._initializeDtlsTransport = function() {
|
2344
|
2322
|
}
|
2345
|
2323
|
};
|
2346
|
2324
|
|
|
2325
|
+/**
|
|
2326
|
+ * Sets the max bitrates on the video m-lines when VP9 is the selected codec.
|
|
2327
|
+ *
|
|
2328
|
+ * @param {RTCSessionDescription} description - The local description that needs to be munged.
|
|
2329
|
+ * @returns RTCSessionDescription
|
|
2330
|
+ */
|
|
2331
|
+TraceablePeerConnection.prototype._setVp9MaxBitrates = function(description) {
|
|
2332
|
+ if (!this.codecPreference) {
|
|
2333
|
+ return description;
|
|
2334
|
+ }
|
|
2335
|
+
|
|
2336
|
+ const parsedSdp = transform.parse(description.sdp);
|
|
2337
|
+ const mLines = FeatureFlags.isMultiStreamSupportEnabled()
|
|
2338
|
+ ? parsedSdp.media.filter(m => m.type === MediaType.VIDEO && m.direction !== MediaDirection.RECVONLY)
|
|
2339
|
+ : [ parsedSdp.media.find(m => m.type === MediaType.VIDEO) ];
|
|
2340
|
+
|
|
2341
|
+ // Find the mid associated with the desktop track so that bitrates can be configured accordingly on the
|
|
2342
|
+ // corresponding m-line.
|
|
2343
|
+ const getDesktopTrackMid = () => {
|
|
2344
|
+ const desktopTrack = this.getLocalVideoTracks().find(track => track.getVideoType() === VideoType.DESKTOP);
|
|
2345
|
+ let mid;
|
|
2346
|
+
|
|
2347
|
+ if (desktopTrack) {
|
|
2348
|
+ const trackIndex = Number(desktopTrack.getSourceName()?.split('-')[1].substring(1));
|
|
2349
|
+
|
|
2350
|
+ if (typeof trackIndex === 'number') {
|
|
2351
|
+ const transceiver = this.peerconnection.getTransceivers()
|
|
2352
|
+ .filter(t => t.receiver.track.kind === MediaType.VIDEO
|
|
2353
|
+ && t.direction !== MediaDirection.RECVONLY)[trackIndex];
|
|
2354
|
+
|
|
2355
|
+ mid = transceiver?.mid;
|
|
2356
|
+ }
|
|
2357
|
+ }
|
|
2358
|
+
|
|
2359
|
+ return Number(mid);
|
|
2360
|
+ };
|
|
2361
|
+
|
|
2362
|
+ for (const mLine of mLines) {
|
|
2363
|
+ if (this.codecPreference.mimeType === CodecMimeType.VP9
|
|
2364
|
+ && this.getConfiguredVideoCodec() === CodecMimeType.VP9) {
|
|
2365
|
+ const bitrates = this.tpcUtils.videoBitrates.VP9 || this.tpcUtils.videoBitrates;
|
|
2366
|
+ const hdBitrate = bitrates.high ? bitrates.high : HD_BITRATE;
|
|
2367
|
+ const mid = mLine.mid;
|
|
2368
|
+ const isSharingScreen = FeatureFlags.isMultiStreamSupportEnabled()
|
|
2369
|
+ ? mid === getDesktopTrackMid()
|
|
2370
|
+ : this._isSharingScreen();
|
|
2371
|
+ const limit = Math.floor((isSharingScreen ? HD_BITRATE : hdBitrate) / 1000);
|
|
2372
|
+
|
|
2373
|
+ // Use only the HD bitrate for now as there is no API available yet for configuring
|
|
2374
|
+ // the bitrates on the individual SVC layers.
|
|
2375
|
+ mLine.bandwidth = [ {
|
|
2376
|
+ type: 'AS',
|
|
2377
|
+ limit
|
|
2378
|
+ } ];
|
|
2379
|
+ } else {
|
|
2380
|
+ // Clear the bandwidth limit in SDP when VP9 is no longer the preferred codec.
|
|
2381
|
+ // This is needed on react native clients as react-native-webrtc returns the
|
|
2382
|
+ // SDP that the application passed instead of returning the SDP off the native side.
|
|
2383
|
+ // This line automatically gets cleared on web on every renegotiation.
|
|
2384
|
+ mLine.bandwidth = undefined;
|
|
2385
|
+ }
|
|
2386
|
+ }
|
|
2387
|
+
|
|
2388
|
+ return new RTCSessionDescription({
|
|
2389
|
+ type: description.type,
|
|
2390
|
+ sdp: transform.write(parsedSdp)
|
|
2391
|
+ });
|
|
2392
|
+};
|
2347
|
2393
|
|
2348
|
2394
|
/**
|
2349
|
2395
|
* Configures the stream encodings depending on the video type and the bitrates configured.
|
|
@@ -2389,10 +2435,9 @@ TraceablePeerConnection.prototype.setLocalDescription = function(description) {
|
2389
|
2435
|
localDescription = this._ensureSimulcastGroupIsLast(localDescription);
|
2390
|
2436
|
}
|
2391
|
2437
|
|
2392
|
|
- // Munge the order of the codecs based on the preferences set through config.js if we are using SDP munging.
|
2393
|
|
- if (!this._usesTransceiverCodecPreferences) {
|
2394
|
|
- localDescription = this._mungeCodecOrder(localDescription);
|
2395
|
|
- }
|
|
2438
|
+ // Munge the order of the codecs based on the preferences set through config.js.
|
|
2439
|
+ localDescription = this._mungeCodecOrder(localDescription);
|
|
2440
|
+ localDescription = this._setVp9MaxBitrates(localDescription);
|
2396
|
2441
|
|
2397
|
2442
|
this.trace('setLocalDescription::postTransform', dumpSDP(localDescription));
|
2398
|
2443
|
|
|
@@ -2549,8 +2594,10 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
|
2549
|
2594
|
return Promise.resolve();
|
2550
|
2595
|
}
|
2551
|
2596
|
|
|
2597
|
+ const isSharingLowFpsScreen = localVideoTrack.getVideoType() === VideoType.DESKTOP && this._capScreenshareBitrate;
|
|
2598
|
+
|
2552
|
2599
|
// Set the degradation preference.
|
2553
|
|
- const preference = this.isSharingLowFpsScreen()
|
|
2600
|
+ const preference = isSharingLowFpsScreen
|
2554
|
2601
|
? DEGRADATION_PREFERENCE_DESKTOP // Prefer resolution for low fps share.
|
2555
|
2602
|
: DEGRADATION_PREFERENCE_CAMERA; // Prefer frame-rate for high fps share and camera.
|
2556
|
2603
|
|
|
@@ -2571,10 +2618,9 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
|
2571
|
2618
|
// encodings.
|
2572
|
2619
|
browser.isFirefox() && (parameters.encodings[encoding].degradationPreference = preference);
|
2573
|
2620
|
|
2574
|
|
- // Max bitrates are configured on the encodings only for VP8.
|
2575
|
2621
|
if (this.getConfiguredVideoCodec() === CodecMimeType.VP8
|
2576
|
2622
|
&& (this.options?.videoQuality?.maxBitratesVideo
|
2577
|
|
- || this.isSharingLowFpsScreen()
|
|
2623
|
+ || isSharingLowFpsScreen
|
2578
|
2624
|
|| this._usesUnifiedPlan)) {
|
2579
|
2625
|
parameters.encodings[encoding].maxBitrate = maxBitrates[encoding];
|
2580
|
2626
|
}
|
|
@@ -2820,8 +2866,7 @@ TraceablePeerConnection.prototype._createOfferOrAnswer = function(
|
2820
|
2866
|
// Configure simulcast for camera tracks and for desktop tracks that need simulcast.
|
2821
|
2867
|
if (this.isSimulcastOn() && browser.usesSdpMungingForSimulcast()
|
2822
|
2868
|
&& (localVideoTrack?.getVideoType() === VideoType.CAMERA
|
2823
|
|
- || this._usesUnifiedPlan
|
2824
|
|
- || !this.isSharingLowFpsScreen())) {
|
|
2869
|
+ || this._usesUnifiedPlan)) {
|
2825
|
2870
|
// eslint-disable-next-line no-param-reassign
|
2826
|
2871
|
resultSdp = this.simulcast.mungeLocalDescription(resultSdp);
|
2827
|
2872
|
this.trace(`create${logName} OnSuccess::postTransform (simulcast)`, dumpSDP(resultSdp));
|