Simplify IAMF extension build process
Removed `Android.mk` and `Application.mk`, allowing `CMake` to run directly from the `build.gradle` file. Users no longer need to check out `NDK` or depend on it, simplifying the usage of the IAMF extension. PiperOrigin-RevId: 684471874
This commit is contained in:
parent
1729e11159
commit
6acddfeee6
@ -1,7 +1,7 @@
|
|||||||
# IAMF decoder module
|
# IAMF decoder module
|
||||||
|
|
||||||
The IAMF module provides `LibiamfAudioRenderer`, which uses libiamf (the IAMF
|
The IAMF module provides `LibiamfAudioRenderer`, which uses the libiamf native
|
||||||
decoding library) to decode IAMF audio.
|
library to decode IAMF audio.
|
||||||
|
|
||||||
## License note
|
## License note
|
||||||
|
|
||||||
@ -17,58 +17,33 @@ To use the module you need to clone this GitHub project and depend on its
|
|||||||
modules locally. Instructions for doing this can be found in the
|
modules locally. Instructions for doing this can be found in the
|
||||||
[top level README][].
|
[top level README][].
|
||||||
|
|
||||||
In addition, it's necessary to build the module's native components as follows:
|
In addition, it's necessary to fetch libiamf as follows:
|
||||||
|
|
||||||
* Set the following environment variables:
|
* Set the following environment variables:
|
||||||
|
|
||||||
```
|
```
|
||||||
cd "<path to project checkout>"
|
cd "<path to project checkout>"
|
||||||
|
|
||||||
IAMF_MODULE_PATH="$(pwd)/libraries/decoder_iamf/src/main"
|
IAMF_MODULE_PATH="$(pwd)/libraries/decoder_iamf/src/main"
|
||||||
```
|
```
|
||||||
|
|
||||||
* Download the [Android NDK][] and set its location in an environment
|
|
||||||
variable. This build configuration has been tested on NDK r27.
|
|
||||||
|
|
||||||
```
|
|
||||||
NDK_PATH="<path to Android NDK>"
|
|
||||||
```
|
|
||||||
|
|
||||||
* Fetch libiamf:
|
* Fetch libiamf:
|
||||||
|
|
||||||
Clone the repository containing libiamf to a local folder of choice - preferably
|
|
||||||
outside of the project checkout. Link it to the project's jni folder through
|
|
||||||
symlink.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
cd <preferred location for libiamf>
|
cd "${IAMF_MODULE_PATH}/jni" && \
|
||||||
|
git clone https://github.com/AOMediaCodec/libiamf.git
|
||||||
|
|
||||||
git clone https://github.com/AOMediaCodec/libiamf.git libiamf && \
|
|
||||||
cd libiamf && \
|
|
||||||
LIBIAMF_PATH=$(pwd)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* Symlink the folder containing libiamf to the project's JNI folder and run
|
* [Install CMake][]
|
||||||
the script to convert libiamf code to NDK compatible format:
|
|
||||||
|
|
||||||
```
|
Having followed these steps, gradle will build the module automatically when run
|
||||||
cd "${IAMF_MODULE_PATH}"/jni && \
|
on the command line or via Android Studio, using [CMake][] and [Ninja][] to
|
||||||
ln -s $LIBIAMF_PATH libiamf && \
|
configure and build libiamf and the module's [JNI wrapper library][].
|
||||||
cd libiamf/code &&\
|
|
||||||
cmake . && \
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
* Build the JNI native libraries from the command line:
|
|
||||||
|
|
||||||
```
|
|
||||||
cd "${IAMF_MODULE_PATH}"/jni && \
|
|
||||||
${NDK_PATH}/ndk-build APP_ABI=all -j4
|
|
||||||
```
|
|
||||||
|
|
||||||
[top level README]: ../../README.md
|
[top level README]: ../../README.md
|
||||||
[Android NDK]: https://developer.android.com/tools/sdk/ndk/index.html
|
[Install CMake]: https://developer.android.com/studio/projects/install-ndk
|
||||||
|
[CMake]: https://cmake.org/
|
||||||
|
[Ninja]: https://ninja-build.org
|
||||||
|
[JNI wrapper library]: src/main/jni/iamf_jni.cc
|
||||||
|
|
||||||
## Build instructions (Windows)
|
## Build instructions (Windows)
|
||||||
|
|
||||||
@ -77,13 +52,6 @@ be possible to follow the Linux instructions in [Windows PowerShell][].
|
|||||||
|
|
||||||
[Windows PowerShell]: https://docs.microsoft.com/en-us/powershell/scripting/getting-started/getting-started-with-windows-powershell
|
[Windows PowerShell]: https://docs.microsoft.com/en-us/powershell/scripting/getting-started/getting-started-with-windows-powershell
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
* Every time there is a change to the libiamf checkout clean and re-build the
|
|
||||||
project.
|
|
||||||
* If you want to use your own version of libiamf, place it in
|
|
||||||
`${IAMF_MODULE_PATH}/jni/libiamf`.
|
|
||||||
|
|
||||||
## Using the module with ExoPlayer
|
## Using the module with ExoPlayer
|
||||||
|
|
||||||
Once you've followed the instructions above to check out, build and depend on
|
Once you've followed the instructions above to check out, build and depend on
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2024 The Android Open Source Project
|
// Copyright 2024 The Android Open Source Project
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -17,12 +17,32 @@ android {
|
|||||||
namespace 'androidx.media3.decoder.iamf'
|
namespace 'androidx.media3.decoder.iamf'
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
|
||||||
jniLibs.srcDir 'src/main/libs'
|
|
||||||
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
|
|
||||||
}
|
|
||||||
androidTest.assets.srcDir '../test_data/src/test/assets'
|
androidTest.assets.srcDir '../test_data/src/test/assets'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
targets "iamfJNI"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure the native build only if libiamf is present to avoid gradle sync
|
||||||
|
// failures if libiamf hasn't been built according to the README instructions.
|
||||||
|
if (project.file('src/main/jni/libiamf').exists()) {
|
||||||
|
android.externalNativeBuild.cmake {
|
||||||
|
path = 'src/main/jni/CMakeLists.txt'
|
||||||
|
version = '3.21.0+'
|
||||||
|
if (project.hasProperty('externalNativeBuildDir')) {
|
||||||
|
if (!new File(externalNativeBuildDir).isAbsolute()) {
|
||||||
|
ext.externalNativeBuildDir =
|
||||||
|
new File(rootDir, it.externalNativeBuildDir)
|
||||||
|
}
|
||||||
|
buildStagingDirectory = "${externalNativeBuildDir}/${project.name}"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (C) 2024 The Android Open Source Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
WORKING_DIR := $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
# build libiamf.a
|
|
||||||
LOCAL_PATH := $(WORKING_DIR)
|
|
||||||
include libiamf.mk
|
|
||||||
|
|
||||||
# build libiamfJNI.so
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
LOCAL_PATH := $(WORKING_DIR)
|
|
||||||
LOCAL_MODULE := libiamfJNI
|
|
||||||
LOCAL_ARM_MODE := arm
|
|
||||||
LOCAL_CPP_EXTENSION := .cc
|
|
||||||
LOCAL_SRC_FILES := iamf_jni.cc
|
|
||||||
LOCAL_LDLIBS := -llog -lz -lm
|
|
||||||
LOCAL_STATIC_LIBRARIES := libiamf
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
|
@ -1,18 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (C) 2024 The Android Open Source Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
APP_ABI := all
|
|
||||||
APP_PLATFORM := android-21
|
|
46
libraries/decoder_iamf/src/main/jni/CMakeLists.txt
Normal file
46
libraries/decoder_iamf/src/main/jni/CMakeLists.txt
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 The Android Open Source Project
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
# Enable C++11 features.
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
# Define project name for your JNI module
|
||||||
|
project(libiamfJNI C CXX)
|
||||||
|
|
||||||
|
set(libiamf_jni_root "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
# Build libiamf.
|
||||||
|
add_subdirectory("${libiamf_jni_root}/libiamf/code"
|
||||||
|
EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
# Add the include directory from libiamf.
|
||||||
|
include_directories ("${libiamf_jni_root}/libiamf/code/include")
|
||||||
|
|
||||||
|
# Build libiamfJNI.
|
||||||
|
add_library(iamfJNI
|
||||||
|
SHARED
|
||||||
|
iamf_jni.cc)
|
||||||
|
|
||||||
|
# Locate NDK log library.
|
||||||
|
find_library(android_log_lib log)
|
||||||
|
|
||||||
|
# Link libgav1JNI against used libraries.
|
||||||
|
target_link_libraries(iamfJNI
|
||||||
|
PRIVATE android
|
||||||
|
PRIVATE iamf
|
||||||
|
PRIVATE ${android_log_lib})
|
@ -1,35 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (C) 2024 The Android Open Source Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
LOCAL_PATH := $(WORKING_DIR)/libiamf
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE := libiamf
|
|
||||||
LOCAL_ARM_MODE := arm
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/code/include \
|
|
||||||
$(LOCAL_PATH)/code/src/iamf_dec \
|
|
||||||
$(LOCAL_PATH)/code/src/common \
|
|
||||||
$(LOCAL_PATH)/code/dep_codecs/include \
|
|
||||||
$(LOCAL_PATH)/code/dep_external/include
|
|
||||||
LOCAL_SRC_FILES := $(shell find $(LOCAL_PATH)/code/src -name "*.c")
|
|
||||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/code/include \
|
|
||||||
$(LOCAL_PATH)/code/src/iamf_dec \
|
|
||||||
$(LOCAL_PATH)/code/src/common \
|
|
||||||
$(LOCAL_PATH)/code/dep_codecs/include \
|
|
||||||
$(LOCAL_PATH)/code/dep_external/include
|
|
||||||
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
|
Loading…
x
Reference in New Issue
Block a user