|
@@ -2222,22 +2222,6 @@ TraceablePeerConnection.prototype.setSenderVideoConstraints = function(frameHeig
|
2222
|
2222
|
return Promise.resolve();
|
2223
|
2223
|
}
|
2224
|
2224
|
|
2225
|
|
- const configuredResolution = this.tpcUtils.getConfiguredEncodeResolution(
|
2226
|
|
- localVideoTrack,
|
2227
|
|
- this.getConfiguredVideoCodec());
|
2228
|
|
-
|
2229
|
|
- // Ignore sender constraints if the client is already sending video of the requested resolution. Note that for
|
2230
|
|
- // screensharing sources, the max resolution will be the height of the window being captured irrespective of the
|
2231
|
|
- // height being requested by the peer.
|
2232
|
|
- if ((localVideoTrack.getVideoType() === VideoType.CAMERA && configuredResolution === frameHeight)
|
2233
|
|
- || (localVideoTrack.getVideoType() === VideoType.DESKTOP
|
2234
|
|
- && frameHeight > 0
|
2235
|
|
- && configuredResolution === localVideoTrack.getCaptureResolution())) {
|
2236
|
|
- return Promise.resolve();
|
2237
|
|
- }
|
2238
|
|
-
|
2239
|
|
- this._senderMaxHeights.set(sourceName, frameHeight);
|
2240
|
|
-
|
2241
|
2225
|
return this._updateVideoSenderParameters(
|
2242
|
2226
|
() => this._updateVideoSenderEncodings(frameHeight, localVideoTrack));
|
2243
|
2227
|
};
|
|
@@ -2286,22 +2270,32 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
|
2286
|
2270
|
: DEGRADATION_PREFERENCE_CAMERA; // Prefer frame-rate for high fps share and camera.
|
2287
|
2271
|
|
2288
|
2272
|
parameters.degradationPreference = preference;
|
2289
|
|
- logger.info(`${this} Setting degradation preference [preference=${preference},track=${localVideoTrack}`);
|
2290
|
2273
|
|
2291
|
2274
|
// Calculate the encodings active state based on the resolution requested by the bridge.
|
2292
|
2275
|
const codec = this.getConfiguredVideoCodec();
|
2293
|
|
- const maxBitrates = this.tpcUtils.calculateEncodingsBitrates(localVideoTrack, codec, frameHeight);
|
2294
|
|
- const encodingsActiveState = this.tpcUtils.calculateEncodingsActiveState(localVideoTrack, codec, frameHeight);
|
2295
|
|
- const scaleFactor = this.tpcUtils.calculateEncodingsScaleFactor(localVideoTrack, codec, frameHeight);
|
|
2276
|
+ const bitrates = this.tpcUtils.calculateEncodingsBitrates(localVideoTrack, codec, frameHeight);
|
|
2277
|
+ const activeState = this.tpcUtils.calculateEncodingsActiveState(localVideoTrack, codec, frameHeight);
|
|
2278
|
+ const scaleFactors = this.tpcUtils.calculateEncodingsScaleFactor(localVideoTrack, codec, frameHeight);
|
2296
|
2279
|
const scalabilityModes = this.tpcUtils.calculateEncodingsScalabilityMode(localVideoTrack, codec, frameHeight);
|
2297
|
|
-
|
2298
|
|
- for (const encoding in parameters.encodings) {
|
2299
|
|
- if (parameters.encodings.hasOwnProperty(encoding)) {
|
2300
|
|
- parameters.encodings[encoding].active = encodingsActiveState[encoding];
|
|
2280
|
+ let needsUpdate = false;
|
|
2281
|
+
|
|
2282
|
+ for (const idx in parameters.encodings) {
|
|
2283
|
+ if (parameters.encodings.hasOwnProperty(idx)) {
|
|
2284
|
+ const {
|
|
2285
|
+ active = undefined,
|
|
2286
|
+ maxBitrate = undefined,
|
|
2287
|
+ scalabilityMode = undefined,
|
|
2288
|
+ scaleResolutionDownBy = undefined
|
|
2289
|
+ } = parameters.encodings[idx];
|
|
2290
|
+
|
|
2291
|
+ if (active !== activeState[idx]) {
|
|
2292
|
+ parameters.encodings[idx].active = activeState[idx];
|
|
2293
|
+ needsUpdate = true;
|
|
2294
|
+ }
|
2301
|
2295
|
|
2302
|
2296
|
// Firefox doesn't follow the spec and lets application specify the degradation preference on the
|
2303
|
2297
|
// encodings.
|
2304
|
|
- browser.isFirefox() && (parameters.encodings[encoding].degradationPreference = preference);
|
|
2298
|
+ browser.isFirefox() && (parameters.encodings[idx].degradationPreference = preference);
|
2305
|
2299
|
|
2306
|
2300
|
// Do not configure 'scaleResolutionDownBy' and 'maxBitrate' for encoders running in legacy K-SVC mode
|
2307
|
2301
|
// since the browser sends only the lowest resolution layer when those are configured.
|
|
@@ -2309,21 +2303,36 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
|
2309
|
2303
|
|| !this.isSpatialScalabilityOn()
|
2310
|
2304
|
|| (browser.supportsScalabilityModeAPI()
|
2311
|
2305
|
&& this.tpcUtils.codecSettings[codec].scalabilityModeEnabled)) {
|
2312
|
|
- parameters.encodings[encoding].scaleResolutionDownBy = scaleFactor[encoding];
|
2313
|
|
- parameters.encodings[encoding].maxBitrate = maxBitrates[encoding];
|
|
2306
|
+ if (scaleResolutionDownBy !== scaleFactors[idx]) {
|
|
2307
|
+ parameters.encodings[idx].scaleResolutionDownBy = scaleFactors[idx];
|
|
2308
|
+ needsUpdate = true;
|
|
2309
|
+ }
|
|
2310
|
+ if (maxBitrate !== bitrates[idx]) {
|
|
2311
|
+ parameters.encodings[idx].maxBitrate = bitrates[idx];
|
|
2312
|
+ needsUpdate = true;
|
|
2313
|
+ }
|
2314
|
2314
|
}
|
2315
|
2315
|
|
2316
|
2316
|
// Configure scalability mode when its supported and enabled.
|
2317
|
2317
|
if (scalabilityModes) {
|
2318
|
|
- parameters.encodings[encoding].scalabilityMode = scalabilityModes[encoding];
|
|
2318
|
+ if (scalabilityMode !== scalabilityModes[idx]) {
|
|
2319
|
+ parameters.encodings[idx].scalabilityMode = scalabilityModes[idx];
|
|
2320
|
+ needsUpdate = true;
|
|
2321
|
+ }
|
2319
|
2322
|
} else {
|
2320
|
|
- parameters.encodings[encoding].scalabilityMode = undefined;
|
|
2323
|
+ parameters.encodings[idx].scalabilityMode = undefined;
|
2321
|
2324
|
}
|
2322
|
2325
|
}
|
2323
|
2326
|
}
|
|
2327
|
+
|
|
2328
|
+ if (!needsUpdate) {
|
|
2329
|
+ return Promise.resolve();
|
|
2330
|
+ }
|
|
2331
|
+
|
2324
|
2332
|
logger.info(`${this} setting max height=${frameHeight},encodings=${JSON.stringify(parameters.encodings)}`);
|
2325
|
2333
|
|
2326
|
2334
|
return videoSender.setParameters(parameters).then(() => {
|
|
2335
|
+ this._senderMaxHeights.set(localVideoTrack.getSourceName(), frameHeight);
|
2327
|
2336
|
localVideoTrack.maxEnabledResolution = frameHeight;
|
2328
|
2337
|
this.eventEmitter.emit(RTCEvents.LOCAL_TRACK_MAX_ENABLED_RESOLUTION_CHANGED, localVideoTrack);
|
2329
|
2338
|
});
|