summaryrefslogtreecommitdiff
path: root/chromium/components/webrtc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/webrtc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/webrtc')
-rw-r--r--chromium/components/webrtc/media_stream_devices_controller.cc43
1 files changed, 27 insertions, 16 deletions
diff --git a/chromium/components/webrtc/media_stream_devices_controller.cc b/chromium/components/webrtc/media_stream_devices_controller.cc
index ed32c6bca94..461fe000504 100644
--- a/chromium/components/webrtc/media_stream_devices_controller.cc
+++ b/chromium/components/webrtc/media_stream_devices_controller.cc
@@ -112,9 +112,13 @@ void MediaStreamDevicesController::RequestPermissions(
will_prompt_for_video =
permission_status.content_setting == CONTENT_SETTING_ASK;
-#if !defined(OS_ANDROID)
- // TODO(crbug.com/934063): Check that hardware supports PTZ before
- if (request.request_pan_tilt_zoom_permission) {
+ // Request CAMERA_PAN_TILT_ZOOM only if the the website requested
+ // the pan-tilt-zoom permission and there are suitable PTZ capable devices
+ // available.
+ if (request.request_pan_tilt_zoom_permission &&
+ controller->HasAvailableDevices(
+ ContentSettingsType::CAMERA_PAN_TILT_ZOOM,
+ request.requested_video_device_id)) {
permissions::PermissionResult permission_status =
permission_manager->GetPermissionStatusForFrame(
ContentSettingsType::CAMERA_PAN_TILT_ZOOM, rfh,
@@ -129,7 +133,6 @@ void MediaStreamDevicesController::RequestPermissions(
content_settings_types.push_back(
ContentSettingsType::CAMERA_PAN_TILT_ZOOM);
}
-#endif
}
permission_manager->RequestPermissions(
@@ -521,7 +524,8 @@ bool MediaStreamDevicesController::HasAvailableDevices(
const MediaStreamDevices* devices = nullptr;
if (content_type == ContentSettingsType::MEDIASTREAM_MIC) {
devices = &enumerator_->GetAudioCaptureDevices();
- } else if (content_type == ContentSettingsType::MEDIASTREAM_CAMERA) {
+ } else if (content_type == ContentSettingsType::MEDIASTREAM_CAMERA ||
+ content_type == ContentSettingsType::CAMERA_PAN_TILT_ZOOM) {
devices = &enumerator_->GetVideoCaptureDevices();
} else {
NOTREACHED();
@@ -535,19 +539,26 @@ bool MediaStreamDevicesController::HasAvailableDevices(
if (devices->empty())
return false;
- // Note: we check device_id before dereferencing devices. If the requested
- // device id is non-empty, then the corresponding device list must not be
- // nullptr.
- if (!device_id.empty()) {
- auto it = std::find_if(devices->begin(), devices->end(),
- [device_id](const blink::MediaStreamDevice& device) {
- return device.id == device_id;
- });
- if (it == devices->end())
- return false;
+ // If there are no particular device requirements, all devices will do.
+ if (device_id.empty() &&
+ content_type != ContentSettingsType::CAMERA_PAN_TILT_ZOOM) {
+ return true;
}
- return true;
+ // Try to find a device which fulfils all device requirements.
+ for (const blink::MediaStreamDevice& device : *devices) {
+ if (!device_id.empty() && device.id != device_id) {
+ continue;
+ }
+ if (content_type == ContentSettingsType::CAMERA_PAN_TILT_ZOOM &&
+ device.pan_tilt_zoom_supported.has_value() &&
+ !device.pan_tilt_zoom_supported.value()) {
+ continue;
+ }
+ return true;
+ }
+
+ return false;
}
} // namespace webrtc