Skip to content

Commit

Permalink
wip: video player
Browse files Browse the repository at this point in the history
  • Loading branch information
stergiotis committed Jul 17, 2024
1 parent 4463373 commit 4286522
Show file tree
Hide file tree
Showing 13 changed files with 386 additions and 5 deletions.
47 changes: 42 additions & 5 deletions dhall/sourceTreeParts.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,27 @@ let render = let dir = "./src" in sourceTreePart::{
] : List Text
}
}
let sdl2mpv = let dir = "./sdl2_mpv" in sourceTreePart::{
, name = "render"
, dir = dir
, includeDirs = {
, local = [
] : List Text
, global = [] : List Text
}
, sources = [
, "${dir}/main.cpp"
]
, cxxflags = {
, global = [
] : List Text
, local = [] : List Text
}
, ldflags = {
, global = [
] : List Text
}
}
let binding = let dir = "./src/binding" in sourceTreePart::{
, name = "binding"
, dir = dir
Expand Down Expand Up @@ -715,7 +736,6 @@ let skiaSdl = \(asan : Bool) ->
, imgui.dir
, imguiImplot.dir
, render.dir
, "./contrib/sdl3/include"
]
, global = [
, "${contribDir}"
Expand Down Expand Up @@ -805,7 +825,6 @@ let skiaSdl = \(asan : Bool) ->
, "${objDir}/../libskshaper.a"
, "${objDir}/../libskunicode.a"
, "${objDir}/../libwindow.a"
, "./contrib/sdl3/build/libSDL3.a"
] # static3rdPartyLibraries
}
let flatbuffers = let dir = "./contrib/flatbuffers" in
Expand All @@ -818,7 +837,7 @@ let flatbuffers = let dir = "./contrib/flatbuffers" in
}
, sources = [] : List Text
}
let sdl3 = let dir = "./contrib/sdl" in
let sdl3 = let dir = "./contrib/sdl3" in
sourceTreePart::{
, dir = dir
, name = "sdl3"
Expand All @@ -828,8 +847,24 @@ let sdl3 = let dir = "./contrib/sdl" in
}
, sources = [] : List Text
, nonSourceObjs = [
, "build/libSDL3.a"
]
-- , "build/libSDL3.a"
] : List Text
}
let mpv =
sourceTreePart::{
, dir = ""
, name = "mpv"
, includeDirs = {
, local = [] : List Text
, global = [] : List Text
}
, sources = [] : List Text
, ldflags = {
, global = [ "-lmpv" ] : List Text
}
, nonSourceObjs = [
, "./contrib/sdl3/build/libSDL3.a"
] : List Text
}
let imguiWithSkia = imgui // {
, name = "imguiWithSkia"
Expand Down Expand Up @@ -869,4 +904,6 @@ in
, tracyEnabled
, tracyDisabled
, sdl3
, sdl2mpv
, mpv
}
1 change: 1 addition & 0 deletions skia/generate_links.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ link ../common/contrib/imgui_ImGuiColorTextEdit/TextEditor.cpp ./imcolortextedit
link ../common/contrib/imgui_ImGuiColorTextEdit/TextEditor.h ./imcolortextedit/TextEditor.h
link ../common/contrib/sdl3 contrib/sdl3
link ../common/contrib/qoi contrib/qoi
link ../common/contrib/tracy contrib/tracy
4 changes: 4 additions & 0 deletions video_player/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
imzero_video_play
build
cmake-build-*
.idea
27 changes: 27 additions & 0 deletions video_player/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# generated using cmakelists.dhall
cmake_minimum_required(VERSION 3.24)
project(mzero_video_play)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_LINKER clang++)
set(CMAKE_CXX_COMPILER clang++)

add_compile_definitions()
include_directories("${CMAKE_CURRENT_LIST_DIR}/./contrib/sdl3/include"
"${CMAKE_CURRENT_LIST_DIR}/./contrib/tracy/public")
set(COMPILE_OPTIONS -std=c++20
-fno-exceptions
-O3)
link_libraries(-DNDEBUG
-lmpv)


add_library(render OBJECT "${CMAKE_CURRENT_LIST_DIR}/./sdl2_mpv/main.cpp")

add_library(mpv_imported OBJECT IMPORTED)
set_property(TARGET mpv_imported PROPERTY IMPORTED_OBJECTS "${CMAKE_CURRENT_LIST_DIR}/./contrib/sdl3/build/libSDL3.a")

add_library(tracyDisabled OBJECT "${CMAKE_CURRENT_LIST_DIR}/./contrib/tracy/public/TracyClient.cpp")
add_executable(imzero_video_play $<TARGET_OBJECTS:render>
$<TARGET_OBJECTS:mpv_imported>
$<TARGET_OBJECTS:tracyDisabled>)

6 changes: 6 additions & 0 deletions video_player/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -ev
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
cd "$here"
source "env.sh"
./build_cpp.sh
25 changes: 25 additions & 0 deletions video_player/build_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -ev
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
cd "$here"

./cmakelists.dhall

generate_buildinfo() {
echo -en "#pragma once\nnamespace buildinfo {\n static const char *gitCommit=\""
git log -1 --pretty=format:"%H" | tr -d "\n"
echo -en "\";\n static const bool gitDirty="
if [[ $(git diff --stat) != '' ]]; then
echo -n "true"
else
echo -n "false"
fi
echo -en ";\n}\n"
}
generate_buildinfo > src/buildinfo.gen.h

mkdir -p build
cd build
cmake ../CMakeLists.txt
cmake --build . -j
mv imzero_video_play ..
16 changes: 16 additions & 0 deletions video_player/cmakelists.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env -S dhall text --output CMakeLists.txt --file
let prelude = ../dhall/prelude.dhall
let lib = ../dhall/lib.dhall
let cmake = ../dhall/cmakelists.dhall
let sourceTreePartsRepo = ../dhall/sourceTreeParts.dhall
let common = ./common.dhall
in
cmake.cmakelistsToText cmake.cmakelists::{
, cxx = common.cxx
, linker = common.linker
, exe = "imzero_video_play"
, projectName = "mzero_video_play"
, cxxflags = ["-std=c++${Natural/show common.cppstd}" ] # common.cxxflags # common.stdlibFlags
, ldflags = common.ldflags # common.stdlibFlags
, sourceTreeParts = common.sourceTreeParts
}
50 changes: 50 additions & 0 deletions video_player/common.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
let lib = ../dhall/lib.dhall
let debug = False
let asan = False
--let clangdir = env:CLANGDIR as Text -- FIXME sync with ./build_skia_asan.sh
let sourceTreePartsRepo = ../dhall/sourceTreeParts.dhall
let sourceTreeParts = [
, sourceTreePartsRepo.sdl3
, sourceTreePartsRepo.sdl2mpv
, sourceTreePartsRepo.mpv
] # (if debug then [ , sourceTreePartsRepo.tracyEnabled ] else [ ,sourceTreePartsRepo.tracyDisabled ] : List lib.sourceTreePart.Type )
--let cxx = "${clangdir}/bin/clang++"
let cxx = "clang++"
let cppstd = 20
let cxxflags = ["-fno-exceptions"]
let cxxflagsDebug = [
, "-g"
, "-gdwarf-4"
, "-Wall"
, "-Wformat"
, "-Wextra"
, "-O1"
] # (if asan then [ "-fsanitize=address", "-fsanitize=undefined" ] else [] : List Text) #
[, "-fno-omit-frame-pointer"
, "-DIMZERO_DEBUG_BUILD"
--, "-fno-optimize-sibling-calls" -- no tail calls for better stacktraces
]
let cxxflagsRelease = [
, "-O3"
]
let ldflagsDebug = if asan then [
, "-fsanitize=address"
, "-fsanitize=undefined"
, "-fuse-ld=lld"
, "-v"
-- , "-Wl,-rpath,${clangdir}/lib/x86_64-unknown-linux-gnu"
] else [] : List Text
let ldflagsRelease = ["-DNDEBUG"] : List Text
--let stdlibFlags = ["-stdlib=libc++"] : List Text
let stdlibFlags = [] : List Text
let linker = cxx
in {
, sourceTreeParts
, cxx
, linker
, cppstd
, cxxflags = cxxflags # (if debug then cxxflagsDebug else cxxflagsRelease)
, ldflags = if debug then ldflagsDebug else ldflagsRelease
, stdlibFlags
, debug
}
1 change: 1 addition & 0 deletions video_player/contrib/sdl3
1 change: 1 addition & 0 deletions video_player/contrib/tracy
5 changes: 5 additions & 0 deletions video_player/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export PKG_CONFIG_OUTPUT_CFLAGS_FREETYPE2=""
export PKG_CONFIG_OUTPUT_LIBS_FREETYPE2=""
export PKG_CONFIG_OUTPUT_CFLAGS_GLFW3=""
export PKG_CONFIG_OUTPUT_LIBS_GLFW3=""
export CLANGDIR=""
7 changes: 7 additions & 0 deletions video_player/generate_links.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
cd "$here"
source "../common/lib.sh"

link ../common/contrib/sdl3 contrib/sdl3
link ../common/contrib/tracy contrib/tracy
Loading

0 comments on commit 4286522

Please sign in to comment.