Commit 8e666bc7 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

CCA: Filter out photo resolution options without corresponding preview

Makes setting view get available capture resolutions from
ConstraintsPreferrer instead of DeviceInfoUpdator.  The
PhotoConstraintsPreferrer will first pair capture and preview resolution
so as to filter out capture resolution without corresponding preview and
feed the correct available options to settings view.

Bug: 1113589
Test: Plugin c930e webcam, see will photo resolution options are
togglable.
Test: tast run -verbose <DUT> "camera.CCAUI*"

Change-Id: Ifa305d48d41c7dde7bd2b5ea1f3168bfd36609ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2358939
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800039}
parent b138f042
......@@ -130,7 +130,6 @@ copy("chrome_camera_app_js_device") {
"src/js/device/camera3_device_info.js",
"src/js/device/constraints_preferrer.js",
"src/js/device/device_info_updater.js",
"src/js/device/error.js",
]
outputs = [ "$out_camera_app_dir/js/device/{{source_file_part}}" ]
......
......@@ -26,7 +26,6 @@
<structure name="IDR_CAMERA_CHROME_UTIL_JS" file="src/js/chrome_util.js" type="chrome_html" />
<structure name="IDR_CAMERA_COMLINK_JS" file="src/js/lib/comlink.js" type="chrome_html" />
<structure name="IDR_CAMERA_CONSTRAINTS_PREFERRER_JS" file="src/js/device/constraints_preferrer.js" type="chrome_html" />
<structure name="IDR_CAMERA_DEVICE_ERROR_JS" file="src/js/device/error.js" type="chrome_html" />
<structure name="IDR_CAMERA_DEVICE_INFO_UPDATER_JS" file="src/js/device/device_info_updater.js" type="chrome_html" />
<structure name="IDR_CAMERA_DEVICE_OPERATOR_JS" file="src/js/mojo/device_operator.js" type="chrome_html" />
<structure name="IDR_CAMERA_DIALOG_JS" file="src/js/views/dialog.js" type="chrome_html" />
......
......@@ -27,7 +27,6 @@ js_library("compile_resources") {
"device/camera3_device_info.js",
"device/constraints_preferrer.js",
"device/device_info_updater.js",
"device/error.js",
"error.js",
"gallerybutton.js",
"intent.js",
......
......@@ -12,7 +12,6 @@ import {
PhotoConstraintsPreferrer, // eslint-disable-line no-unused-vars
VideoConstraintsPreferrer, // eslint-disable-line no-unused-vars
} from './constraints_preferrer.js';
import {LegacyVCDError} from './error.js';
/**
* Contains information of all cameras on the device and will updates its value
......@@ -240,21 +239,4 @@ export class DeviceInfoUpdater {
async getCamera3DevicesInfo() {
return this.camera3DevicesInfo_;
}
/**
* Gets supported photo and video resolutions for specified video device.
* @param {string} deviceId Device id of the video device.
* @return {!Promise<{photo: !ResolutionList, video: !ResolutionList}>}
* Supported photo and video resolutions.
* @throws {!Error} May fail on HALv1 device without capability of querying
* supported resolutions.
*/
async getDeviceResolutions(deviceId) {
const devices = await this.getCamera3DevicesInfo();
if (!devices) {
throw new LegacyVCDError();
}
const info = devices.find((info) => info.deviceId === deviceId);
return {photo: info.photoResols, video: info.videoResols};
}
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Throws from calls to methods requiring mojo supporting VCD on HALv1 device
* equipped with legacy VCD implementation.
*/
export class LegacyVCDError extends Error {
/**
* @param {string=} message
* @public
*/
constructor(
message =
'Call to unsupported mojo operation on legacy VCD implementation.') {
super(message);
this.name = this.constructor.name;
}
}
......@@ -499,10 +499,7 @@ export class Camera extends View {
let resolCandidates = null;
if (deviceOperator !== null) {
if (deviceId !== null) {
const previewRs =
(await this.infoUpdater_.getDeviceResolutions(deviceId)).video;
resolCandidates =
this.modes_.getResolutionCandidates(mode, deviceId, previewRs);
resolCandidates = this.modes_.getResolutionCandidates(mode, deviceId);
} else {
console.error(
'Null device id present on HALv3 device. Fallback to v1.');
......
......@@ -386,12 +386,11 @@ export class Modes {
* constraints for the given mode.
* @param {!Mode} mode
* @param {string} deviceId
* @param {!ResolutionList} previewResolutions
* @return {!Array<!CaptureCandidate>}
*/
getResolutionCandidates(mode, deviceId, previewResolutions) {
getResolutionCandidates(mode, deviceId) {
return this.allModes_[mode].constraintsPreferrer.getSortedCandidates(
deviceId, previewResolutions);
deviceId);
}
/**
......
......@@ -303,7 +303,11 @@ export class ResolutionSettings extends BaseSettings {
this.frontSetting_ = this.backSetting_ = null;
this.externalSettings_ = [];
devices.forEach(({deviceId, facing, photoResols, videoResols}) => {
devices.forEach(({deviceId, facing}) => {
const photoResols =
this.photoPreferrer_.getSupportedResolutions(deviceId);
const videoResols =
this.videoPreferrer_.getSupportedResolutions(deviceId);
const /** !DeviceSetting */ deviceSetting = {
deviceId,
photo: {
......
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