tor-browser

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

video_capture_pipewire.h (2726B)


      1 /*
      2 *  Copyright (c) 2022 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_PIPEWIRE_H_
     12 #define MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_PIPEWIRE_H_
     13 
     14 #include <pipewire/pipewire.h>
     15 #include <spa/pod/pod.h>
     16 #include <spa/utils/hook.h>
     17 
     18 #include <cstdint>
     19 
     20 #include "api/scoped_refptr.h"
     21 #include "common_video/libyuv/include/webrtc_libyuv.h"
     22 #include "modules/video_capture/linux/pipewire_session.h"
     23 #include "modules/video_capture/video_capture_defines.h"
     24 #include "modules/video_capture/video_capture_impl.h"
     25 #include "rtc_base/thread_annotations.h"
     26 #include "system_wrappers/include/clock.h"
     27 
     28 namespace webrtc {
     29 namespace videocapturemodule {
     30 class VideoCaptureModulePipeWire : public VideoCaptureImpl {
     31 public:
     32  VideoCaptureModulePipeWire(Clock* clock, VideoCaptureOptions* options);
     33  ~VideoCaptureModulePipeWire() override;
     34  int32_t Init(const char* deviceUniqueId);
     35  int32_t StartCapture(const VideoCaptureCapability& capability) override;
     36  int32_t StopCapture() override;
     37  bool CaptureStarted() override;
     38  int32_t CaptureSettings(VideoCaptureCapability& settings) override;
     39 
     40  static VideoType PipeWireRawFormatToVideoType(uint32_t format);
     41  static uint32_t VideoTypeToPipeWireRawFormat(VideoType type);
     42 
     43 private:
     44  static void OnStreamParamChanged(void* data,
     45                                   uint32_t id,
     46                                   const struct spa_pod* format);
     47  static void OnStreamStateChanged(void* data,
     48                                   pw_stream_state old_state,
     49                                   pw_stream_state state,
     50                                   const char* error_message);
     51 
     52  static void OnStreamProcess(void* data);
     53 
     54  void OnFormatChanged(const struct spa_pod* format);
     55  void ProcessBuffers();
     56 
     57  const webrtc::scoped_refptr<PipeWireSession> session_
     58      RTC_GUARDED_BY(api_checker_);
     59  bool initialized_ RTC_GUARDED_BY(api_checker_);
     60  bool started_ RTC_GUARDED_BY(api_lock_);
     61  int node_id_ RTC_GUARDED_BY(capture_checker_);
     62  VideoCaptureCapability configured_capability_
     63      RTC_GUARDED_BY(capture_checker_);
     64 
     65  struct pw_stream* stream_ RTC_GUARDED_BY(capture_checker_) = nullptr;
     66  struct spa_hook stream_listener_ RTC_GUARDED_BY(capture_checker_);
     67 };
     68 }  // namespace videocapturemodule
     69 }  // namespace webrtc
     70 
     71 #endif  // MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_PIPEWIRE_H_