diff --git a/CMakeLists.txt b/CMakeLists.txt index cd4e7037..45d4bf74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) project(Sunshine) -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) add_subdirectory(third-party/Simple-Web-Server) @@ -102,18 +102,45 @@ else() add_compile_definitions(SUNSHINE_PLATFORM="linux") list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps_linux.json") - find_package(X11 REQUIRED) - find_package(FFmpeg REQUIRED) + option(SUNSHINE_ENABLE_DRM "Enable KMS grab if available" ON) + option(SUNSHINE_ENABLE_X11 "Enable X11 grab if available" ON) - set(PLATFORM_TARGET_FILES + if(${SUNSHINE_ENABLE_X11}) + find_package(X11) + endif() + if(${SUNSHINE_ENABLE_DRM}) + find_package(LIBDRM) + endif() + + find_package(FFMPEG REQUIRED) + + if(X11_FOUND) + add_compile_definitions(SUNSHINE_BUILD_X11) + include_directories(${X11_INCLUDE_DIR}) + list(APPEND PLATFORM_TARGET_FILES sunshine/platform/linux/x11grab.cpp) + endif() + if(LIBDRM_FOUND) + add_compile_definitions(SUNSHINE_BUILD_DRM) + include_directories(${LIBDRM_INCLUDE_DIRS}) + list(APPEND PLATFORM_LIBRARIES ${LIBDRM_LIBRARIES}) + list(APPEND PLATFORM_TARGET_FILES sunshine/platform/linux/kmsgrab.cpp) + list(APPEND SUNSHINE_DEFINITIONS EGL_NO_X11=1) + endif() + if(NOT X11_FOUND AND NOT LIBDRM_FOUND) + message(FATAL "Couldn't find either x11 or libdrm") + endif() + + list(APPEND PLATFORM_TARGET_FILES sunshine/platform/linux/publish.cpp sunshine/platform/linux/vaapi.h sunshine/platform/linux/vaapi.cpp + sunshine/platform/linux/graphics.h + sunshine/platform/linux/graphics.cpp sunshine/platform/linux/misc.h sunshine/platform/linux/misc.cpp - sunshine/platform/linux/display.cpp sunshine/platform/linux/audio.cpp sunshine/platform/linux/input.cpp + sunshine/platform/linux/x11grab.h third-party/glad/src/egl.c third-party/glad/src/gl.c third-party/glad/include/EGL/eglplatform.h @@ -121,22 +148,14 @@ else() third-party/glad/include/glad/gl.h third-party/glad/include/glad/egl.h) - set(PLATFORM_LIBRARIES - Xfixes - Xtst - xcb - xcb-shm - xcb-xfixes - Xrandr - ${X11_LIBRARIES} + list(APPEND PLATFORM_LIBRARIES dl evdev pulse pulse-simple ) - set(PLATFORM_INCLUDE_DIRS - ${X11_INCLUDE_DIR} + include_directories( /usr/include/libevdev-1.0 third-party/glad/include) diff --git a/README.md b/README.md index b78bc234..dea0e76f 100644 --- a/README.md +++ b/README.md @@ -14,21 +14,38 @@ Sunshine is a Gamestream host for Moonlight ## Linux ### Requirements: + Ubuntu 20.04: -Install the following +Install the following: +#### X11 Only ``` sudo apt install cmake gcc-10 g++-10 libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev ``` +#### X11 + KMS (Requires additional setup) +KMS allows Sunshine to grab the monitor with lower latency then through X11 + +``` +sudo apt install cmake gcc-10 g++-10 libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev +``` + ### Compilation: + +#### X11 Only +- `git clone https://github.com/loki-47-6F-64/sunshine.git --recurse-submodules` +- `cd sunshine && mkdir build && cd build` +- `cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DSUNSHINE_ENABLE_DRM=OFF ..` +- `make -j ${nproc}` + +#### X11 + KMS - `git clone https://github.com/loki-47-6F-64/sunshine.git --recurse-submodules` - `cd sunshine && mkdir build && cd build` - `cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..` - `make -j ${nproc}` - ### Setup: sunshine needs access to uinput to create mouse and gamepad events: + - Add user to group 'input': `usermod -a -G input $USER` - Create udev rules: @@ -52,6 +69,11 @@ sunshine needs access to uinput to create mouse and gamepad events: - `assets/apps.json` is an [example](README.md#application-list) of a list of applications that are started just before running a stream +#### Additional Setup for KMS: +Please note that `cap_sys_admin` may as well be root, except you don't need to be root to run it. +It's necessary to allow Sunshine to use KMS +- `sudo setcap cap_sys_admin+ep sunshine` + ### Trouleshooting: - If you get "Could not create Sunshine Gamepad: Permission Denied", ensure you are part of the group "input": - `groups $USER` diff --git a/appveyor.yml b/appveyor.yml index bee10a61..02a93587 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: install: - sh: sudo apt update --ignore-missing - - sh: sudo apt install -y build-essential fakeroot gcc-10 g++-10 cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev + - sh: sudo apt install -y build-essential fakeroot gcc-10 g++-10 cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev - cmd: C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -S mingw-w64-x86_64-openssl mingw-w64-x86_64-cmake mingw-w64-x86_64-toolchain mingw-w64-x86_64-opus mingw-w64-x86_64-x265 mingw-w64-x86_64-boost git yasm nasm diffutils make" before_build: diff --git a/assets/web/apps.html b/assets/web/apps.html index 812d5588..c87dbc89 100644 --- a/assets/web/apps.html +++ b/assets/web/apps.html @@ -150,6 +150,22 @@ that sleeps indefinitely + +
+ + +
+ The working directory that should be passed to the process. + For example, some applications use the working directory to search for configuration files. + If not set, Sunshine will default to the parent directory of the command +
+