1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 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 11 #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ 12 #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <memory> 18 19 #include "modules/video_capture/video_capture_defines.h" 20 #include "modules/video_capture/video_capture_impl.h" 21 #include "rtc_base/platform_thread.h" 22 #include "rtc_base/synchronization/mutex.h" 23 24 namespace webrtc { 25 namespace videocapturemodule { 26 class VideoCaptureModuleV4L2 : public VideoCaptureImpl { 27 public: 28 VideoCaptureModuleV4L2(); 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; 35 36 private: 37 enum { kNoOfV4L2Bufffers = 4 }; 38 39 static void CaptureThread(void*); 40 bool CaptureProcess(); 41 bool AllocateVideoBuffers(); 42 bool DeAllocateVideoBuffers(); 43 44 // TODO(pbos): Stop using unique_ptr and resetting the thread. 45 std::unique_ptr<rtc::PlatformThread> _captureThread; 46 Mutex capture_lock_; 47 bool quit_ RTC_GUARDED_BY(capture_lock_); 48 int32_t _deviceId; 49 int32_t _deviceFd; 50 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; 62 }; 63 } // namespace videocapturemodule 64 } // namespace webrtc 65 66 #endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_ 67