Skip to content

Commit

Permalink
Linux: Fix AppRun for GStreamer
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Oct 18, 2024
1 parent 13031c3 commit fd57709
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 129 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
Expand All @@ -41,6 +41,8 @@ jobs:
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
large-packages: false
continue-on-error: true

- name: Checkout repo
Expand All @@ -58,12 +60,12 @@ jobs:
- uses: lukka/get-cmake@latest

- name: Install Vulkan
run: |
wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.283-focal.list https://packages.lunarg.com/vulkan/1.3.283/lunarg-vulkan-1.3.283-focal.list
sudo apt update
sudo apt install vulkan-sdk
# - name: Install Vulkan
# run: |
# wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
# sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.283-focal.list https://packages.lunarg.com/vulkan/1.3.283/lunarg-vulkan-1.3.283-focal.list
# sudo apt update
# sudo apt install vulkan-sdk

- name: Install Compiler
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
for package in *.pkg ;
do sudo installer -verbose -pkg "$package" -target /
done
echo "PKG_CONFIG_PATH=/Library/Frameworks/GStreamer.framework/lib/pkgconfig:/Library/Frameworks/GStreamer.framework/lib/gstreamer-1.0/pkgconfig:${{ env.PKG_CONFIG_PATH }}" >> "$GITHUB_ENV"
- name: Set Up Cache
uses: hendrikmuhs/[email protected]
Expand Down
27 changes: 16 additions & 11 deletions cmake/CreateAppImage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ message(STATUS "Creating AppImage")
# TODO: https://github.com/AppImageCommunity/AppImageUpdate

set(APPDIR_PATH "${CMAKE_BINARY_DIR}/AppDir")
# set(APPIMAGETOOL_PATH "${CMAKE_BINARY_DIR}/appimagetool-x86_64.AppImage")
set(APPIMAGETOOL_PATH "${CMAKE_BINARY_DIR}/appimagetool-x86_64.AppImage")
set(LD_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-x86_64.AppImage")
set(LD_APPIMAGEPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-appimage-x86_64.AppImage")
# set(LD_APPIMAGEPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-appimage-x86_64.AppImage")
# set(LD_QTPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-qt-x86_64.AppImage")
# set(LD_GSTPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-gstreamer.sh")
# set(LD_GTKPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-gtk.sh")

# if(NOT EXISTS "${APPIMAGETOOL_PATH}")
# file(DOWNLOAD https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage "${APPIMAGETOOL_PATH}")
# execute_process(COMMAND chmod a+x "${APPIMAGETOOL_PATH}")
# endif()
if(NOT EXISTS "${APPIMAGETOOL_PATH}")
file(DOWNLOAD https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage "${APPIMAGETOOL_PATH}")
# file(DOWNLOAD https://github.com/probonopd/go-appimage/releases/download/832/appimagetool-823-x86_64.AppImage "${APPIMAGETOOL_PATH}") # TODO: Use Continuous Release
execute_process(COMMAND chmod a+x "${APPIMAGETOOL_PATH}")
endif()
if(NOT EXISTS "${LD_PATH}")
file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage "${LD_PATH}")
execute_process(COMMAND chmod a+x "${LD_PATH}")
endif()
if(NOT EXISTS "${LD_APPIMAGEPLUGIN_PATH}")
file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage "${LD_APPIMAGEPLUGIN_PATH}")
execute_process(COMMAND chmod a+x "${LD_APPIMAGEPLUGIN_PATH}")
endif()
# if(NOT EXISTS "${LD_APPIMAGEPLUGIN_PATH}")
# file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage "${LD_APPIMAGEPLUGIN_PATH}")
# execute_process(COMMAND chmod a+x "${LD_APPIMAGEPLUGIN_PATH}")
# endif()
# if(NOT EXISTS "${LD_QTPLUGIN_PATH}")
# file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage "${LD_QTPLUGIN_PATH}")
# execute_process(COMMAND chmod a+x "${LD_QTPLUGIN_PATH}")
Expand All @@ -34,7 +35,7 @@ endif()
# execute_process(COMMAND chmod a+x "${LD_GSTPLUGIN_PATH}")
# endif()

execute_process(COMMAND ${LD_PATH} --appdir ${APPDIR_PATH} --output appimage --custom-apprun ${CMAKE_BINARY_DIR}/AppRun)
execute_process(COMMAND ${LD_PATH} --appdir ${APPDIR_PATH} --custom-apprun ${CMAKE_BINARY_DIR}/AppRun)
# --exclude-library "libX*"
# --exclude-library "libglib*"
# --exclude-library "libgobject*"
Expand All @@ -48,3 +49,7 @@ execute_process(COMMAND ${LD_PATH} --appdir ${APPDIR_PATH} --output appimage --c
# --exclude-library "libgst*"
# --exclude-library "libgthread*"
# --plugin qt --plugin gtk --plugin gstreamer

set(ENV{ARCH} x86_64)
# set(ENV{VERSION} 5.0)
execute_process(COMMAND ${APPIMAGETOOL_PATH} ${APPDIR_PATH})
96 changes: 57 additions & 39 deletions cmake/find-modules/FindGStreamer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ elseif(MACOS)
set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/pkgconfig:${GSTREAMER_PREFIX}/lib/gstreamer-1.0/pkgconfig:$ENV{PKG_CONFIG_PATH}")
elseif(LINUX)
set(GSTREAMER_PREFIX "/usr")
set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/pkgconfig:$ENV{PKG_CONFIG_PATH}")
set(ENV{PKG_CONFIG_PATH} "${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/pkgconfig:${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu/gstreamer-1.0/pkgconfig:$ENV{PKG_CONFIG_PATH}")
# if(QGC_GST_STATIC_BUILD)
# list(APPEND PKG_CONFIG_ARGN
# --dont-define-prefix
# --define-variable=prefix=${GSTREAMER_PREFIX}
# --define-variable=libdir=${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu
# --define-variable=includedir=${GSTREAMER_PREFIX}/include
# )
# endif()
elseif(IOS)
list(APPEND CMAKE_FRAMEWORK_PATH "~/Library/Developer/GStreamer/iPhone.sdk")
if(DEFINED ENV{GSTREAMER_PREFIX_IOS} AND EXISTS $ENV{GSTREAMER_PREFIX_IOS})
Expand Down Expand Up @@ -120,6 +128,16 @@ endif()
list(PREPEND CMAKE_PREFIX_PATH ${GSTREAMER_PREFIX})
cmake_print_variables(GSTREAMER_PREFIX)

# TODO: find_path
if(LINUX)
set(GSTREAMER_LIB_PATH ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu)
elseif(MACOS OR ANDROID OR WIN32)
set(GSTREAMER_LIB_PATH ${GSTREAMER_PREFIX}/lib)
elseif(IOS)

endif()
cmake_print_variables(GSTREAMER_LIB_PATH)

################################################################################

include(CMakeFindDependencyMacro)
Expand Down Expand Up @@ -238,6 +256,7 @@ function(find_gstreamer_component component)
target_link_libraries(GStreamer::${component} INTERFACE ${ARGS_DEPENDENCIES})
endif()
set_target_properties(GStreamer::${component} PROPERTIES VERSION ${GStreamer_VERSION})
cmake_print_variables(component)
endif()
mark_as_advanced(GStreamer_${component}_INCLUDE_DIR GStreamer_${component}_LIBRARY)
endif()
Expand Down Expand Up @@ -274,6 +293,15 @@ find_gstreamer_component(Gl
LIBRARY gstgl-1.0
DEPENDENCIES GStreamer::Core GStreamer::Base GStreamer::Video)

find_package(GLESv2 QUIET)
find_package(OpenGL QUIET OPTIONAL_COMPONENTS EGL GLX OpenGL) # GLES2 GLES3
set(Gl_DEPENDENCIES GLESv2::GLESv2 OpenGL::GL OpenGL::EGL OpenGL::GLX OpenGL::OpenGL)
foreach(dependency IN LISTS Gl_DEPENDENCIES)
if(TARGET ${dependency})
target_link_libraries(GStreamer::Gl INTERFACE ${dependency})
endif()
endforeach()

################################################################################

if(Allocators IN_LIST GStreamer_FIND_COMPONENTS)
Expand All @@ -287,7 +315,7 @@ endif()
if(App IN_LIST GStreamer_FIND_COMPONENTS)
find_gstreamer_component(App
PC_NAME gstreamer-app-1.0
HEADER gst/app/gstappsink.h
HEADER gst/app/app.h
LIBRARY gstapp-1.0
DEPENDENCIES GStreamer::Core GStreamer::Base)
endif()
Expand Down Expand Up @@ -319,49 +347,47 @@ endif()
if(Fft IN_LIST GStreamer_FIND_COMPONENTS)
find_gstreamer_component(Fft
PC_NAME gstreamer-fft-1.0
HEADER gst/fft/cfft.h
HEADER gst/fft/fft.h
LIBRARY gstfft-1.0
DEPENDENCIES GStreamer::Core)
endif()

if(GlEgl IN_LIST GStreamer_FIND_COMPONENTS)
# find_package(EGL)
find_package(EGL QUIET)
find_gstreamer_component(GlEgl
PC_NAME gstreamer-gl-egl-1.0
HEADER gst/gl/egl/gstgldisplay_egl.h
HEADER gst/gl/egl/egl.h
LIBRARY gstgl-1.0
DEPENDENCIES GStreamer::Gl EGL::EGL)
endif()

if(GlPrototypes IN_LIST GStreamer_FIND_COMPONENTS)
# find_package(GLESv2)
# find_package(OpenGL OPTIONAL_COMPONENTS EGL GLX OpenGL) # GLES2 GLES3
find_gstreamer_component(GlPrototypes
PC_NAME gstreamer-gl-prototypes-1.0
HEADER gst/gl/glprototypes/all_functions.h
LIBRARY gstglproto-1.0
DEPENDENCIES GStreamer::Gl GLESv2::GLESv2 OpenGL::GL)
DEPENDENCIES GStreamer::Gl)
endif()

if(GlWayland IN_LIST GStreamer_FIND_COMPONENTS)
# find_package(Wayland COMPONENTS Client Cursor Egl)
# find_package(WaylandProtocols)
# find_package(WaylandScanner)
# find_package(Qt6 COMPONENTS WaylandClient)
find_package(Wayland QUIET COMPONENTS Client Egl) # Cursor
# find_package(WaylandProtocols QUIET)
# find_package(WaylandScanner QUIET)
# find_package(Qt6 QUIET COMPONENTS WaylandClient)
find_gstreamer_component(GlWayland
PC_NAME gstreamer-gl-wayland-1.0
HEADER gst/gl/wayland/gstgldisplay_wayland.h
HEADER gst/gl/wayland/wayland.h
LIBRARY gstgl-1.0
DEPENDENCIES GStreamer::Gl Wayland::EGL Wayland::Client)
DEPENDENCIES GStreamer::Gl Wayland::Egl Wayland::Client)
endif()

if(GlX11 IN_LIST GStreamer_FIND_COMPONENTS)
# find_package(X11)
# find_package(XCB COMPONENTS XCB GLX)
# find_package(X11_XCB)
find_package(X11 QUIET)
find_package(XCB QUIET)
find_package(X11_XCB QUIET)
find_gstreamer_component(GlX11
PC_NAME gstreamer-gl-x11-1.0
HEADER gst/gl/x11/gstgldisplay_x11.h
HEADER gst/gl/x11/x11.h
LIBRARY gstgl-1.0
DEPENDENCIES GStreamer::Gl X11::XCB)
endif()
Expand Down Expand Up @@ -463,7 +489,7 @@ if(Tag IN_LIST GStreamer_FIND_COMPONENTS)
endif()

if(Va IN_LIST GStreamer_FIND_COMPONENTS)
# find_package(VAAPI)
find_package(VAAPI QUIET)
find_gstreamer_component(Va
PC_NAME gstreamer-va-1.0
HEADER gst/va/gstva.h
Expand Down Expand Up @@ -516,39 +542,27 @@ if(QGC_GST_STATIC_BUILD)
target_compile_definitions(GStreamer::GStreamer INTERFACE QGC_GST_STATIC_BUILD)
endif()

# TODO: find_path
if(LINUX)
set(GSTREAMER_LIB_PATH ${GSTREAMER_PREFIX}/lib/x86_64-linux-gnu)
elseif(MACOS)
set(GSTREAMER_LIB_PATH ${GSTREAMER_PREFIX}/lib)
elseif(ANDROID OR WIN32)
set(GSTREAMER_LIB_PATH ${GSTREAMER_PREFIX}/lib)
elseif(IOS)

endif()
set(GSTREAMER_PLUGIN_PATH ${GSTREAMER_LIB_PATH}/gstreamer-1.0)

target_include_directories(GStreamer::GStreamer
INTERFACE
${GSTREAMER_PREFIX}/include
${GSTREAMER_PREFIX}/include/glib-2.0
${GSTREAMER_PREFIX}/include/graphene-1.0
${GSTREAMER_PREFIX}/include/gstreamer-1.0
${GSTREAMER_LIB_PATH}/glib-2.0/include
${GSTREAMER_LIB_PATH}/graphene-1.0/include
${GSTREAMER_PLUGIN_PATH}/include
# ${GSTREAMER_PREFIX}/include/graphene-1.0
# ${GSTREAMER_LIB_PATH}/graphene-1.0/include
)

target_link_directories(GStreamer::GStreamer
INTERFACE
${GSTREAMER_LIB_PATH}
${GSTREAMER_PLUGIN_PATH}
)
target_link_directories(GStreamer::GStreamer INTERFACE ${GSTREAMER_LIB_PATH})

################################################################################

add_library(GStreamer::Plugins INTERFACE IMPORTED)

set(GSTREAMER_PLUGIN_PATH ${GSTREAMER_LIB_PATH}/gstreamer-1.0)
target_include_directories(GStreamer::GStreamer INTERFACE ${GSTREAMER_PLUGIN_PATH}/include)
target_link_directories(GStreamer::GStreamer INTERFACE ${GSTREAMER_PLUGIN_PATH})
cmake_print_variables(GSTREAMER_PLUGIN_PATH)

set(GST_PLUGINS
gstcoreelements
gstisomp4
Expand Down Expand Up @@ -596,6 +610,10 @@ foreach(plugin IN LISTS GST_PLUGINS)
set(GST_PLUGIN_${plugin}_FOUND TRUE)
endif()
endif()

# if(GST_PLUGIN_${plugin}_FOUND)
# cmake_print_variables(plugin)
# endif()
endforeach()

if(NOT MACOS)
Expand Down
30 changes: 16 additions & 14 deletions deploy/linux/AppRun
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/bin/bash

set -e
if [ -z "$APPDIR" ]; then
APPDIR="$(dirname "$(readlink -f "$0")")"
fi

HERE="$(dirname "$(readlink -f "${0}")")"

# export LD_LIBRARY_PATH="$HERE/usr/lib:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${APPDIR}/usr/lib/gstreamer-1.0:${LD_LIBRARY_PATH}"

export GST_REGISTRY_REUSE_PLUGIN_SCANNER="no"
export GIO_EXTRA_MODULES="$HERE/usr/lib/gio/modules"
export GIO_EXTRA_MODULES="${APPDIR}/usr/lib/gio/modules"

export GST_PLUGIN_SYSTEM_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SCANNER="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PLUGIN_SCANNER_1_0="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PTP_HELPER="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"
export GST_PTP_HELPER_1_0="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"

export GST_PLUGIN_SYSTEM_PATH="$HERE/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH_1_0="$HERE/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH="$HERE/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="$HERE/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SCANNER="$HERE/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PLUGIN_SCANNER_1_0="$HERE/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PTP_HELPER="$HERE/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"
export GST_PTP_HELPER_1_0="$HERE/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"
export QT_QPA_PLATFORM="xcb"

exec "$HERE/usr/bin/QGroundControl" "$@"
exec "${APPDIR}/usr/bin/QGroundControl" "$@"
17 changes: 9 additions & 8 deletions src/VideoManager/VideoReceiver/GStreamer/GStreamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ GST_PLUGIN_STATIC_DECLARE(matroska);
GST_PLUGIN_STATIC_DECLARE(mpegtsdemux);
GST_PLUGIN_STATIC_DECLARE(opengl);
GST_PLUGIN_STATIC_DECLARE(tcp);
GST_PLUGIN_STATIC_DECLARE(asf);
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_MAC)
GST_PLUGIN_STATIC_DECLARE(va);
#endif
// GST_PLUGIN_STATIC_DECLARE(asf);
// #ifndef Q_OS_ANDROID
// GST_PLUGIN_STATIC_DECLARE(va);
// #endif
#ifdef Q_OS_ANDROID
GST_PLUGIN_STATIC_DECLARE(androidmedia);
#elif defined(Q_OS_IOS)
Expand Down Expand Up @@ -115,6 +115,7 @@ static void _setGstEnvVars()
_qgcputenv("GST_PLUGIN_SYSTEM_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/1.0/lib/gstreamer-1.0");
_qgcputenv("GST_PLUGIN_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/1.0/lib/gstreamer-1.0");
_qgcputenv("GST_PLUGIN_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/1.0/lib/gstreamer-1.0");
_qgcputenv("GTK_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/1.0");
#elif defined(Q_OS_WIN)
_qgcputenv("GST_REGISTRY_REUSE_PLUGIN_SCANNER", "no");
_qgcputenv("GST_PLUGIN_SCANNER", currentDir, "/../libexec/gstreamer-1.0/gst-plugin-scanner");
Expand Down Expand Up @@ -144,10 +145,10 @@ static void _registerPlugins()
GST_PLUGIN_STATIC_REGISTER(mpegtsdemux);
GST_PLUGIN_STATIC_REGISTER(opengl);
GST_PLUGIN_STATIC_REGISTER(tcp);
GST_PLUGIN_STATIC_REGISTER(asf);
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_MAC)
GST_PLUGIN_STATIC_REGISTER(va);
#endif
// GST_PLUGIN_STATIC_REGISTER(asf);
// #ifndef Q_OS_ANDROID
// GST_PLUGIN_STATIC_REGISTER(va);
// #endif
#ifdef Q_OS_ANDROID
GST_PLUGIN_STATIC_REGISTER(androidmedia);
#elif defined(Q_OS_IOS)
Expand Down
Loading

0 comments on commit fd57709

Please sign in to comment.