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 = ...@@ -133,10 +133,10 @@ cca.device.VideoConstraintsPreferrer =
super(resolBroker, doReconfigureStream); super(resolBroker, doReconfigureStream);
/** /**
* Object saving information of supported constant fps. Each of its key as * Object saving information of device supported constant fps. Each of its
* device id and value as an object mapping from resolution to all constant * key as device id and value as an object mapping from resolution to all
* fps options supported by that resolution. * constant fps options supported by that resolution.
* @type {!Object<string, Object<Array<number>, Array<number>>>} * @type {!Object<string, !Object<!Array<number>, !Array<number>>>}
* @private * @private
*/ */
this.constFpsInfo_ = {}; this.constFpsInfo_ = {};
...@@ -238,12 +238,12 @@ cca.device.VideoConstraintsPreferrer = ...@@ -238,12 +238,12 @@ cca.device.VideoConstraintsPreferrer =
} }
this.prefResolution_[deviceId] = {width, height}; this.prefResolution_[deviceId] = {width, height};
const constFpses = cca.device.SUPPORTED_CONSTANT_FPS.filter( const constFpses =
(fps) => !!fpsRanges.find( fpsRanges.filter(([minFps, maxFps]) => minFps === maxFps)
([minFps, maxFps]) => minFps === fps && maxFps === fps)); .map(([fps]) => fps);
const fpsInfo = {}; const fpsInfo = {};
for (const r of Object.keys(videoMaxFps).map((r) => r.toString())) { for (const [resolution, maxFps] of Object.entries(videoMaxFps)) {
fpsInfo[r] = constFpses.filter((fps) => fps <= videoMaxFps[r]); fpsInfo[resolution] = constFpses.filter((fps) => fps <= maxFps);
} }
this.constFpsInfo_[deviceId] = fpsInfo; this.constFpsInfo_[deviceId] = fpsInfo;
}); });
...@@ -263,11 +263,11 @@ cca.device.VideoConstraintsPreferrer = ...@@ -263,11 +263,11 @@ cca.device.VideoConstraintsPreferrer =
this.resolBroker_.notifyVideoPrefResolChange(deviceId, width, height); this.resolBroker_.notifyVideoPrefResolChange(deviceId, width, height);
const fps = stream.getVideoTracks()[0].getSettings().frameRate; const fps = stream.getVideoTracks()[0].getSettings().frameRate;
const availableFpses = this.constFpsInfo_[deviceId][[width, height]];
if (availableFpses.includes(fps)) {
this.setPreferredConstFps_(deviceId, width, height, fps); this.setPreferredConstFps_(deviceId, width, height, fps);
} const supportedConstFpses =
cca.state.set('multi-fps', availableFpses.length > 1); 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 = ...@@ -305,14 +305,21 @@ cca.device.VideoConstraintsPreferrer =
// support multiple constant fps options. The resolution-fps tuple are // support multiple constant fps options. The resolution-fps tuple are
// sorted by user preference of constant fps. // sorted by user preference of constant fps.
const getFpses = (r) => { const getFpses = (r) => {
let constFpses = [null]; let constFpses;
if (this.constFpsInfo_[deviceId][r].includes(30)) { const constFpsInfo = this.constFpsInfo_[deviceId][r];
if (this.constFpsInfo_[deviceId][r].includes(60)) { // 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 = const prefFps =
this.prefFpses_[deviceId] && this.prefFpses_[deviceId][r] || 30; this.prefFpses_[deviceId] && this.prefFpses_[deviceId][r] || 30;
constFpses = prefFps == 30 ? [30, 60] : [60, 30]; constFpses = prefFps == 30 ? [30, 60] : [60, 30];
} else { } else {
constFpses = [30]; constFpses = [null];
if (constFpsInfo.length > 0) {
const maxConstFps = Math.max(...constFpsInfo);
if (maxConstFps >= 30) {
constFpses.unshift(maxConstFps);
}
} }
} }
return constFpses.map((fps) => [...r, fps]); return constFpses.map((fps) => [...r, fps]);
...@@ -384,7 +391,6 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { ...@@ -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]); (maxR, R) => (maxR[0] * maxR[1] < R[0] * R[1] ? R : maxR), [0, 0]);
} }
this.prefResolution_[deviceId] = {width, height}; this.prefResolution_[deviceId] = {width, height};
return [deviceId, width, height, photoResols];
}); });
cca.proxy.browserProxy.localStorageSet( cca.proxy.browserProxy.localStorageSet(
{devicePhotoResolution: this.prefResolution_}); {devicePhotoResolution: this.prefResolution_});
...@@ -455,7 +461,6 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { ...@@ -455,7 +461,6 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
audio: false, audio: false,
video: { video: {
deviceId: {exact: deviceId}, deviceId: {exact: deviceId},
frameRate: {min: 24},
width, width,
height, 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