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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « media/capture/video/video_capture_device_descriptor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/capture/video/video_capture_device_descriptor.h" 5 #include "media/capture/video/video_capture_device_descriptor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 25 matching lines...) Expand all
36 model_id(model_id), 36 model_id(model_id),
37 facing(facing), 37 facing(facing),
38 capture_api(capture_api), 38 capture_api(capture_api),
39 transport_type(transport_type) {} 39 transport_type(transport_type) {}
40 40
41 VideoCaptureDeviceDescriptor::~VideoCaptureDeviceDescriptor() {} 41 VideoCaptureDeviceDescriptor::~VideoCaptureDeviceDescriptor() {}
42 42
43 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor( 43 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor(
44 const VideoCaptureDeviceDescriptor& other) = default; 44 const VideoCaptureDeviceDescriptor& other) = default;
45 45
46 bool VideoCaptureDeviceDescriptor::operator<(
47 const VideoCaptureDeviceDescriptor& other) const {
48 static constexpr int kFacingMapping[NUM_MEDIA_VIDEO_FACING_MODE] = {0, 2, 1};
49 static_assert(kFacingMapping[MEDIA_VIDEO_FACING_NONE] == 0,
50 "FACING_NONE has a wrong value");
51 static_assert(kFacingMapping[MEDIA_VIDEO_FACING_ENVIRONMENT] == 1,
52 "FACING_ENVIRONMENT has a wrong value");
53 static_assert(kFacingMapping[MEDIA_VIDEO_FACING_USER] == 2,
54 "FACING_USER has a wrong value");
55 if (kFacingMapping[facing] > kFacingMapping[other.facing])
56 return true;
57 if (device_id < other.device_id)
58 return true;
59 return capture_api < other.capture_api;
60 }
61
46 const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const { 62 const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const {
47 switch (capture_api) { 63 switch (capture_api) {
48 case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE: 64 case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE:
49 return "V4L2 SPLANE"; 65 return "V4L2 SPLANE";
50 case VideoCaptureApi::WIN_MEDIA_FOUNDATION: 66 case VideoCaptureApi::WIN_MEDIA_FOUNDATION:
51 return "Media Foundation"; 67 return "Media Foundation";
52 case VideoCaptureApi::WIN_DIRECT_SHOW: 68 case VideoCaptureApi::WIN_DIRECT_SHOW:
53 return "Direct Show"; 69 return "Direct Show";
54 case VideoCaptureApi::MACOSX_AVFOUNDATION: 70 case VideoCaptureApi::MACOSX_AVFOUNDATION:
55 return "AV Foundation"; 71 return "AV Foundation";
(...skipping 16 matching lines...) Expand all
72 } 88 }
73 } 89 }
74 90
75 std::string VideoCaptureDeviceDescriptor::GetNameAndModel() const { 91 std::string VideoCaptureDeviceDescriptor::GetNameAndModel() const {
76 if (model_id.empty()) 92 if (model_id.empty())
77 return display_name; 93 return display_name;
78 return display_name + " (" + model_id + ")"; 94 return display_name + " (" + model_id + ")";
79 } 95 }
80 96
81 } // namespace media 97 } // namespace media
OLDNEW
« 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