Skip to content

Commit b5d1bab

Browse files
authored
Merge pull request #2 from games-on-whales/gstreamer
Implemented streaming audio and video via Gstreamer
2 parents cd5aa47 + 95cbd1c commit b5d1bab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+7850
-943
lines changed

.github/workflows/linux-build-test.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,45 @@ on: [ push, pull_request ]
66
jobs:
77
build:
88
name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}}
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-22.04
1010
strategy:
11+
fail-fast: false
1112
matrix:
1213
cxx:
13-
- g++-9
1414
- g++-10
15-
- clang++-9
16-
- clang++-10
15+
- g++-11
16+
- clang++-11
17+
- clang++-14
1718
build_type: [ Debug, Release ]
1819
std: [ 17 ]
1920
include:
20-
- cxx: g++-9
21-
other_pkgs: g++-9 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
2221
- cxx: g++-10
23-
other_pkgs: g++-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
24-
- cxx: clang++-9
25-
other_pkgs: clang-9 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
26-
- cxx: clang++-10
27-
other_pkgs: clang-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
28-
- cxx: clang++-10
29-
build_type: Debug
30-
std: 17
31-
other_pkgs: clang-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
32-
- cxx: clang++-10
33-
build_type: Release
34-
std: 17
35-
other_pkgs: clang-10 libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
22+
other_pkgs: [ g++-10 ]
23+
- cxx: g++-11
24+
other_pkgs: [ g++-11 ]
25+
- cxx: clang++-11
26+
other_pkgs: [ clang-11 ]
27+
- cxx: clang++-14
28+
other_pkgs: [ clang-14 ]
29+
3630

3731
steps:
38-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v3
3933
with:
40-
submodules: true
34+
submodules: recursive
4135

4236
- name: Prepare environment
43-
run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
37+
# ubuntu-latest breaks without libunwind-dev,
38+
# see: https://github.com/actions/runner-images/issues/6399#issuecomment-1286050292
39+
run: |
40+
sudo apt-get update -y
41+
sudo apt-get install -y libunwind-dev
42+
sudo apt-get install -y \
43+
ninja-build \
44+
libboost-thread-dev libboost-filesystem-dev libboost-log-dev libboost-stacktrace-dev \
45+
libssl-dev \
46+
libgstreamer1.0-dev \
47+
${{ join(matrix.other_pkgs, ' ') }}
4448
4549
- name: Configure build
4650
working-directory: ${{runner.workspace}}
@@ -59,11 +63,8 @@ jobs:
5963
6064
- name: Build tests + lib
6165
working-directory: ${{runner.workspace}}/build
62-
run: ninja
66+
run: ninja -j 2 wolftests
6367

6468
- name: Run tests
65-
env:
66-
CTEST_OUTPUT_ON_FAILURE: 1
67-
working-directory: ${{runner.workspace}}/build
68-
# Hardcode 2 cores we know are there
69-
run: ctest -C ${{matrix.build_type}} -j 2
69+
working-directory: ${{runner.workspace}}/build/tests
70+
run: ./wolftests

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ _deps
1212
build
1313
.vscode
1414
.idea
15-
cmake-build-debug
16-
cmake-build-debug-debian-vm
15+
cmake-build-*
16+
DartConfiguration.tcl
17+
.DS_Store

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Works with 3.11 and tested through 3.22
2-
cmake_minimum_required(VERSION 3.11...3.22)
1+
# Works with 3.11 and tested through 3.24
2+
cmake_minimum_required(VERSION 3.13...3.24)
33

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

21+
set(BUILD_SHARED_LIBS ON)
22+
# set(Boost_USE_STATIC_LIBS ON)
23+
2124
# Testing only available if this is the main app
2225
# Note this needs to be done in the main CMakeLists
2326
# since it calls enable_testing, which must be in the
2427
# main CMakeLists.
2528
include(CTest)
2629
endif ()
2730

31+
find_program(CCACHE_FOUND ccache)
32+
if (CCACHE_FOUND)
33+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
34+
endif (CCACHE_FOUND)
35+
36+
2837
# FetchContent added in CMake 3.11, downloads during the configure step
2938
include(FetchContent)
30-
# FetchContent_MakeAvailable was not added until CMake 3.14; use our shim
31-
if (${CMAKE_VERSION} VERSION_LESS 3.14)
32-
include(cmake/add_FetchContent_MakeAvailable.cmake)
33-
endif ()
39+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
3440
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
3541

3642

3743
add_subdirectory(src/crypto)
3844
add_subdirectory(src/moonlight)
45+
add_subdirectory(src/streaming)
3946
add_subdirectory(src/wolf)
4047

4148
# Testing only available if this is the main app

README.md

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,8 @@
33
[![Discord](https://img.shields.io/discord/856434175455133727.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/kRGUDHNHt2)
44
[![GitHub license](https://img.shields.io/github/license/games-on-whales/wolf)](https://github.com/games-on-whales/wolf/blob/main/LICENSE)
55

6-
Howling under the Moonlight
7-
86
> An intelligent wolf is better than a foolish lion.
97
>
108
> &mdash; <cite>Matshona Dhliwayo.</cite>
119
12-
## Rationale
13-
14-
The goal is to create an open source backend for [Moonlight](https://moonlight-stream.org/).
15-
16-
In the process we would like to create a **platform agnostic** C++ library that clearly defines the protocol and that
17-
can be used in other projects. While doing so, we are working on documenting and testing the protocol.
18-
At the start it'll be focused on running in Docker so that we can
19-
replace [Sunshine](https://github.com/loki-47-6F-64/sunshine) in [GOW](https://github.com/games-on-whales/gow) but the
20-
code is already structured in order to support multiple platforms.
21-
22-
## Code structure
23-
24-
The code is written in order to be as readable as possible **with no side effects** and **no global objects/variables**.
25-
We (try to) follow a functional approach where all the methods take immutable inputs and returns new outputs.
26-
This way the core of the protocol is fully decoupled from the underlying platform/HTTP server of choice and can be
27-
re-used by other projects, also, it enables us to *easily* test most of the methods in isolation.
28-
29-
We are trying to isolate the Moonlight protocol from the actual implementation so that we can create a portable C++
30-
library of stateless methods, where possible, the code has been separated in logical modules.
31-
32-
### src/crypto
33-
34-
The crypto module depends on OpenSSL and provides an interface ([crypto.hpp](src/crypto/crypto/crypto.hpp)) to all the
35-
crypto related methods that are used by the other modules.
36-
37-
### src/moonlight
38-
39-
Here we define the moonlight protocol interface ([protocol.hpp](src/moonlight/moonlight/protocol.hpp)) and the
40-
implementation ([moonlight.cpp](src/moonlight/moonlight.cpp)).
41-
This module depends on the `crypto` module and [`Boost`](https://www.boost.org/).
42-
43-
### src/wolf
44-
45-
The wolf module defines the glue code in order to make the moonlight protocol to work over an HTTP REST API. Here will
46-
live all the platform dependent code and the result will be an executable binary: `wolf`.
47-
This module depends on `crypto`, `moonlight`, [`Boost`](https://www.boost.org/), [`FMT`](https://github.com/fmtlib/fmt)
48-
and [`Simple-web-server`](https://gitlab.com/eidheim/Simple-Web-Server/)
49-
50-
### tests
51-
52-
Unit tests will live under `tests/`, they'll be focused on testing the library protocol methods.
53-
54-
## Dependencies
55-
56-
```
57-
cmake g++-10 gcc-10 libpipewire-0.3-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libssl-dev libboost-stacktrace-dev
58-
```
59-
60-
## Acknowledgements
61-
62-
- [@loki-47-6F-64](https://github.com/loki-47-6F-64) for creating and
63-
sharing [Sunshine](https://github.com/loki-47-6F-64/sunshine)
64-
- All the guys at the [Moonlight](https://moonlight-stream.org/) Discord channel, for the tireless help they provide to
65-
anyone
66-
- [@ReenigneArcher](https://github.com/ReenigneArcher) for beying the first stargazer of the project and taking care of
67-
keeping [Sunshine alive](https://github.com/SunshineStream/Sunshine)
10+
Please [READ THE DOCS](https://games-on-whales.github.io/wolf/)

cmake/EnableCMP0048.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# see: https://stackoverflow.com/questions/37582508/silence-cmp0048-warnings-in-vendored-projects
2+
cmake_policy(SET CMP0048 NEW)

cmake/FindGLIB2.cmake

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# - Try to find the GLIB2 libraries
2+
# Once done this will define
3+
#
4+
# GLIB2_FOUND - system has glib2
5+
# GLIB2_INCLUDE_DIR - the glib2 include directory
6+
# GLIB2_LIBRARIES - glib2 library
7+
8+
# Copyright (c) 2008 Laurent Montel, <[email protected]>
9+
#
10+
# Redistribution and use is allowed according to the terms of the BSD license.
11+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
12+
13+
14+
if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
15+
# Already in cache, be silent
16+
set(GLIB2_FIND_QUIETLY TRUE)
17+
endif (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
18+
19+
if (NOT WIN32)
20+
find_package(PkgConfig QUIET)
21+
if (PKG_CONFIG_FOUND)
22+
pkg_check_modules(PKG_GLIB QUIET glib-2.0)
23+
endif ()
24+
endif (NOT WIN32)
25+
26+
find_path(GLIB2_MAIN_INCLUDE_DIR glib.h
27+
PATH_SUFFIXES glib-2.0
28+
HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_INCLUDEDIR})
29+
30+
# search the glibconfig.h include dir under the same root where the library is found
31+
find_library(GLIB2_LIBRARIES
32+
NAMES glib-2.0
33+
HINTS ${PKG_GLIB_LIBRARY_DIRS} ${PKG_GLIB_LIBDIR})
34+
35+
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
36+
PATH_SUFFIXES glib-2.0/include ../lib/glib-2.0/include
37+
HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_LIBRARIES} ${CMAKE_SYSTEM_LIBRARY_PATH})
38+
39+
set(GLIB2_INCLUDE_DIR ${GLIB2_MAIN_INCLUDE_DIR})
40+
41+
# not sure if this include dir is optional or required
42+
# for now it is optional
43+
if (GLIB2_INTERNAL_INCLUDE_DIR)
44+
set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR})
45+
endif (GLIB2_INTERNAL_INCLUDE_DIR)
46+
47+
include(FindPackageHandleStandardArgs)
48+
find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)
49+
50+
mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES)
51+
52+
53+
find_program(GLIB2_GENMARSHAL_UTIL glib-genmarshal)
54+
55+
macro(glib2_genmarshal output_name)
56+
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/genmarshal_tmp)
57+
foreach (_declaration ${ARGN})
58+
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/genmarshal_tmp "${_declaration}\n")
59+
endforeach ()
60+
add_custom_command(
61+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output_name}.h ${CMAKE_CURRENT_BINARY_DIR}/${output_name}.c
62+
COMMAND ${GLIB2_GENMARSHAL_UTIL} --header genmarshal_tmp > ${output_name}.h
63+
COMMAND ${GLIB2_GENMARSHAL_UTIL} --body genmarshal_tmp > ${output_name}.c
64+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
65+
)
66+
endmacro()

cmake/FindGObject.cmake

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# - Try to find GObject
2+
# Once done this will define
3+
#
4+
# GOBJECT_FOUND - system has GObject
5+
# GOBJECT_INCLUDE_DIR - the GObject include directory
6+
# GOBJECT_LIBRARIES - the libraries needed to use GObject
7+
# GOBJECT_DEFINITIONS - Compiler switches required for using GObject
8+
9+
# Copyright (c) 2006, Tim Beaulen <[email protected]>
10+
# Copyright (c) 2008 Helio Chissini de Castro, <[email protected]>
11+
#
12+
# Redistribution and use is allowed according to the terms of the BSD license.
13+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14+
15+
16+
IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
17+
# in cache already
18+
SET(GObject_FIND_QUIETLY TRUE)
19+
ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
20+
SET(GObject_FIND_QUIETLY FALSE)
21+
ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
22+
23+
IF (NOT WIN32)
24+
FIND_PACKAGE(PkgConfig REQUIRED)
25+
# use pkg-config to get the directories and then use these values
26+
# in the FIND_PATH() and FIND_LIBRARY() calls
27+
PKG_CHECK_MODULES(PKG_GOBJECT2 REQUIRED gobject-2.0)
28+
SET(GOBJECT_DEFINITIONS ${PKG_GOBJECT2_CFLAGS})
29+
ENDIF (NOT WIN32)
30+
31+
FIND_PATH(GOBJECT_INCLUDE_DIR gobject/gobject.h
32+
HINTS ${PKG_GOBJECT2_INCLUDE_DIRS} ${PKG_GOBJECT2_INCLUDEDIR}
33+
PATHS /usr/include/glib-2.0/
34+
PATH_SUFFIXES glib-2.0
35+
)
36+
37+
FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
38+
HINTS
39+
${PKG_GOBJECT2_LIBRARY_DIRS}
40+
${PKG_GOBJECT2_LIBDIR}
41+
)
42+
FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
43+
HINTS
44+
${PKG_GOBJECT2_LIBRARY_DIRS}
45+
${PKG_GOBJECT2_LIBDIR}
46+
)
47+
FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
48+
HINTS
49+
${PKG_GOBJECT2_LIBRARY_DIRS}
50+
${PKG_GOBJECT2_LIBDIR}
51+
)
52+
FIND_LIBRARY(_GLibs NAMES glib-2.0
53+
HINTS
54+
${PKG_GOBJECT2_LIBRARY_DIRS}
55+
${PKG_GOBJECT2_LIBDIR}
56+
)
57+
58+
SET(GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs})
59+
60+
MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR GOBJECT_LIBRARIES)
61+
62+
INCLUDE(FindPackageHandleStandardArgs)
63+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GObject DEFAULT_MSG GOBJECT_INCLUDE_DIR GOBJECT_LIBRARIES)

0 commit comments

Comments
 (0)