xref: /aosp_15_r20/external/webrtc/modules/desktop_capture/window_capturer_linux.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2018 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 #include <memory>
12 
13 #include "modules/desktop_capture/desktop_capture_options.h"
14 #include "modules/desktop_capture/desktop_capturer.h"
15 
16 #if defined(WEBRTC_USE_PIPEWIRE)
17 #include "modules/desktop_capture/linux/wayland/base_capturer_pipewire.h"
18 #endif  // defined(WEBRTC_USE_PIPEWIRE)
19 
20 #if defined(WEBRTC_USE_X11)
21 #include "modules/desktop_capture/linux/x11/window_capturer_x11.h"
22 #endif  // defined(WEBRTC_USE_X11)
23 
24 namespace webrtc {
25 
26 // static
CreateRawWindowCapturer(const DesktopCaptureOptions & options)27 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
28     const DesktopCaptureOptions& options) {
29 #if defined(WEBRTC_USE_PIPEWIRE)
30   if (options.allow_pipewire() && BaseCapturerPipeWire::IsSupported()) {
31     return std::make_unique<BaseCapturerPipeWire>(options,
32                                                   CaptureType::kWindow);
33   }
34 #endif  // defined(WEBRTC_USE_PIPEWIRE)
35 
36 #if defined(WEBRTC_USE_X11)
37   if (!DesktopCapturer::IsRunningUnderWayland())
38     return WindowCapturerX11::CreateRawWindowCapturer(options);
39 #endif  // defined(WEBRTC_USE_X11)
40 
41   return nullptr;
42 }
43 
44 }  // namespace webrtc
45