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