Skip to content

Commit 4286522

Browse files
committed
wip: video player
1 parent 4463373 commit 4286522

File tree

13 files changed

+386
-5
lines changed

13 files changed

+386
-5
lines changed

dhall/sourceTreeParts.dhall

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,27 @@ let render = let dir = "./src" in sourceTreePart::{
325325
] : List Text
326326
}
327327
}
328+
let sdl2mpv = let dir = "./sdl2_mpv" in sourceTreePart::{
329+
, name = "render"
330+
, dir = dir
331+
, includeDirs = {
332+
, local = [
333+
] : List Text
334+
, global = [] : List Text
335+
}
336+
, sources = [
337+
, "${dir}/main.cpp"
338+
]
339+
, cxxflags = {
340+
, global = [
341+
] : List Text
342+
, local = [] : List Text
343+
}
344+
, ldflags = {
345+
, global = [
346+
] : List Text
347+
}
348+
}
328349
let binding = let dir = "./src/binding" in sourceTreePart::{
329350
, name = "binding"
330351
, dir = dir
@@ -715,7 +736,6 @@ let skiaSdl = \(asan : Bool) ->
715736
, imgui.dir
716737
, imguiImplot.dir
717738
, render.dir
718-
, "./contrib/sdl3/include"
719739
]
720740
, global = [
721741
, "${contribDir}"
@@ -805,7 +825,6 @@ let skiaSdl = \(asan : Bool) ->
805825
, "${objDir}/../libskshaper.a"
806826
, "${objDir}/../libskunicode.a"
807827
, "${objDir}/../libwindow.a"
808-
, "./contrib/sdl3/build/libSDL3.a"
809828
] # static3rdPartyLibraries
810829
}
811830
let flatbuffers = let dir = "./contrib/flatbuffers" in
@@ -818,7 +837,7 @@ let flatbuffers = let dir = "./contrib/flatbuffers" in
818837
}
819838
, sources = [] : List Text
820839
}
821-
let sdl3 = let dir = "./contrib/sdl" in
840+
let sdl3 = let dir = "./contrib/sdl3" in
822841
sourceTreePart::{
823842
, dir = dir
824843
, name = "sdl3"
@@ -828,8 +847,24 @@ let sdl3 = let dir = "./contrib/sdl" in
828847
}
829848
, sources = [] : List Text
830849
, nonSourceObjs = [
831-
, "build/libSDL3.a"
832-
]
850+
-- , "build/libSDL3.a"
851+
] : List Text
852+
}
853+
let mpv =
854+
sourceTreePart::{
855+
, dir = ""
856+
, name = "mpv"
857+
, includeDirs = {
858+
, local = [] : List Text
859+
, global = [] : List Text
860+
}
861+
, sources = [] : List Text
862+
, ldflags = {
863+
, global = [ "-lmpv" ] : List Text
864+
}
865+
, nonSourceObjs = [
866+
, "./contrib/sdl3/build/libSDL3.a"
867+
] : List Text
833868
}
834869
let imguiWithSkia = imgui // {
835870
, name = "imguiWithSkia"
@@ -869,4 +904,6 @@ in
869904
, tracyEnabled
870905
, tracyDisabled
871906
, sdl3
907+
, sdl2mpv
908+
, mpv
872909
}

skia/generate_links.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ link ../common/contrib/imgui_ImGuiColorTextEdit/TextEditor.cpp ./imcolortextedit
2121
link ../common/contrib/imgui_ImGuiColorTextEdit/TextEditor.h ./imcolortextedit/TextEditor.h
2222
link ../common/contrib/sdl3 contrib/sdl3
2323
link ../common/contrib/qoi contrib/qoi
24+
link ../common/contrib/tracy contrib/tracy

video_player/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
imzero_video_play
2+
build
3+
cmake-build-*
4+
.idea

video_player/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# generated using cmakelists.dhall
2+
cmake_minimum_required(VERSION 3.24)
3+
project(mzero_video_play)
4+
set(CMAKE_CXX_STANDARD 20)
5+
set(CMAKE_LINKER clang++)
6+
set(CMAKE_CXX_COMPILER clang++)
7+
8+
add_compile_definitions()
9+
include_directories("${CMAKE_CURRENT_LIST_DIR}/./contrib/sdl3/include"
10+
"${CMAKE_CURRENT_LIST_DIR}/./contrib/tracy/public")
11+
set(COMPILE_OPTIONS -std=c++20
12+
-fno-exceptions
13+
-O3)
14+
link_libraries(-DNDEBUG
15+
-lmpv)
16+
17+
18+
add_library(render OBJECT "${CMAKE_CURRENT_LIST_DIR}/./sdl2_mpv/main.cpp")
19+
20+
add_library(mpv_imported OBJECT IMPORTED)
21+
set_property(TARGET mpv_imported PROPERTY IMPORTED_OBJECTS "${CMAKE_CURRENT_LIST_DIR}/./contrib/sdl3/build/libSDL3.a")
22+
23+
add_library(tracyDisabled OBJECT "${CMAKE_CURRENT_LIST_DIR}/./contrib/tracy/public/TracyClient.cpp")
24+
add_executable(imzero_video_play $<TARGET_OBJECTS:render>
25+
$<TARGET_OBJECTS:mpv_imported>
26+
$<TARGET_OBJECTS:tracyDisabled>)
27+

video_player/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -ev
3+
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
4+
cd "$here"
5+
source "env.sh"
6+
./build_cpp.sh

video_player/build_cpp.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -ev
3+
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
4+
cd "$here"
5+
6+
./cmakelists.dhall
7+
8+
generate_buildinfo() {
9+
echo -en "#pragma once\nnamespace buildinfo {\n static const char *gitCommit=\""
10+
git log -1 --pretty=format:"%H" | tr -d "\n"
11+
echo -en "\";\n static const bool gitDirty="
12+
if [[ $(git diff --stat) != '' ]]; then
13+
echo -n "true"
14+
else
15+
echo -n "false"
16+
fi
17+
echo -en ";\n}\n"
18+
}
19+
generate_buildinfo > src/buildinfo.gen.h
20+
21+
mkdir -p build
22+
cd build
23+
cmake ../CMakeLists.txt
24+
cmake --build . -j
25+
mv imzero_video_play ..

video_player/cmakelists.dhall

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env -S dhall text --output CMakeLists.txt --file
2+
let prelude = ../dhall/prelude.dhall
3+
let lib = ../dhall/lib.dhall
4+
let cmake = ../dhall/cmakelists.dhall
5+
let sourceTreePartsRepo = ../dhall/sourceTreeParts.dhall
6+
let common = ./common.dhall
7+
in
8+
cmake.cmakelistsToText cmake.cmakelists::{
9+
, cxx = common.cxx
10+
, linker = common.linker
11+
, exe = "imzero_video_play"
12+
, projectName = "mzero_video_play"
13+
, cxxflags = ["-std=c++${Natural/show common.cppstd}" ] # common.cxxflags # common.stdlibFlags
14+
, ldflags = common.ldflags # common.stdlibFlags
15+
, sourceTreeParts = common.sourceTreeParts
16+
}

video_player/common.dhall

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
let lib = ../dhall/lib.dhall
2+
let debug = False
3+
let asan = False
4+
--let clangdir = env:CLANGDIR as Text -- FIXME sync with ./build_skia_asan.sh
5+
let sourceTreePartsRepo = ../dhall/sourceTreeParts.dhall
6+
let sourceTreeParts = [
7+
, sourceTreePartsRepo.sdl3
8+
, sourceTreePartsRepo.sdl2mpv
9+
, sourceTreePartsRepo.mpv
10+
] # (if debug then [ , sourceTreePartsRepo.tracyEnabled ] else [ ,sourceTreePartsRepo.tracyDisabled ] : List lib.sourceTreePart.Type )
11+
--let cxx = "${clangdir}/bin/clang++"
12+
let cxx = "clang++"
13+
let cppstd = 20
14+
let cxxflags = ["-fno-exceptions"]
15+
let cxxflagsDebug = [
16+
, "-g"
17+
, "-gdwarf-4"
18+
, "-Wall"
19+
, "-Wformat"
20+
, "-Wextra"
21+
, "-O1"
22+
] # (if asan then [ "-fsanitize=address", "-fsanitize=undefined" ] else [] : List Text) #
23+
[, "-fno-omit-frame-pointer"
24+
, "-DIMZERO_DEBUG_BUILD"
25+
--, "-fno-optimize-sibling-calls" -- no tail calls for better stacktraces
26+
]
27+
let cxxflagsRelease = [
28+
, "-O3"
29+
]
30+
let ldflagsDebug = if asan then [
31+
, "-fsanitize=address"
32+
, "-fsanitize=undefined"
33+
, "-fuse-ld=lld"
34+
, "-v"
35+
-- , "-Wl,-rpath,${clangdir}/lib/x86_64-unknown-linux-gnu"
36+
] else [] : List Text
37+
let ldflagsRelease = ["-DNDEBUG"] : List Text
38+
--let stdlibFlags = ["-stdlib=libc++"] : List Text
39+
let stdlibFlags = [] : List Text
40+
let linker = cxx
41+
in {
42+
, sourceTreeParts
43+
, cxx
44+
, linker
45+
, cppstd
46+
, cxxflags = cxxflags # (if debug then cxxflagsDebug else cxxflagsRelease)
47+
, ldflags = if debug then ldflagsDebug else ldflagsRelease
48+
, stdlibFlags
49+
, debug
50+
}

video_player/contrib/sdl3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/contrib/sdl3

video_player/contrib/tracy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/contrib/tracy

0 commit comments

Comments
 (0)