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 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 explicit VideoCaptureDeviceLinux(const Name& device_name); | 25 explicit VideoCaptureDeviceLinux(const Name& device_name); |
26 virtual ~VideoCaptureDeviceLinux(); | 26 virtual ~VideoCaptureDeviceLinux(); |
27 | 27 |
28 // VideoCaptureDevice implementation. | 28 // VideoCaptureDevice implementation. |
29 virtual void AllocateAndStart(const VideoCaptureParams& params, | 29 virtual void AllocateAndStart(const VideoCaptureParams& params, |
30 scoped_ptr<Client> client) OVERRIDE; | 30 scoped_ptr<Client> client) OVERRIDE; |
31 | 31 |
32 virtual void StopAndDeAllocate() OVERRIDE; | 32 virtual void StopAndDeAllocate() OVERRIDE; |
33 | 33 |
| 34 protected: |
| 35 void SetRotation(int rotation); |
| 36 |
| 37 // Once |v4l2_thread_| is started, only called on that thread. |
| 38 void SetRotationOnV4L2Thread(int rotation); |
| 39 |
34 private: | 40 private: |
35 enum InternalState { | 41 enum InternalState { |
36 kIdle, // The device driver is opened but camera is not in use. | 42 kIdle, // The device driver is opened but camera is not in use. |
37 kCapturing, // Video is being captured. | 43 kCapturing, // Video is being captured. |
38 kError // Error accessing HW functions. | 44 kError // Error accessing HW functions. |
39 // User needs to recover by destroying the object. | 45 // User needs to recover by destroying the object. |
40 }; | 46 }; |
41 | 47 |
42 // Buffers used to receive video frames from with v4l2. | 48 // Buffers used to receive video frames from with v4l2. |
43 struct Buffer { | 49 struct Buffer { |
(...skipping 17 matching lines...) Expand all Loading... |
61 InternalState state_; | 67 InternalState state_; |
62 scoped_ptr<VideoCaptureDevice::Client> client_; | 68 scoped_ptr<VideoCaptureDevice::Client> client_; |
63 Name device_name_; | 69 Name device_name_; |
64 base::ScopedFD device_fd_; // File descriptor for the opened camera device. | 70 base::ScopedFD device_fd_; // File descriptor for the opened camera device. |
65 base::Thread v4l2_thread_; // Thread used for reading data from the device. | 71 base::Thread v4l2_thread_; // Thread used for reading data from the device. |
66 Buffer* buffer_pool_; | 72 Buffer* buffer_pool_; |
67 int buffer_pool_size_; // Number of allocated buffers. | 73 int buffer_pool_size_; // Number of allocated buffers. |
68 int timeout_count_; | 74 int timeout_count_; |
69 VideoCaptureFormat capture_format_; | 75 VideoCaptureFormat capture_format_; |
70 | 76 |
| 77 // Clockwise rotation. This is only used on |v4l2_thread_| when it is |
| 78 // running, or the constructor thread otherwise. |
| 79 int rotation_; |
| 80 |
71 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); | 81 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); |
72 }; | 82 }; |
73 | 83 |
74 } // namespace media | 84 } // namespace media |
75 | 85 |
76 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 86 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
OLD | NEW |