| 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 // Linux specific implementation of VideoCaptureDevice. | 5 // Linux specific implementation of VideoCaptureDevice. |
| 6 // V4L2 is used for capturing. V4L2 does not provide its own thread for | 6 // V4L2 is used for capturing. V4L2 does not provide its own thread for |
| 7 // capturing so this implementation uses a Chromium thread for fetching frames | 7 // capturing so this implementation uses a Chromium thread for fetching frames |
| 8 // from V4L2. | 8 // from V4L2. |
| 9 | 9 |
| 10 #ifndef MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 10 #ifndef MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Buffers used to receive video frames from with v4l2. | 52 // Buffers used to receive video frames from with v4l2. |
| 53 struct Buffer { | 53 struct Buffer { |
| 54 Buffer() : start(0), length(0) {} | 54 Buffer() : start(0), length(0) {} |
| 55 void* start; | 55 void* start; |
| 56 size_t length; | 56 size_t length; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Called on the v4l2_thread_. | 59 // Called on the v4l2_thread_. |
| 60 void OnAllocateAndStart(int width, | 60 void OnAllocateAndStart(int width, |
| 61 int height, | 61 int height, |
| 62 int frame_rate, | 62 float frame_rate, |
| 63 scoped_ptr<Client> client); | 63 scoped_ptr<Client> client); |
| 64 void OnStopAndDeAllocate(); | 64 void OnStopAndDeAllocate(); |
| 65 void OnCaptureTask(); | 65 void OnCaptureTask(); |
| 66 | 66 |
| 67 bool AllocateVideoBuffers(); | 67 bool AllocateVideoBuffers(); |
| 68 void DeAllocateVideoBuffers(); | 68 void DeAllocateVideoBuffers(); |
| 69 void SetErrorState(const std::string& reason); | 69 void SetErrorState(const std::string& reason); |
| 70 | 70 |
| 71 InternalState state_; | 71 InternalState state_; |
| 72 scoped_ptr<VideoCaptureDevice::Client> client_; | 72 scoped_ptr<VideoCaptureDevice::Client> client_; |
| 73 Name device_name_; | 73 Name device_name_; |
| 74 base::ScopedFD device_fd_; // File descriptor for the opened camera device. | 74 base::ScopedFD device_fd_; // File descriptor for the opened camera device. |
| 75 base::Thread v4l2_thread_; // Thread used for reading data from the device. | 75 base::Thread v4l2_thread_; // Thread used for reading data from the device. |
| 76 Buffer* buffer_pool_; | 76 Buffer* buffer_pool_; |
| 77 int buffer_pool_size_; // Number of allocated buffers. | 77 int buffer_pool_size_; // Number of allocated buffers. |
| 78 int timeout_count_; | 78 int timeout_count_; |
| 79 VideoCaptureFormat capture_format_; | 79 VideoCaptureFormat capture_format_; |
| 80 | 80 |
| 81 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. | 81 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. |
| 82 // This is only used on |v4l2_thread_| when it is running, or the constructor | 82 // This is only used on |v4l2_thread_| when it is running, or the constructor |
| 83 // thread otherwise. | 83 // thread otherwise. |
| 84 int rotation_; | 84 int rotation_; |
| 85 | 85 |
| 86 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); | 86 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace media | 89 } // namespace media |
| 90 | 90 |
| 91 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 91 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
| OLD | NEW |