Skip to content
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

Feat: Render recording #205

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1a534db
feat: add render recording button, WIP
Totto16 Nov 7, 2024
07f6532
feat: add render video functionality, WIP
Totto16 Nov 7, 2024
1034220
fix: fix a few minor issues with the video render
Totto16 Nov 8, 2024
cb101d7
cleanup: de-duplicate code for layout generation
Totto16 Nov 8, 2024
2759f90
fix: fix the color format of the sdl surface + do a correct sdl rende…
Totto16 Nov 8, 2024
f7f03e3
feat: WIP; add windows ffmpeg / video backend implementation
Totto16 Nov 10, 2024
477e645
fix: use the same render arguments for linux and windows
Totto16 Nov 10, 2024
48facb8
fix: fix windows compilation
Totto16 Nov 10, 2024
5c79b5f
fix: fix linux build
Totto16 Nov 10, 2024
e723ff3
fix: fix ffmpeg usage for vide rendering
Totto16 Nov 11, 2024
efb023e
feat: add function to determine, if ffmpeg is supported at runtime
Totto16 Nov 11, 2024
b5661ae
fix: support android embedded ffmpeg
Totto16 Nov 11, 2024
82cc123
feat: add embedded ffmpeg encoding
Totto16 Nov 12, 2024
8f142cb
feat: add method to set thread name
Totto16 Nov 12, 2024
71a9e54
fix: don't include iostream in <core/helper/utils.,hpp>
Totto16 Nov 12, 2024
5881c6a
fix: finalize the embedded ffmpeg encoder
Totto16 Nov 13, 2024
a2224a6
fix: name main thread
Totto16 Nov 13, 2024
bd7b32b
fix: small improvements on the ffmpeg embedded encoder
Totto16 Nov 13, 2024
b860303
fix: ci, add ANDROID_SDK_HOME env variable
Totto16 Nov 13, 2024
cd9af58
fix: fix multiple compile errors
Totto16 Nov 13, 2024
38cb4b9
fix: fix c macros extension warning on gcc
Totto16 Nov 13, 2024
0850461
fix: remove unnecessary line in android build script
Totto16 Nov 13, 2024
fb2c680
fix: fix missing libraries on switch cross build
Totto16 Nov 13, 2024
f80d24e
build: fix building on android
Totto16 Nov 13, 2024
c4ab1e0
build: add explicit ffmpeg embed options to 3ds and switch builds,
Totto16 Nov 13, 2024
b5bd3c1
feat: make loglevel of ffmpeg dependent on buildtype (debug or not)
Totto16 Nov 13, 2024
1059299
fix: correctly implement set_thread_name on macos
Totto16 Nov 13, 2024
73bf75c
fix: build mingw correctly in ffmepg encoder
Totto16 Nov 13, 2024
f476b65
fix: switch build, replace dependency< name of required libdav1d to d…
Totto16 Nov 13, 2024
a858c66
ci: lint, install correct ffmpeg dev packages
Totto16 Nov 13, 2024
1ccff73
fix: fix switch build
Totto16 Nov 13, 2024
36b85a8
fix: allow render button to be pressed
Totto16 Nov 13, 2024
ef23c8f
feat: split spinner and loading screen into two separate parts, so th…
Totto16 Nov 13, 2024
9dbf0fa
fix: explicitly move all bool helper values, instead of copying unnec…
Totto16 Nov 14, 2024
9bf3aaa
fix: use struct instead of std::tuple, to silence gcc uninitialized e…
Totto16 Nov 14, 2024
4dab336
fix: use windows ffmpeg fro mingw
Totto16 Nov 14, 2024
4a25c70
fix: don't use deprecated incldue header for stringstream
Totto16 Nov 14, 2024
b8b27ee
fix: windows: correctly initialize SECURITY_ATTRIBUTES struct
Totto16 Nov 14, 2024
ae367d9
chore: update wrappers to latest main of each wrapper
Totto16 Nov 14, 2024
ebba4d2
ci: lint, don't include windows specific file
Totto16 Nov 14, 2024
5269f29
fix: fix clang-tidy errors
Totto16 Nov 14, 2024
38a46da
feat: add web support for ffmpeg
Totto16 Nov 19, 2024
bc3cc6a
fix: enabled correct encoders etc. for web ffmpeg usage
Totto16 Nov 19, 2024
0621370
fix: web, use IDBFS to persist files correctly
Totto16 Nov 19, 2024
8327b58
fix: use correct ffmpeg libraries, as the pkgconfig names start with lib
Totto16 Nov 19, 2024
23f0862
fix: correctly get the locally built x264 dependency
Totto16 Nov 19, 2024
269ec86
fix: fix ffmpeg web build
Totto16 Nov 20, 2024
9f0b7de
fix: fix a few typos
Totto16 Nov 20, 2024
f9108d1
fix: fix 3ds build
Totto16 Nov 20, 2024
fc7ee29
fix: ffmpeg android build:
Totto16 Dec 2, 2024
e3a6ca9
fix: fix web build
Totto16 Dec 2, 2024
57a8503
ci: fix android build for x86_64, install nasm, which is needed for t…
Totto16 Dec 2, 2024
1b7cde6
fix: web: fix naming change in web sdl image dependency
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