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

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: 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 unified diff | Download patch
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 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
49 facing_mapping[MEDIA_VIDEO_FACING_USER] = 2;
50 facing_mapping[MEDIA_VIDEO_FACING_ENVIRONMENT] = 1;
51 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.
52 if (facing_mapping[facing] > facing_mapping[other.facing])
53 return true;
54 if (device_id < other.device_id)
55 return true;
56 return capture_api < other.capture_api;
57 }
58
46 const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const { 59 const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const {
47 switch (capture_api) { 60 switch (capture_api) {
48 case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE: 61 case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE:
49 return "V4L2 SPLANE"; 62 return "V4L2 SPLANE";
50 case VideoCaptureApi::WIN_MEDIA_FOUNDATION: 63 case VideoCaptureApi::WIN_MEDIA_FOUNDATION:
51 return "Media Foundation"; 64 return "Media Foundation";
52 case VideoCaptureApi::WIN_DIRECT_SHOW: 65 case VideoCaptureApi::WIN_DIRECT_SHOW:
53 return "Direct Show"; 66 return "Direct Show";
54 case VideoCaptureApi::MACOSX_AVFOUNDATION: 67 case VideoCaptureApi::MACOSX_AVFOUNDATION:
55 return "AV Foundation"; 68 return "AV Foundation";
(...skipping 16 matching lines...) Expand all
72 } 85 }
73 } 86 }
74 87
75 std::string VideoCaptureDeviceDescriptor::GetNameAndModel() const { 88 std::string VideoCaptureDeviceDescriptor::GetNameAndModel() const {
76 if (model_id.empty()) 89 if (model_id.empty())
77 return display_name; 90 return display_name;
78 return display_name + " (" + model_id + ")"; 91 return display_name + " (" + model_id + ")";
79 } 92 }
80 93
81 } // namespace media 94 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698