|
|
@@ -1576,6 +1576,16 @@ TraceablePeerConnection.prototype._getSSRC = function(rtcId) {
|
|
1576
|
1576
|
return this.localSSRCs.get(rtcId);
|
|
1577
|
1577
|
};
|
|
1578
|
1578
|
|
|
|
1579
|
+/**
|
|
|
1580
|
+ * Checks if low fps screensharing is in progress.
|
|
|
1581
|
+ *
|
|
|
1582
|
+ * @private
|
|
|
1583
|
+ * @returns {boolean} Returns true if 5 fps screensharing is in progress, false otherwise.
|
|
|
1584
|
+ */
|
|
|
1585
|
+TraceablePeerConnection.prototype._isSharingLowFpsScreen = function() {
|
|
|
1586
|
+ return this._isSharingScreen() && this._capScreenshareBitrate;
|
|
|
1587
|
+};
|
|
|
1588
|
+
|
|
1579
|
1589
|
/**
|
|
1580
|
1590
|
* Checks if screensharing is in progress.
|
|
1581
|
1591
|
*
|
|
|
@@ -1692,11 +1702,7 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
|
|
1692
|
1702
|
return Promise.reject(error);
|
|
1693
|
1703
|
}
|
|
1694
|
1704
|
} else {
|
|
1695
|
|
- // In all other cases, i.e., plan-b and unified plan bridge case, use addStream API to
|
|
1696
|
|
- // add the track to the peerconnection.
|
|
1697
|
|
- // TODO - addTransceiver doesn't generate a MSID for the stream, which is needed for signaling
|
|
1698
|
|
- // the ssrc to Jicofo. Switch to using UUID as MSID when addTransceiver is used in Unified plan
|
|
1699
|
|
- // JVB connection case as well.
|
|
|
1705
|
+ // Use addStream API for the plan-b case.
|
|
1700
|
1706
|
const webrtcStream = track.getOriginalStream();
|
|
1701
|
1707
|
|
|
1702
|
1708
|
if (webrtcStream) {
|
|
|
@@ -1855,7 +1861,7 @@ TraceablePeerConnection.prototype.getConfiguredVideoCodec = function() {
|
|
1855
|
1861
|
TraceablePeerConnection.prototype.setDesktopSharingFrameRate = function(maxFps) {
|
|
1856
|
1862
|
const lowFps = maxFps <= SS_DEFAULT_FRAME_RATE;
|
|
1857
|
1863
|
|
|
1858
|
|
- this._capScreenshareBitrate = this.isSimulcastOn() && lowFps && !this._usesUnifiedPlan;
|
|
|
1864
|
+ this._capScreenshareBitrate = this.isSimulcastOn() && lowFps;
|
|
1859
|
1865
|
};
|
|
1860
|
1866
|
|
|
1861
|
1867
|
/**
|
|
|
@@ -2311,15 +2317,13 @@ TraceablePeerConnection.prototype.setSenderVideoDegradationPreference = function
|
|
2311
|
2317
|
return Promise.resolve();
|
|
2312
|
2318
|
}
|
|
2313
|
2319
|
const parameters = videoSender.getParameters();
|
|
2314
|
|
- const preference = localVideoTrack.videoType === VideoType.CAMERA
|
|
2315
|
|
- ? DEGRADATION_PREFERENCE_CAMERA
|
|
2316
|
|
- : this._capScreenshareBitrate && !this._usesUnifiedPlan
|
|
|
2320
|
+ const preference = this._isSharingLowFpsScreen()
|
|
2317
|
2321
|
|
|
2318
|
|
- // Prefer resolution for low fps share.
|
|
2319
|
|
- ? DEGRADATION_PREFERENCE_DESKTOP
|
|
|
2322
|
+ // Prefer resolution for low fps share.
|
|
|
2323
|
+ ? DEGRADATION_PREFERENCE_DESKTOP
|
|
2320
|
2324
|
|
|
2321
|
|
- // Prefer frame-rate for high fps share.
|
|
2322
|
|
- : DEGRADATION_PREFERENCE_CAMERA;
|
|
|
2325
|
+ // Prefer frame-rate for high fps share and camera.
|
|
|
2326
|
+ : DEGRADATION_PREFERENCE_CAMERA;
|
|
2323
|
2327
|
|
|
2324
|
2328
|
logger.info(`${this} Setting a degradation preference [preference=${preference},track=${localVideoTrack}`);
|
|
2325
|
2329
|
parameters.degradationPreference = preference;
|
|
|
@@ -2349,16 +2353,14 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
|
|
2349
|
2353
|
return Promise.resolve();
|
|
2350
|
2354
|
}
|
|
2351
|
2355
|
|
|
2352
|
|
- const videoType = localVideoTrack.videoType;
|
|
2353
|
|
- const planBScreenSharing = !this._usesUnifiedPlan && videoType === VideoType.DESKTOP;
|
|
|
2356
|
+ const videoType = localVideoTrack.getVideoType();
|
|
2354
|
2357
|
|
|
2355
|
2358
|
// Apply the maxbitrates on the video track when one of the conditions is met.
|
|
2356
|
2359
|
// 1. Max. bitrates for video are specified through videoQuality settings in config.js
|
|
2357
|
|
- // 2. Track is a desktop track and bitrate is capped using capScreenshareBitrate option in plan-b mode.
|
|
2358
|
|
- // 3. The client is running in Unified plan mode.
|
|
2359
|
|
- if (!((this.options.videoQuality && this.options.videoQuality.maxBitratesVideo)
|
|
2360
|
|
- || (planBScreenSharing && this._capScreenshareBitrate)
|
|
2361
|
|
- || this._usesUnifiedPlan)) {
|
|
|
2360
|
+ // 2. Track is a low fps desktop track.
|
|
|
2361
|
+ // 3. The client is running in Unified plan mode (the same sender is re-used for different types
|
|
|
2362
|
+ // of tracks so bitrates have to be configured whenever the local tracks are replaced).
|
|
|
2363
|
+ if (!(this.options?.videoQuality?.maxBitratesVideo || this._isSharingLowFpsScreen() || this._usesUnifiedPlan)) {
|
|
2362
|
2364
|
return Promise.resolve();
|
|
2363
|
2365
|
}
|
|
2364
|
2366
|
|
|
|
@@ -2371,31 +2373,25 @@ TraceablePeerConnection.prototype.setMaxBitRate = function() {
|
|
2371
|
2373
|
}
|
|
2372
|
2374
|
const parameters = videoSender.getParameters();
|
|
2373
|
2375
|
|
|
2374
|
|
- if (!(parameters.encodings && parameters.encodings.length)) {
|
|
|
2376
|
+ if (!parameters.encodings?.length) {
|
|
2375
|
2377
|
return Promise.resolve();
|
|
2376
|
2378
|
}
|
|
2377
|
2379
|
|
|
2378
|
2380
|
if (this.isSimulcastOn()) {
|
|
2379
|
2381
|
for (const encoding in parameters.encodings) {
|
|
2380
|
2382
|
if (parameters.encodings.hasOwnProperty(encoding)) {
|
|
2381
|
|
- let bitrate;
|
|
|
2383
|
+ const bitrate = this._isSharingLowFpsScreen()
|
|
2382
|
2384
|
|
|
2383
|
|
- if (planBScreenSharing) {
|
|
2384
|
|
- // On chromium, set a max bitrate of 500 Kbps for screenshare when capScreenshareBitrate
|
|
2385
|
|
- // is enabled through config.js and presenter is not turned on.
|
|
|
2385
|
+ // For low fps screensharing, set a max bitrate of 500 Kbps when presenter is not turned on.
|
|
2386
|
2386
|
// FIXME the top 'isSimulcastOn' condition is confusing for screensharing, because
|
|
2387
|
|
- // if capScreenshareBitrate option is enabled then the simulcast is turned off
|
|
2388
|
|
- bitrate = this._capScreenshareBitrate
|
|
2389
|
|
- ? presenterEnabled ? HD_BITRATE : DESKTOP_SHARE_RATE
|
|
2390
|
|
-
|
|
2391
|
|
- // Remove the bitrate config if not capScreenshareBitrate:
|
|
2392
|
|
- // When switching from camera to desktop and videoQuality.maxBitratesVideo were set,
|
|
2393
|
|
- // then the 'maxBitrate' setting must be cleared, because if simulcast is enabled for screen
|
|
2394
|
|
- // and maxBitrates are set then Chrome will not send the screen stream (plan B).
|
|
2395
|
|
- : undefined;
|
|
2396
|
|
- } else {
|
|
2397
|
|
- bitrate = this.tpcUtils.localStreamEncodingsConfig[encoding].maxBitrate;
|
|
2398
|
|
- }
|
|
|
2387
|
+ // if capScreenshareBitrate option is enabled then simulcast is turned off for the stream.
|
|
|
2388
|
+ ? presenterEnabled ? HD_BITRATE : DESKTOP_SHARE_RATE
|
|
|
2389
|
+
|
|
|
2390
|
+ // For high fps screenshare, 'maxBitrate' setting must be cleared on Chrome, because if simulcast is
|
|
|
2391
|
+ // enabled for screen and maxBitrates are set then Chrome will not send the desktop stream.
|
|
|
2392
|
+ : videoType === VideoType.DESKTOP && browser.isChromiumBased()
|
|
|
2393
|
+ ? undefined
|
|
|
2394
|
+ : this.tpcUtils.localStreamEncodingsConfig[encoding].maxBitrate;
|
|
2399
|
2395
|
|
|
2400
|
2396
|
logger.info(`${this} Setting a max bitrate of ${bitrate} bps on layer `
|
|
2401
|
2397
|
+ `${this.tpcUtils.localStreamEncodingsConfig[encoding].rid}`);
|
|
|
@@ -2546,7 +2542,7 @@ TraceablePeerConnection.prototype.setSenderVideoConstraint = function(frameHeigh
|
|
2546
|
2542
|
}
|
|
2547
|
2543
|
const parameters = videoSender.getParameters();
|
|
2548
|
2544
|
|
|
2549
|
|
- if (!parameters || !parameters.encodings || !parameters.encodings.length) {
|
|
|
2545
|
+ if (!parameters?.encodings?.length) {
|
|
2550
|
2546
|
return Promise.resolve();
|
|
2551
|
2547
|
}
|
|
2552
|
2548
|
|
|
|
@@ -2565,6 +2561,18 @@ TraceablePeerConnection.prototype.setSenderVideoConstraint = function(frameHeigh
|
|
2565
|
2561
|
if (newHeight > 0 && ldStreamIndex !== -1) {
|
|
2566
|
2562
|
this.encodingsEnabledState[ldStreamIndex] = true;
|
|
2567
|
2563
|
}
|
|
|
2564
|
+
|
|
|
2565
|
+ // Disable the lower spatial layers for screensharing in Unified plan when low fps screensharing is in progress
|
|
|
2566
|
+ // There is no way to enable or disable simulcast during the call since we are re-using the same sender.
|
|
|
2567
|
+ // Safari is an exception here since it does not send the desktop stream at all if only the high resolution
|
|
|
2568
|
+ // stream is enabled.
|
|
|
2569
|
+ if (this._isSharingLowFpsScreen() && this._usesUnifiedPlan && !browser.isWebKitBased()) {
|
|
|
2570
|
+ const highResolutionEncoding = browser.isFirefox() ? 0 : this.encodingsEnabledState.length - 1;
|
|
|
2571
|
+
|
|
|
2572
|
+ this.encodingsEnabledState = this.encodingsEnabledState
|
|
|
2573
|
+ .map((encoding, idx) => idx === highResolutionEncoding);
|
|
|
2574
|
+ }
|
|
|
2575
|
+
|
|
2568
|
2576
|
for (const encoding in parameters.encodings) {
|
|
2569
|
2577
|
if (parameters.encodings.hasOwnProperty(encoding)) {
|
|
2570
|
2578
|
parameters.encodings[encoding].active = this.encodingsEnabledState[encoding];
|
|
|
@@ -2572,9 +2580,7 @@ TraceablePeerConnection.prototype.setSenderVideoConstraint = function(frameHeigh
|
|
2572
|
2580
|
}
|
|
2573
|
2581
|
this.tpcUtils.updateEncodingsResolution(parameters);
|
|
2574
|
2582
|
} else if (newHeight > 0) {
|
|
2575
|
|
- // Do not scale down the desktop tracks until SendVideoController is able to propagate the sender constraints
|
|
2576
|
|
- // only on the active media connection. Right now, the sender constraints received on the bridge channel
|
|
2577
|
|
- // are propagated on both the jvb and p2p connections in cases where they both are active at the same time.
|
|
|
2583
|
+ // Do not scale down encodings for desktop tracks for non-simulcast case.
|
|
2578
|
2584
|
parameters.encodings[0].scaleResolutionDownBy
|
|
2579
|
2585
|
= localVideoTrack.videoType === VideoType.DESKTOP || localVideoTrack.resolution <= newHeight
|
|
2580
|
2586
|
? 1
|
|
|
@@ -2793,11 +2799,11 @@ TraceablePeerConnection.prototype._createOfferOrAnswer = function(
|
|
2793
|
2799
|
dumpSDP(resultSdp));
|
|
2794
|
2800
|
}
|
|
2795
|
2801
|
|
|
2796
|
|
- // Configure simulcast for camera tracks always and for desktop tracks only when
|
|
2797
|
|
- // the "capScreenshareBitrate" flag in config.js is disabled.
|
|
|
2802
|
+ const localVideoTrack = this.getLocalVideoTrack();
|
|
|
2803
|
+
|
|
|
2804
|
+ // Configure simulcast for camera tracks and for desktop tracks that need simulcast.
|
|
2798
|
2805
|
if (this.isSimulcastOn() && browser.usesSdpMungingForSimulcast()
|
|
2799
|
|
- && (!this._capScreenshareBitrate
|
|
2800
|
|
- || (this._capScreenshareBitrate && !this._isSharingScreen()))) {
|
|
|
2806
|
+ && (localVideoTrack?.getVideoType() === VideoType.CAMERA || !this._isSharingLowFpsScreen())) {
|
|
2801
|
2807
|
// eslint-disable-next-line no-param-reassign
|
|
2802
|
2808
|
resultSdp = this.simulcast.mungeLocalDescription(resultSdp);
|
|
2803
|
2809
|
this.trace(
|
|
|
@@ -2997,11 +3003,9 @@ TraceablePeerConnection.prototype.generateNewStreamSSRCInfo = function(track) {
|
|
2997
|
3003
|
logger.error(`${this} Overwriting local SSRCs for track id=${rtcId}`);
|
|
2998
|
3004
|
}
|
|
2999
|
3005
|
|
|
3000
|
|
- // Configure simulcast for camera tracks always and for desktop tracks only when
|
|
3001
|
|
- // the "capScreenshareBitrate" flag in config.js is disabled.
|
|
|
3006
|
+ // Configure simulcast for camera tracks and desktop tracks that need simulcast.
|
|
3002
|
3007
|
if (this.isSimulcastOn()
|
|
3003
|
|
- && (!this._capScreenshareBitrate
|
|
3004
|
|
- || (this._capScreenshareBitrate && !this._isSharingScreen()))) {
|
|
|
3008
|
+ && (track.getVideoType() === VideoType.CAMERA || !this._isSharingLowFpsScreen())) {
|
|
3005
|
3009
|
ssrcInfo = {
|
|
3006
|
3010
|
ssrcs: [],
|
|
3007
|
3011
|
groups: []
|