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 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
kwiberg | e065fcf | 2016-03-02 01:01:11 -0800 | [diff] [blame] | 17 | #include <memory> |
| 18 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 19 | #include "modules/video_capture/video_capture_defines.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "modules/video_capture/video_capture_impl.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 21 | #include "rtc_base/critical_section.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "rtc_base/platform_thread.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 24 | namespace webrtc { |
| 25 | namespace videocapturemodule { |
| 26 | class VideoCaptureModuleV4L2 : public VideoCaptureImpl { |
| 27 | public: |
| 28 | VideoCaptureModuleV4L2(); |
Mirko Bonadei | 5aec1f6 | 2018-08-29 13:27:15 +0200 | [diff] [blame] | 29 | ~VideoCaptureModuleV4L2() override; |
| 30 | int32_t Init(const char* deviceUniqueId); |
| 31 | int32_t StartCapture(const VideoCaptureCapability& capability) override; |
| 32 | int32_t StopCapture() override; |
| 33 | bool CaptureStarted() override; |
| 34 | int32_t CaptureSettings(VideoCaptureCapability& settings) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 36 | private: |
| 37 | enum { kNoOfV4L2Bufffers = 4 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
Niels Möller | 4731f00 | 2019-05-03 09:34:24 +0200 | [diff] [blame] | 39 | static void CaptureThread(void*); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 40 | bool CaptureProcess(); |
| 41 | bool AllocateVideoBuffers(); |
| 42 | bool DeAllocateVideoBuffers(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 44 | // TODO(pbos): Stop using unique_ptr and resetting the thread. |
| 45 | std::unique_ptr<rtc::PlatformThread> _captureThread; |
| 46 | rtc::CriticalSection _captureCritSect; |
Niels Möller | 4731f00 | 2019-05-03 09:34:24 +0200 | [diff] [blame] | 47 | bool quit_ RTC_GUARDED_BY(_captureCritSect); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 48 | int32_t _deviceId; |
| 49 | int32_t _deviceFd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 51 | int32_t _buffersAllocatedByDevice; |
| 52 | int32_t _currentWidth; |
| 53 | int32_t _currentHeight; |
| 54 | int32_t _currentFrameRate; |
| 55 | bool _captureStarted; |
| 56 | VideoType _captureVideoType; |
| 57 | struct Buffer { |
| 58 | void* start; |
| 59 | size_t length; |
| 60 | }; |
| 61 | Buffer* _pool; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 63 | } // namespace videocapturemodule |
| 64 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 66 | #endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ |