| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/linux/video_capture_device_linux.h" | 5 #include "media/capture/video/linux/video_capture_device_linux.h" |
| 6 | 6 |
| 7 #if defined(OS_OPENBSD) | 7 #if defined(OS_OPENBSD) |
| 8 #include <sys/videoio.h> | 8 #include <sys/videoio.h> |
| 9 #else | 9 #else |
| 10 #include <linux/videodev2.h> | 10 #include <linux/videodev2.h> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // USB VID and PID are both 4 bytes long. | 21 // USB VID and PID are both 4 bytes long. |
| 22 static const size_t kVidPidSize = 4; | 22 static const size_t kVidPidSize = 4; |
| 23 | 23 |
| 24 // /sys/class/video4linux/video{N}/device is a symlink to the corresponding | 24 // /sys/class/video4linux/video{N}/device is a symlink to the corresponding |
| 25 // USB device info directory. | 25 // USB device info directory. |
| 26 static const char kVidPathTemplate[] = | 26 static const char kVidPathTemplate[] = |
| 27 "/sys/class/video4linux/%s/device/../idVendor"; | 27 "/sys/class/video4linux/%s/device/../idVendor"; |
| 28 static const char kPidPathTemplate[] = | 28 static const char kPidPathTemplate[] = |
| 29 "/sys/class/video4linux/%s/device/../idProduct"; | 29 "/sys/class/video4linux/%s/device/../idProduct"; |
| 30 | 30 |
| 31 static bool ReadIdFile(const std::string path, std::string* id) { | 31 static bool ReadIdFile(const std::string& path, std::string* id) { |
| 32 char id_buf[kVidPidSize]; | 32 char id_buf[kVidPidSize]; |
| 33 FILE* file = fopen(path.c_str(), "rb"); | 33 FILE* file = fopen(path.c_str(), "rb"); |
| 34 if (!file) | 34 if (!file) |
| 35 return false; | 35 return false; |
| 36 const bool success = fread(id_buf, kVidPidSize, 1, file) == 1; | 36 const bool success = fread(id_buf, kVidPidSize, 1, file) == 1; |
| 37 fclose(file); | 37 fclose(file); |
| 38 if (!success) | 38 if (!success) |
| 39 return false; | 39 return false; |
| 40 id->append(id_buf, kVidPidSize); | 40 id->append(id_buf, kVidPidSize); |
| 41 return true; | 41 return true; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return V4L2_CID_POWER_LINE_FREQUENCY_50HZ; | 138 return V4L2_CID_POWER_LINE_FREQUENCY_50HZ; |
| 139 case static_cast<int>(media::PowerLineFrequency::FREQUENCY_60HZ): | 139 case static_cast<int>(media::PowerLineFrequency::FREQUENCY_60HZ): |
| 140 return V4L2_CID_POWER_LINE_FREQUENCY_60HZ; | 140 return V4L2_CID_POWER_LINE_FREQUENCY_60HZ; |
| 141 default: | 141 default: |
| 142 // If we have no idea of the frequency, at least try and set it to AUTO. | 142 // If we have no idea of the frequency, at least try and set it to AUTO. |
| 143 return V4L2_CID_POWER_LINE_FREQUENCY_AUTO; | 143 return V4L2_CID_POWER_LINE_FREQUENCY_AUTO; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace media | 147 } // namespace media |
| OLD | NEW |