From c606eb5e0917f0b212aa89bf54843e0ccda0514a Mon Sep 17 00:00:00 2001 From: Aleksey Kontsevich Date: Fri, 15 Oct 2021 00:38:59 +0300 Subject: [PATCH] Fixed GStreamer support in Android build It seems that `QT_ARCH` has gone out of favor at some point [[0](https://bugreports.qt.io/browse/QTBUG-21224)] [[1](https://bugreports.qt.io/browse/QTBUG-80582)]. It's not even [a documented qmake variable](https://doc.qt.io/qt-5/qmake-variable-reference.html). When compiling with a `message(QT_ARCH)`, the message would be empty. So it would always load up the x86 (32-bit) headers and then get compiler errors for some static asserts about pointer size assumptions. A little bit of digging found [`ANDROID_ABIS`](https://doc.qt.io/qt-5/qmake-variable-reference.html#android-abis) which is a list of the ABIs selected on the project panel in Qt Creator. That's better but not helpful for a multi-arch build where each arch needs to look at a different set of headers. @keith-bennett-airmap found Android documents the [`TARGET_ARCH`](https://developer.android.com/ndk/guides/android_mk#target_arch) and made an educated guess that it might be `ANDROID_TARGET_ARCH`. Seems to work though I'm 100% sure where the variable is getting set -- @keith-bennett-airmap assumes it's set by qmake while it iterates through `ANDROID_ABIS` since it's not in the build environment list on the project pane. While writing this comment, @keith-bennett-airmap found [this](https://stackoverflow.com/a/2658176) which is probably a more canonical answer for a more general (non-Android) solution: to use `QMAKE_TARGET.arch` --- .travis.yml | 6 +++--- src/VideoReceiver/README.md | 6 +++--- src/VideoReceiver/VideoReceiver.pri | 15 +++++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ac7826..6c98b6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,9 +107,9 @@ install: # android dependencies: qt, gstreamer, android-ndk - if [ "${SPEC}" = "android-clang" ]; then - wget --quiet https://qgroundcontrol.s3-us-west-2.amazonaws.com/dependencies/gstreamer-1.0-android-universal-1.18.1.tar.xz && - mkdir gstreamer-1.0-android-universal-1.18.1 && - tar xf gstreamer-1.0-android-universal-1.18.1.tar.xz -C gstreamer-1.0-android-universal-1.18.1 && + wget --quiet https://gstreamer.freedesktop.org/data/pkg/android/1.18.5/gstreamer-1.0-android-universal-1.18.5.tar.xz && + mkdir gstreamer-1.0-android-universal-1.18.5 && + tar xf gstreamer-1.0-android-universal-1.18.5.tar.xz -C gstreamer-1.0-android-universal-1.18.5 && wget --quiet https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip && unzip android-ndk-r20-linux-x86_64.zip > /dev/null && export ANDROID_NDK_ROOT=`pwd`/android-ndk-r20 && diff --git a/src/VideoReceiver/README.md b/src/VideoReceiver/README.md index 85f45d1..db79152 100644 --- a/src/VideoReceiver/README.md +++ b/src/VideoReceiver/README.md @@ -89,12 +89,12 @@ The installer places them under ~/Library/Developer/GStreamer/iPhone.sdk/GStream ### Android -Download the gstreamer from here: [gstreamer-1.0-android-universal-1.18.1.tar.xz](https://gstreamer.freedesktop.org/data/pkg/android/1.18.1/gstreamer-1.0-android-universal-1.18.1.tar.xz) +Download the gstreamer from here: [gstreamer-1.0-android-universal-1.18.5.tar.xz](https://gstreamer.freedesktop.org/data/pkg/android/1.18.5/gstreamer-1.0-android-universal-1.18.5.tar.xz) -Create a directory named "gstreamer-1.0-android-universal-1.18.1" under the root qgroundcontrol directory (the same directory qgroundcontrol.pro is located). Extract the downloaded archive under this directory. That's where the build system will look for it. Make sure your archive tool doesn't create any additional top level directories. The structure after extracting the archive should look like this: +Create a directory named "gstreamer-1.0-android-universal-1.18.5" under the root qgroundcontrol directory (the same directory qgroundcontrol.pro is located). Extract the downloaded archive under this directory. That's where the build system will look for it. Make sure your archive tool doesn't create any additional top level directories. The structure after extracting the archive should look like this: ``` qgroundcontrol -├── gstreamer-1.0-android-universal-1.18.1 +├── gstreamer-1.0-android-universal-1.18.5 │ │ │   ├──armv7 │   │   ├── bin diff --git a/src/VideoReceiver/VideoReceiver.pri b/src/VideoReceiver/VideoReceiver.pri index be3fb48..03f924e 100644 --- a/src/VideoReceiver/VideoReceiver.pri +++ b/src/VideoReceiver/VideoReceiver.pri @@ -62,13 +62,16 @@ LinuxBuild { QMAKE_POST_LINK += $$escape_expand(\\n) xcopy \"$$GST_ROOT_WIN\\lib\\gstreamer-1.0\\*.dll\" \"$$DESTDIR_WIN\\gstreamer-plugins\\\" /Y $$escape_expand(\\n) } } else:AndroidBuild { - #- gstreamer assumed to be installed in $$PWD/../../gstreamer-1.0-android-universal-1.18.1/*** - contains(QT_ARCH, arm) { - GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.1/armv7 - } else:contains(QT_ARCH, arm64) { - GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.1/arm64 + #- gstreamer assumed to be installed in $$PWD/../../gstreamer-1.0-android-universal-1.18.5/*** + contains(ANDROID_TARGET_ARCH, armeabi-v7a) { + GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.5/armv7 + } else:contains(ANDROID_TARGET_ARCH, arm64-v8a) { + GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.5/arm64 + } else:contains(ANDROID_TARGET_ARCH, x86_64) { + GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.5/x86_64 } else { - GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.1/x86 + message(Unknown ANDROID_TARGET_ARCH $$ANDROID_TARGET_ARCH) + GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.5/x86 } exists($$GST_ROOT) { QMAKE_CXXFLAGS += -pthread