| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |