Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
912 changes: 912 additions & 0 deletions 2507.patch

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion cmake/compile_definitions/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,29 @@ if(X11_FOUND)
"${CMAKE_SOURCE_DIR}/src/platform/linux/x11grab.cpp")
endif()

# XDG portal
if (${SUNSHINE_ENABLE_PORTAL})
pkg_check_modules(GIO gio-2.0 gio-unix-2.0)
pkg_check_modules(PIPEWIRE libpipewire-0.3)
else()
set(GIO_FOUND OFF)
set(PIPEWIRE_FOUND OFF)
endif()
if(PIPEWIRE_FOUND)
add_compile_definitions(SUNSHINE_BUILD_PORTAL)
include_directories(${GIO_INCLUDE_DIRS} ${PIPEWIRE_INCLUDE_DIRS})
list(APPEND PLATFORM_LIBRARIES ${GIO_LIBRARIES} ${PIPEWIRE_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/linux/portalgrab.cpp")
endif()

if(NOT ${CUDA_FOUND}
AND NOT ${WAYLAND_FOUND}
AND NOT ${X11_FOUND}
AND NOT ${PIPEWIRE_FOUND}
AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND})
AND NOT ${LIBVA_FOUND})
message(FATAL_ERROR "Couldn't find either cuda, wayland, x11, (libdrm and libcap), or libva")
message(FATAL_ERROR "Couldn't find either cuda, wayland, x11, pipewire, (libdrm and libcap), or libva")
endif()

# tray icon
Expand Down
2 changes: 2 additions & 0 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ elseif(UNIX) # Linux
"Enable building wayland specific code." ON)
option(SUNSHINE_ENABLE_X11
"Enable X11 grab if available." ON)
option(SUNSHINE_ENABLE_PORTAL
"Enable XDG portal grab if available" ON)
endif()
34 changes: 34 additions & 0 deletions src/platform/linux/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ namespace platf {
#endif
#ifdef SUNSHINE_BUILD_X11
X11, ///< X11
#endif
#ifdef SUNSHINE_BUILD_PORTAL
PORTAL,
#endif
MAX_FLAGS ///< The maximum number of flags
};
Expand Down Expand Up @@ -827,6 +830,18 @@ namespace platf {
}
#endif

#ifdef SUNSHINE_BUILD_PORTAL
std::vector<std::string>
portal_display_names();
std::shared_ptr<display_t>
portal_display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);

bool
verify_portal() {
return !portal_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
Expand All @@ -848,6 +863,11 @@ namespace platf {
if (sources[source::X11]) {
return x11_display_names();
}
#endif
#ifdef SUNSHINE_BUILD_PORTAL
if (sources[source::PORTAL]) {
return portal_display_names();
}
#endif
return {};
}
Expand All @@ -862,6 +882,12 @@ namespace platf {
}

std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config) {
#ifdef SUNSHINE_BUILD_PORTAL
if (sources[source::PORTAL]) {
BOOST_LOG(info) << "Screencasting with XDG portal"sv;
return portal_display(hwdevice_type, display_name, config);
}
#endif
#ifdef SUNSHINE_BUILD_CUDA
if (sources[source::NVFBC] && hwdevice_type == mem_type_e::cuda) {
BOOST_LOG(info) << "Screencasting with NvFBC"sv;
Expand Down Expand Up @@ -944,6 +970,14 @@ namespace platf {
}
}
#endif
#ifdef SUNSHINE_BUILD_PORTAL
if (config::video.capture.empty() || config::video.capture == "portal") {
if (verify_portal()) {
sources[source::PORTAL] = true;
}
}
#endif


if (sources.none()) {
BOOST_LOG(error) << "Unable to initialize capture method"sv;
Expand Down
Loading