Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from MGTheTrain/feature/video-module
Browse files Browse the repository at this point in the history
[Feature] - video module
  • Loading branch information
MGTheTrain committed Apr 20, 2024
2 parents ffb6287 + 6169d8d commit b473138
Show file tree
Hide file tree
Showing 31 changed files with 698 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/dotnet-8.0/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev nasm libwayland-dev libxkbcommon-dev libegl1-mesa-dev
#pip3 install clang-format cpplint
pip3 install jinja2

cd /tmp/
# vcpkg
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/go/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev nasm libwayland-dev libxkbcommon-dev libegl1-mesa-dev
# pip3 install clang-format cpplint
pip3 install jinja2

cd /tmp/
# vcpkg
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/python/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev
pip3 install clang-format cpplint
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev nasm libwayland-dev libxkbcommon-dev libegl1-mesa-dev
pip3 install clang-format cpplint jinja2

cd /tmp/
# vcpkg
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/rust/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev
pip3 install clang-format cpplint
apt-get install -y cmake python3 python3-pip pkg-config portaudio19-dev nasm libwayland-dev libxkbcommon-dev libegl1-mesa-dev
pip3 install clang-format cpplint jinja2

cd /tmp/
# vcpkg
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential cmake portaudio19-dev libasound2-dev alsa-utils
- name: Check ALSA Mixer Settings
run: alsamixer
build-essential \
cmake portaudio19-dev nasm
- name: Install vcpkg
run: |
git clone https://github.com/Microsoft/vcpkg.git
Expand All @@ -30,7 +30,6 @@ jobs:

build_windows:
runs-on: windows-latest
needs: [build_and_test_ubuntu]
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -53,13 +52,12 @@ jobs:

build_macos:
runs-on: macos-latest
needs: [build_and_test_ubuntu]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install third-party brew dependencies
run: |
brew install pkg-config cmake portaudio
brew install pkg-config cmake portaudio nasm
- name: Install vcpkg
run: |
git clone https://github.com/Microsoft/vcpkg.git
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Install third-party apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential cmake portaudio19-dev libasound2-dev alsa-utils
- name: Check ALSA Mixer Settings
run: alsamixer
apt-get install -y \
build-essential \
cmake portaudio19-dev nasm
- name: Install vcpkg
run: |
git clone https://github.com/Microsoft/vcpkg.git
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ __pycache__
obj
bin
Cargo.lock
target
target
vcpkg
*.backup
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.0] - 20-04-2024

### Added

- [Feature] C++ video module **(Optional, Experimental)**.

## [0.6.0] - 17-04-2024

### Updated
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ A collection of sample code snippets demonstrating how to create bindings for va

- Download and install [CMake from the official website](https://cmake.org/download/) or trough a package manager
- Install [vcpkg from the official website](https://vcpkg.io/en/getting-started.html) or trough a package manager
- Check dependencies required for your Linux, MacOS or Windows system in [pr.yml workflow](./.github/workflows/pr.yml)

### CMake

Expand Down
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# SOFTWARE.

add_subdirectory(audio-player)
# add_subdirectory(video-player)
add_subdirectory(video-player)
23 changes: 23 additions & 0 deletions apps/video-player/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# The MIT License
#
# Copyright (c) 2024 MGTheTrain
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(BUILD_APP)
add_subdirectory(src)
endif()
25 changes: 25 additions & 0 deletions apps/video-player/include/video-player.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The MIT License
//
// Copyright (c) 2024 MGTheTrain
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#ifdef VIDEO_PLAYER
#include <video.h>
#endif
49 changes: 49 additions & 0 deletions apps/video-player/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# The MIT License
#
# Copyright (c) 2024 MGTheTrain
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

cmake_minimum_required(VERSION 3.10)
set(TARGET video_player)
project(${TARGET})

add_definitions(-DVIDEO_PLAYER)

find_package(FFMPEG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)

include_directories(../include
../../../modules/video/include
${FFMPEG_INCLUDE_DIRS}
)
set(VIDEO_PLAYER_SRC video-player.cpp)

add_executable(${TARGET} ${VIDEO_PLAYER_SRC})
if(WIN32)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../../../assets/
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/assets/)
elseif(APPLE OR UNIX)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../../../assets/
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/assets/)
else()
message(WARNING "Unsupported platform")
endif()

target_link_libraries(${TARGET} PRIVATE video ${FFMPEG_LIBRARIES} SDL2::SDL2)

install(TARGETS ${TARGET})
53 changes: 53 additions & 0 deletions apps/video-player/src/video-player.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// The MIT License
//
// Copyright (c) 2024 MGTheTrain
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#ifdef VIDEO_PLAYER
#include <video-player.h>

int main(int argc, char* argv[]) {
if (argc < 2) {
printf("Usage: %s <video_file>\n", argv[0]);
return -1;
}

const char* videoFileName = argv[1];

VideoPlayer player;

if (!initVideoPlayer(player)) {
std::cerr << "Failed to initialize video player\n";
return -1;
}

if (!loadVideo(player, videoFileName)) {
std::cerr << "Failed to load video: " << videoFileName << "\n";
closeVideoPlayer(player);
return -1;
}

playVideo(player);

closeVideoPlayer(player);

return 0;
}
#endif
Binary file added assets/mp4/file_example_MP4_1280_10MG.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion devops/scripts/bash/compile_source_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ echo -e "$BLUE INFO: $NC Compilation of the source code and linking binaries suc

if [ "$NoTests" = false ]; then
cd "build"
ctest --verbose -E audio_test # ignore audio_test executable in workflows
ctest --verbose -E "video_test|audio_test" # ignore audio_test and video_test executable in workflows
# ctest --verbose
fi
2 changes: 1 addition & 1 deletion modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_subdirectory(core)
add_subdirectory(audio)
# add_subdirectory(video)
add_subdirectory(video)
2 changes: 1 addition & 1 deletion modules/audio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ else()
target_link_libraries(${TARGET} SndFile::sndfile portaudio)
target_link_libraries(${TARGET}_wrapper SndFile::sndfile portaudio)
endif()
install(TARGETS ${TARGET})
install(TARGETS ${TARGET} ${TARGET}_wrapper)
2 changes: 1 addition & 1 deletion modules/core/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ set(CORE_SRC
add_library(${TARGET} STATIC ${CORE_SRC})
add_library(${TARGET}_wrapper SHARED ${CORE_SRC}) # required for bindings

install(TARGETS ${TARGET})
install(TARGETS ${TARGET} ${TARGET}_wrapper)
28 changes: 27 additions & 1 deletion modules/video/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
TBD
# The MIT License
#
# Copyright (c) 2024 MGTheTrain
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(BUILD_LIB)
add_subdirectory(src)
endif()

if(BUILD_TEST)
add_subdirectory(test)
endif()
Empty file removed modules/video/include/.gitignore
Empty file.
Loading

0 comments on commit b473138

Please sign in to comment.