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

Unified Diff: media/capture/video/video_capture_device_descriptor.h

Issue 2648973003: Sort camera device list to use front camera first (Closed)
Patch Set: address comments Created 3 years, 11 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 | « media/capture/video/linux/video_capture_device_factory_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/video_capture_device_descriptor.h
diff --git a/media/capture/video/video_capture_device_descriptor.h b/media/capture/video/video_capture_device_descriptor.h
index 84ff841dbf4347b67cc29e1534f66bd6cf7c1c53..5ec1c4ca8234a78528b66e17e0bddba1155ade11 100644
--- a/media/capture/video/video_capture_device_descriptor.h
+++ b/media/capture/video/video_capture_device_descriptor.h
@@ -5,6 +5,7 @@
#ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_
#define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_
+#include <map>
#include <string>
#include <vector>
@@ -67,6 +68,16 @@ struct CAPTURE_EXPORT VideoCaptureDeviceDescriptor {
return (other.device_id == device_id) && (other.capture_api == capture_api);
}
bool operator<(const VideoCaptureDeviceDescriptor& other) const {
+ std::vector<media::VideoFacingMode> facing_prefer_list{
+ MEDIA_VIDEO_FACING_USER, MEDIA_VIDEO_FACING_ENVIRONMENT,
+ MEDIA_VIDEO_FACING_NONE,
+ };
+ std::map<media::VideoFacingMode, size_t> facing_mapping;
+ for (size_t i = 0; i < facing_prefer_list.size(); i++) {
+ facing_mapping[facing_prefer_list[i]] = i;
+ }
hta - Chromium 2017/01/24 09:46:24 The two-step process here seems strange. Why not i
henryhsu 2017/01/24 10:26:40 Done.
+ if (facing_mapping.at(facing) < facing_mapping.at(other.facing))
hta - Chromium 2017/01/24 09:46:24 What happens here if facing = MEDIA_VIDEO_FACING_L
henryhsu 2017/01/24 10:26:40 It's impossible to have MEDIA_VIDEO_FACING_LEFT va
+ return true;
hta - Chromium 2017/01/24 09:46:24 I would expect a function this long to get hollere
henryhsu 2017/01/24 10:26:40 Done.
if (device_id < other.device_id)
return true;
return capture_api < other.capture_api;
« no previous file with comments | « media/capture/video/linux/video_capture_device_factory_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698