From 13d9f51c679bb6d2a91b3d275e927b8ce42beeab Mon Sep 17 00:00:00 2001 From: loki Date: Sun, 8 Dec 2019 18:55:58 +0100 Subject: [PATCH] Moved source files to seperate folder --- CMakeLists.txt | 72 +++++++++++-------- sunshine.conf.example => assets/sunshine.conf | 0 assets/sunshine.service | 4 +- audio.cpp => sunshine/audio.cpp | 0 audio.h => sunshine/audio.h | 0 config.cpp => sunshine/config.cpp | 0 config.h => sunshine/config.h | 0 crypto.cpp => sunshine/crypto.cpp | 0 crypto.h => sunshine/crypto.h | 0 input.cpp => sunshine/input.cpp | 0 input.h => sunshine/input.h | 2 +- main.cpp => sunshine/main.cpp | 0 nvhttp.cpp => sunshine/nvhttp.cpp | 0 nvhttp.h => sunshine/nvhttp.h | 0 {platform => sunshine/platform}/common.h | 2 +- {platform => sunshine/platform}/linux.cpp | 0 .../platform}/linux_evdev.cpp | 2 +- queue.h => sunshine/queue.h | 0 stream.cpp => sunshine/stream.cpp | 2 +- stream.h => sunshine/stream.h | 0 utility.h => sunshine/utility.h | 0 uuid.h => sunshine/uuid.h | 0 video.cpp => sunshine/video.cpp | 2 +- video.h => sunshine/video.h | 0 24 files changed, 49 insertions(+), 37 deletions(-) rename sunshine.conf.example => assets/sunshine.conf (100%) rename audio.cpp => sunshine/audio.cpp (100%) rename audio.h => sunshine/audio.h (100%) rename config.cpp => sunshine/config.cpp (100%) rename config.h => sunshine/config.h (100%) rename crypto.cpp => sunshine/crypto.cpp (100%) rename crypto.h => sunshine/crypto.h (100%) rename input.cpp => sunshine/input.cpp (100%) rename input.h => sunshine/input.h (87%) rename main.cpp => sunshine/main.cpp (100%) rename nvhttp.cpp => sunshine/nvhttp.cpp (100%) rename nvhttp.h => sunshine/nvhttp.h (100%) rename {platform => sunshine/platform}/common.h (97%) rename {platform => sunshine/platform}/linux.cpp (100%) rename {platform => sunshine/platform}/linux_evdev.cpp (99%) rename queue.h => sunshine/queue.h (100%) rename stream.cpp => sunshine/stream.cpp (99%) rename stream.h => sunshine/stream.h (100%) rename utility.h => sunshine/utility.h (100%) rename uuid.h => sunshine/uuid.h (100%) rename video.cpp => sunshine/video.cpp (99%) rename video.h => sunshine/video.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fec71631..ee68f7d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,24 @@ project(Sunshine) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(Simple-Web-Server) add_subdirectory(moonlight-common-c/enet) + +find_package(X11 REQUIRED) +set(PLATFORM_TARGET_FILES + sunshine/platform/linux.cpp + sunshine/platform/linux_evdev.cpp) + +set(PLATFORM_LIBRARIES + Xfixes + Xtst + ${X11_LIBRARIES} + evdev + pulse + pulse-simple) + +set(PLATFORM_INCLUDE_DIRS + ${X11_INCLUDE_DIR} + /usr/include/libevdev-1.0) + set(SUNSHINE_TARGET_FILES moonlight-common-c/reedsolomon/rs.c moonlight-common-c/reedsolomon/rs.h @@ -39,43 +57,45 @@ set(SUNSHINE_TARGET_FILES moonlight-common-c/src/VideoDepacketizer.c moonlight-common-c/src/Video.h moonlight-common-c/src/VideoStream.c - utility.h - uuid.h - config.h config.cpp - main.cpp - crypto.cpp crypto.h - nvhttp.cpp nvhttp.h - stream.cpp stream.h - video.cpp video.h - queue.h - input.cpp input.h - audio.cpp audio.h - platform/linux.cpp - platform/linux_evdev.cpp - platform/common.h) + sunshine/utility.h + sunshine/uuid.h + sunshine/config.h + sunshine/config.cpp + sunshine/main.cpp + sunshine/crypto.cpp + sunshine/crypto.h + sunshine/nvhttp.cpp + sunshine/nvhttp.h + sunshine/stream.cpp + sunshine/stream.h + sunshine/video.cpp + sunshine/video.h + sunshine/queue.h + sunshine/input.cpp + sunshine/input.h + sunshine/audio.cpp + sunshine/audio.h + sunshine/platform/common.h + ${PLATFORM_TARGET_FILES}) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Simple-Web-Server ${CMAKE_CURRENT_SOURCE_DIR}/moonlight-common-c/enet/include ${CMAKE_CURRENT_SOURCE_DIR}/moonlight-common-c/reedsolomon - ${X11_INCLUDE_DIR} - /usr/include/libevdev-1.0 ${FFMPEG_INCLUDE_DIRS} + ${PLATFORM_INCLUDE_DIRS} ) find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) find_package(FFmpeg REQUIRED) -#FIXME: libX11 is Linux only -find_package(X11 REQUIRED) - list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare) string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) if("x${BUILD_TYPE}" STREQUAL "xDEBUG") list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3) -elseif("x${BUILD_TYPE}" STREQUAL "xRELEASE") +else() add_definitions(-DNDEBUG) list(APPEND SUNSHINE_COMPILE_OPTIONS -O3) endif() @@ -84,17 +104,9 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} enet - Xfixes - Xtst - ${X11_LIBRARIES} - ${FFMPEG_LIBRARIES} - - #FIXME: libpulse is linux only - pulse - pulse-simple - opus - evdev) + ${FFMPEG_LIBRARIES} + ${PLATFORM_LIBRARIES}) add_definitions(-DSUNSHINE_ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets") add_executable(sunshine ${SUNSHINE_TARGET_FILES}) diff --git a/sunshine.conf.example b/assets/sunshine.conf similarity index 100% rename from sunshine.conf.example rename to assets/sunshine.conf diff --git a/assets/sunshine.service b/assets/sunshine.service index b5645c70..b365fa9a 100644 --- a/assets/sunshine.service +++ b/assets/sunshine.service @@ -1,11 +1,11 @@ [Unit] -Description=Remote desktop service (VNC) +Description=Sunshine Gamestream Server for Moonlight [Service] WorkingDirectory=/home/%u Environment="DISPLAY=:0" Type=simple -# wait for Xorg started by ${USER} +# wait for Xorg ExecStartPre=/bin/sh -c 'while ! pgrep Xorg; do sleep 2; done' ExecStart=/home/%u/Github/sunshine/cmake-build-release/sunshine diff --git a/audio.cpp b/sunshine/audio.cpp similarity index 100% rename from audio.cpp rename to sunshine/audio.cpp diff --git a/audio.h b/sunshine/audio.h similarity index 100% rename from audio.h rename to sunshine/audio.h diff --git a/config.cpp b/sunshine/config.cpp similarity index 100% rename from config.cpp rename to sunshine/config.cpp diff --git a/config.h b/sunshine/config.h similarity index 100% rename from config.h rename to sunshine/config.h diff --git a/crypto.cpp b/sunshine/crypto.cpp similarity index 100% rename from crypto.cpp rename to sunshine/crypto.cpp diff --git a/crypto.h b/sunshine/crypto.h similarity index 100% rename from crypto.h rename to sunshine/crypto.h diff --git a/input.cpp b/sunshine/input.cpp similarity index 100% rename from input.cpp rename to sunshine/input.cpp diff --git a/input.h b/sunshine/input.h similarity index 87% rename from input.h rename to sunshine/input.h index 0e66bc5b..444d43e1 100644 --- a/input.h +++ b/sunshine/input.h @@ -5,7 +5,7 @@ #ifndef SUNSHINE_INPUT_H #define SUNSHINE_INPUT_H -#include +#include "platform/common.h" namespace input { void print(void *input); diff --git a/main.cpp b/sunshine/main.cpp similarity index 100% rename from main.cpp rename to sunshine/main.cpp diff --git a/nvhttp.cpp b/sunshine/nvhttp.cpp similarity index 100% rename from nvhttp.cpp rename to sunshine/nvhttp.cpp diff --git a/nvhttp.h b/sunshine/nvhttp.h similarity index 100% rename from nvhttp.h rename to sunshine/nvhttp.h diff --git a/platform/common.h b/sunshine/platform/common.h similarity index 97% rename from platform/common.h rename to sunshine/platform/common.h index 92c1180f..0de6597a 100644 --- a/platform/common.h +++ b/sunshine/platform/common.h @@ -6,7 +6,7 @@ #define SUNSHINE_COMMON_H #include -#include +#include "sunshine/utility.h" namespace platf { diff --git a/platform/linux.cpp b/sunshine/platform/linux.cpp similarity index 100% rename from platform/linux.cpp rename to sunshine/platform/linux.cpp diff --git a/platform/linux_evdev.cpp b/sunshine/platform/linux_evdev.cpp similarity index 99% rename from platform/linux_evdev.cpp rename to sunshine/platform/linux_evdev.cpp index 485db827..d4e0481f 100644 --- a/platform/linux_evdev.cpp +++ b/sunshine/platform/linux_evdev.cpp @@ -11,7 +11,7 @@ #include #include "common.h" -#include "utility.h" +#include "sunshine/utility.h" namespace platf { constexpr std::uint16_t DPAD_UP = 0x0001; diff --git a/queue.h b/sunshine/queue.h similarity index 100% rename from queue.h rename to sunshine/queue.h diff --git a/stream.cpp b/sunshine/stream.cpp similarity index 99% rename from stream.cpp rename to sunshine/stream.cpp index be02a594..1f6f6fbb 100644 --- a/stream.cpp +++ b/sunshine/stream.cpp @@ -173,7 +173,7 @@ public: std::vector full_payload; auto old_msg = std::move(_queue_packet); - TUPLE_2D_REF(_, old_packet, old_msg); + TUPLE_2D(_, old_packet, std::move(_queue_packet)); std::string_view new_payload { (char*)packet->data, packet->dataLength }; diff --git a/stream.h b/sunshine/stream.h similarity index 100% rename from stream.h rename to sunshine/stream.h diff --git a/utility.h b/sunshine/utility.h similarity index 100% rename from utility.h rename to sunshine/utility.h diff --git a/uuid.h b/sunshine/uuid.h similarity index 100% rename from uuid.h rename to sunshine/uuid.h diff --git a/video.cpp b/sunshine/video.cpp similarity index 99% rename from video.cpp rename to sunshine/video.cpp index c78d5818..d5d87256 100644 --- a/video.cpp +++ b/sunshine/video.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include "platform/common.h" extern "C" { #include diff --git a/video.h b/sunshine/video.h similarity index 100% rename from video.h rename to sunshine/video.h