Skip to content
Merged
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.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ jobs:
build-essential \
gcc-10 \
g++-10 \
libappindicator3-dev \
libavdevice-dev \
libcap-dev \
libcurl4-openssl-dev \
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
path = third-party/nanors
url = https://github.com/sleepybishop/nanors.git
branch = master
[submodule "third-party/tray"]
path = third-party/tray
url = https://github.com/dmikushin/tray
branch = master
44 changes: 43 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ find_package(Boost COMPONENTS locale log filesystem program_options REQUIRED)

list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)

# enable system tray, we will disable this later if we cannot find the required package config on linux
set(SUNSHINE_TRAY 1)

if(WIN32)
enable_language(RC)
set(CMAKE_RC_COMPILER windres)
Expand All @@ -168,6 +171,7 @@ if(WIN32)
src/platform/windows/display_vram.cpp
src/platform/windows/display_ram.cpp
src/platform/windows/audio.cpp
third-party/tray/tray_windows.c
third-party/ViGEmClient/src/ViGEmClient.cpp
third-party/ViGEmClient/include/ViGEm/Client.h
third-party/ViGEmClient/include/ViGEm/Common.h
Expand Down Expand Up @@ -207,13 +211,15 @@ elseif(APPLE)

FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices )
FIND_LIBRARY(AV_FOUNDATION_LIBRARY AVFoundation )
FIND_LIBRARY(COCOA Cocoa REQUIRED ) # tray icon
FIND_LIBRARY(CORE_MEDIA_LIBRARY CoreMedia )
FIND_LIBRARY(CORE_VIDEO_LIBRARY CoreVideo )
FIND_LIBRARY(VIDEO_TOOLBOX_LIBRARY VideoToolbox )
FIND_LIBRARY(FOUNDATION_LIBRARY Foundation )
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${APP_SERVICES_LIBRARY}
${AV_FOUNDATION_LIBRARY}
${COCOA}
${CORE_MEDIA_LIBRARY}
${CORE_VIDEO_LIBRARY}
${VIDEO_TOOLBOX_LIBRARY}
Expand All @@ -240,6 +246,7 @@ elseif(APPLE)
src/platform/macos/publish.cpp
third-party/TPCircularBuffer/TPCircularBuffer.c
third-party/TPCircularBuffer/TPCircularBuffer.h
third-party/tray/tray_darwin.m
${APPLE_PLIST_FILE})
else()
add_compile_definitions(SUNSHINE_PLATFORM="linux")
Expand All @@ -248,6 +255,7 @@ else()
option(SUNSHINE_ENABLE_X11 "Enable X11 grab if available" ON)
option(SUNSHINE_ENABLE_WAYLAND "Enable building wayland specific code" ON)
option(SUNSHINE_ENABLE_CUDA "Enable cuda specific code" ON)
option(SUNSHINE_ENABLE_TRAY "Enable tray icon" ON)

if(${SUNSHINE_ENABLE_X11})
find_package(X11)
Expand Down Expand Up @@ -413,10 +421,27 @@ ${CMAKE_BINARY_DIR}/generated-src/${filename}.h")
src/platform/linux/wlgrab.cpp
src/platform/linux/wayland.cpp)
endif()
if(NOT ${X11_FOUND} AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND}) AND NOT ${WAYLAND_FOUND} AND NOT ${})
if(NOT ${X11_FOUND} AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND}) AND NOT ${WAYLAND_FOUND})
message(FATAL_ERROR "Couldn't find either x11, wayland, cuda or (libdrm and libcap)")
endif()

# tray icon
if(${SUNSHINE_ENABLE_TRAY})
pkg_check_modules(APPINDICATOR appindicator3-0.1)
if(NOT APPINDICATOR_FOUND)
message(WARNING "Couldn't find appindicator, disabling tray icon")
set(SUNSHINE_TRAY 0)
else()
include_directories(${APPINDICATOR_INCLUDE_DIRS})
link_directories(${APPINDICATOR_LIBRARY_DIRS})

list(APPEND PLATFORM_TARGET_FILES third-party/tray/tray_linux.c)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${APPINDICATOR_LIBRARIES})
endif()
else()
set(SUNSHINE_TRAY 0)
endif()

list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/publish.cpp
src/platform/linux/vaapi.h
Expand Down Expand Up @@ -466,6 +491,7 @@ set(SUNSHINE_TARGET_FILES
third-party/moonlight-common-c/src/Rtsp.h
third-party/moonlight-common-c/src/RtspParser.c
third-party/moonlight-common-c/src/Video.h
third-party/tray/tray.h
src/upnp.cpp
src/upnp.h
src/cbs.cpp
Expand Down Expand Up @@ -499,6 +525,8 @@ set(SUNSHINE_TARGET_FILES
src/network.cpp
src/network.h
src/move_by_copy.h
src/system_tray.cpp
src/system_tray.h
src/task_pool.h
src/thread_pool.h
src/thread_safe.h
Expand All @@ -511,6 +539,8 @@ set_source_files_properties(src/upnp.cpp PROPERTIES COMPILE_FLAGS -Wno-pedantic)
set_source_files_properties(third-party/nanors/rs.c
PROPERTIES COMPILE_FLAGS "-include deps/obl/autoshim.h -ftree-vectorize")

list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_TRAY=${SUNSHINE_TRAY})

# Pre-compiled binaries
if(WIN32)
set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-windows-x86_64")
Expand Down Expand Up @@ -890,6 +920,18 @@ elseif(UNIX)
pulseaudio-libs >= 10.0")
# This should automatically figure out dependencies, doesn't work with the current config
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)

if(${SUNSHINE_TRAY} STREQUAL 1)
install(FILES "${CMAKE_SOURCE_DIR}/sunshine.svg"
DESTINATION "/usr/share/icons")

set(CPACK_DEBIAN_PACKAGE_DEPENDS "\
${CPACK_DEBIAN_PACKAGE_DEPENDS}, \
libappindicator3-1")
set(CPACK_RPM_PACKAGE_REQUIRES "\
${CPACK_RPM_PACKAGE_REQUIRES}, \
libappindicator-gtk3 >= 12.10.0")
endif()
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions docker/fedora-36.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dnf -y install \
gcc-12.0.1* \
gcc-c++-12.0.1* \
git-2.39.2* \
libappindicator-gtk3-devel-12.10.0* \
libcap-devel-2.48* \
libcurl-devel-7.82.0* \
libdrm-devel-2.4.110* \
Expand Down
1 change: 1 addition & 0 deletions docker/fedora-37.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dnf -y install \
gcc-12.2.1* \
gcc-c++-12.2.1* \
git-2.39.2* \
libappindicator-gtk3-devel-12.10.1* \
libcap-devel-2.48* \
libcurl-devel-7.85.0* \
libdrm-devel-2.4.112* \
Expand Down
1 change: 1 addition & 0 deletions docker/ubuntu-20.04.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ apt-get install -y --no-install-recommends \
gcc-10=10.3.0* \
g++-10=10.3.0* \
git=1:2.25.1* \
libappindicator3-dev=12.10.1* \
libavdevice-dev=7:4.2.* \
libboost-filesystem-dev=1.71.0* \
libboost-locale-dev=1.71.0* \
Expand Down
1 change: 1 addition & 0 deletions docker/ubuntu-22.04.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ apt-get install -y --no-install-recommends \
build-essential=12.9* \
cmake=3.22.1* \
git=1:2.34.1* \
libappindicator3-dev=12.10.1* \
libavdevice-dev=7:4.4.* \
libboost-filesystem-dev=1.74.0* \
libboost-locale-dev=1.74.0* \
Expand Down
3 changes: 3 additions & 0 deletions docs/source/building/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Install Requirements
gcc \
gcc-c++ \
intel-mediasdk-devel \ # x86_64 only
libappindicator-gtk3-devel \
libcap-devel \
libcurl-devel \
libdrm-devel \
Expand Down Expand Up @@ -94,6 +95,7 @@ Install Requirements
build-essential \
cmake \
g++-10 \
libappindicator3-dev \
libavdevice-dev \
libboost-filesystem-dev \
libboost-locale-dev \
Expand Down Expand Up @@ -142,6 +144,7 @@ Install Requirements
sudo apt update && sudo apt install \
build-essential \
cmake \
libappindicator3-dev \
libavdevice-dev \
libboost-filesystem-dev \
libboost-locale-dev \
Expand Down
1 change: 1 addition & 0 deletions docs/source/source/src.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Code
src/rtsp
src/stream
src/sync
src/system_tray
src/task_pool
src/thread_pool
src/thread_safe
Expand Down
4 changes: 4 additions & 0 deletions docs/source/source/src/system_tray.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
system_tray
===========

.. doxygenfile:: system_tray.h
2 changes: 1 addition & 1 deletion packaging/linux/aur/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ arch=('x86_64' 'aarch64')
url=@PROJECT_HOMEPAGE_URL@
license=('GPL3')

depends=('avahi' 'boost-libs' 'curl' 'libevdev' 'libmfx' 'libpulse' 'libva' 'libvdpau' 'libx11' 'libxcb' 'libxfixes' 'libxrandr' 'libxtst' 'numactl' 'openssl' 'opus' 'udev')
depends=('avahi' 'boost-libs' 'curl' 'libappindicator-gtk3' 'libevdev' 'libmfx' 'libpulse' 'libva' 'libvdpau' 'libx11' 'libxcb' 'libxfixes' 'libxrandr' 'libxtst' 'numactl' 'openssl' 'opus' 'udev')
makedepends=('boost' 'cmake' 'git' 'make' 'nodejs' 'npm')
optdepends=('cuda: NvFBC capture support'
'libcap'
Expand Down
11 changes: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "platform/common.h"
#include "process.h"
#include "rtsp.h"
#include "system_tray.h"
#include "thread_pool.h"
#include "upnp.h"
#include "version.h"
Expand Down Expand Up @@ -301,6 +302,11 @@ int main(int argc, char *argv[]) {
BOOST_LOG(info) << PROJECT_NAME << " version: " << PROJECT_VER << std::endl;
task_pool.start(1);

#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1
// create tray thread and detach it
system_tray::run_tray();
#endif

// Create signal handler after logging has been initialized
auto shutdown_event = mail::man->event<bool>(mail::shutdown);
on_signal(SIGINT, [&force_shutdown, shutdown_event]() {
Expand Down Expand Up @@ -371,6 +377,11 @@ int main(int argc, char *argv[]) {
task_pool.stop();
task_pool.join();

// stop system tray
#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1
system_tray::end_tray();
#endif

return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ extern boost::log::sources::severity_logger<int> fatal;
// functions
int main(int argc, char *argv[]);
void log_flush();
void open_url(const std::string &url);
void tray_open_ui_cb(struct tray_menu *item);
void tray_donate_github_cb(struct tray_menu *item);
void tray_donate_mee6_cb(struct tray_menu *item);
void tray_donate_patreon_cb(struct tray_menu *item);
void tray_donate_paypal_cb(struct tray_menu *item);
void tray_quit_cb(struct tray_menu *item);
void print_help(const char *name);
std::string read_file(const char *path);
int write_file(const char *path, const std::string_view &contents);
Expand Down
Loading