Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: media/video/capture/linux/video_capture_device_linux.h

Issue 25388002: Eliminates the use of VideoCaptureDevice1 in VideoCaptureDeviceLinux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/video/capture/linux/video_capture_device_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "media/video/capture/video_capture_device.h" 16 #include "media/video/capture/video_capture_device.h"
17 #include "media/video/capture/video_capture_types.h" 17 #include "media/video/capture/video_capture_types.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 class VideoCaptureDeviceLinux : public VideoCaptureDevice1 { 21 class VideoCaptureDeviceLinux : public VideoCaptureDevice {
22 public: 22 public:
23 explicit VideoCaptureDeviceLinux(const Name& device_name); 23 explicit VideoCaptureDeviceLinux(const Name& device_name);
24 virtual ~VideoCaptureDeviceLinux(); 24 virtual ~VideoCaptureDeviceLinux();
25 25
26 // VideoCaptureDevice implementation. 26 // VideoCaptureDevice implementation.
27 virtual void Allocate(const VideoCaptureCapability& capture_format, 27 virtual void AllocateAndStart(const VideoCaptureCapability& capture_format,
28 VideoCaptureDevice::Client* client) OVERRIDE; 28 scoped_ptr<Client> client) OVERRIDE;
29 virtual void Start() OVERRIDE; 29
30 virtual void Stop() OVERRIDE; 30 virtual void StopAndDeAllocate() OVERRIDE;
31 virtual void DeAllocate() OVERRIDE;
32 virtual const Name& device_name() OVERRIDE;
33 31
34 private: 32 private:
35 enum InternalState { 33 enum InternalState {
36 kIdle, // The device driver is opened but camera is not in use. 34 kIdle, // The device driver is opened but camera is not in use.
37 kAllocated, // The camera has been allocated and can be started.
38 kCapturing, // Video is being captured. 35 kCapturing, // Video is being captured.
39 kError // Error accessing HW functions. 36 kError // Error accessing HW functions.
40 // User needs to recover by destroying the object. 37 // User needs to recover by destroying the object.
41 }; 38 };
42 39
43 // Buffers used to receive video frames from with v4l2. 40 // Buffers used to receive video frames from with v4l2.
44 struct Buffer { 41 struct Buffer {
45 Buffer() : start(0), length(0) {} 42 Buffer() : start(0), length(0) {}
46 void* start; 43 void* start;
47 size_t length; 44 size_t length;
48 }; 45 };
49 46
50 // Called on the v4l2_thread_. 47 // Called on the v4l2_thread_.
51 void OnAllocate(int width, 48 void OnAllocateAndStart(int width,
52 int height, 49 int height,
53 int frame_rate, 50 int frame_rate,
54 VideoCaptureDevice::Client* client); 51 scoped_ptr<Client> client);
55 void OnStart(); 52 void OnStopAndDeAllocate();
56 void OnStop();
57 void OnDeAllocate();
58 void OnCaptureTask(); 53 void OnCaptureTask();
59 54
60 bool AllocateVideoBuffers(); 55 bool AllocateVideoBuffers();
61 void DeAllocateVideoBuffers(); 56 void DeAllocateVideoBuffers();
62 void SetErrorState(const std::string& reason); 57 void SetErrorState(const std::string& reason);
63 58
64 InternalState state_; 59 InternalState state_;
65 VideoCaptureDevice::Client* client_; 60 scoped_ptr<VideoCaptureDevice::Client> client_;
66 Name device_name_; 61 Name device_name_;
67 int device_fd_; // File descriptor for the opened camera device. 62 int device_fd_; // File descriptor for the opened camera device.
68 base::Thread v4l2_thread_; // Thread used for reading data from the device. 63 base::Thread v4l2_thread_; // Thread used for reading data from the device.
69 Buffer* buffer_pool_; 64 Buffer* buffer_pool_;
70 int buffer_pool_size_; // Number of allocated buffers. 65 int buffer_pool_size_; // Number of allocated buffers.
71 int timeout_count_; 66 int timeout_count_;
72 67
73 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); 68 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux);
74 }; 69 };
75 70
76 } // namespace media 71 } // namespace media
77 72
78 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ 73 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | media/video/capture/linux/video_capture_device_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698