Commit b1a7500d authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Change preferred fps range for photo and video preview.

Preferred default fps range for photo mode preview. Preferred maximal
constant fps for video mode preview.

Bug: 976602
Test: Verify the fps range chosen by CCA in both video mode and photo
mode are correct.

Change-Id: Iefe209fe4596d69d29a135ebdc246de04e148015
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1861435
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705883}
parent 4bb33bf1
......@@ -133,10 +133,10 @@ cca.device.VideoConstraintsPreferrer =
super(resolBroker, doReconfigureStream);
/**
* Object saving information of supported constant fps. Each of its key as
* device id and value as an object mapping from resolution to all constant
* fps options supported by that resolution.
* @type {!Object<string, Object<Array<number>, Array<number>>>}
* Object saving information of device supported constant fps. Each of its
* key as device id and value as an object mapping from resolution to all
* constant fps options supported by that resolution.
* @type {!Object<string, !Object<!Array<number>, !Array<number>>>}
* @private
*/
this.constFpsInfo_ = {};
......@@ -238,12 +238,12 @@ cca.device.VideoConstraintsPreferrer =
}
this.prefResolution_[deviceId] = {width, height};
const constFpses = cca.device.SUPPORTED_CONSTANT_FPS.filter(
(fps) => !!fpsRanges.find(
([minFps, maxFps]) => minFps === fps && maxFps === fps));
const constFpses =
fpsRanges.filter(([minFps, maxFps]) => minFps === maxFps)
.map(([fps]) => fps);
const fpsInfo = {};
for (const r of Object.keys(videoMaxFps).map((r) => r.toString())) {
fpsInfo[r] = constFpses.filter((fps) => fps <= videoMaxFps[r]);
for (const [resolution, maxFps] of Object.entries(videoMaxFps)) {
fpsInfo[resolution] = constFpses.filter((fps) => fps <= maxFps);
}
this.constFpsInfo_[deviceId] = fpsInfo;
});
......@@ -263,11 +263,11 @@ cca.device.VideoConstraintsPreferrer =
this.resolBroker_.notifyVideoPrefResolChange(deviceId, width, height);
const fps = stream.getVideoTracks()[0].getSettings().frameRate;
const availableFpses = this.constFpsInfo_[deviceId][[width, height]];
if (availableFpses.includes(fps)) {
this.setPreferredConstFps_(deviceId, width, height, fps);
}
cca.state.set('multi-fps', availableFpses.length > 1);
this.setPreferredConstFps_(deviceId, width, height, fps);
const supportedConstFpses =
this.constFpsInfo_[deviceId][[width, height]].filter(
(fps) => cca.device.SUPPORTED_CONSTANT_FPS.includes(fps));
cca.state.set('multi-fps', supportedConstFpses.length > 1);
}
/**
......@@ -305,14 +305,21 @@ cca.device.VideoConstraintsPreferrer =
// support multiple constant fps options. The resolution-fps tuple are
// sorted by user preference of constant fps.
const getFpses = (r) => {
let constFpses = [null];
if (this.constFpsInfo_[deviceId][r].includes(30)) {
if (this.constFpsInfo_[deviceId][r].includes(60)) {
const prefFps =
this.prefFpses_[deviceId] && this.prefFpses_[deviceId][r] || 30;
constFpses = prefFps == 30 ? [30, 60] : [60, 30];
} else {
constFpses = [30];
let constFpses;
const constFpsInfo = this.constFpsInfo_[deviceId][r];
// The higher constant fps will be ignored if constant 30 and 60 presented
// due to currently lack of UI support for toggling it.
if (constFpsInfo.includes(30) && constFpsInfo.includes(60)) {
const prefFps =
this.prefFpses_[deviceId] && this.prefFpses_[deviceId][r] || 30;
constFpses = prefFps == 30 ? [30, 60] : [60, 30];
} else {
constFpses = [null];
if (constFpsInfo.length > 0) {
const maxConstFps = Math.max(...constFpsInfo);
if (maxConstFps >= 30) {
constFpses.unshift(maxConstFps);
}
}
}
return constFpses.map((fps) => [...r, fps]);
......@@ -384,7 +391,6 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
(maxR, R) => (maxR[0] * maxR[1] < R[0] * R[1] ? R : maxR), [0, 0]);
}
this.prefResolution_[deviceId] = {width, height};
return [deviceId, width, height, photoResols];
});
cca.proxy.browserProxy.localStorageSet(
{devicePhotoResolution: this.prefResolution_});
......@@ -455,7 +461,6 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
audio: false,
video: {
deviceId: {exact: deviceId},
frameRate: {min: 24},
width,
height,
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment