Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Unified Diff: content/browser/renderer_host/media/media_devices_dispatcher_host.cc

Issue 2694163004: Use fallback capabilities for devices that cannot list camera capabilities. (Closed)
Patch Set: rename constants Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/media_devices_dispatcher_host.cc
diff --git a/content/browser/renderer_host/media/media_devices_dispatcher_host.cc b/content/browser/renderer_host/media/media_devices_dispatcher_host.cc
index 7882ef1d92384a7765e761b49f7fc59a71059353..2a28c625bb7c09e59f102e847de7f169efe66827 100644
--- a/content/browser/renderer_host/media/media_devices_dispatcher_host.cc
+++ b/content/browser/renderer_host/media/media_devices_dispatcher_host.cc
@@ -30,6 +30,17 @@ namespace content {
namespace {
+// Resolutions used if the source doesn't support capability enumeration.
+struct {
+ int width;
+ int height;
+} const kFallbackVideoResolutions[] = {{1920, 1080}, {1280, 720}, {960, 720},
+ {640, 480}, {640, 360}, {320, 240},
+ {320, 180}};
+
+// Frame rates for sources with no support for capability enumeration.
+const int kFallbackVideoFrameRates[] = {30, 60};
+
MediaDeviceInfo TranslateDeviceInfo(bool has_permission,
const std::string& device_id_salt,
const std::string& group_id_salt,
@@ -359,6 +370,17 @@ void MediaDevicesDispatcherHost::FinalizeGetVideoInputCapabilities(
::mojom::VideoInputDeviceCapabilities::New();
capabilities->device_id = std::move(hmac_device_id);
capabilities->formats = GetVideoInputFormats(descriptor.device_id);
+ if (capabilities->formats.empty()) {
+ // The device does not seem to support capability enumeration. Compose
+ // a fallback list of capabilities.
+ for (const auto& resolution : kFallbackVideoResolutions) {
+ for (const auto frame_rate : kFallbackVideoFrameRates) {
+ capabilities->formats.push_back(media::VideoCaptureFormat(
+ gfx::Size(resolution.width, resolution.height), frame_rate,
+ media::PIXEL_FORMAT_I420));
+ }
+ }
+ }
capabilities->facing_mode = ToFacingMode(descriptor.facing);
#if defined(OS_ANDROID)
// On Android, the facing mode is not available in the |facing| field,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698