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

Fix CCA selected resolution not shown bug

Bug: None

Change-Id: Ifbbbe1ad0c5f50ea7454e1256b0ba8f9cdce2e55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1624365Reviewed-by: default avatarSheng-hao Tsao <shenghao@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662985}
parent f8df5d0f
...@@ -165,6 +165,7 @@ copy("chrome_camera_app_js_views_camera") { ...@@ -165,6 +165,7 @@ copy("chrome_camera_app_js_views_camera") {
"src/js/views/camera/options.js", "src/js/views/camera/options.js",
"src/js/views/camera/preview.js", "src/js/views/camera/preview.js",
"src/js/views/camera/recordtime.js", "src/js/views/camera/recordtime.js",
"src/js/views/camera/resolution_preference.js",
"src/js/views/camera/timertick.js", "src/js/views/camera/timertick.js",
] ]
......
...@@ -137,6 +137,7 @@ RESOURCES = \ ...@@ -137,6 +137,7 @@ RESOURCES = \
src/js/views/camera/options.js \ src/js/views/camera/options.js \
src/js/views/camera/preview.js \ src/js/views/camera/preview.js \
src/js/views/camera/recordtime.js \ src/js/views/camera/recordtime.js \
src/js/views/camera/resolution_preference.js \
src/js/views/camera/timertick.js \ src/js/views/camera/timertick.js \
src/js/views/dialog.js \ src/js/views/dialog.js \
src/js/views/gallery_base.js \ src/js/views/gallery_base.js \
......
...@@ -30,6 +30,20 @@ cca.views.Camera = function(model, resolBroker) { ...@@ -30,6 +30,20 @@ cca.views.Camera = function(model, resolBroker) {
*/ */
this.model_ = model; this.model_ = model;
/**
* @type {cca.views.camera.PhotoResolPreferrer}
* @private
*/
this.photoResolPreferrer_ = new cca.views.camera.PhotoResolPreferrer(
resolBroker, this.stop_.bind(this));
/**
* @type {cca.views.camera.VideoResolPreferrer}
* @private
*/
this.videoResolPreferrer_ = new cca.views.camera.VideoResolPreferrer(
resolBroker, this.stop_.bind(this));
/** /**
* Layout handler for the camera view. * Layout handler for the camera view.
* @type {cca.views.camera.Layout} * @type {cca.views.camera.Layout}
...@@ -49,8 +63,9 @@ cca.views.Camera = function(model, resolBroker) { ...@@ -49,8 +63,9 @@ cca.views.Camera = function(model, resolBroker) {
* @type {cca.views.camera.Options} * @type {cca.views.camera.Options}
* @private * @private
*/ */
this.options_ = this.options_ = new cca.views.camera.Options(
new cca.views.camera.Options(resolBroker, this.stop_.bind(this)); this.photoResolPreferrer_, this.videoResolPreferrer_,
this.stop_.bind(this));
/** /**
* Modes for the camera. * Modes for the camera.
...@@ -58,8 +73,8 @@ cca.views.Camera = function(model, resolBroker) { ...@@ -58,8 +73,8 @@ cca.views.Camera = function(model, resolBroker) {
* @private * @private
*/ */
this.modes_ = new cca.views.camera.Modes( this.modes_ = new cca.views.camera.Modes(
resolBroker, this.stop_.bind(this), this.stop_.bind(this), this.photoResolPreferrer_, this.videoResolPreferrer_,
async (blob, isMotionPicture, filename) => { this.stop_.bind(this), async (blob, isMotionPicture, filename) => {
if (blob) { if (blob) {
cca.metrics.log( cca.metrics.log(
cca.metrics.Type.CAPTURE, this.facingMode_, blob.mins); cca.metrics.Type.CAPTURE, this.facingMode_, blob.mins);
...@@ -225,10 +240,9 @@ cca.views.Camera.prototype.stop_ = function() { ...@@ -225,10 +240,9 @@ cca.views.Camera.prototype.stop_ = function() {
cca.views.Camera.prototype.startWithDevice_ = async function(deviceId) { cca.views.Camera.prototype.startWithDevice_ = async function(deviceId) {
let supportedModes = null; let supportedModes = null;
for (const mode of this.modes_.getModeCandidates()) { for (const mode of this.modes_.getModeCandidates()) {
const [photoRs, videoRs] = const previewRs = (await this.options_.getDeviceResolutions(deviceId))[1];
await this.options_.getDeviceResolutions(deviceId);
for (const [[width, height], previewCandidates] of this.modes_ for (const [[width, height], previewCandidates] of this.modes_
.getResolutionCandidates(mode, deviceId, photoRs, videoRs)) { .getResolutionCandidates(mode, deviceId, previewRs)) {
for (const constraints of previewCandidates) { for (const constraints of previewCandidates) {
try { try {
const stream = await navigator.mediaDevices.getUserMedia(constraints); const stream = await navigator.mediaDevices.getUserMedia(constraints);
......
...@@ -21,16 +21,24 @@ cca.views.camera = cca.views.camera || {}; ...@@ -21,16 +21,24 @@ cca.views.camera = cca.views.camera || {};
/** /**
* Creates a controller for the options of Camera view. * Creates a controller for the options of Camera view.
* @param {cca.ResolutionEventBroker} resolBroker * @param {cca.views.camera.PhotoResolPreferrer} photoResolPreferrer
* @param {cca.views.camera.VideoResolPreferrer} videoResolPreferrer
* @param {function()} doSwitchDevice Callback to trigger device switching. * @param {function()} doSwitchDevice Callback to trigger device switching.
* @constructor * @constructor
*/ */
cca.views.camera.Options = function(resolBroker, doSwitchDevice) { cca.views.camera.Options = function(
photoResolPreferrer, videoResolPreferrer, doSwitchDevice) {
/** /**
* @type {cca.ResolutionEventBroker} * @type {cca.views.camera.PhotoResolPreferrer}
* @private * @private
*/ */
this.resolBroker_ = resolBroker; this.photoResolPreferrer_ = photoResolPreferrer;
/**
* @type {cca.views.camera.VideoResolPreferrer}
* @private
*/
this.videoResolPreferrer_ = videoResolPreferrer;
/** /**
* @type {function()} * @type {function()}
...@@ -132,13 +140,6 @@ cca.views.camera.Options.FRONT_CAMERA_LABEL = 'Front Camera'; ...@@ -132,13 +140,6 @@ cca.views.camera.Options.FRONT_CAMERA_LABEL = 'Front Camera';
*/ */
cca.views.camera.Options.BACK_CAMERA_LABEL = 'Back Camera'; cca.views.camera.Options.BACK_CAMERA_LABEL = 'Back Camera';
/**
* Label of external facing camera from MediaDeviceInfo.
* @type {string}
* @const
*/
cca.views.camera.Options.EXTERNAL_CAMERA_LABEL = 'External Camera';
/** /**
* Switches to the next available camera device. * Switches to the next available camera device.
* @private * @private
...@@ -300,15 +301,19 @@ cca.views.camera.Options.prototype.maybeRefreshVideoDeviceIds_ = function() { ...@@ -300,15 +301,19 @@ cca.views.camera.Options.prototype.maybeRefreshVideoDeviceIds_ = function() {
case cca.views.camera.Options.BACK_CAMERA_LABEL: case cca.views.camera.Options.BACK_CAMERA_LABEL:
backSetting = setting; backSetting = setting;
break; break;
case cca.views.camera.Options.EXTERNAL_CAMERA_LABEL:
externalSettings.push(setting);
break;
default: default:
console.error(`Ignore device of unknown label: ${label}`); // TODO(inker): Use private API to get camera facing information.
externalSettings.push(setting);
} }
}); });
this.resolBroker_.notifyUpdateDeviceResolutions( this.photoResolPreferrer_.updateResolutions(
frontSetting, backSetting, externalSettings); frontSetting && [frontSetting[0], frontSetting[1]],
backSetting && [backSetting[0], backSetting[1]],
externalSettings.map(([deviceId, photoRs]) => [deviceId, photoRs]));
this.videoResolPreferrer_.updateResolutions(
frontSetting && [frontSetting[0], frontSetting[2]],
backSetting && [backSetting[0], backSetting[2]],
externalSettings.map(([deviceId, , videoRs]) => [deviceId, videoRs]));
}); });
}; };
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<script src="../js/views/camera/options.js"></script> <script src="../js/views/camera/options.js"></script>
<script src="../js/views/camera/preview.js"></script> <script src="../js/views/camera/preview.js"></script>
<script src="../js/views/camera/recordtime.js"></script> <script src="../js/views/camera/recordtime.js"></script>
<script src="../js/views/camera/resolution_preference.js"></script>
<script src="../js/views/camera/timertick.js"></script> <script src="../js/views/camera/timertick.js"></script>
<script src="../js/views/camera/modes.js"></script> <script src="../js/views/camera/modes.js"></script>
<script src="../js/views/dialog.js"></script> <script src="../js/views/dialog.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