blob: c0649a5170bc181d8c85f901472f8ac81368e1a2 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
mallinath@webrtc.org0d757b82012-02-21 16:47:55 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#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.com470e71d2011-07-07 08:21:25 +000013
kwiberge065fcf2016-03-02 01:01:11 -080014#include <memory>
15
Mirko Bonadei71207422017-09-15 13:58:09 +020016#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/video_capture/video_capture_impl.h"
18#include "rtc_base/criticalsection.h"
19#include "rtc_base/platform_thread.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
21namespace webrtc
22{
niklase@google.com470e71d2011-07-07 08:21:25 +000023namespace videocapturemodule
24{
25class VideoCaptureModuleV4L2: public VideoCaptureImpl
26{
27public:
nisseb29b9c82016-12-12 00:22:56 -080028 VideoCaptureModuleV4L2();
niklase@google.com470e71d2011-07-07 08:21:25 +000029 virtual ~VideoCaptureModuleV4L2();
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000030 virtual int32_t Init(const char* deviceUniqueId);
31 virtual int32_t StartCapture(const VideoCaptureCapability& capability);
32 virtual int32_t StopCapture();
niklase@google.com470e71d2011-07-07 08:21:25 +000033 virtual bool CaptureStarted();
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000034 virtual int32_t CaptureSettings(VideoCaptureCapability& settings);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
36private:
37 enum {kNoOfV4L2Bufffers=4};
38
39 static bool CaptureThread(void*);
40 bool CaptureProcess();
41 bool AllocateVideoBuffers();
42 bool DeAllocateVideoBuffers();
43
kwiberge065fcf2016-03-02 01:01:11 -080044 // TODO(pbos): Stop using unique_ptr and resetting the thread.
45 std::unique_ptr<rtc::PlatformThread> _captureThread;
kthelgasonff046c72017-03-31 02:03:55 -070046 rtc::CriticalSection _captureCritSect;
niklase@google.com470e71d2011-07-07 08:21:25 +000047
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000048 int32_t _deviceId;
49 int32_t _deviceFd;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
pbos@webrtc.orgdfc5bb92013-04-10 08:23:13 +000051 int32_t _buffersAllocatedByDevice;
52 int32_t _currentWidth;
53 int32_t _currentHeight;
54 int32_t _currentFrameRate;
niklase@google.com470e71d2011-07-07 08:21:25 +000055 bool _captureStarted;
nisseeb44b392017-04-28 07:18:05 -070056 VideoType _captureVideoType;
niklase@google.com470e71d2011-07-07 08:21:25 +000057 struct Buffer
58 {
59 void *start;
60 size_t length;
61 };
mallinath@webrtc.org0d757b82012-02-21 16:47:55 +000062 Buffer *_pool;
niklase@google.com470e71d2011-07-07 08:21:25 +000063};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000064} // namespace videocapturemodule
65} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000066
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020067#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_