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

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 comments Created 3 years, 10 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 <map>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 10
9 namespace media { 11 namespace media {
10 12
11 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor() 13 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor()
12 : facing(VideoFacingMode::MEDIA_VIDEO_FACING_NONE), 14 : facing(VideoFacingMode::MEDIA_VIDEO_FACING_NONE),
13 capture_api(VideoCaptureApi::UNKNOWN), 15 capture_api(VideoCaptureApi::UNKNOWN),
14 transport_type(VideoCaptureTransportType::OTHER_TRANSPORT) {} 16 transport_type(VideoCaptureTransportType::OTHER_TRANSPORT) {}
15 17
16 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor( 18 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor(
(...skipping 19 matching lines...) Expand all
36 model_id(model_id), 38 model_id(model_id),
37 facing(facing), 39 facing(facing),
38 capture_api(capture_api), 40 capture_api(capture_api),
39 transport_type(transport_type) {} 41 transport_type(transport_type) {}
40 42
41 VideoCaptureDeviceDescriptor::~VideoCaptureDeviceDescriptor() {} 43 VideoCaptureDeviceDescriptor::~VideoCaptureDeviceDescriptor() {}
42 44
43 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor( 45 VideoCaptureDeviceDescriptor::VideoCaptureDeviceDescriptor(
44 const VideoCaptureDeviceDescriptor& other) = default; 46 const VideoCaptureDeviceDescriptor& other) = default;
45 47
48 bool VideoCaptureDeviceDescriptor::operator<(
49 const VideoCaptureDeviceDescriptor& other) const {
50 std::map<media::VideoFacingMode, size_t> facing_mapping{
Guido Urdaneta 2017/01/24 10:42:07 nit: Optional. the map is fine, but maybe you can
henryhsu 2017/01/25 03:28:18 Done.
51 {MEDIA_VIDEO_FACING_USER, 0},
52 {MEDIA_VIDEO_FACING_ENVIRONMENT, 1},
53 {MEDIA_VIDEO_FACING_NONE, 2}};
54 if (facing_mapping.at(facing) < facing_mapping.at(other.facing))
55 return true;
56 if (device_id < other.device_id)
57 return true;
58 return capture_api < other.capture_api;
59 }
60
46 const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const { 61 const char* VideoCaptureDeviceDescriptor::GetCaptureApiTypeString() const {
47 switch (capture_api) { 62 switch (capture_api) {
48 case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE: 63 case VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE:
49 return "V4L2 SPLANE"; 64 return "V4L2 SPLANE";
50 case VideoCaptureApi::WIN_MEDIA_FOUNDATION: 65 case VideoCaptureApi::WIN_MEDIA_FOUNDATION:
51 return "Media Foundation"; 66 return "Media Foundation";
52 case VideoCaptureApi::WIN_DIRECT_SHOW: 67 case VideoCaptureApi::WIN_DIRECT_SHOW:
53 return "Direct Show"; 68 return "Direct Show";
54 case VideoCaptureApi::MACOSX_AVFOUNDATION: 69 case VideoCaptureApi::MACOSX_AVFOUNDATION:
55 return "AV Foundation"; 70 return "AV Foundation";
(...skipping 16 matching lines...) Expand all
72 } 87 }
73 } 88 }
74 89
75 std::string VideoCaptureDeviceDescriptor::GetNameAndModel() const { 90 std::string VideoCaptureDeviceDescriptor::GetNameAndModel() const {
76 if (model_id.empty()) 91 if (model_id.empty())
77 return display_name; 92 return display_name;
78 return display_name + " (" + model_id + ")"; 93 return display_name + " (" + model_id + ")";
79 } 94 }
80 95
81 } // namespace media 96 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698