video_capture_options.h (2367B)
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 #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_OPTIONS_H_ 11 #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_OPTIONS_H_ 12 13 #include "api/scoped_refptr.h" 14 #include "rtc_base/system/rtc_export.h" 15 16 #if defined(WEBRTC_USE_PIPEWIRE) 17 #include "modules/portal/pipewire_utils.h" 18 #endif 19 20 namespace webrtc { 21 22 #if defined(WEBRTC_USE_PIPEWIRE) 23 namespace videocapturemodule { 24 class PipeWireSession; 25 } // namespace videocapturemodule 26 #endif 27 28 // An object that stores initialization parameters for video capturers 29 class RTC_EXPORT VideoCaptureOptions { 30 public: 31 VideoCaptureOptions(); 32 VideoCaptureOptions(const VideoCaptureOptions& options); 33 VideoCaptureOptions(VideoCaptureOptions&& options); 34 ~VideoCaptureOptions(); 35 36 VideoCaptureOptions& operator=(const VideoCaptureOptions& options); 37 VideoCaptureOptions& operator=(VideoCaptureOptions&& options); 38 39 enum class Status { 40 SUCCESS, 41 UNINITIALIZED, 42 UNAVAILABLE, 43 DENIED, 44 ERROR, 45 MAX_VALUE = ERROR 46 }; 47 48 class Callback { 49 public: 50 virtual void OnInitialized(Status status) = 0; 51 52 protected: 53 virtual ~Callback() = default; 54 }; 55 56 void Init(Callback* callback); 57 58 #if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD) 59 bool allow_v4l2() const { return allow_v4l2_; } 60 void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; } 61 #endif 62 63 #if defined(WEBRTC_USE_PIPEWIRE) 64 bool allow_pipewire() const { return allow_pipewire_; } 65 void set_allow_pipewire(bool allow) { allow_pipewire_ = allow; } 66 void set_pipewire_fd(int fd) { pipewire_fd_ = fd; } 67 scoped_refptr<videocapturemodule::PipeWireSession> pipewire_session(); 68 #endif 69 70 private: 71 #if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD) 72 bool allow_v4l2_ = false; 73 #endif 74 #if defined(WEBRTC_USE_PIPEWIRE) 75 bool allow_pipewire_ = false; 76 int pipewire_fd_ = kInvalidPipeWireFd; 77 scoped_refptr<videocapturemodule::PipeWireSession> pipewire_session_; 78 #endif 79 }; 80 81 } // namespace webrtc 82 83 #endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_OPTIONS_H_