diff --git a/.gitignore b/.gitignore index f5bcbf1..27306d1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ setup/input/ setup/output/ **/validation_results.txt **/openssl_onvif_log.txt + +player/build/ +deb/build/ +flatpak/build/ \ No newline at end of file diff --git a/deb/build-package.sh b/deb/build-package.sh new file mode 100755 index 0000000..ba836a7 --- /dev/null +++ b/deb/build-package.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +# Exit on error +set -e + +# Function to check Ubuntu version +check_ubuntu_version() { + if [[ $(lsb_release -rs) != "24.04" || $(lsb_release -is) != "Ubuntu" ]]; then + echo "Error: This script is only for Ubuntu 24.04." + exit 1 + fi +} + +# Check the system is Ubuntu 24.04 +check_ubuntu_version + +# Install required packages +sudo apt update -y && sudo apt install -y libssl-dev cmake build-essential qtbase5-dev qt5-qmake libqt5multimedia5-plugins qtmultimedia5-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio + +# Parse arguments +if [[ $# -ne 4 ]]; then + echo "Usage: $0 " + exit 1 +fi + +BUILD_TYPE=$1 +SIGNING_TYPE=$2 +FFMPEG_PATH=$3 +VERSION=$4 + +TEMPLATE_PACKAGE_NAME=onvif-player_ubuntu24.04-amd64 +PACKAGE_NAME=onvif-player-${VERSION}_ubuntu24.04-amd64 + +# Validate BUILD_TYPE +if [[ $BUILD_TYPE != "Release" && $BUILD_TYPE != "Debug" ]]; then + echo "Error: BUILD_TYPE must be 'Release' or 'Debug'." + exit 1 +fi + +# Validate SIGNING_TYPE +if [[ $SIGNING_TYPE != "threaded-signing" && $SIGNING_TYPE != "unthreaded-signing" ]]; then + echo "Error: SIGNING_TYPE must be 'threaded-signing' or 'unthreaded-signing'." + exit 1 +fi + +# Validate FFMPEG_PATH +if [[ ! -d $FFMPEG_PATH ]]; then + echo "Error: FFMPEG_PATH does not exist or is not a directory." + exit 1 +fi + +# Step 6: Remove and recreate 'build' directory +rm -rf build +mkdir build + +# Prepare build folder +cp -r $TEMPLATE_PACKAGE_NAME build/$PACKAGE_NAME +ln -s -r ../player build/player + +cd build + +# Prepare postinst file +chmod 775 $PACKAGE_NAME/DEBIAN/postinst + +# Replace $VERSION in control file +sed -i "s/\$VERSION/$VERSION/g" $PACKAGE_NAME/DEBIAN/control + +# Replace $VERSION in desktop file +mkdir -p $PACKAGE_NAME/usr/share/applications +sed -i "s/\$VERSION/$VERSION/g" $PACKAGE_NAME/usr/share/applications/OnvifPlayer.desktop + +cd player + +# Create build folder +mkdir -p build +cd build + +# Run cmake +cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLUGIN_NAME=$SIGNING_TYPE -DFFMPEG_PATH=$FFMPEG_PATH .. + +# Build the project +cmake --build . -j $(nproc) + +cd ../.. + +# Copy ONVIFPlayer binary +mkdir -p $PACKAGE_NAME/usr/local/bin +cp player/build/bin/${BUILD_TYPE}/ONVIFPlayer $PACKAGE_NAME/usr/local/bin/onvif-player +chmod 775 $PACKAGE_NAME/usr/local/bin/onvif-player + +# Copy FFmpeg shared libraries +mkdir -p $PACKAGE_NAME/usr/local/lib +cp -r $FFMPEG_PATH/lib $PACKAGE_NAME/usr/local/lib/onvif-player +rm -rf $PACKAGE_NAME/usr/local/lib/onvif-player/libavdevice.* +rm -rf $PACKAGE_NAME/usr/local/lib/onvif-player/libavfilter.* +rm -rf $PACKAGE_NAME/usr/local/lib/onvif-player/libpostproc.* +rm -rf $PACKAGE_NAME/usr/local/lib/onvif-player/pkgconfig + +# Step 20: Build Debian package +dpkg-deb --build $PACKAGE_NAME + +echo "Debian package built successfully: $PACKAGE_NAME" + diff --git a/deb/onvif-player_ubuntu24.04-amd64/DEBIAN/control b/deb/onvif-player_ubuntu24.04-amd64/DEBIAN/control new file mode 100644 index 0000000..054ef5c --- /dev/null +++ b/deb/onvif-player_ubuntu24.04-amd64/DEBIAN/control @@ -0,0 +1,25 @@ +Package: onvif-player +Version: $VERSION +Maintainer: Vladimir Dergachyov +Architecture: amd64 +Description: Onvif Player $VERSION +Depends: libssl3t64, + libqt5core5t64, + libqt5gui5t64, + libqt5network5t64, + libqt5widgets5t64, + libqt5multimedia5-plugins, + libgstreamer1.0-0, + gstreamer1.0-plugins-base, + gstreamer1.0-plugins-good, + gstreamer1.0-plugins-bad, + gstreamer1.0-plugins-ugly, + gstreamer1.0-libav, + gstreamer1.0-tools, + gstreamer1.0-x, + gstreamer1.0-alsa, + gstreamer1.0-gl, + gstreamer1.0-gtk3, + gstreamer1.0-qt5, + gstreamer1.0-pulseaudio + diff --git a/deb/onvif-player_ubuntu24.04-amd64/DEBIAN/postinst b/deb/onvif-player_ubuntu24.04-amd64/DEBIAN/postinst new file mode 100644 index 0000000..f446552 --- /dev/null +++ b/deb/onvif-player_ubuntu24.04-amd64/DEBIAN/postinst @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "/usr/local/lib/onvif-player" > /etc/ld.so.conf.d/onvif-player.conf +ldconfig + diff --git a/deb/onvif-player_ubuntu24.04-amd64/usr/share/applications/OnvifPlayer.desktop b/deb/onvif-player_ubuntu24.04-amd64/usr/share/applications/OnvifPlayer.desktop new file mode 100644 index 0000000..c360164 --- /dev/null +++ b/deb/onvif-player_ubuntu24.04-amd64/usr/share/applications/OnvifPlayer.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Onvif Player +Comment=Onvif Player $VERSION +Exec=/usr/local/bin/onvif-player +Icon=/usr/share/icons/onvif-player.png +Terminal=false +Type=Application +Categories=AudioVideo; + diff --git a/deb/onvif-player_ubuntu24.04-amd64/usr/share/icons/onvif-player.png b/deb/onvif-player_ubuntu24.04-amd64/usr/share/icons/onvif-player.png new file mode 100644 index 0000000..138a541 Binary files /dev/null and b/deb/onvif-player_ubuntu24.04-amd64/usr/share/icons/onvif-player.png differ diff --git a/flatpak/build-package.sh b/flatpak/build-package.sh new file mode 100755 index 0000000..1883af2 --- /dev/null +++ b/flatpak/build-package.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Validate arguments +if [ "$#" -ne 4 ]; then + echo "Usage: $0 " + exit 1 +fi + +BUILD_TYPE=$1 +SIGNING_TYPE=$2 +FFMPEG_PATH=$3 +VERSION=$4 + +# Check if the first argument is Release or Debug +if [[ "$BUILD_TYPE" != "Release" && "$BUILD_TYPE" != "Debug" ]]; then + echo "Error: First argument must be 'Release' or 'Debug'." + exit 1 +fi + +# Check if the second argument is threaded-signing or unthreaded-signing +if [[ "$SIGNING_TYPE" != "threaded-signing" && "$SIGNING_TYPE" != "unthreaded-signing" ]]; then + echo "Error: Second argument must be 'threaded-signing' or 'unthreaded-signing'." + exit 1 +fi + +# Check if the third argument is a valid directory +if [ ! -d "$FFMPEG_PATH" ]; then + echo "Error: Third argument must be a valid directory." + exit 1 +fi + +# Check if flatpak is installed and executable +if ! command -v flatpak &> /dev/null; then + echo "Error: 'flatpak' is not installed or not in PATH. Please install it and try again." + exit 1 +fi + +# Check if flatpak-builder is installed and executable +if ! command -v flatpak-builder &> /dev/null; then + echo "Error: 'flatpak-builder' is not installed or not in PATH. Please install it and try again." + exit 1 +fi + +# Remove 'build' directory if it exists and create a new one +rm -rf build +mkdir build + +# Copy necessary files to the build directory +cp org.onvif.Player.yaml build/ + +# Create a symlink to the player folder in the build directory +ln -s -r "../player" build/player + +# Create a symlink to the ffmpeg folder in the build directory +ln -s "$FFMPEG_PATH" build/ffmpeg + +# Prepare share folder +cp -r ./share build/share + +# Change to the build directory +cd build + +# Replace placeholders +sed -i "s|\$VERSION|$VERSION|g" share/org.onvif.Player.desktop +sed -i "s|\$BUILD_TYPE|$BUILD_TYPE|g" org.onvif.Player.yaml +sed -i "s|\$SIGNING_TYPE|$SIGNING_TYPE|g" org.onvif.Player.yaml + +# Add the Flathub repository if it doesn't exist +flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo + +# Build the Flatpak package +flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo builddir org.onvif.Player.yaml + +# Create the Flatpak bundle +flatpak build-bundle repo onvif-player-$VERSION-x86_64.flatpak org.onvif.Player + +echo "Build completed successfully. Output file: onvif-player-$VERSION-x86_64.flatpak" + diff --git a/flatpak/org.onvif.Player.yaml b/flatpak/org.onvif.Player.yaml new file mode 100644 index 0000000..3831870 --- /dev/null +++ b/flatpak/org.onvif.Player.yaml @@ -0,0 +1,48 @@ +app-id: org.onvif.Player +runtime: org.kde.Platform +runtime-version: 5.15-24.08 +sdk: org.kde.Sdk +command: onvif-player +finish-args: + - --socket=pulseaudio + - --device=all + - --filesystem=host + - --socket=x11 + - --socket=fallback-x11 +cleanup-commands: + - find /app/ffmpeg -mindepth 1 -maxdepth 1 ! -name 'lib' -exec rm -rf {} \; + - rm -rf /app/ffmpeg/lib/libavdevice.* + - rm -rf /app/ffmpeg/lib/libavfilter.* + - rm -rf /app/ffmpeg/lib/libpostproc.* + - rm -rf /app/ffmpeg/lib/pkgconfig +modules: + - name: ffmpeg + buildsystem: simple + build-commands: + - mkdir -p /app/ffmpeg + - cp -r ./* /app/ffmpeg + sources: + - type: dir + path: ffmpeg + - name: onvif-player + buildsystem: simple + builddir: true + build-commands: + - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLUGIN_NAME=$SIGNING_TYPE -DFFMPEG_PATH=/app/ffmpeg . + - cmake --build . -j $(nproc) + - mkdir -p /app/bin + - mv bin/$BUILD_TYPE/ONVIFPlayer /app/bin/onvif-player + sources: + - type: dir + path: player + - name: share + buildsystem: simple + builddir: true + build-commands: + - mkdir -p /app/share/applications + - cp org.onvif.Player.desktop /app/share/applications/ + - mkdir -p /app/share/icons/hicolor/32x32/apps + - cp org.onvif.Player.png /app/share/icons/hicolor/32x32/apps/ + sources: + - type: dir + path: share diff --git a/flatpak/share/org.onvif.Player.desktop b/flatpak/share/org.onvif.Player.desktop new file mode 100644 index 0000000..c6d9d82 --- /dev/null +++ b/flatpak/share/org.onvif.Player.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Onvif Player +Comment=Onvif Player $VERSION +Exec=onvif-player +Icon=org.onvif.Player +Terminal=false +Type=Application +Categories=AudioVideo; diff --git a/flatpak/share/org.onvif.Player.png b/flatpak/share/org.onvif.Player.png new file mode 100644 index 0000000..c6fe1e1 Binary files /dev/null and b/flatpak/share/org.onvif.Player.png differ diff --git a/player/CMakeLists.txt b/player/CMakeLists.txt index 50821d1..a9ea8d3 100644 --- a/player/CMakeLists.txt +++ b/player/CMakeLists.txt @@ -4,7 +4,7 @@ if(NOT LINUX) message( FATAL_ERROR "Only for linux build" ) endif() -project(ONVIFPlayer VERSION 2.0.0 LANGUAGES CXX) +project(ONVIFPlayer VERSION 3.0.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -73,3 +73,4 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) add_subdirectory(src) +