| 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 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (!ReadIdFile(vidPath, &usb_id)) | 74 if (!ReadIdFile(vidPath, &usb_id)) |
| 75 return ""; | 75 return ""; |
| 76 usb_id.append(":"); | 76 usb_id.append(":"); |
| 77 if (!ReadIdFile(pidPath, &usb_id)) | 77 if (!ReadIdFile(pidPath, &usb_id)) |
| 78 return ""; | 78 return ""; |
| 79 | 79 |
| 80 return usb_id; | 80 return usb_id; |
| 81 } | 81 } |
| 82 | 82 |
| 83 VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name) | 83 VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name) |
| 84 : v4l2_thread_("V4L2CaptureThread"), device_name_(device_name) { | 84 : v4l2_thread_("V4L2CaptureThread"), device_name_(device_name) {} |
| 85 } | |
| 86 | 85 |
| 87 VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { | 86 VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { |
| 88 // Check if the thread is running. | 87 // Check if the thread is running. |
| 89 // This means that the device has not been StopAndDeAllocate()d properly. | 88 // This means that the device has not been StopAndDeAllocate()d properly. |
| 90 DCHECK(!v4l2_thread_.IsRunning()); | 89 DCHECK(!v4l2_thread_.IsRunning()); |
| 91 v4l2_thread_.Stop(); | 90 v4l2_thread_.Stop(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 void VideoCaptureDeviceLinux::AllocateAndStart( | 93 void VideoCaptureDeviceLinux::AllocateAndStart( |
| 95 const VideoCaptureParams& params, | 94 const VideoCaptureParams& params, |
| 96 scoped_ptr<VideoCaptureDevice::Client> client) { | 95 scoped_ptr<VideoCaptureDevice::Client> client) { |
| 97 DCHECK(!capture_impl_); | 96 DCHECK(!capture_impl_); |
| 98 if (v4l2_thread_.IsRunning()) | 97 if (v4l2_thread_.IsRunning()) |
| 99 return; // Wrong state. | 98 return; // Wrong state. |
| 100 v4l2_thread_.Start(); | 99 v4l2_thread_.Start(); |
| 101 | 100 |
| 102 const int line_frequency = | 101 const int line_frequency = |
| 103 TranslatePowerLineFrequencyToV4L2(GetPowerLineFrequency(params)); | 102 TranslatePowerLineFrequencyToV4L2(GetPowerLineFrequency(params)); |
| 104 capture_impl_ = V4L2CaptureDelegate::CreateV4L2CaptureDelegate( | 103 capture_impl_ = new V4L2CaptureDelegate( |
| 105 device_name_, v4l2_thread_.task_runner(), line_frequency); | 104 device_name_, v4l2_thread_.task_runner(), line_frequency); |
| 106 if (!capture_impl_) { | 105 if (!capture_impl_) { |
| 107 client->OnError(FROM_HERE, "Failed to create VideoCaptureDelegate"); | 106 client->OnError(FROM_HERE, "Failed to create VideoCaptureDelegate"); |
| 108 return; | 107 return; |
| 109 } | 108 } |
| 110 v4l2_thread_.message_loop()->PostTask( | 109 v4l2_thread_.message_loop()->PostTask( |
| 111 FROM_HERE, | 110 FROM_HERE, |
| 112 base::Bind(&V4L2CaptureDelegate::AllocateAndStart, capture_impl_, | 111 base::Bind(&V4L2CaptureDelegate::AllocateAndStart, capture_impl_, |
| 113 params.requested_format.frame_size.width(), | 112 params.requested_format.frame_size.width(), |
| 114 params.requested_format.frame_size.height(), | 113 params.requested_format.frame_size.height(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 142 return V4L2_CID_POWER_LINE_FREQUENCY_50HZ; | 141 return V4L2_CID_POWER_LINE_FREQUENCY_50HZ; |
| 143 case media::PowerLineFrequency::FREQUENCY_60HZ: | 142 case media::PowerLineFrequency::FREQUENCY_60HZ: |
| 144 return V4L2_CID_POWER_LINE_FREQUENCY_60HZ; | 143 return V4L2_CID_POWER_LINE_FREQUENCY_60HZ; |
| 145 default: | 144 default: |
| 146 // If we have no idea of the frequency, at least try and set it to AUTO. | 145 // If we have no idea of the frequency, at least try and set it to AUTO. |
| 147 return V4L2_CID_POWER_LINE_FREQUENCY_AUTO; | 146 return V4L2_CID_POWER_LINE_FREQUENCY_AUTO; |
| 148 } | 147 } |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace media | 150 } // namespace media |
| OLD | NEW |