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

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

Issue 2648973003: Sort camera device list to use front camera first (Closed)
Patch Set: address comment 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
Index: media/capture/video/video_capture_device_descriptor.cc
diff --git a/media/capture/video/video_capture_device_descriptor.cc b/media/capture/video/video_capture_device_descriptor.cc
index f1e288cbe32954ee07a9a6de78c723e2a37b3bb2..006a27f27c9a584848b9b7ac855af916d79cc0a6 100644
--- a/media/capture/video/video_capture_device_descriptor.cc
+++ b/media/capture/video/video_capture_device_descriptor.cc
@@ -43,6 +43,19 @@ VideoCaptureDeviceDescriptor::~VideoCaptureDeviceDescriptor() {}
VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor(
const VideoCaptureDeviceDescriptor& other) = default;
+bool VideoCaptureDeviceDescriptor::operator<(
+ const VideoCaptureDeviceDescriptor& other) const {
+ int facing_mapping[NUM_MEDIA_VIDEO_FACING_MODE] = {0};
Guido Urdaneta 2017/01/25 10:27:23 nit: I don't think you need the {0} initialization
+ facing_mapping[MEDIA_VIDEO_FACING_USER] = 2;
+ facing_mapping[MEDIA_VIDEO_FACING_ENVIRONMENT] = 1;
+ facing_mapping[MEDIA_VIDEO_FACING_NONE] = 0;
mcasas 2017/01/25 17:35:15 I'd do: static const int kFacingMapping[] = {0, 1
henryhsu 2017/01/26 02:22:54 Done.
+ if (facing_mapping[facing] > facing_mapping[other.facing])
+ return true;
+ if (device_id < other.device_id)
+ return true;
+ return capture_api < other.capture_api;
+}
+
const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const {
switch (capture_api) {
case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE:

Powered by Google App Engine
This is Rietveld 408576698