Update audio extension build configurations

- Fix FLAC extension build (currently broken due to use of std::array,
  but fixed by migrating to NDK r20).
- Move opus and ffmpeg extensions to NDK r20. For ffmpeg, upgrade to
  release 4.2 which requires using libswresample and updates to the
  build script.

Issue: #6601
PiperOrigin-RevId: 277924119
This commit is contained in:
andrewlewis 2019-11-01 14:38:22 +00:00 committed by Oliver Woodman
parent 2106e5f328
commit a4e7274cca
10 changed files with 36 additions and 20 deletions

View file

@ -107,6 +107,12 @@
* Fix the start of audio getting truncated when transitioning to a new
item in a playlist of opus streams.
* Fix detection of Dolby Atmos in HLS to match the HLS authoring specification.
* Fix FLAC extension build
([#6601](https://github.com/google/ExoPlayer/issues/6601).
* Update the ffmpeg, flac and opus extension build instructions to use NDK r20.
* Update the ffmpeg extension to release 4.2. It is necessary to rebuild the
native part of the extension after this change, following the instructions in
the extension's readme.
### 2.10.6 (2019-10-17) ###

View file

@ -29,7 +29,7 @@ FFMPEG_EXT_PATH="$(pwd)/extensions/ffmpeg/src/main/jni"
```
* Download the [Android NDK][] and set its location in a shell variable.
Only versions up to NDK 15c are supported currently.
This build configuration has been tested on NDK r20.
```
NDK_PATH="<path to Android NDK>"
@ -50,7 +50,7 @@ ENABLED_DECODERS=(vorbis opus flac)
```
* Fetch and build FFmpeg. For example, executing script `build_ffmpeg.sh` will
fetch and build FFmpeg release 4.0 for armeabi-v7a, arm64-v8a and x86:
fetch and build FFmpeg release 4.2 for armeabi-v7a, arm64-v8a and x86:
```
cd "${FFMPEG_EXT_PATH}" && \

View file

@ -34,7 +34,7 @@ public final class FfmpegLibrary {
private static final String TAG = "FfmpegLibrary";
private static final LibraryLoader LOADER =
new LibraryLoader("avutil", "avresample", "avcodec", "ffmpeg");
new LibraryLoader("avutil", "avresample", "swresample", "avcodec", "ffmpeg");
private FfmpegLibrary() {}

View file

@ -22,12 +22,17 @@ LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavutil
LOCAL_MODULE := libavresample
LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavresample
LOCAL_MODULE := libswresample
LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavutil
LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
@ -35,6 +40,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := ffmpeg_jni.cc
LOCAL_C_INCLUDES := ffmpeg
LOCAL_SHARED_LIBRARIES := libavcodec libavresample libavutil
LOCAL_SHARED_LIBRARIES := libavcodec libavresample libswresample libavutil
LOCAL_LDLIBS := -Lffmpeg/android-libs/$(TARGET_ARCH_ABI) -llog
include $(BUILD_SHARED_LIBRARY)

View file

@ -15,6 +15,6 @@
#
APP_OPTIM := release
APP_STL := gnustl_static
APP_STL := c++_static
APP_CPPFLAGS := -frtti
APP_PLATFORM := android-9

View file

@ -32,9 +32,10 @@ COMMON_OPTIONS="
--disable-postproc
--disable-avfilter
--disable-symver
--disable-swresample
--enable-avresample
--enable-swresample
"
TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
for decoder in "${ENABLED_DECODERS[@]}"
do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-decoder=${decoder}"
@ -42,13 +43,14 @@ done
cd "${FFMPEG_EXT_PATH}"
(git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
cd ffmpeg
git checkout release/4.0
git checkout release/4.2
./configure \
--libdir=android-libs/armeabi-v7a \
--arch=arm \
--cpu=armv7-a \
--cross-prefix="${NDK_PATH}/toolchains/arm-linux-androideabi-4.9/prebuilt/${HOST_PLATFORM}/bin/arm-linux-androideabi-" \
--sysroot="${NDK_PATH}/platforms/android-9/arch-arm/" \
--cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-" \
--nm="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-nm" \
--strip="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-strip" \
--extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
--extra-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \
@ -60,8 +62,9 @@ make clean
--libdir=android-libs/arm64-v8a \
--arch=aarch64 \
--cpu=armv8-a \
--cross-prefix="${NDK_PATH}/toolchains/aarch64-linux-android-4.9/prebuilt/${HOST_PLATFORM}/bin/aarch64-linux-android-" \
--sysroot="${NDK_PATH}/platforms/android-21/arch-arm64/" \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-" \
--nm="${TOOLCHAIN_PREFIX}/aarch64-linux-android-nm" \
--strip="${TOOLCHAIN_PREFIX}/aarch64-linux-android-strip" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS}
make -j4
@ -71,8 +74,9 @@ make clean
--libdir=android-libs/x86 \
--arch=x86 \
--cpu=i686 \
--cross-prefix="${NDK_PATH}/toolchains/x86-4.9/prebuilt/${HOST_PLATFORM}/bin/i686-linux-android-" \
--sysroot="${NDK_PATH}/platforms/android-9/arch-x86/" \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android16-" \
--nm="${TOOLCHAIN_PREFIX}/i686-linux-android-nm" \
--strip="${TOOLCHAIN_PREFIX}/i686-linux-android-strip" \
--extra-ldexeflags=-pie \
--disable-asm \
${COMMON_OPTIONS}

View file

@ -28,8 +28,8 @@ EXOPLAYER_ROOT="$(pwd)"
FLAC_EXT_PATH="${EXOPLAYER_ROOT}/extensions/flac/src/main"
```
* Download the [Android NDK][] (version <= 17c) and set its location in an
environment variable:
* Download the [Android NDK][] and set its location in an environment variable.
This build configuration has been tested on NDK r20.
```
NDK_PATH="<path to Android NDK>"

View file

@ -15,6 +15,6 @@
#
APP_OPTIM := release
APP_STL := gnustl_static
APP_STL := c++_static
APP_CPPFLAGS := -frtti
APP_PLATFORM := android-14

View file

@ -28,7 +28,8 @@ EXOPLAYER_ROOT="$(pwd)"
OPUS_EXT_PATH="${EXOPLAYER_ROOT}/extensions/opus/src/main"
```
* Download the [Android NDK][] and set its location in an environment variable:
* Download the [Android NDK][] and set its location in an environment variable.
This build configuration has been tested on NDK r20.
```
NDK_PATH="<path to Android NDK>"

View file

@ -15,6 +15,6 @@
#
APP_OPTIM := release
APP_STL := gnustl_static
APP_STL := c++_static
APP_CPPFLAGS := -frtti
APP_PLATFORM := android-9