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

[CCA] Announce different active camera.

In former behavior, the CCA will only announce camera active after click
on switch camera facing button. This CL integrate the announce logic
into camera reconfiguration cycle and announce once the change of active
camera used in preview.

Bug: 1020239
Test: Navigate and toggle buttons related to stream reconfiguration by
chromevox manually, see if the CCA announce as expected.

Change-Id: I95656861f0d34c4bb3cc03e9f9df42952a5e1c54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1909677
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714435}
parent 06abb805
......@@ -202,7 +202,6 @@ cca.device.DeviceInfoUpdater = class {
await this.lockingUpdate_;
}
/**
* Gets MediaDeviceInfo for all available video devices.
* @return {!Promise<!Array<!MediaDeviceInfo>>}
......@@ -212,6 +211,17 @@ cca.device.DeviceInfoUpdater = class {
return this.devicesInfo_;
}
/**
* Gets MediaDeviceInfo of specific video device.
* @param {string} deviceId Device id of video device to get information from.
* @return {!Promise<?MediaDeviceInfo>}
* @private
*/
async getDeviceInfo(deviceId) {
const /** !Array<!MediaDeviceInfo> */ infos = await this.getDevicesInfo();
return infos.find((d) => d.deviceId === deviceId) || null;
}
/**
* Gets Camera3DeviceInfo for all available video devices.
* @return {!Promise<?Array<!cca.device.Camera3DeviceInfo>>}
......
......@@ -73,6 +73,14 @@ cca.views.Camera = function(
*/
this.resultSaver_ = resultSaver;
/**
* Device id of video device of active preview stream. Sets to null when
* preview become inactive.
* @type {?string}
* @private
*/
this.activeDeviceId_ = null;
const createVideoSaver = async () => resultSaver.startSaveVideo();
/**
......@@ -381,6 +389,17 @@ cca.views.Camera.prototype.start_ = async function() {
if (!this.suspended) {
for (const id of await this.options_.videoDeviceIds()) {
if (await this.startWithDevice_(id)) {
// Make the different active camera announced by screen reader.
const currentId = this.options_.currentDeviceId;
if (currentId === this.activeDeviceId_) {
return;
}
this.activeDeviceId_ = currentId;
const info = await this.infoUpdater_.getDeviceInfo(id);
if (info !== null) {
cca.toast.speak(chrome.i18n.getMessage(
'status_msg_camera_switched', info.label));
}
return;
}
}
......@@ -390,6 +409,7 @@ cca.views.Camera.prototype.start_ = async function() {
this.configuring_ = null;
return true;
} catch (error) {
this.activeDeviceId_ = null;
if (!(error instanceof cca.views.CameraSuspendedError)) {
console.error(error);
cca.nav.open('warning', 'no-camera');
......
......@@ -128,6 +128,16 @@ cca.views.camera.Options = function(infoUpdater, doSwitchDevice) {
});
};
cca.views.camera.Options.prototype = {
/**
* Device id of the camera device currently used or selected.
* @return {string}
*/
get currentDeviceId() {
return this.videoDeviceId_;
},
};
/**
* Switches to the next available camera device.
* @private
......@@ -148,12 +158,6 @@ cca.views.camera.Options.prototype.switchDevice_ = async function() {
this.videoDeviceId_ = devices[index].deviceId;
}
await this.doSwitchDevice_();
// Make the active camera announced by screen reader.
var found = devices.find((entry) => entry.deviceId == this.videoDeviceId_);
if (found) {
cca.toast.speak(
chrome.i18n.getMessage('status_msg_camera_switched', found.label));
}
};
/**
......
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