niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mallinath@webrtc.org | 0d757b8 | 2012-02-21 16:47:55 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ |
| 12 | #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | e065fcf | 2016-03-02 01:01:11 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 16 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "modules/video_capture/video_capture_impl.h" |
| 18 | #include "rtc_base/criticalsection.h" |
| 19 | #include "rtc_base/platform_thread.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc |
| 22 | { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | namespace videocapturemodule |
| 24 | { |
| 25 | class VideoCaptureModuleV4L2: public VideoCaptureImpl |
| 26 | { |
| 27 | public: |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 28 | VideoCaptureModuleV4L2(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | virtual ~VideoCaptureModuleV4L2(); |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 30 | virtual int32_t Init(const char* deviceUniqueId); |
| 31 | virtual int32_t StartCapture(const VideoCaptureCapability& capability); |
| 32 | virtual int32_t StopCapture(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | virtual bool CaptureStarted(); |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 34 | virtual int32_t CaptureSettings(VideoCaptureCapability& settings); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
| 36 | private: |
| 37 | enum {kNoOfV4L2Bufffers=4}; |
| 38 | |
| 39 | static bool CaptureThread(void*); |
| 40 | bool CaptureProcess(); |
| 41 | bool AllocateVideoBuffers(); |
| 42 | bool DeAllocateVideoBuffers(); |
| 43 | |
kwiberg | e065fcf | 2016-03-02 01:01:11 -0800 | [diff] [blame] | 44 | // TODO(pbos): Stop using unique_ptr and resetting the thread. |
| 45 | std::unique_ptr<rtc::PlatformThread> _captureThread; |
kthelgason | ff046c7 | 2017-03-31 02:03:55 -0700 | [diff] [blame] | 46 | rtc::CriticalSection _captureCritSect; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 48 | int32_t _deviceId; |
| 49 | int32_t _deviceFd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 51 | int32_t _buffersAllocatedByDevice; |
| 52 | int32_t _currentWidth; |
| 53 | int32_t _currentHeight; |
| 54 | int32_t _currentFrameRate; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | bool _captureStarted; |
nisse | eb44b39 | 2017-04-28 07:18:05 -0700 | [diff] [blame] | 56 | VideoType _captureVideoType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | struct Buffer |
| 58 | { |
| 59 | void *start; |
| 60 | size_t length; |
| 61 | }; |
mallinath@webrtc.org | 0d757b8 | 2012-02-21 16:47:55 +0000 | [diff] [blame] | 62 | Buffer *_pool; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 64 | } // namespace videocapturemodule |
| 65 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 67 | #endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ |