feat(capture/linux): add KWin direct screencast capture method (#5009)
Co-authored-by: Ramalama2 <6314556+Ramalama2@users.noreply.github.com>
This commit is contained in:
@@ -963,6 +963,9 @@ namespace platf {
|
||||
#ifdef SUNSHINE_BUILD_X11
|
||||
X11, ///< X11
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_KWIN
|
||||
KWIN, ///< KWin ScreenCast
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_PORTAL
|
||||
PORTAL, ///< XDG PORTAL
|
||||
#endif
|
||||
@@ -1017,6 +1020,17 @@ namespace platf {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUNSHINE_BUILD_KWIN
|
||||
bool kwin_available();
|
||||
std::vector<std::string> kwin_display_names();
|
||||
std::shared_ptr<display_t> kwin_display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);
|
||||
|
||||
bool verify_kwin() {
|
||||
// Note: The separate kwin_available check is necessary because with CAP_SYS_ADMIN kwin_display_names is never empty during startup
|
||||
return window_system == window_system_e::WAYLAND && kwin_available() && !kwin_display_names().empty();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::string> display_names(mem_type_e hwdevice_type) {
|
||||
#ifdef SUNSHINE_BUILD_CUDA
|
||||
// display using NvFBC only supports mem_type_e::cuda
|
||||
@@ -1043,6 +1057,11 @@ namespace platf {
|
||||
if (sources[source::PORTAL]) {
|
||||
return portal_display_names();
|
||||
}
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_KWIN
|
||||
if (sources[source::KWIN]) {
|
||||
return kwin_display_names();
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
@@ -1087,6 +1106,12 @@ namespace platf {
|
||||
return portal_display(hwdevice_type, display_name, config);
|
||||
}
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_KWIN
|
||||
if (sources[source::KWIN]) {
|
||||
BOOST_LOG(info) << "Screencasting with KWin ScreenCast"sv;
|
||||
return kwin_display(hwdevice_type, display_name, config);
|
||||
}
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1145,6 +1170,11 @@ namespace platf {
|
||||
sources[source::PORTAL] = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef SUNSHINE_BUILD_KWIN
|
||||
if (((config::video.capture.empty() && sources.none()) || config::video.capture == "kwin") && verify_kwin()) {
|
||||
sources[source::KWIN] = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sources.none()) {
|
||||
BOOST_LOG(error) << "Unable to initialize capture method"sv;
|
||||
|
||||
Reference in New Issue
Block a user