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

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

Issue 2648973003: Sort camera device list to use front camera first (Closed)
Patch Set: remove #if 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/video_capture_device_descriptor.h ('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.cc
diff --git a/media/capture/video/video_capture_device_descriptor.cc b/media/capture/video/video_capture_device_descriptor.cc
index f1e288cbe32954ee07a9a6de78c723e2a37b3bb2..3a259543979580ebe3b6680c2e9113136d1640db 100644
--- a/media/capture/video/video_capture_device_descriptor.cc
+++ b/media/capture/video/video_capture_device_descriptor.cc
@@ -43,6 +43,22 @@ VideoCaptureDeviceDescriptor::~VideoCaptureDeviceDescriptor() {}
VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor(
const VideoCaptureDeviceDescriptor& other) = default;
+bool VideoCaptureDeviceDescriptor::operator<(
+ const VideoCaptureDeviceDescriptor& other) const {
+ static constexpr int kFacingMapping[NUM_MEDIA_VIDEO_FACING_MODE] = {0, 2, 1};
+ static_assert(kFacingMapping[MEDIA_VIDEO_FACING_NONE] == 0,
+ "FACING_NONE has a wrong value");
+ static_assert(kFacingMapping[MEDIA_VIDEO_FACING_ENVIRONMENT] == 1,
+ "FACING_ENVIRONMENT has a wrong value");
+ static_assert(kFacingMapping[MEDIA_VIDEO_FACING_USER] == 2,
+ "FACING_USER has a wrong value");
+ if (kFacingMapping[facing] > kFacingMapping[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:
« no previous file with comments | « media/capture/video/video_capture_device_descriptor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698