Skip to content

Feat: Render recording #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
cac63e6
feat: add render recording button, WIP
Totto16 Nov 7, 2024
e2dc40a
feat: add render video functionality, WIP
Totto16 Nov 7, 2024
1519f04
fix: fix a few minor issues with the video render
Totto16 Nov 8, 2024
8a9829a
cleanup: de-duplicate code for layout generation
Totto16 Nov 8, 2024
e540086
fix: fix the color format of the sdl surface + do a correct sdl rende…
Totto16 Nov 8, 2024
fd769ec
feat: WIP; add windows ffmpeg / video backend implementation
Totto16 Nov 10, 2024
2f4f150
fix: use the same render arguments for linux and windows
Totto16 Nov 10, 2024
3a97189
fix: fix windows compilation
Totto16 Nov 10, 2024
bd03245
fix: fix linux build
Totto16 Nov 10, 2024
44cdebb
fix: fix ffmpeg usage for vide rendering
Totto16 Nov 11, 2024
33b4d45
feat: add function to determine, if ffmpeg is supported at runtime
Totto16 Nov 11, 2024
d36d102
fix: support android embedded ffmpeg
Totto16 Nov 11, 2024
e8c675d
feat: add embedded ffmpeg encoding
Totto16 Nov 12, 2024
80f4b20
feat: add method to set thread name
Totto16 Nov 12, 2024
7595ddf
fix: don't include iostream in <core/helper/utils.,hpp>
Totto16 Nov 12, 2024
858433b
fix: finalize the embedded ffmpeg encoder
Totto16 Nov 13, 2024
a56c446
fix: name main thread
Totto16 Nov 13, 2024
b8fdc0d
fix: small improvements on the ffmpeg embedded encoder
Totto16 Nov 13, 2024
d76ac22
fix: ci, add ANDROID_SDK_HOME env variable
Totto16 Nov 13, 2024
f1ae15e
fix: fix multiple compile errors
Totto16 Nov 13, 2024
3ab1d97
fix: fix c macros extension warning on gcc
Totto16 Nov 13, 2024
2e0b99e
fix: remove unnecessary line in android build script
Totto16 Nov 13, 2024
f8e70e2
fix: fix missing libraries on switch cross build
Totto16 Nov 13, 2024
8181754
build: fix building on android
Totto16 Nov 13, 2024
4f9e6c6
build: add explicit ffmpeg embed options to 3ds and switch builds,
Totto16 Nov 13, 2024
568f02c
feat: make loglevel of ffmpeg dependent on buildtype (debug or not)
Totto16 Nov 13, 2024
b1c9fa6
fix: correctly implement set_thread_name on macos
Totto16 Nov 13, 2024
abc8f90
fix: build mingw correctly in ffmepg encoder
Totto16 Nov 13, 2024
e849eb1
fix: switch build, replace dependency< name of required libdav1d to d…
Totto16 Nov 13, 2024
f83633f
ci: lint, install correct ffmpeg dev packages
Totto16 Nov 13, 2024
bd25056
fix: fix switch build
Totto16 Nov 13, 2024
d85e44b
fix: allow render button to be pressed
Totto16 Nov 13, 2024
4e10330
feat: split spinner and loading screen into two separate parts, so th…
Totto16 Nov 13, 2024
4d4d717
fix: explicitly move all bool helper values, instead of copying unnec…
Totto16 Nov 14, 2024
5b1d7b9
fix: use struct instead of std::tuple, to silence gcc uninitialized e…
Totto16 Nov 14, 2024
a4d8854
fix: use windows ffmpeg fro mingw
Totto16 Nov 14, 2024
bff8e61
fix: don't use deprecated incldue header for stringstream
Totto16 Nov 14, 2024
e4bd4d4
fix: windows: correctly initialize SECURITY_ATTRIBUTES struct
Totto16 Nov 14, 2024
48317d6
chore: update wrappers to latest main of each wrapper
Totto16 Nov 14, 2024
804d0c7
ci: lint, don't include windows specific file
Totto16 Nov 14, 2024
e5a93c7
fix: fix clang-tidy errors
Totto16 Nov 14, 2024
79eba25
feat: add web support for ffmpeg
Totto16 Nov 19, 2024
b23934b
fix: enabled correct encoders etc. for web ffmpeg usage
Totto16 Nov 19, 2024
41a121d
fix: web, use IDBFS to persist files correctly
Totto16 Nov 19, 2024
1a1eeee
fix: use correct ffmpeg libraries, as the pkgconfig names start with lib
Totto16 Nov 19, 2024
f529ff6
fix: correctly get the locally built x264 dependency
Totto16 Nov 19, 2024
66f4f9a
fix: fix ffmpeg web build
Totto16 Nov 20, 2024
1b1440b
fix: fix 3ds build
Totto16 Nov 20, 2024
151ba5f
fix: ffmpeg android build:
Totto16 Dec 2, 2024
64b363e
fix: fix web build
Totto16 Dec 2, 2024
6990489
ci: fix android build for x86_64, install nasm, which is needed for t…
Totto16 Dec 2, 2024
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
5 changes: 3 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
run: |
pip install meson --break-system-packages

- name: Setup ninja
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build jq -y --no-install-recommends
sudo apt-get install ninja-build jq nasm -y --no-install-recommends

- name: Setup JDK
uses: actions/setup-java@v4
Expand All @@ -50,6 +50,7 @@ jobs:

- name: Build native libraries
run: |
export ANDROID_SDK_HOME="$HOME/.android/sdk"
bash ./platforms/build-android.sh ${{ matrix.config.arch }} complete_rebuild release
cp -r ./assets/ platforms/android/app/src/main

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
- name: Prepare compile_commands.json
run: |
sudo apt-get update
sudo apt-get install ninja-build libsdl2-2.0-0 libsdl2-dev libsdl2-ttf* libsdl2-mixer* libsdl2-image* desktop-file-utils -y --no-install-recommends
sudo apt-get install ninja-build libsdl2-2.0-0 libsdl2-dev libsdl2-ttf* libsdl2-mixer* libsdl2-image* desktop-file-utils libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev -y --no-install-recommends

meson setup build -Dbuildtype=release -Dclang_libcpp=disabled -Dtests=true
meson setup build -Dbuildtype=release -Dclang_libcpp=disabled -Dtests=true -Duse_embedded_ffmpeg=enabled
meson compile -C build git_version.hpp

- uses: cpp-linter/cpp-linter-action@v2
Expand All @@ -52,7 +52,7 @@ jobs:
tidy-checks: ''
step-summary: true
file-annotations: true
ignore: subprojects|build|android|assets|recordings|docs|toolchains|platforms|wrapper|src/libs/core/hash-library|tests|src/helper/web_utils.*|src/lobby/web_client.*|src/lobby/curl_client.*
ignore: subprojects|build|android|assets|recordings|docs|toolchains|platforms|wrapper|src/libs/core/hash-library|tests|src/graphics/video_renderer_windows.*|src/helper/web_utils.*|src/lobby/web_client.*|src/lobby/curl_client.*

- name: Fail CI run if linter checks failed
if: steps.linter.outputs.checks-failed != 0
Expand Down
7 changes: 7 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ option(
value: false,
description: 'if you only want to build the libs, enable this',
)

option(
'use_embedded_ffmpeg',
type: 'feature',
value: 'auto',
description: 'embed ffmpeg to render recording videos',
)
38 changes: 37 additions & 1 deletion platforms/android/app/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,42 @@ LOCAL_SRC_FILES := $(shell find "${SUBPROJECTS_PATH}" -name libkeyutils.so)
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := libavutil
LOCAL_SRC_FILES := $(shell meson introspect --dependencies "${BUILD_PATH}" | jq -r ".[] | select(.name==\"libavutil\") | .link_args | .[]")
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := libavcodec
LOCAL_SRC_FILES := $(shell meson introspect --dependencies "${BUILD_PATH}" | jq -r ".[] | select(.name==\"libavcodec\") | .link_args | .[]")
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := libavformat
LOCAL_SRC_FILES := $(shell meson introspect --dependencies "${BUILD_PATH}" | jq -r ".[] | select(.name==\"libavformat\") | .link_args | .[]")
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := libavfilter
LOCAL_SRC_FILES := $(shell meson introspect --dependencies "${BUILD_PATH}" | jq -r ".[] | select(.name==\"libavfilter\") | .link_args | .[]")
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := libswscale
LOCAL_SRC_FILES := $(shell meson introspect --dependencies "${BUILD_PATH}" | jq -r ".[] | select(.name==\"libswscale\") | .link_args | .[]")
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := libswresample
LOCAL_SRC_FILES := $(shell meson introspect --dependencies "${BUILD_PATH}" | jq -r ".[] | select(.name==\"libswresample\") | .link_args | .[]")
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := oopetris_core
LIB_PATH := $(BUILD_PATH)/src/libs/core
Expand Down Expand Up @@ -99,7 +135,7 @@ include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SHARED_LIBRARIES := SDL2 sdl2_ttf freetype png16 sdl2_mixer vorbis vorbisfile ogg sdl2_image fmt keyutils oopetris_core oopetris_recordings oopetris_graphics oopetris
LOCAL_SHARED_LIBRARIES := SDL2 sdl2_ttf freetype png16 sdl2_mixer vorbis vorbisfile ogg sdl2_image fmt keyutils oopetris_core oopetris_recordings oopetris_graphics oopetris libavutil libavcodec libavformat libavfilter libswscale libswresample
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
LOCAL_LDFLAGS := -Wl,--no-undefined
include $(BUILD_SHARED_LIBRARY)
67 changes: 62 additions & 5 deletions platforms/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do
export BIN_DIR="$HOST_ROOT/bin"
export PATH="$BIN_DIR:$PATH"

LIB_PATH="${SYS_ROOT}/usr/lib/$ARM_TRIPLE:${SYS_ROOT}/usr/lib/$ARM_TRIPLE/${SDK_VERSION}"
INC_PATH="${SYS_ROOT}/usr/include"
export LIB_PATH="${SYS_ROOT}/usr/lib/$ARM_TRIPLE:${SYS_ROOT}/usr/lib/$ARM_TRIPLE/${SDK_VERSION}"
export INC_PATH="${SYS_ROOT}/usr/include"
export PKG_CONFIG_PATH="${SYS_ROOT}/usr/lib/pkgconfig/"

export LIBRARY_PATH="$SYS_ROOT/usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION"

Expand Down Expand Up @@ -146,6 +147,16 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do

find "$HOST_ROOT/sysroot/usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION/" -maxdepth 1 -name "*.o" -exec ln -s "{}" "${SYS_ROOT:?}/usr/lib/" \;

# TODO: remove this temporary fix:
# see: https://github.com/android/ndk/issues/2107
if [ "$ARCH_VERSION" = "armv7a" ]; then
sed -i -e 's/asm(/__asm__(/g' "$HOST_ROOT/sysroot/usr/include/arm-linux-androideabi/asm/swab.h"
elif [ "$ARCH_VERSION" = "i686" ]; then
sed -i -e 's/asm(/__asm__(/g' "$HOST_ROOT/sysroot/usr/include/i686-linux-android/asm/swab.h"
elif [ "$ARCH_VERSION" = "x86_64" ]; then
sed -i -e 's/asm(/__asm__(/g' "$HOST_ROOT/sysroot/usr/include/x86_64-linux-android/asm/swab.h"
fi

cd "$LAST_DIR"

fi
Expand Down Expand Up @@ -270,7 +281,6 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do
-DBUILD_SHARED_LIBS=OFF \
-DINSTALL_PKGCONFIG_MODULES=ON


cmake --build .

cmake --install .
Expand Down Expand Up @@ -344,6 +354,52 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do

cd "$LAST_DIR"

## build ffmpeg for android (using https://github.com/Javernaut/ffmpeg-android-maker)

LAST_DIR="$PWD"

cd "$SYS_ROOT"

BUILD_DIR_FFMPEG="build-ffmpeg"

BUILD_FFMPEG_FILE="$SYS_ROOT/$BUILD_DIR_FFMPEG/build_successfull.meta"

if [ "$COMPILE_TYPE" == "complete_rebuild" ] || ! [ -e "$BUILD_FFMPEG_FILE" ]; then

mkdir -p "$BUILD_DIR_FFMPEG"

cd "$BUILD_DIR_FFMPEG"

FFMPEG_MAKER_DIR="maker"

if ! [ -e "$FFMPEG_MAKER_DIR" ]; then

git clone https://github.com/Javernaut/ffmpeg-android-maker.git "$FFMPEG_MAKER_DIR"

cd "$FFMPEG_MAKER_DIR"
else
cd "$FFMPEG_MAKER_DIR"

git pull

fi

./ffmpeg-android-maker.sh "--target-abis=$ARCH" "--android-api-level=$SDK_VERSION" --enable-libx264

FFMPEG_MAKER_OUTPUT_DIR="output"

find "$FFMPEG_MAKER_OUTPUT_DIR/include/" -maxdepth 3 -mindepth 2 -type d -exec cp -r {} "$SYS_ROOT/usr/include/" \;

find "$FFMPEG_MAKER_OUTPUT_DIR/lib/" -type f -exec cp -r {} "$SYS_ROOT/usr/lib/" \;

find "build/" -maxdepth 5 -mindepth 4 -type f -name "*.pc" -exec cp -r {} "$SYS_ROOT/usr/lib/pkgconfig/" \;

touch "$BUILD_FFMPEG_FILE"

fi

cd "$LAST_DIR"

## END of manual build of dependencies

MESON_CPU_FAMILY=$ARCH
Expand Down Expand Up @@ -393,7 +449,7 @@ prefix = '$SYS_ROOT'
libdir = '$LIB_PATH'

[properties]
pkg_config_libdir = '$SYS_ROOT/usr/lib/pkgconfig'
pkg_config_libdir = '$PKG_CONFIG_PATH'
sys_root = '${SYS_ROOT}'

EOF
Expand Down Expand Up @@ -436,7 +492,8 @@ EOF
--cross-file "./platforms/crossbuild-android-$ARM_TARGET_ARCH.ini" \
"-Dbuildtype=$BUILDTYPE" \
-Dsdl2:use_hidapi=enabled \
-Dclang_libcpp=disabled
-Dclang_libcpp=disabled \
-Duse_embedded_ffmpeg=enabled

fi

Expand Down
3 changes: 2 additions & 1 deletion platforms/build-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then
-Dcurl:unittests=disabled \
-Dcurl:bearer-auth=enabled \
-Dcurl:brotli=enabled \
-Dcurl:libz=enabled
-Dcurl:libz=enabled \
-Duse_embedded_ffmpeg=enabled

fi

Expand Down
Loading
Loading