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

Side by Side Diff: media/capture/video/video_capture_device_descriptor.h

Issue 2648973003: Sort camera device list to use front camera first (Closed)
Patch Set: address comments 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/linux/video_capture_device_factory_linux.cc ('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 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_ 5 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_
6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_ 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "media/base/video_facing.h" 12 #include "media/base/video_facing.h"
12 #include "media/capture/capture_export.h" 13 #include "media/capture/capture_export.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 // A Java counterpart will be generated for this enum. 17 // A Java counterpart will be generated for this enum.
17 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.media 18 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.media
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 VideoCaptureDeviceDescriptor(const VideoCaptureDeviceDescriptor& other); 61 VideoCaptureDeviceDescriptor(const VideoCaptureDeviceDescriptor& other);
61 ~VideoCaptureDeviceDescriptor(); 62 ~VideoCaptureDeviceDescriptor();
62 63
63 // These operators are needed due to storing the name in an STL container. 64 // These operators are needed due to storing the name in an STL container.
64 // In the shared build, all methods from the STL container will be exported 65 // In the shared build, all methods from the STL container will be exported
65 // so even though they're not used, they're still depended upon. 66 // so even though they're not used, they're still depended upon.
66 bool operator==(const VideoCaptureDeviceDescriptor& other) const { 67 bool operator==(const VideoCaptureDeviceDescriptor& other) const {
67 return (other.device_id == device_id) && (other.capture_api == capture_api); 68 return (other.device_id == device_id) && (other.capture_api == capture_api);
68 } 69 }
69 bool operator<(const VideoCaptureDeviceDescriptor& other) const { 70 bool operator<(const VideoCaptureDeviceDescriptor& other) const {
71 std::vector<media::VideoFacingMode> facing_prefer_list{
72 MEDIA_VIDEO_FACING_USER, MEDIA_VIDEO_FACING_ENVIRONMENT,
73 MEDIA_VIDEO_FACING_NONE,
74 };
75 std::map<media::VideoFacingMode, size_t> facing_mapping;
76 for (size_t i = 0; i < facing_prefer_list.size(); i++) {
77 facing_mapping[facing_prefer_list[i]] = i;
78 }
hta - Chromium 2017/01/24 09:46:24 The two-step process here seems strange. Why not i
henryhsu 2017/01/24 10:26:40 Done.
79 if (facing_mapping.at(facing) < facing_mapping.at(other.facing))
hta - Chromium 2017/01/24 09:46:24 What happens here if facing = MEDIA_VIDEO_FACING_L
henryhsu 2017/01/24 10:26:40 It's impossible to have MEDIA_VIDEO_FACING_LEFT va
80 return true;
hta - Chromium 2017/01/24 09:46:24 I would expect a function this long to get hollere
henryhsu 2017/01/24 10:26:40 Done.
70 if (device_id < other.device_id) 81 if (device_id < other.device_id)
71 return true; 82 return true;
72 return capture_api < other.capture_api; 83 return capture_api < other.capture_api;
73 } 84 }
74 85
75 const char* GetCaptureApiTypeString() const; 86 const char* GetCaptureApiTypeString() const;
76 // Friendly name of a device, plus the model identifier in parentheses. 87 // Friendly name of a device, plus the model identifier in parentheses.
77 std::string GetNameAndModel() const; 88 std::string GetNameAndModel() const;
78 89
79 std::string display_name; // Name that is intended for display in the UI 90 std::string display_name; // Name that is intended for display in the UI
80 std::string device_id; 91 std::string device_id;
81 // A unique hardware identifier of the capture device. 92 // A unique hardware identifier of the capture device.
82 // It is of the form "[vid]:[pid]" when a USB device is detected, and empty 93 // It is of the form "[vid]:[pid]" when a USB device is detected, and empty
83 // otherwise. 94 // otherwise.
84 std::string model_id; 95 std::string model_id;
85 96
86 VideoFacingMode facing; 97 VideoFacingMode facing;
87 98
88 VideoCaptureApi capture_api; 99 VideoCaptureApi capture_api;
89 VideoCaptureTransportType transport_type; 100 VideoCaptureTransportType transport_type;
90 }; 101 };
91 102
92 using VideoCaptureDeviceDescriptors = std::vector<VideoCaptureDeviceDescriptor>; 103 using VideoCaptureDeviceDescriptors = std::vector<VideoCaptureDeviceDescriptor>;
93 104
94 } // namespace media 105 } // namespace media
95 106
96 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_ 107 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_H_
OLDNEW
« no previous file with comments | « media/capture/video/linux/video_capture_device_factory_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698