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 16 matching lines...) Expand all Loading... | |
60 | 66 |
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_; |
76 int rotation_; // Clockwise rotation. | |
mcasas
2014/05/11 18:41:25
Comment that |rotation_| is used in |v4l2_thread_|
Zachary Kuznia
2014/05/12 02:54:18
Done.
| |
70 | 77 |
71 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); | 78 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); |
72 }; | 79 }; |
73 | 80 |
74 } // namespace media | 81 } // namespace media |
75 | 82 |
76 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 83 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
OLD | NEW |