Skip to content
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/ci-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
graphics/wayland \
lang/python312 \
multimedia/libva \
multimedia/pipewire \
net/miniupnpc \
ports-mgmt/pkg \
security/openssl \
Expand Down
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 REQUIRED)
pkg_check_modules(PIPEWIRE libpipewire-0.3 REQUIRED)
else()
set(GIO_FOUND OFF)
set(PIPEWIRE_FOUND OFF)
endif()
if(PIPEWIRE_FOUND)
add_compile_definitions(SUNSHINE_BUILD_PORTAL)
include_directories(SYSTEM ${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, libva, pipewire, wayland, x11, or (libdrm and libcap)")
endif()

# tray icon
Expand Down
3 changes: 2 additions & 1 deletion cmake/packaging/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ list(APPEND CPACK_FREEBSD_PACKAGE_DEPS
audio/opus
ftp/curl
devel/libevdev
multimedia/pipewire
net/avahi
x11/libX11
net/miniupnpc
security/openssl
x11/libX11
)

if(NOT BOOST_USE_STATIC)
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()
1 change: 1 addition & 0 deletions packaging/linux/Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ depends=(
'libevdev'
'libmfx'
'libnotify'
'libpipewire'
'libpulse'
'libva'
'libx11'
Expand Down
1 change: 1 addition & 0 deletions packaging/linux/copr/Sunshine.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ BuildRequires: libXrandr-devel
BuildRequires: libXtst-devel
BuildRequires: npm
BuildRequires: openssl-devel
BuildRequires: pipewire-devel
BuildRequires: rpm-build
BuildRequires: systemd-rpm-macros
BuildRequires: wget
Expand Down
1 change: 1 addition & 0 deletions packaging/sunshine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Sunshine < Formula
depends_on "libxtst"
depends_on "mesa"
depends_on "numactl"
depends_on "pipewire"
depends_on "pulseaudio"
depends_on "systemd"
depends_on "wayland"
Expand Down
2 changes: 2 additions & 0 deletions scripts/linux_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ function add_debian_based_deps() {
"libnotify-dev"
"libnuma-dev"
"libopus-dev"
"libpipewire-0.3-dev"
"libpulse-dev"
"libssl-dev"
"libsystemd-dev"
Expand Down Expand Up @@ -311,6 +312,7 @@ function add_fedora_deps() {
"numactl-devel"
"openssl-devel"
"opus-devel"
"pipewire-devel"
"pulseaudio-libs-devel"
"rpm-build" # if you want to build an RPM binary package
"wget" # necessary for cuda install with `run` file
Expand Down
30 changes: 30 additions & 0 deletions src/platform/linux/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,9 @@ namespace platf {
#endif
#ifdef SUNSHINE_BUILD_X11
X11, ///< X11
#endif
#ifdef SUNSHINE_BUILD_PORTAL
PORTAL, ///< XDG PORTAL
#endif
MAX_FLAGS ///< The maximum number of flags
};
Expand Down Expand Up @@ -923,6 +926,15 @@ 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 @@ -944,6 +956,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 @@ -958,6 +975,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 @@ -1040,6 +1063,13 @@ 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
Loading