|
@@ -25,10 +25,13 @@ import { SIM_LAYER_RIDS, TPCUtils } from './TPCUtils';
|
25
|
25
|
// FIXME SDP tools should end up in some kind of util module
|
26
|
26
|
|
27
|
27
|
const logger = getLogger(__filename);
|
28
|
|
-const MAX_BITRATE = 2500000;
|
29
|
|
-const DESKSTOP_SHARE_RATE = 500000;
|
30
|
28
|
const DEGRADATION_PREFERENCE_CAMERA = 'maintain-framerate';
|
31
|
29
|
const DEGRADATION_PREFERENCE_DESKTOP = 'maintain-resolution';
|
|
30
|
+const DESKSTOP_SHARE_RATE = 500000;
|
|
31
|
+const HD_BITRATE = 2500000;
|
|
32
|
+const LD_BITRATE = 200000;
|
|
33
|
+const SD_BITRATE = 700000;
|
|
34
|
+
|
32
|
35
|
/* eslint-disable max-params */
|
33
|
36
|
|
34
|
37
|
/**
|
|
@@ -209,7 +212,23 @@ export default function TraceablePeerConnection(
|
209
|
212
|
|
210
|
213
|
this.peerconnection
|
211
|
214
|
= new RTCUtils.RTCPeerConnectionType(iceConfig, constraints);
|
212
|
|
- this.tpcUtils = new TPCUtils(this);
|
|
215
|
+
|
|
216
|
+ // The standard video bitrates are used in Unified plan when switching
|
|
217
|
+ // between camera/desktop tracks on the same sender.
|
|
218
|
+ const standardVideoBitrates = {
|
|
219
|
+ low: LD_BITRATE,
|
|
220
|
+ standard: SD_BITRATE,
|
|
221
|
+ high: HD_BITRATE
|
|
222
|
+ };
|
|
223
|
+
|
|
224
|
+ // Check if the max. bitrates for video are specified through config.js
|
|
225
|
+ // videoQuality settings. These bitrates will be applied on all browsers
|
|
226
|
+ // for camera sources in simulcast mode.
|
|
227
|
+ const videoBitrates = this.options.videoQuality
|
|
228
|
+ ? this.options.videoQuality.maxBitratesVideo
|
|
229
|
+ : standardVideoBitrates;
|
|
230
|
+
|
|
231
|
+ this.tpcUtils = new TPCUtils(this, videoBitrates);
|
213
|
232
|
this.updateLog = [];
|
214
|
233
|
this.stats = {};
|
215
|
234
|
this.statsinterval = null;
|
|
@@ -1526,7 +1545,7 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
|
1526
|
1545
|
|
1527
|
1546
|
// Construct the simulcast stream constraints for the newly added track.
|
1528
|
1547
|
if (track.isVideoTrack() && track.videoType === VideoType.CAMERA && this.isSimulcastOn()) {
|
1529
|
|
- this.tpcUtils._setSimulcastStreamConstraints(track.getTrack());
|
|
1548
|
+ this.tpcUtils.setSimulcastStreamConstraints(track.getTrack());
|
1530
|
1549
|
}
|
1531
|
1550
|
};
|
1532
|
1551
|
|
|
@@ -1982,15 +2001,21 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
|
1982
|
2001
|
* @param {JitsiLocalTrack} localTrack - the local track whose
|
1983
|
2002
|
* max bitrate is to be configured.
|
1984
|
2003
|
*/
|
1985
|
|
-TraceablePeerConnection.prototype.setMaxBitRate = function(localTrack) {
|
|
2004
|
+TraceablePeerConnection.prototype.setMaxBitRate = function(localTrack = null) {
|
|
2005
|
+ if (!localTrack) {
|
|
2006
|
+ // eslint-disable-next-line no-param-reassign
|
|
2007
|
+ localTrack = Array.from(this.localTracks.values()).find(t => t.isVideoTrack());
|
|
2008
|
+ }
|
1986
|
2009
|
const trackId = localTrack.track.id;
|
1987
|
2010
|
const videoType = localTrack.videoType;
|
1988
|
2011
|
|
1989
|
2012
|
// No need to set max bitrates on the streams in the following cases.
|
1990
|
2013
|
// 1. When a 'camera' track is replaced in plan-b mode, since its a new sender.
|
1991
|
2014
|
// 2. When the config.js option for capping the SS bitrate is not enabled.
|
1992
|
|
- if ((browser.usesPlanB() && !this.options.capScreenshareBitrate)
|
1993
|
|
- || (browser.usesPlanB() && videoType === VideoType.CAMERA)) {
|
|
2015
|
+ // The above two conditions are ignored When max video bitrates are specified through config.js.
|
|
2016
|
+ if (((browser.usesPlanB() && !this.options.capScreenshareBitrate)
|
|
2017
|
+ || (browser.usesPlanB() && videoType === VideoType.CAMERA))
|
|
2018
|
+ && !(this.options.videoQuality && this.options.videoQuality.maxBitratesVideo)) {
|
1994
|
2019
|
return;
|
1995
|
2020
|
}
|
1996
|
2021
|
if (!this.peerconnection.getSenders) {
|
|
@@ -2017,15 +2042,15 @@ TraceablePeerConnection.prototype.setMaxBitRate = function(localTrack) {
|
2017
|
2042
|
// capScreenshareBitrate is enabled through config.js and presenter
|
2018
|
2043
|
// is not turned on.
|
2019
|
2044
|
parameters.encodings[encoding].maxBitrate
|
2020
|
|
- = browser.usesPlanB()
|
2021
|
|
- ? presenterEnabled ? MAX_BITRATE : DESKSTOP_SHARE_RATE
|
|
2045
|
+ = browser.usesPlanB() && videoType === VideoType.DESKTOP
|
|
2046
|
+ ? presenterEnabled ? HD_BITRATE : DESKSTOP_SHARE_RATE
|
2022
|
2047
|
|
2023
|
2048
|
// In unified plan, simulcast for SS is on by default.
|
2024
|
2049
|
// When simulcast is disabled through a config.js option,
|
2025
|
2050
|
// we cap the bitrate on desktop and camera tracks to 2500 Kbps.
|
2026
|
2051
|
: this.isSimulcastOn()
|
2027
|
2052
|
? this.tpcUtils.simulcastEncodings[encoding].maxBitrate
|
2028
|
|
- : MAX_BITRATE;
|
|
2053
|
+ : HD_BITRATE;
|
2029
|
2054
|
}
|
2030
|
2055
|
}
|
2031
|
2056
|
sender.setParameters(parameters);
|
|
@@ -2078,13 +2103,13 @@ TraceablePeerConnection.prototype.setRemoteDescription = function(description) {
|
2078
|
2103
|
description = this.simulcast.mungeRemoteDescription(description);
|
2079
|
2104
|
|
2080
|
2105
|
// eslint-disable-next-line no-param-reassign
|
2081
|
|
- description = this.tpcUtils._insertUnifiedPlanSimulcastReceive(description);
|
|
2106
|
+ description = this.tpcUtils.insertUnifiedPlanSimulcastReceive(description);
|
2082
|
2107
|
this.trace(
|
2083
|
2108
|
'setRemoteDescription::postTransform (sim receive)',
|
2084
|
2109
|
dumpSDP(description));
|
2085
|
2110
|
|
2086
|
2111
|
// eslint-disable-next-line no-param-reassign
|
2087
|
|
- description = this.tpcUtils._ensureCorrectOrderOfSsrcs(description);
|
|
2112
|
+ description = this.tpcUtils.ensureCorrectOrderOfSsrcs(description);
|
2088
|
2113
|
}
|
2089
|
2114
|
}
|
2090
|
2115
|
|