Skip to content

Commit

Permalink
Merge pull request #2 from games-on-whales/gstreamer
Browse files Browse the repository at this point in the history
Implemented streaming audio and video via Gstreamer
  • Loading branch information
ABeltramo authored Nov 26, 2022
2 parents cd5aa47 + 95cbd1c commit b5d1bab
Show file tree
Hide file tree
Showing 82 changed files with 7,850 additions and 943 deletions.
57 changes: 29 additions & 28 deletions .github/workflows/linux-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,45 @@ on: [ push, pull_request ]
jobs:
build:
name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
cxx:
- g++-9
- g++-10
- clang++-9
- clang++-10
- g++-11
- clang++-11
- clang++-14
build_type: [ Debug, Release ]
std: [ 17 ]
include:
- cxx: g++-9
other_pkgs: g++-9 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
- cxx: g++-10
other_pkgs: g++-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
- cxx: clang++-9
other_pkgs: clang-9 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
- cxx: clang++-10
other_pkgs: clang-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
- cxx: clang++-10
build_type: Debug
std: 17
other_pkgs: clang-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
- cxx: clang++-10
build_type: Release
std: 17
other_pkgs: clang-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
other_pkgs: [ g++-10 ]
- cxx: g++-11
other_pkgs: [ g++-11 ]
- cxx: clang++-11
other_pkgs: [ clang-11 ]
- cxx: clang++-14
other_pkgs: [ clang-14 ]


steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
submodules: recursive

- name: Prepare environment
run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
# ubuntu-latest breaks without libunwind-dev,
# see: https://github.com/actions/runner-images/issues/6399#issuecomment-1286050292
run: |
sudo apt-get update -y
sudo apt-get install -y libunwind-dev
sudo apt-get install -y \
ninja-build \
libboost-thread-dev libboost-filesystem-dev libboost-log-dev libboost-stacktrace-dev \
libssl-dev \
libgstreamer1.0-dev \
${{ join(matrix.other_pkgs, ' ') }}
- name: Configure build
working-directory: ${{runner.workspace}}
Expand All @@ -59,11 +63,8 @@ jobs:
- name: Build tests + lib
working-directory: ${{runner.workspace}}/build
run: ninja
run: ninja -j 2 wolftests

- name: Run tests
env:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{runner.workspace}}/build
# Hardcode 2 cores we know are there
run: ctest -C ${{matrix.build_type}} -j 2
working-directory: ${{runner.workspace}}/build/tests
run: ./wolftests
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ _deps
build
.vscode
.idea
cmake-build-debug
cmake-build-debug-debian-vm
cmake-build-*
DartConfiguration.tcl
.DS_Store
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Works with 3.11 and tested through 3.22
cmake_minimum_required(VERSION 3.11...3.22)
# Works with 3.11 and tested through 3.24
cmake_minimum_required(VERSION 3.13...3.24)

# Project name and a few useful settings. Other commands can pick up the results
project(wolf
Expand All @@ -18,24 +18,31 @@ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Let's nicely support folders in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(BUILD_SHARED_LIBS ON)
# set(Boost_USE_STATIC_LIBS ON)

# Testing only available if this is the main app
# Note this needs to be done in the main CMakeLists
# since it calls enable_testing, which must be in the
# main CMakeLists.
include(CTest)
endif ()

find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif (CCACHE_FOUND)


# FetchContent added in CMake 3.11, downloads during the configure step
include(FetchContent)
# FetchContent_MakeAvailable was not added until CMake 3.14; use our shim
if (${CMAKE_VERSION} VERSION_LESS 3.14)
include(cmake/add_FetchContent_MakeAvailable.cmake)
endif ()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)


add_subdirectory(src/crypto)
add_subdirectory(src/moonlight)
add_subdirectory(src/streaming)
add_subdirectory(src/wolf)

# Testing only available if this is the main app
Expand Down
59 changes: 1 addition & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,8 @@
[![Discord](https://img.shields.io/discord/856434175455133727.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/kRGUDHNHt2)
[![GitHub license](https://img.shields.io/github/license/games-on-whales/wolf)](https://github.com/games-on-whales/wolf/blob/main/LICENSE)

Howling under the Moonlight

> An intelligent wolf is better than a foolish lion.
>
> &mdash; <cite>Matshona Dhliwayo.</cite>
## Rationale

The goal is to create an open source backend for [Moonlight](https://moonlight-stream.org/).

In the process we would like to create a **platform agnostic** C++ library that clearly defines the protocol and that
can be used in other projects. While doing so, we are working on documenting and testing the protocol.
At the start it'll be focused on running in Docker so that we can
replace [Sunshine](https://github.com/loki-47-6F-64/sunshine) in [GOW](https://github.com/games-on-whales/gow) but the
code is already structured in order to support multiple platforms.

## Code structure

The code is written in order to be as readable as possible **with no side effects** and **no global objects/variables**.
We (try to) follow a functional approach where all the methods take immutable inputs and returns new outputs.
This way the core of the protocol is fully decoupled from the underlying platform/HTTP server of choice and can be
re-used by other projects, also, it enables us to *easily* test most of the methods in isolation.

We are trying to isolate the Moonlight protocol from the actual implementation so that we can create a portable C++
library of stateless methods, where possible, the code has been separated in logical modules.

### src/crypto

The crypto module depends on OpenSSL and provides an interface ([crypto.hpp](src/crypto/crypto/crypto.hpp)) to all the
crypto related methods that are used by the other modules.

### src/moonlight

Here we define the moonlight protocol interface ([protocol.hpp](src/moonlight/moonlight/protocol.hpp)) and the
implementation ([moonlight.cpp](src/moonlight/moonlight.cpp)).
This module depends on the `crypto` module and [`Boost`](https://www.boost.org/).

### src/wolf

The wolf module defines the glue code in order to make the moonlight protocol to work over an HTTP REST API. Here will
live all the platform dependent code and the result will be an executable binary: `wolf`.
This module depends on `crypto`, `moonlight`, [`Boost`](https://www.boost.org/), [`FMT`](https://github.com/fmtlib/fmt)
and [`Simple-web-server`](https://gitlab.com/eidheim/Simple-Web-Server/)

### tests

Unit tests will live under `tests/`, they'll be focused on testing the library protocol methods.

## Dependencies

```
cmake g++-10 gcc-10 libpipewire-0.3-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
```

## Acknowledgements

- [@loki-47-6F-64](https://github.com/loki-47-6F-64) for creating and
sharing [Sunshine](https://github.com/loki-47-6F-64/sunshine)
- All the guys at the [Moonlight](https://moonlight-stream.org/) Discord channel, for the tireless help they provide to
anyone
- [@ReenigneArcher](https://github.com/ReenigneArcher) for beying the first stargazer of the project and taking care of
keeping [Sunshine alive](https://github.com/SunshineStream/Sunshine)
Please [READ THE DOCS](https://games-on-whales.github.io/wolf/)
2 changes: 2 additions & 0 deletions cmake/EnableCMP0048.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# see: https://stackoverflow.com/questions/37582508/silence-cmp0048-warnings-in-vendored-projects
cmake_policy(SET CMP0048 NEW)
66 changes: 66 additions & 0 deletions cmake/FindGLIB2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# - Try to find the GLIB2 libraries
# Once done this will define
#
# GLIB2_FOUND - system has glib2
# GLIB2_INCLUDE_DIR - the glib2 include directory
# GLIB2_LIBRARIES - glib2 library

# Copyright (c) 2008 Laurent Montel, <[email protected]>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# Already in cache, be silent
set(GLIB2_FIND_QUIETLY TRUE)
endif (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)

if (NOT WIN32)
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PKG_GLIB QUIET glib-2.0)
endif ()
endif (NOT WIN32)

find_path(GLIB2_MAIN_INCLUDE_DIR glib.h
PATH_SUFFIXES glib-2.0
HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_INCLUDEDIR})

# search the glibconfig.h include dir under the same root where the library is found
find_library(GLIB2_LIBRARIES
NAMES glib-2.0
HINTS ${PKG_GLIB_LIBRARY_DIRS} ${PKG_GLIB_LIBDIR})

find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include ../lib/glib-2.0/include
HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_LIBRARIES} ${CMAKE_SYSTEM_LIBRARY_PATH})

set(GLIB2_INCLUDE_DIR ${GLIB2_MAIN_INCLUDE_DIR})

# not sure if this include dir is optional or required
# for now it is optional
if (GLIB2_INTERNAL_INCLUDE_DIR)
set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR})
endif (GLIB2_INTERNAL_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)

mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES)


find_program(GLIB2_GENMARSHAL_UTIL glib-genmarshal)

macro(glib2_genmarshal output_name)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/genmarshal_tmp)
foreach (_declaration ${ARGN})
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/genmarshal_tmp "${_declaration}\n")
endforeach ()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output_name}.h ${CMAKE_CURRENT_BINARY_DIR}/${output_name}.c
COMMAND ${GLIB2_GENMARSHAL_UTIL} --header genmarshal_tmp > ${output_name}.h
COMMAND ${GLIB2_GENMARSHAL_UTIL} --body genmarshal_tmp > ${output_name}.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endmacro()
63 changes: 63 additions & 0 deletions cmake/FindGObject.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# - Try to find GObject
# Once done this will define
#
# GOBJECT_FOUND - system has GObject
# GOBJECT_INCLUDE_DIR - the GObject include directory
# GOBJECT_LIBRARIES - the libraries needed to use GObject
# GOBJECT_DEFINITIONS - Compiler switches required for using GObject

# Copyright (c) 2006, Tim Beaulen <[email protected]>
# Copyright (c) 2008 Helio Chissini de Castro, <[email protected]>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
# in cache already
SET(GObject_FIND_QUIETLY TRUE)
ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
SET(GObject_FIND_QUIETLY FALSE)
ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)

IF (NOT WIN32)
FIND_PACKAGE(PkgConfig REQUIRED)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
PKG_CHECK_MODULES(PKG_GOBJECT2 REQUIRED gobject-2.0)
SET(GOBJECT_DEFINITIONS ${PKG_GOBJECT2_CFLAGS})
ENDIF (NOT WIN32)

FIND_PATH(GOBJECT_INCLUDE_DIR gobject/gobject.h
HINTS ${PKG_GOBJECT2_INCLUDE_DIRS} ${PKG_GOBJECT2_INCLUDEDIR}
PATHS /usr/include/glib-2.0/
PATH_SUFFIXES glib-2.0
)

FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
HINTS
${PKG_GOBJECT2_LIBRARY_DIRS}
${PKG_GOBJECT2_LIBDIR}
)
FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
HINTS
${PKG_GOBJECT2_LIBRARY_DIRS}
${PKG_GOBJECT2_LIBDIR}
)
FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
HINTS
${PKG_GOBJECT2_LIBRARY_DIRS}
${PKG_GOBJECT2_LIBDIR}
)
FIND_LIBRARY(_GLibs NAMES glib-2.0
HINTS
${PKG_GOBJECT2_LIBRARY_DIRS}
${PKG_GOBJECT2_LIBDIR}
)

SET(GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs})

MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR GOBJECT_LIBRARIES)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GObject DEFAULT_MSG GOBJECT_INCLUDE_DIR GOBJECT_LIBRARIES)
Loading

0 comments on commit b5d1bab

Please sign in to comment.