blob: 9022652ec26caee49ee5962f97122f4ad1d870f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/desktop_capturer.h"
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <utility>
#include "modules/desktop_capture/cropping_window_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer_differ_wrapper.h"
#if defined(RTC_ENABLE_WIN_WGC)
#include "modules/desktop_capture/win/wgc_capturer_win.h"
#include "rtc_base/win/windows_version.h"
#endif // defined(RTC_ENABLE_WIN_WGC)
#if defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11)
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#endif
namespace webrtc {
DesktopCapturer::~DesktopCapturer() = default;
void DesktopCapturer::SetSharedMemoryFactory(
std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {}
void DesktopCapturer::SetExcludedWindow(WindowId window) {}
bool DesktopCapturer::GetSourceList(SourceList* sources) {
return true;
}
bool DesktopCapturer::SelectSource(SourceId id) {
return false;
}
bool DesktopCapturer::FocusOnSelectedSource() {
return false;
}
bool DesktopCapturer::IsOccluded(const DesktopVector& pos) {
return false;
}
// static
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateWindowCapturer(
const DesktopCaptureOptions& options) {
#if defined(RTC_ENABLE_WIN_WGC)
if (options.allow_wgc_capturer() && IsWgcSupported(CaptureType::kWindow)) {
return WgcCapturerWin::CreateRawWindowCapturer(options);
}
#endif // defined(RTC_ENABLE_WIN_WGC)
#if defined(WEBRTC_WIN)
if (options.allow_cropping_window_capturer()) {
return CroppingWindowCapturer::CreateCapturer(options);
}
#endif // defined(WEBRTC_WIN)
std::unique_ptr<DesktopCapturer> capturer = CreateRawWindowCapturer(options);
if (capturer && options.detect_updated_region()) {
capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
}
return capturer;
}
// static
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateScreenCapturer(
const DesktopCaptureOptions& options) {
#if defined(RTC_ENABLE_WIN_WGC)
if (options.allow_wgc_capturer() && IsWgcSupported(CaptureType::kScreen)) {
return WgcCapturerWin::CreateRawScreenCapturer(options);
}
#endif // defined(RTC_ENABLE_WIN_WGC)
std::unique_ptr<DesktopCapturer> capturer = CreateRawScreenCapturer(options);
if (capturer && options.detect_updated_region()) {
capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
}
return capturer;
}
// static
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateTabCapturer(
const DesktopCaptureOptions& options) {
std::unique_ptr<DesktopCapturer> capturer = CreateRawTabCapturer(options);
if (capturer && options.detect_updated_region()) {
capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
}
return capturer;
}
#if defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11)
bool DesktopCapturer::IsRunningUnderWayland() {
const char* xdg_session_type = getenv("XDG_SESSION_TYPE");
if (!xdg_session_type || strncmp(xdg_session_type, "wayland", 7) != 0)
return false;
if (!(getenv("WAYLAND_DISPLAY")))
return false;
return true;
}
#endif // defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11)
} // namespace webrtc
|