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_ |
11 #define MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 11 #define MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/scoped_file.h" |
16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
17 #include "media/video/capture/video_capture_device.h" | 18 #include "media/video/capture/video_capture_device.h" |
18 #include "media/video/capture/video_capture_types.h" | 19 #include "media/video/capture/video_capture_types.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 | 22 |
22 class VideoCaptureDeviceLinux : public VideoCaptureDevice { | 23 class VideoCaptureDeviceLinux : public VideoCaptureDevice { |
23 public: | 24 public: |
24 explicit VideoCaptureDeviceLinux(const Name& device_name); | 25 explicit VideoCaptureDeviceLinux(const Name& device_name); |
25 virtual ~VideoCaptureDeviceLinux(); | 26 virtual ~VideoCaptureDeviceLinux(); |
(...skipping 27 matching lines...) Expand all Loading... |
53 void OnStopAndDeAllocate(); | 54 void OnStopAndDeAllocate(); |
54 void OnCaptureTask(); | 55 void OnCaptureTask(); |
55 | 56 |
56 bool AllocateVideoBuffers(); | 57 bool AllocateVideoBuffers(); |
57 void DeAllocateVideoBuffers(); | 58 void DeAllocateVideoBuffers(); |
58 void SetErrorState(const std::string& reason); | 59 void SetErrorState(const std::string& reason); |
59 | 60 |
60 InternalState state_; | 61 InternalState state_; |
61 scoped_ptr<VideoCaptureDevice::Client> client_; | 62 scoped_ptr<VideoCaptureDevice::Client> client_; |
62 Name device_name_; | 63 Name device_name_; |
63 int device_fd_; // File descriptor for the opened camera device. | 64 base::ScopedFD device_fd_; // File descriptor for the opened camera device. |
64 file_util::ScopedFD device_fd_closer_; | |
65 base::Thread v4l2_thread_; // Thread used for reading data from the device. | 65 base::Thread v4l2_thread_; // Thread used for reading data from the device. |
66 Buffer* buffer_pool_; | 66 Buffer* buffer_pool_; |
67 int buffer_pool_size_; // Number of allocated buffers. | 67 int buffer_pool_size_; // Number of allocated buffers. |
68 int timeout_count_; | 68 int timeout_count_; |
69 VideoCaptureFormat capture_format_; | 69 VideoCaptureFormat capture_format_; |
70 | 70 |
71 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); | 71 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); |
72 }; | 72 }; |
73 | 73 |
74 } // namespace media | 74 } // namespace media |
75 | 75 |
76 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 76 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
OLD | NEW |