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

[CCA] Remove ResolutionEventBroker.

ResolutionEventBroker was designed for aggregating a set of resolution
related callbacks passing to all deep nested resolution related
components. After several refactor works, all resolution related
function will be moved into ConstraintsPreferrer and this broker is no
longer needed.

Bug: b/141518780
Test: Pass closure compiler check, tast run <DUT> 'camera.CCAUI*'
and validate all function of CCA on HALv1/v3 device works correctly.

Change-Id: I92f0b22b4d645155862f506347752d48e8b63714
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883470
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714409}
parent 7b813bbc
...@@ -119,7 +119,6 @@ copy("chrome_camera_app_js") { ...@@ -119,7 +119,6 @@ copy("chrome_camera_app_js") {
"src/js/main.js", "src/js/main.js",
"src/js/metrics.js", "src/js/metrics.js",
"src/js/nav.js", "src/js/nav.js",
"src/js/resolution_event_broker.js",
"src/js/scrollbar.js", "src/js/scrollbar.js",
"src/js/sound.js", "src/js/sound.js",
"src/js/state.js", "src/js/state.js",
......
...@@ -139,7 +139,6 @@ RESOURCES = \ ...@@ -139,7 +139,6 @@ RESOURCES = \
src/js/mojo/device_operator.js \ src/js/mojo/device_operator.js \
src/js/mojo/image_capture.js \ src/js/mojo/image_capture.js \
src/js/nav.js \ src/js/nav.js \
src/js/resolution_event_broker.js \
src/js/scrollbar.js \ src/js/scrollbar.js \
src/js/sound.js \ src/js/sound.js \
src/js/state.js \ src/js/state.js \
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
<structure name="IDR_CAMERA_OPTIONS_JS" file="src/js/views/camera/options.js" type="chrome_html" /> <structure name="IDR_CAMERA_OPTIONS_JS" file="src/js/views/camera/options.js" type="chrome_html" />
<structure name="IDR_CAMERA_PREVIEW_JS" file="src/js/views/camera/preview.js" type="chrome_html" /> <structure name="IDR_CAMERA_PREVIEW_JS" file="src/js/views/camera/preview.js" type="chrome_html" />
<structure name="IDR_CAMERA_RECORDTIME_JS" file="src/js/views/camera/recordtime.js" type="chrome_html" /> <structure name="IDR_CAMERA_RECORDTIME_JS" file="src/js/views/camera/recordtime.js" type="chrome_html" />
<structure name="IDR_CAMERA_RESOLUTION_EVENT_BROKER_JS" file="src/js/resolution_event_broker.js" type="chrome_html" />
<structure name="IDR_CAMERA_RESULT_SAVER_JS" file="src/js/models/result_saver.js" type="chrome_html" /> <structure name="IDR_CAMERA_RESULT_SAVER_JS" file="src/js/models/result_saver.js" type="chrome_html" />
<structure name="IDR_CAMERA_REVIEW_RESULT_JS" file="src/js/views/camera/review_result.js" type="chrome_html" /> <structure name="IDR_CAMERA_REVIEW_RESULT_JS" file="src/js/views/camera/review_result.js" type="chrome_html" />
<structure name="IDR_CAMERA_SCROLLBAR_JS" file="src/js/scrollbar.js" type="chrome_html" /> <structure name="IDR_CAMERA_SCROLLBAR_JS" file="src/js/scrollbar.js" type="chrome_html" />
......
...@@ -21,7 +21,6 @@ js_type_check("compile_resources") { ...@@ -21,7 +21,6 @@ js_type_check("compile_resources") {
":intent", ":intent",
":metrics", ":metrics",
":nav", ":nav",
":resolution_event_broker",
":state", ":state",
":toast", ":toast",
":tooltip", ":tooltip",
...@@ -42,9 +41,6 @@ js_library("metrics") { ...@@ -42,9 +41,6 @@ js_library("metrics") {
] ]
} }
js_library("resolution_event_broker") {
}
js_library("type") { js_library("type") {
} }
......
...@@ -23,7 +23,6 @@ js_library("camera3_device_info") { ...@@ -23,7 +23,6 @@ js_library("camera3_device_info") {
js_library("constraints_preferrer") { js_library("constraints_preferrer") {
deps = [ deps = [
":camera3_device_info", ":camera3_device_info",
"..:resolution_event_broker",
"..:state", "..:state",
"..:type", "..:type",
"../browser_proxy:browser_proxy", "../browser_proxy:browser_proxy",
......
...@@ -42,18 +42,11 @@ var CaptureCandidate; ...@@ -42,18 +42,11 @@ var CaptureCandidate;
*/ */
cca.device.ConstraintsPreferrer = class { cca.device.ConstraintsPreferrer = class {
/** /**
* @param {!cca.ResolutionEventBroker} resolBroker
* @param {!function()} doReconfigureStream Trigger stream reconfiguration to * @param {!function()} doReconfigureStream Trigger stream reconfiguration to
* reflect changes in user preferred settings. * reflect changes in user preferred settings.
* @protected * @protected
*/ */
constructor(resolBroker, doReconfigureStream) { constructor(doReconfigureStream) {
/**
* @type {!cca.ResolutionEventBroker}
* @protected
*/
this.resolBroker_ = resolBroker;
/** /**
* @type {!function()} * @type {!function()}
* @protected * @protected
...@@ -82,6 +75,14 @@ cca.device.ConstraintsPreferrer = class { ...@@ -82,6 +75,14 @@ cca.device.ConstraintsPreferrer = class {
* @protected * @protected
*/ */
this.deviceResolutions_ = {}; this.deviceResolutions_ = {};
/**
* Listener for changes of preferred resolution used on particular video
* device.
* @type {!function(string, !Resolution)}
* @private
*/
this.preferredResolutionChangeListener_ = () => {};
} }
/** /**
...@@ -150,6 +151,23 @@ cca.device.ConstraintsPreferrer = class { ...@@ -150,6 +151,23 @@ cca.device.ConstraintsPreferrer = class {
* constraints-candidates. * constraints-candidates.
*/ */
getSortedCandidates(deviceId, previewResolutions) {} getSortedCandidates(deviceId, previewResolutions) {}
/**
* Changes user preferred capture resolution.
* @abstract
* @param {string} deviceId Device id of the video device to be changed.
* @param {!Resolution} resolution Preferred capture resolution.
*/
changePreferredResolution(deviceId, resolution) {}
/**
* Sets listener for changes of preferred resolution used in taking photo on
* particular video device.
* @param {!function(string, !Resolution)} listener
*/
setPreferredResolutionChangeListener(listener) {
this.preferredResolutionChangeListener_ = listener;
}
}; };
/** /**
...@@ -165,12 +183,11 @@ cca.device.SUPPORTED_CONSTANT_FPS = [30, 60]; ...@@ -165,12 +183,11 @@ cca.device.SUPPORTED_CONSTANT_FPS = [30, 60];
cca.device.VideoConstraintsPreferrer = cca.device.VideoConstraintsPreferrer =
class extends cca.device.ConstraintsPreferrer { class extends cca.device.ConstraintsPreferrer {
/** /**
* @param {!cca.ResolutionEventBroker} resolBroker
* @param {!function()} doReconfigureStream * @param {!function()} doReconfigureStream
* @public * @public
*/ */
constructor(resolBroker, doReconfigureStream) { constructor(doReconfigureStream) {
super(resolBroker, doReconfigureStream); super(doReconfigureStream);
/** /**
* Object saving information of device supported constant fps. Each of its * Object saving information of device supported constant fps. Each of its
...@@ -206,17 +223,6 @@ cca.device.VideoConstraintsPreferrer = ...@@ -206,17 +223,6 @@ cca.device.VideoConstraintsPreferrer =
this.resolution_ = new Resolution(0, -1); this.resolution_ = new Resolution(0, -1);
this.restoreResolutionPreference_('deviceVideoResolution'); this.restoreResolutionPreference_('deviceVideoResolution');
this.restoreFpsPreference_(); this.restoreFpsPreference_();
this.resolBroker_.registerChangeVideoPrefResolHandler(
(deviceId, width, height) => {
this.prefResolution_[deviceId] = new Resolution(width, height);
this.saveResolutionPreference_('deviceVideoResolution');
if (cca.state.get('video-mode') && deviceId == this.deviceId_) {
this.doReconfigureStream_();
} else {
this.resolBroker_.notifyVideoPrefResolChange(
deviceId, width, height);
}
});
this.toggleFps_.addEventListener('click', (event) => { this.toggleFps_.addEventListener('click', (event) => {
if (!cca.state.get('streaming') || cca.state.get('taking')) { if (!cca.state.get('streaming') || cca.state.get('taking')) {
...@@ -249,6 +255,19 @@ cca.device.VideoConstraintsPreferrer = ...@@ -249,6 +255,19 @@ cca.device.VideoConstraintsPreferrer =
cca.proxy.browserProxy.localStorageSet({deviceVideoFps: this.prefFpses_}); cca.proxy.browserProxy.localStorageSet({deviceVideoFps: this.prefFpses_});
} }
/**
* @override
*/
changePreferredResolution(deviceId, resolution) {
this.prefResolution_[deviceId] = resolution;
this.saveResolutionPreference_('deviceVideoResolution');
if (cca.state.get('video-mode') && deviceId === this.deviceId_) {
this.doReconfigureStream_();
} else {
this.preferredResolutionChangeListener_(deviceId, resolution);
}
}
/** /**
* Sets the preferred fps used in video recording for particular video device * Sets the preferred fps used in video recording for particular video device
* with particular resolution. * with particular resolution.
...@@ -263,7 +282,7 @@ cca.device.VideoConstraintsPreferrer = ...@@ -263,7 +282,7 @@ cca.device.VideoConstraintsPreferrer =
} }
this.toggleFps_.checked = prefFps === 60; this.toggleFps_.checked = prefFps === 60;
cca.device.SUPPORTED_CONSTANT_FPS.forEach( cca.device.SUPPORTED_CONSTANT_FPS.forEach(
(fps) => cca.state.set(`_${fps}fps`, fps == prefFps)); (fps) => cca.state.set(`_${fps}fps`, fps === prefFps));
this.prefFpses_[deviceId] = this.prefFpses_[deviceId] || {}; this.prefFpses_[deviceId] = this.prefFpses_[deviceId] || {};
this.prefFpses_[deviceId][resolution] = prefFps; this.prefFpses_[deviceId][resolution] = prefFps;
this.saveFpsPreference_(); this.saveFpsPreference_();
...@@ -284,7 +303,7 @@ cca.device.VideoConstraintsPreferrer = ...@@ -284,7 +303,7 @@ cca.device.VideoConstraintsPreferrer =
* @return {!Resolution|undefined} * @return {!Resolution|undefined}
*/ */
const findResol = (width, height) => const findResol = (width, height) =>
videoResols.find((r) => r.width == width && r.height == height); videoResols.find((r) => r.width === width && r.height === height);
/** @type {!Resolution} */ /** @type {!Resolution} */
let prefR = this.getPrefResolution(deviceId) || findResol(1920, 1080) || let prefR = this.getPrefResolution(deviceId) || findResol(1920, 1080) ||
findResol(1280, 720) || new Resolution(0, -1); findResol(1280, 720) || new Resolution(0, -1);
...@@ -316,7 +335,7 @@ cca.device.VideoConstraintsPreferrer = ...@@ -316,7 +335,7 @@ cca.device.VideoConstraintsPreferrer =
this.resolution_ = new Resolution(width, height); this.resolution_ = new Resolution(width, height);
this.prefResolution_[deviceId] = this.resolution_; this.prefResolution_[deviceId] = this.resolution_;
this.saveResolutionPreference_('deviceVideoResolution'); this.saveResolutionPreference_('deviceVideoResolution');
this.resolBroker_.notifyVideoPrefResolChange(deviceId, width, height); this.preferredResolutionChangeListener_(deviceId, this.resolution_);
const fps = stream.getVideoTracks()[0].getSettings().frameRate; const fps = stream.getVideoTracks()[0].getSettings().frameRate;
this.setPreferredConstFps_(deviceId, this.resolution_, fps); this.setPreferredConstFps_(deviceId, this.resolution_, fps);
...@@ -381,7 +400,7 @@ cca.device.VideoConstraintsPreferrer = ...@@ -381,7 +400,7 @@ cca.device.VideoConstraintsPreferrer =
if (constFpsInfo.includes(30) && constFpsInfo.includes(60)) { 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 = constFpses =
[...constFpsInfo.filter((fps) => fps >= 30).sort().reverse(), null]; [...constFpsInfo.filter((fps) => fps >= 30).sort().reverse(), null];
...@@ -420,25 +439,26 @@ cca.device.VideoConstraintsPreferrer = ...@@ -420,25 +439,26 @@ cca.device.VideoConstraintsPreferrer =
*/ */
cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
/** /**
* @param {!cca.ResolutionEventBroker} resolBroker
* @param {!function()} doReconfigureStream * @param {!function()} doReconfigureStream
* @public * @public
*/ */
constructor(resolBroker, doReconfigureStream) { constructor(doReconfigureStream) {
super(resolBroker, doReconfigureStream); super(doReconfigureStream);
this.restoreResolutionPreference_('devicePhotoResolution'); this.restoreResolutionPreference_('devicePhotoResolution');
this.resolBroker_.registerChangePhotoPrefResolHandler( }
(deviceId, width, height) => {
this.prefResolution_[deviceId] = new Resolution(width, height); /**
this.saveResolutionPreference_('devicePhotoResolution'); * @override
if (!cca.state.get('video-mode') && deviceId == this.deviceId_) { */
this.doReconfigureStream_(); changePreferredResolution(deviceId, resolution) {
} else { this.prefResolution_[deviceId] = resolution;
this.resolBroker_.notifyPhotoPrefResolChange( this.saveResolutionPreference_('devicePhotoResolution');
deviceId, width, height); if (!cca.state.get('video-mode') && deviceId === this.deviceId_) {
} this.doReconfigureStream_();
}); } else {
this.preferredResolutionChangeListener_(deviceId, resolution);
}
} }
/** /**
...@@ -465,10 +485,11 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { ...@@ -465,10 +485,11 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
* @override * @override
*/ */
updateValues(deviceId, stream, width, height) { updateValues(deviceId, stream, width, height) {
const resolution = new Resolution(width, height);
this.deviceId_ = deviceId; this.deviceId_ = deviceId;
this.prefResolution_[deviceId] = new Resolution(width, height); this.prefResolution_[deviceId] = resolution;
this.saveResolutionPreference_('devicePhotoResolution'); this.saveResolutionPreference_('devicePhotoResolution');
this.resolBroker_.notifyPhotoPrefResolChange(deviceId, width, height); this.preferredResolutionChangeListener_(deviceId, resolution);
} }
/** /**
...@@ -549,7 +570,7 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { ...@@ -549,7 +570,7 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
* @return {!ResolutionList} * @return {!ResolutionList}
*/ */
const sortPreview = (rs) => { const sortPreview = (rs) => {
if (rs.length == 0) { if (rs.length === 0) {
return []; return [];
} }
rs = [...rs].sort((r1, r2) => r2.width - r1.width); rs = [...rs].sort((r1, r2) => r2.width - r1.width);
......
...@@ -24,25 +24,19 @@ cca.App = function() { ...@@ -24,25 +24,19 @@ cca.App = function() {
*/ */
this.gallery_ = new cca.models.Gallery(); this.gallery_ = new cca.models.Gallery();
/**
* @type {cca.ResolutionEventBroker}
* @private
*/
this.resolBroker_ = new cca.ResolutionEventBroker();
/** /**
* @type {cca.device.PhotoResolPreferrer} * @type {cca.device.PhotoResolPreferrer}
* @private * @private
*/ */
this.photoPreferrer_ = new cca.device.PhotoResolPreferrer( this.photoPreferrer_ =
this.resolBroker_, () => this.cameraView_.restart()); new cca.device.PhotoResolPreferrer(() => this.cameraView_.restart());
/** /**
* @type {cca.device.VideoConstraintsPreferrer} * @type {cca.device.VideoConstraintsPreferrer}
* @private * @private
*/ */
this.videoPreferrer_ = new cca.device.VideoConstraintsPreferrer( this.videoPreferrer_ = new cca.device.VideoConstraintsPreferrer(
this.resolBroker_, () => this.cameraView_.restart()); () => this.cameraView_.restart());
/** /**
* @type {cca.device.DeviceInfoUpdater} * @type {cca.device.DeviceInfoUpdater}
...@@ -91,8 +85,7 @@ cca.App = function() { ...@@ -91,8 +85,7 @@ cca.App = function() {
new cca.views.BaseSettings('#gridsettings'), new cca.views.BaseSettings('#gridsettings'),
new cca.views.BaseSettings('#timersettings'), new cca.views.BaseSettings('#timersettings'),
new cca.views.ResolutionSettings( new cca.views.ResolutionSettings(
this.infoUpdater_, this.photoPreferrer_, this.videoPreferrer_, this.infoUpdater_, this.photoPreferrer_, this.videoPreferrer_),
this.resolBroker_),
new cca.views.BaseSettings('#photoresolutionsettings'), new cca.views.BaseSettings('#photoresolutionsettings'),
new cca.views.BaseSettings('#videoresolutionsettings'), new cca.views.BaseSettings('#videoresolutionsettings'),
new cca.views.BaseSettings('#expertsettings'), new cca.views.BaseSettings('#expertsettings'),
......
// 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.
'use strict';
/**
* Namespace for the Camera app.
*/
var cca = cca || {};
/**
* Broker for registering or notifying resolution related events.
*/
cca.ResolutionEventBroker = class {
/** @public */
constructor() {
/**
* Handler for requests of changing user-preferred resolution used in photo
* taking.
* @type {!function(string, number, number)}
* @private
*/
this.photoChangePrefResolHandler_ = () => {};
/**
* Handler for requests of changing user-preferred resolution used in video
* recording.
* @type {!function(string, number, number)}
* @private
*/
this.videoChangePrefResolHandler_ = () => {};
/**
* Listener for changes of preferred photo resolution used on particular
* video device.
* @type {!function(string, number, number)}
* @private
*/
this.photoPrefResolChangeListener_ = () => {};
/**
* Listener for changes of preferred video resolution used on particular
* video device.
* @type {!function(string, number, number)}
* @private
*/
this.videoPrefResolChangeListener_ = () => {};
}
/**
* Registers handler for requests of changing user-preferred resolution used
* in photo taking.
* @param {!function(string, number, number)} handler Called with device id of
* video device to be changed and width, height of new resolution.
*/
registerChangePhotoPrefResolHandler(handler) {
this.photoChangePrefResolHandler_ = handler;
}
/**
* Registers handler for requests of changing user-preferred resolution used
* in video recording.
* @param {!function(string, number, number)} handler Called with device id of
* video device to be changed and width, height of new resolution.
*/
registerChangeVideoPrefResolHandler(handler) {
this.videoChangePrefResolHandler_ = handler;
}
/**
* Requests for changing user-preferred resolution used in photo taking.
* @param {string} deviceId Device id of video device to be changed.
* @param {number} width Change to resolution width.
* @param {number} height Change to resolution height.
*/
requestChangePhotoPrefResol(deviceId, width, height) {
this.photoChangePrefResolHandler_(deviceId, width, height);
}
/**
* Requests for changing user-preferred resolution used in video recording.
* @param {string} deviceId Device id of video device to be changed.
* @param {number} width Change to resolution width.
* @param {number} height Change to resolution height.
*/
requestChangeVideoPrefResol(deviceId, width, height) {
this.videoChangePrefResolHandler_(deviceId, width, height);
}
/**
* Adds listener for changes of preferred resolution used in taking photo on
* particular video device.
* @param {!function(string, number, number)} listener Called with changed
* video device id and new preferred resolution width, height.
*/
addPhotoPrefResolChangeListener(listener) {
this.photoPrefResolChangeListener_ = listener;
}
/**
* Adds listener for changes of preferred resolution used in video recording
* on particular video device.
* @param {!function(string, number, number)} listener Called with changed
* video device id and new preferred resolution width, height.
*/
addVideoPrefResolChangeListener(listener) {
this.videoPrefResolChangeListener_ = listener;
}
/**
* Notifies the change of preferred resolution used in photo taking on
* particular video device.
* @param {string} deviceId Device id of changed video device.
* @param {number} width New resolution width.
* @param {number} height New resolution height.
*/
notifyPhotoPrefResolChange(deviceId, width, height) {
this.photoPrefResolChangeListener_(deviceId, width, height);
}
/**
* Notifies the change of preferred resolution used in video recording on
* particular video device.
* @param {string} deviceId Device id of changed video device.
* @param {number} width New resolution width.
* @param {number} height New resolution height.
*/
notifyVideoPrefResolChange(deviceId, width, height) {
this.videoPrefResolChangeListener_(deviceId, width, height);
}
};
...@@ -134,12 +134,11 @@ cca.views.MasterSettings.prototype.openFeedback = function() { ...@@ -134,12 +134,11 @@ cca.views.MasterSettings.prototype.openFeedback = function() {
* @param {!cca.device.DeviceInfoUpdater} infoUpdater * @param {!cca.device.DeviceInfoUpdater} infoUpdater
* @param {!cca.device.PhotoResolPreferrer} photoPreferrer * @param {!cca.device.PhotoResolPreferrer} photoPreferrer
* @param {!cca.device.VideoConstraintsPreferrer} videoPreferrer * @param {!cca.device.VideoConstraintsPreferrer} videoPreferrer
* @param {!cca.ResolutionEventBroker} resolBroker
* @extends {cca.views.BaseSettings} * @extends {cca.views.BaseSettings}
* @constructor * @constructor
*/ */
cca.views.ResolutionSettings = function( cca.views.ResolutionSettings = function(
infoUpdater, photoPreferrer, videoPreferrer, resolBroker) { infoUpdater, photoPreferrer, videoPreferrer) {
/** /**
* @param {function(): ?cca.views.DeviceSetting} getSetting * @param {function(): ?cca.views.DeviceSetting} getSetting
* @param {function(): !HTMLElement} getElement * @param {function(): !HTMLElement} getElement
...@@ -173,10 +172,16 @@ cca.views.ResolutionSettings = function( ...@@ -173,10 +172,16 @@ cca.views.ResolutionSettings = function(
}); });
/** /**
* @type {!cca.ResolutionEventBroker} * @type {!cca.device.PhotoResolPreferrer}
* @private * @private
*/ */
this.resolBroker_ = resolBroker; this.photoPreferrer_ = photoPreferrer;
/**
* @type {!cca.device.VideoConstraintsPreferrer}
* @private
*/
this.videoPreferrer_ = videoPreferrer;
/** /**
* @type {!HTMLElement} * @type {!HTMLElement}
...@@ -317,9 +322,9 @@ cca.views.ResolutionSettings = function( ...@@ -317,9 +322,9 @@ cca.views.ResolutionSettings = function(
this.updateResolutions_(); this.updateResolutions_();
}); });
this.resolBroker_.addPhotoPrefResolChangeListener( this.photoPreferrer_.setPreferredResolutionChangeListener(
this.updateSelectedPhotoResolution_.bind(this)); this.updateSelectedPhotoResolution_.bind(this));
this.resolBroker_.addVideoPrefResolChangeListener( this.videoPreferrer_.setPreferredResolutionChangeListener(
this.updateSelectedVideoResolution_.bind(this)); this.updateSelectedVideoResolution_.bind(this));
}; };
...@@ -497,14 +502,13 @@ cca.views.ResolutionSettings.prototype.updateResolutions_ = function() { ...@@ -497,14 +502,13 @@ cca.views.ResolutionSettings.prototype.updateResolutions_ = function() {
/** /**
* Updates current selected photo resolution. * Updates current selected photo resolution.
* @param {string} deviceId Device id of the selected resolution. * @param {string} deviceId Device id of the selected resolution.
* @param {number} width Width of selected resolution. * @param {!Resolution} resolution Selected resolution.
* @param {number} height Height of selected resolution.
* @private * @private
*/ */
cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ = cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ =
function(deviceId, width, height) { function(deviceId, resolution) {
const {photo} = this.getDeviceSetting_(deviceId); const {photo} = this.getDeviceSetting_(deviceId);
photo.prefResol = new Resolution(width, height); photo.prefResol = resolution;
let /** !HTMLElement */ photoItem; let /** !HTMLElement */ photoItem;
if (this.frontSetting_ && this.frontSetting_.deviceId === deviceId) { if (this.frontSetting_ && this.frontSetting_.deviceId === deviceId) {
photoItem = this.frontPhotoItem_; photoItem = this.frontPhotoItem_;
...@@ -521,7 +525,10 @@ cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ = ...@@ -521,7 +525,10 @@ cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ =
if (cca.state.get('photoresolutionsettings') && if (cca.state.get('photoresolutionsettings') &&
this.openedSettingDeviceId_ === deviceId) { this.openedSettingDeviceId_ === deviceId) {
this.photoResMenu_ this.photoResMenu_
.querySelector(`input[data-width="${width}"][data-height="${height}"]`) .querySelector(
'input' +
`[data-width="${resolution.width}"]` +
`[data-height="${resolution.height}"]`)
.checked = true; .checked = true;
} }
}; };
...@@ -529,14 +536,13 @@ cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ = ...@@ -529,14 +536,13 @@ cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ =
/** /**
* Updates current selected video resolution. * Updates current selected video resolution.
* @param {string} deviceId Device id of the selected resolution. * @param {string} deviceId Device id of the selected resolution.
* @param {number} width Width of selected resolution. * @param {!Resolution} resolution Selected resolution.
* @param {number} height Height of selected resolution.
* @private * @private
*/ */
cca.views.ResolutionSettings.prototype.updateSelectedVideoResolution_ = cca.views.ResolutionSettings.prototype.updateSelectedVideoResolution_ =
function(deviceId, width, height) { function(deviceId, resolution) {
const {video} = this.getDeviceSetting_(deviceId); const {video} = this.getDeviceSetting_(deviceId);
video.prefResol = new Resolution(width, height); video.prefResol = resolution;
let /** !HTMLElement */ videoItem; let /** !HTMLElement */ videoItem;
if (this.frontSetting_ && this.frontSetting_.deviceId === deviceId) { if (this.frontSetting_ && this.frontSetting_.deviceId === deviceId) {
videoItem = this.frontVideoItem_; videoItem = this.frontVideoItem_;
...@@ -553,7 +559,10 @@ cca.views.ResolutionSettings.prototype.updateSelectedVideoResolution_ = ...@@ -553,7 +559,10 @@ cca.views.ResolutionSettings.prototype.updateSelectedVideoResolution_ =
if (cca.state.get('videoresolutionsettings') && if (cca.state.get('videoresolutionsettings') &&
this.openedSettingDeviceId_ === deviceId) { this.openedSettingDeviceId_ === deviceId) {
this.videoResMenu_ this.videoResMenu_
.querySelector(`input[data-width="${width}"][data-height="${height}"]`) .querySelector(
'input' +
`[data-width="${resolution.width}"]` +
`[data-height="${resolution.height}"]`)
.checked = true; .checked = true;
} }
}; };
...@@ -570,8 +579,7 @@ cca.views.ResolutionSettings.prototype.openPhotoResSettings_ = function( ...@@ -570,8 +579,7 @@ cca.views.ResolutionSettings.prototype.openPhotoResSettings_ = function(
this.openedSettingDeviceId_ = deviceId; this.openedSettingDeviceId_ = deviceId;
this.updateMenu_( this.updateMenu_(
resolItem, this.photoResMenu_, this.photoOptTextTempl_, resolItem, this.photoResMenu_, this.photoOptTextTempl_,
(r) => this.resolBroker_.requestChangePhotoPrefResol( (r) => this.photoPreferrer_.changePreferredResolution(deviceId, r),
deviceId, r.width, r.height),
photo.resols, photo.prefResol); photo.resols, photo.prefResol);
this.openSubSettings('photoresolutionsettings'); this.openSubSettings('photoresolutionsettings');
}; };
...@@ -588,8 +596,7 @@ cca.views.ResolutionSettings.prototype.openVideoResSettings_ = function( ...@@ -588,8 +596,7 @@ cca.views.ResolutionSettings.prototype.openVideoResSettings_ = function(
this.openedSettingDeviceId_ = deviceId; this.openedSettingDeviceId_ = deviceId;
this.updateMenu_( this.updateMenu_(
resolItem, this.videoResMenu_, this.videoOptTextTempl_, resolItem, this.videoResMenu_, this.videoOptTextTempl_,
(r) => this.resolBroker_.requestChangeVideoPrefResol( (r) => this.videoPreferrer_.changePreferredResolution(deviceId, r),
deviceId, r.width, r.height),
video.resols, video.prefResol); video.resols, video.prefResol);
this.openSubSettings('videoresolutionsettings'); this.openSubSettings('videoresolutionsettings');
}; };
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
<script src="../js/metrics.js"></script> <script src="../js/metrics.js"></script>
<script src="../js/intent.js"></script> <script src="../js/intent.js"></script>
<script src="../js/util.js"></script> <script src="../js/util.js"></script>
<script src="../js/resolution_event_broker.js"></script>
<script src="../js/toast.js"></script> <script src="../js/toast.js"></script>
<script src="../js/tooltip.js"></script> <script src="../js/tooltip.js"></script>
<script src="../js/state.js"></script> <script src="../js/state.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