tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

video_capture_v4l2.h (2322B)


      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_LINUX_VIDEO_CAPTURE_V4L2_H_
     12 #define MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_V4L2_H_
     13 
     14 #include <cstddef>
     15 #include <cstdint>
     16 
     17 #include "modules/video_capture/video_capture_defines.h"
     18 #include "modules/video_capture/video_capture_impl.h"
     19 #include "rtc_base/platform_thread.h"
     20 #include "rtc_base/synchronization/mutex.h"
     21 #include "rtc_base/thread_annotations.h"
     22 #include "system_wrappers/include/clock.h"
     23 
     24 namespace webrtc {
     25 namespace videocapturemodule {
     26 class VideoCaptureModuleV4L2 : public VideoCaptureImpl {
     27 public:
     28  explicit VideoCaptureModuleV4L2(Clock* clock);
     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() RTC_EXCLUSIVE_LOCKS_REQUIRED(capture_lock_);
     42  bool DeAllocateVideoBuffers() RTC_EXCLUSIVE_LOCKS_REQUIRED(capture_lock_);
     43 
     44  PlatformThread _captureThread RTC_GUARDED_BY(api_checker_);
     45  Mutex capture_lock_ RTC_ACQUIRED_BEFORE(api_lock_);
     46  bool quit_ RTC_GUARDED_BY(capture_lock_);
     47  int32_t _deviceId RTC_GUARDED_BY(api_checker_);
     48  int32_t _deviceFd RTC_GUARDED_BY(capture_checker_);
     49 
     50  int32_t _buffersAllocatedByDevice RTC_GUARDED_BY(capture_lock_);
     51  VideoCaptureCapability configured_capability_
     52      RTC_GUARDED_BY(capture_checker_);
     53  bool _streaming RTC_GUARDED_BY(capture_checker_);
     54  bool _captureStarted RTC_GUARDED_BY(api_checker_);
     55  struct Buffer {
     56    void* start;
     57    size_t length;
     58  };
     59  Buffer* _pool RTC_GUARDED_BY(capture_lock_);
     60 };
     61 }  // namespace videocapturemodule
     62 }  // namespace webrtc
     63 
     64 #endif  // MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_V4L2_H_