Browse Source

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`
QGC4.4
Aleksey Kontsevich 3 years ago committed by Don Gagne
parent
commit
c606eb5e09
  1. 6
      .travis.yml
  2. 6
      src/VideoReceiver/README.md
  3. 15
      src/VideoReceiver/VideoReceiver.pri

6
.travis.yml

@ -107,9 +107,9 @@ install:
# android dependencies: qt, gstreamer, android-ndk # android dependencies: qt, gstreamer, android-ndk
- if [ "${SPEC}" = "android-clang" ]; then - 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 && 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.1 && mkdir gstreamer-1.0-android-universal-1.18.5 &&
tar xf gstreamer-1.0-android-universal-1.18.1.tar.xz -C gstreamer-1.0-android-universal-1.18.1 && 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 && 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 && unzip android-ndk-r20-linux-x86_64.zip > /dev/null &&
export ANDROID_NDK_ROOT=`pwd`/android-ndk-r20 && export ANDROID_NDK_ROOT=`pwd`/android-ndk-r20 &&

6
src/VideoReceiver/README.md

@ -89,12 +89,12 @@ The installer places them under ~/Library/Developer/GStreamer/iPhone.sdk/GStream
### Android ### 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 qgroundcontrol
├── gstreamer-1.0-android-universal-1.18.1 ├── gstreamer-1.0-android-universal-1.18.5
│ │ │ │
   ├──armv7    ├──armv7
     ├── bin      ├── bin

15
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) 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 { } else:AndroidBuild {
#- gstreamer assumed to be installed in $$PWD/../../gstreamer-1.0-android-universal-1.18.1/*** #- gstreamer assumed to be installed in $$PWD/../../gstreamer-1.0-android-universal-1.18.5/***
contains(QT_ARCH, arm) { contains(ANDROID_TARGET_ARCH, armeabi-v7a) {
GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.1/armv7 GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.5/armv7
} else:contains(QT_ARCH, arm64) { } else:contains(ANDROID_TARGET_ARCH, arm64-v8a) {
GST_ROOT = $$PWD/../../gstreamer-1.0-android-universal-1.18.1/arm64 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 { } 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) { exists($$GST_ROOT) {
QMAKE_CXXFLAGS += -pthread QMAKE_CXXFLAGS += -pthread

Loading…
Cancel
Save