Commit 9d7f9f1b authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Convert camera3_device_info.js into ES6 module.

Bug: 141518780
Test: Pass closure compiler check, tast run <DUT> 'camera.CCAUI*' and
manually validate tooltips function of CCA works correctly.

Change-Id: I0d7d71cd0c314c31fe38116a40e1a74b381ca796
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1982334
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727450}
parent 550d6dd5
......@@ -2,73 +2,67 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* Namespace for the Camera app.
*/
var cca = cca || {};
/**
* Namespace for device.
*/
cca.device = cca.device || {};
import {DeviceOperator} from '../mojo/device_operator.js';
import {FpsRangeList, // eslint-disable-line no-unused-vars
MaxFpsInfo, // eslint-disable-line no-unused-vars
Resolution,
ResolutionList, // eslint-disable-line no-unused-vars
VideoConfig, // eslint-disable-line no-unused-vars
} from '../type.js';
/**
* Video device information queried from HALv3 mojo private API.
*/
cca.device.Camera3DeviceInfo = class {
export class Camera3DeviceInfo {
/**
* @public
* @param {!MediaDeviceInfo} deviceInfo Information of the video device.
* @param {!cros.mojom.CameraFacing} facing Camera facing of the video device.
* @param {!cca.ResolutionList} photoResols Supported available photo
* resolutions of the video device.
* @param {!Array<!cca.VideoConfig>} videoResolFpses Supported available video
* @param {!ResolutionList} photoResols Supported available photo resolutions
* of the video device.
* @param {!Array<!VideoConfig>} videoResolFpses Supported available video
* resolutions and maximal capture fps of the video device.
* @param {!cca.FpsRangeList} fpsRanges Supported fps ranges of the video
* device.
* @param {!FpsRangeList} fpsRanges Supported fps ranges of the video device.
*/
constructor(deviceInfo, facing, photoResols, videoResolFpses, fpsRanges) {
/**
* @type {string}
* @const {string}
* @public
*/
this.deviceId = deviceInfo.deviceId;
/**
* @type {cros.mojom.CameraFacing}
* @const {cros.mojom.CameraFacing}
* @public
*/
this.facing = facing;
/**
* @type {!cca.ResolutionList}
* @const {!ResolutionList}
* @public
*/
this.photoResols = photoResols;
/**
* @type {!cca.ResolutionList}
* @const {!ResolutionList}
* @public
*/
this.videoResols = [];
/**
* @type {!cca.MaxFpsInfo}
* @const {!MaxFpsInfo}
* @public
*/
this.videoMaxFps = {};
/**
* @type {!cca.FpsRangeList}
* @const {!FpsRangeList}
* @public
*/
this.fpsRanges = fpsRanges;
videoResolFpses.filter(({maxFps}) => maxFps >= 24)
.forEach(({width, height, maxFps}) => {
const r = new cca.Resolution(width, height);
const r = new Resolution(width, height);
this.videoResols.push(r);
this.videoMaxFps[r] = maxFps;
});
......@@ -78,13 +72,13 @@ cca.device.Camera3DeviceInfo = class {
* Create a Camera3DeviceInfo by given device info and the mojo device
* operator.
* @param {!MediaDeviceInfo} deviceInfo
* @return {!Promise<!cca.device.Camera3DeviceInfo>}
* @return {!Promise<!Camera3DeviceInfo>}
* @throws {Error} Thrown when the device operation is not supported.
*/
static async create(deviceInfo) {
const deviceId = deviceInfo.deviceId;
const deviceOperator = await cca.mojo.DeviceOperator.getInstance();
const deviceOperator = await DeviceOperator.getInstance();
if (!deviceOperator) {
throw new Error('Device operation is not supported');
}
......@@ -94,7 +88,10 @@ cca.device.Camera3DeviceInfo = class {
const supportedFpsRanges =
await deviceOperator.getSupportedFpsRanges(deviceId);
return new cca.device.Camera3DeviceInfo(
return new Camera3DeviceInfo(
deviceInfo, facing, photoResolution, videoConfigs, supportedFpsRanges);
}
};
}
/** @const */
cca.device.Camera3DeviceInfo = Camera3DeviceInfo;
......@@ -9,6 +9,7 @@
// eslint-disable-next-line no-unused-vars
var cca = {
device: {},
mojo: {},
nav: {},
perf: {},
......
......@@ -23,7 +23,7 @@
<script type="module" src="../js/state.js"></script>
<script defer src="../js/sound.js"></script>
<script defer src="../js/device/error.js"></script>
<script defer src="../js/device/camera3_device_info.js"></script>
<script type="module" src="../js/device/camera3_device_info.js"></script>
<script defer src="../js/device/constraints_preferrer.js"></script>
<script defer src="../js/device/device_info_updater.js"></script>
<script defer src="../js/models/filenamer.js"></script>
......
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