|
@@ -10,6 +10,7 @@ import * as MediaType from '../../service/RTC/MediaType';
|
10
|
10
|
import RTCEvents from '../../service/RTC/RTCEvents';
|
11
|
11
|
import * as SignalingEvents from '../../service/RTC/SignalingEvents';
|
12
|
12
|
import * as VideoType from '../../service/RTC/VideoType';
|
|
13
|
+import { SS_DEFAULT_FRAME_RATE } from '../RTC/ScreenObtainer';
|
13
|
14
|
import browser from '../browser';
|
14
|
15
|
import LocalSdpMunger from '../sdp/LocalSdpMunger';
|
15
|
16
|
import RtxModifier from '../sdp/RtxModifier';
|
|
@@ -243,6 +244,11 @@ export default function TraceablePeerConnection(
|
243
|
244
|
this.stats = {};
|
244
|
245
|
this.statsinterval = null;
|
245
|
246
|
|
|
247
|
+ /**
|
|
248
|
+ * Flag used to indicate if simulcast is turned off and a cap of 500 Kbps is applied on screensharing.
|
|
249
|
+ */
|
|
250
|
+ this._capScreenshareBitrate = this.options.capScreenshareBitrate;
|
|
251
|
+
|
246
|
252
|
/**
|
247
|
253
|
* Flag used to indicate if the browser is running in unified plan mode.
|
248
|
254
|
*/
|
|
@@ -1841,6 +1847,17 @@ TraceablePeerConnection.prototype.getConfiguredVideoCodec = function() {
|
1841
|
1847
|
return defaultCodec;
|
1842
|
1848
|
};
|
1843
|
1849
|
|
|
1850
|
+/**
|
|
1851
|
+ * Enables or disables simulcast for screenshare based on the frame rate requested for desktop track capture.
|
|
1852
|
+ *
|
|
1853
|
+ * @param {number} maxFps framerate to be used for desktop track capture.
|
|
1854
|
+ */
|
|
1855
|
+TraceablePeerConnection.prototype.setDesktopSharingFrameRate = function(maxFps) {
|
|
1856
|
+ const lowFps = maxFps <= SS_DEFAULT_FRAME_RATE;
|
|
1857
|
+
|
|
1858
|
+ this._capScreenshareBitrate = this.isSimulcastOn() && lowFps && !this._usesUnifiedPlan;
|
|
1859
|
+};
|
|
1860
|
+
|
1844
|
1861
|
/**
|
1845
|
1862
|
* Sets the codec preference on the peerconnection. The codec preference goes into effect when
|
1846
|
1863
|
* the next renegotiation happens.
|
|
@@ -2296,7 +2313,7 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
|
2296
|
2313
|
const parameters = videoSender.getParameters();
|
2297
|
2314
|
const preference = localVideoTrack.videoType === VideoType.CAMERA
|
2298
|
2315
|
? DEGRADATION_PREFERENCE_CAMERA
|
2299
|
|
- : this.options.capScreenshareBitrate && !this._usesUnifiedPlan
|
|
2316
|
+ : this._capScreenshareBitrate && !this._usesUnifiedPlan
|
2300
|
2317
|
|
2301
|
2318
|
// Prefer resolution for low fps share.
|
2302
|
2319
|
? DEGRADATION_PREFERENCE_DESKTOP
|
|
@@ -2340,7 +2357,7 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
|
2340
|
2357
|
// 2. Track is a desktop track and bitrate is capped using capScreenshareBitrate option in plan-b mode.
|
2341
|
2358
|
// 3. The client is running in Unified plan mode.
|
2342
|
2359
|
if (!((this.options.videoQuality && this.options.videoQuality.maxBitratesVideo)
|
2343
|
|
- || (planBScreenSharing && this.options.capScreenshareBitrate)
|
|
2360
|
+ || (planBScreenSharing && this._capScreenshareBitrate)
|
2344
|
2361
|
|| this._usesUnifiedPlan)) {
|
2345
|
2362
|
return Promise.resolve();
|
2346
|
2363
|
}
|
|
@@ -2368,7 +2385,7 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
|
2368
|
2385
|
// is enabled through config.js and presenter is not turned on.
|
2369
|
2386
|
// FIXME the top 'isSimulcastOn' condition is confusing for screensharing, because
|
2370
|
2387
|
// if capScreenshareBitrate option is enabled then the simulcast is turned off
|
2371
|
|
- bitrate = this.options.capScreenshareBitrate
|
|
2388
|
+ bitrate = this._capScreenshareBitrate
|
2372
|
2389
|
? presenterEnabled ? HD_BITRATE : DESKTOP_SHARE_RATE
|
2373
|
2390
|
|
2374
|
2391
|
// Remove the bitrate config if not capScreenshareBitrate:
|
|
@@ -2779,8 +2796,8 @@ TraceablePeerConnection.prototype._createOfferOrAnswer = function(
|
2779
|
2796
|
// Configure simulcast for camera tracks always and for desktop tracks only when
|
2780
|
2797
|
// the "capScreenshareBitrate" flag in config.js is disabled.
|
2781
|
2798
|
if (this.isSimulcastOn() && browser.usesSdpMungingForSimulcast()
|
2782
|
|
- && (!this.options.capScreenshareBitrate
|
2783
|
|
- || (this.options.capScreenshareBitrate && !this._isSharingScreen()))) {
|
|
2799
|
+ && (!this._capScreenshareBitrate
|
|
2800
|
+ || (this._capScreenshareBitrate && !this._isSharingScreen()))) {
|
2784
|
2801
|
// eslint-disable-next-line no-param-reassign
|
2785
|
2802
|
resultSdp = this.simulcast.mungeLocalDescription(resultSdp);
|
2786
|
2803
|
this.trace(
|
|
@@ -2983,8 +3000,8 @@ TraceablePeerConnection.prototype.generateNewStreamSSRCInfo = function(track) {
|
2983
|
3000
|
// Configure simulcast for camera tracks always and for desktop tracks only when
|
2984
|
3001
|
// the "capScreenshareBitrate" flag in config.js is disabled.
|
2985
|
3002
|
if (this.isSimulcastOn()
|
2986
|
|
- && (!this.options.capScreenshareBitrate
|
2987
|
|
- || (this.options.capScreenshareBitrate && !this._isSharingScreen()))) {
|
|
3003
|
+ && (!this._capScreenshareBitrate
|
|
3004
|
+ || (this._capScreenshareBitrate && !this._isSharingScreen()))) {
|
2988
|
3005
|
ssrcInfo = {
|
2989
|
3006
|
ssrcs: [],
|
2990
|
3007
|
groups: []
|