diff --git a/android/contrib/compile-libsoxr.sh b/android/contrib/compile-libsoxr.sh new file mode 100755 index 0000000000000000000000000000000000000000..78df0cd34cdb0c6632425e1dca48110be52a5168 --- /dev/null +++ b/android/contrib/compile-libsoxr.sh @@ -0,0 +1,103 @@ +#! /usr/bin/env bash +# +# Copyright (C) 2013-2014 Zhang Rui +# +# 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. +# + +#---------- +UNI_BUILD_ROOT=`pwd` +FF_TARGET=$1 +set -e +set +x + +FF_ACT_ARCHS_32="armv5 armv7a x86" +FF_ACT_ARCHS_64="armv5 armv7a arm64 x86 x86_64" +FF_ACT_ARCHS_ALL=$FF_ACT_ARCHS_64 + +echo_archs() { + echo "====================" + echo "[*] check archs" + echo "====================" + echo "FF_ALL_ARCHS = $FF_ACT_ARCHS_ALL" + echo "FF_ACT_ARCHS = $*" + echo "" +} + +echo_usage() { + echo "Usage:" + echo " compile-libsoxr.sh armv5|armv7a|arm64|x86|x86_64" + echo " compile-libsoxr.sh all|all32" + echo " compile-libsoxr.sh all64" + echo " compile-libsoxr.sh clean" + echo " compile-libsoxr.sh check" + exit 1 +} + +echo_nextstep_help() { + #---------- + echo "" + echo "--------------------" + echo "[*] Finished" + echo "--------------------" + echo "# to continue to build ffmpeg, run script below," + echo "sh compile-ffmpeg.sh " + echo "# to continue to build ijkplayer, run script below," + echo "sh compile-ijk.sh " +} + +#---------- +case "$FF_TARGET" in + "") + echo_archs armv7a + sh tools/do-compile-libsoxr.sh armv7a + ;; + armv5|armv7a|arm64|x86|x86_64) + echo_archs $FF_TARGET + sh tools/do-compile-libsoxr.sh $FF_TARGET + echo_nextstep_help + ;; + all32) + echo_archs $FF_ACT_ARCHS_32 + for ARCH in $FF_ACT_ARCHS_32 + do + sh tools/do-compile-libsoxr.sh $ARCH + done + echo_nextstep_help + ;; + all|all64) + echo_archs $FF_ACT_ARCHS_64 + for ARCH in $FF_ACT_ARCHS_64 + do + sh tools/do-compile-libsoxr.sh $ARCH + done + echo_nextstep_help + ;; + clean) + echo_archs FF_ACT_ARCHS_64 + for ARCH in $FF_ACT_ARCHS_ALL + do + if [ -d libsoxr-$ARCH ]; then + cd libsoxr-$ARCH && git clean -xdf && cd - + fi + done + rm -rf ./build/libsoxr-* + ;; + check) + echo_archs FF_ACT_ARCHS_ALL + ;; + *) + echo_usage + exit 1 + ;; +esac diff --git a/android/contrib/tools/do-compile-ffmpeg.sh b/android/contrib/tools/do-compile-ffmpeg.sh index 450031ea474e83c3f0bbb81ff0bb331691c793b9..5aaf44042ad8d0441faf43144792f4c7e69551b4 100755 --- a/android/contrib/tools/do-compile-ffmpeg.sh +++ b/android/contrib/tools/do-compile-ffmpeg.sh @@ -49,6 +49,9 @@ FF_CROSS_PREFIX= FF_DEP_OPENSSL_INC= FF_DEP_OPENSSL_LIB= +FF_DEP_LIBSOXR_INC= +FF_DEP_LIBSOXR_LIB= + FF_CFG_FLAGS= FF_EXTRA_CFLAGS= @@ -75,6 +78,7 @@ FF_GCC_64_VER=$IJK_GCC_64_VER if [ "$FF_ARCH" = "armv7a" ]; then FF_BUILD_NAME=ffmpeg-armv7a FF_BUILD_NAME_OPENSSL=openssl-armv7a + FF_BUILD_NAME_LIBSOXR=libsoxr-armv7a FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME FF_CROSS_PREFIX=arm-linux-androideabi @@ -92,6 +96,7 @@ if [ "$FF_ARCH" = "armv7a" ]; then elif [ "$FF_ARCH" = "armv5" ]; then FF_BUILD_NAME=ffmpeg-armv5 FF_BUILD_NAME_OPENSSL=openssl-armv5 + FF_BUILD_NAME_LIBSOXR=libsoxr-armv5 FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME FF_CROSS_PREFIX=arm-linux-androideabi @@ -107,6 +112,7 @@ elif [ "$FF_ARCH" = "armv5" ]; then elif [ "$FF_ARCH" = "x86" ]; then FF_BUILD_NAME=ffmpeg-x86 FF_BUILD_NAME_OPENSSL=openssl-x86 + FF_BUILD_NAME_LIBSOXR=libsoxr-x86 FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME FF_CROSS_PREFIX=i686-linux-android @@ -124,6 +130,7 @@ elif [ "$FF_ARCH" = "x86_64" ]; then FF_BUILD_NAME=ffmpeg-x86_64 FF_BUILD_NAME_OPENSSL=openssl-x86_64 + FF_BUILD_NAME_LIBSOXR=libsoxr-x86_64 FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME FF_CROSS_PREFIX=x86_64-linux-android @@ -141,6 +148,7 @@ elif [ "$FF_ARCH" = "arm64" ]; then FF_BUILD_NAME=ffmpeg-arm64 FF_BUILD_NAME_OPENSSL=openssl-arm64 + FF_BUILD_NAME_LIBSOXR=libsoxr-arm64 FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME FF_CROSS_PREFIX=aarch64-linux-android @@ -174,6 +182,8 @@ FF_SYSROOT=$FF_TOOLCHAIN_PATH/sysroot FF_PREFIX=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output FF_DEP_OPENSSL_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/include FF_DEP_OPENSSL_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/lib +FF_DEP_LIBSOXR_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_LIBSOXR/output/include +FF_DEP_LIBSOXR_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_LIBSOXR/output/lib case "$UNAME_S" in CYGWIN_NT-*) @@ -237,9 +247,16 @@ if [ -f "${FF_DEP_OPENSSL_LIB}/libssl.a" ]; then FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-openssl" FF_CFLAGS="$FF_CFLAGS -I${FF_DEP_OPENSSL_INC}" - FF_DEP_LIBS="-L${FF_DEP_OPENSSL_LIB} -lssl -lcrypto" + FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_OPENSSL_LIB} -lssl -lcrypto" fi +if [ -f "${FF_DEP_LIBSOXR_LIB}/libsoxr.a" ]; then + echo "libsoxr detected" + FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-libsoxr" + + FF_CFLAGS="$FF_CFLAGS -I${FF_DEP_LIBSOXR_INC}" + FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_LIBSOXR_LIB} -lsoxr" +fi FF_CFG_FLAGS="$FF_CFG_FLAGS $COMMON_FF_CFG_FLAGS" @@ -284,6 +301,7 @@ else ./configure $FF_CFG_FLAGS \ --extra-cflags="$FF_CFLAGS $FF_EXTRA_CFLAGS" \ --extra-ldflags="$FF_DEP_LIBS $FF_EXTRA_LDFLAGS" + head config.log make clean fi @@ -293,7 +311,7 @@ echo "--------------------" echo "[*] compile ffmpeg" echo "--------------------" cp config.* $FF_PREFIX -make $FF_MAKE_FLAGS > /dev/null +make -j4 $FF_MAKE_FLAGS > /dev/null make install mkdir -p $FF_PREFIX/include/libffmpeg cp -f config.h $FF_PREFIX/include/libffmpeg/config.h diff --git a/android/contrib/tools/do-compile-libsoxr.sh b/android/contrib/tools/do-compile-libsoxr.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ea4215ed9399fc12f51c3274967089df035d495 --- /dev/null +++ b/android/contrib/tools/do-compile-libsoxr.sh @@ -0,0 +1,114 @@ +#! /usr/bin/env bash +# +# Copyright (C) 2014 Miguel Botón +# Copyright (C) 2014 Zhang Rui +# +# 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. +# + +#-------------------- +set -e + +if [ -z "$ANDROID_NDK" ]; then + echo "You must define ANDROID_NDK before starting." + echo "They must point to your NDK directories.\n" + exit 1 +fi + +#-------------------- +# common defines +FF_ARCH=$1 +if [ -z "$FF_ARCH" ]; then + echo "You must specific an architecture 'arm, armv7a, x86, ...'.\n" + exit 1 +fi + + +FF_BUILD_ROOT=`pwd` + +FF_BUILD_NAME= +FF_SOURCE= +FF_CROSS_PREFIX= + +FF_CFG_FLAGS= +FF_PLATFORM_CFG_FLAGS= + +FF_EXTRA_CFLAGS= +FF_EXTRA_LDFLAGS= + +FF_CMAKE_ABI= + +#----- armv7a begin ----- +if [ "$FF_ARCH" = "armv7a" ]; then + FF_BUILD_NAME=libsoxr-armv7a + FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME + + FF_CMAKE_ABI="armeabi-v7a with NEON" + +elif [ "$FF_ARCH" = "armv5" ]; then + FF_BUILD_NAME=libsoxr-armv5 + FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME + + FF_CMAKE_ABI="armeabi" + +elif [ "$FF_ARCH" = "x86" ]; then + FF_BUILD_NAME=libsoxr-x86 + FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME + + FF_CMAKE_ABI="x86" + +elif [ "$FF_ARCH" = "x86_64" ]; then + FF_ANDROID_PLATFORM=android-21 + + FF_BUILD_NAME=libsoxr-x86_64 + FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME + + FF_CMAKE_ABI="x86_64" + +elif [ "$FF_ARCH" = "arm64" ]; then + FF_ANDROID_PLATFORM=android-21 + + FF_BUILD_NAME=libsoxr-arm64 + FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME + + FF_CMAKE_ABI="arm64-v8a" + +else + echo "unknown architecture $FF_ARCH"; + exit 1 +fi + +FF_PREFIX=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output +FF_CMAKE_BUILD_DIR=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/build + +mkdir -p $FF_PREFIX +mkdir -p $FF_CMAKE_BUILD_DIR + +#-------------------- +echo "" +echo "--------------------" +echo "[*] configurate libsoxr" +echo "--------------------" +cd $FF_CMAKE_BUILD_DIR +FF_CMAKE_CFG_FLAGS="-DCMAKE_TOOLCHAIN_FILE=${FF_SOURCE}/android.toolchain.cmake -DANDROID_NDK=$ANDROID_NDK -DBUILD_EXAMPLES=0 -DBUILD_LSR_TESTS=0 -DBUILD_SHARED_LIBS=0 -DBUILD_TESTS=0 -DCMAKE_BUILD_TYPE=Release -DHAVE_WORDS_BIGENDIAN_EXITCODE=1 -DWITH_LSR_BINDINGS=0 -DWITH_OPENMP=0 -DWITH_PFFFT=0 -DWITH_SIMD=0" +echo "cmake $FF_CMAKE_CFG_FLAGS -DANDROID_ABI=$FF_CMAKE_ABI -DCMAKE_INSTALL_PREFIX=$FF_PREFIX" +cmake $FF_CMAKE_CFG_FLAGS -DCMAKE_INSTALL_PREFIX=$FF_PREFIX $FF_SOURCE + + +#-------------------- +echo "" +echo "--------------------" +echo "[*] compile libsoxr" +echo "--------------------" +make -j4 +make install diff --git a/init-android-libsoxr.sh b/init-android-libsoxr.sh new file mode 100755 index 0000000000000000000000000000000000000000..1e611c921216f48bd261bd68f0b1596163eb4e54 --- /dev/null +++ b/init-android-libsoxr.sh @@ -0,0 +1,52 @@ +#! /usr/bin/env bash +# +# Copyright (C) 2013-2015 Zhang Rui +# +# 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. +# + +IJK_LIBSOXR_UPSTREAM=http://git.code.sf.net/p/soxr/code +IJK_LIBSOXR_FORK=http://git.code.sf.net/p/soxr/code +IJK_LIBSOXR_COMMIT=0.1.2 +IJK_LIBSOXR_LOCAL_REPO=extra/soxr + +set -e +TOOLS=tools + +echo "== pull soxr base ==" +sh $TOOLS/pull-repo-base.sh $IJK_LIBSOXR_UPSTREAM $IJK_LIBSOXR_LOCAL_REPO + +function pull_fork() +{ + echo "== pull soxr fork $1 ==" + sh $TOOLS/pull-repo-ref.sh $IJK_LIBSOXR_FORK android/contrib/libsoxr-$1 ${IJK_LIBSOXR_LOCAL_REPO} + cp extra/android-cmake/android.toolchain.cmake android/contrib/libsoxr-$1 + cd android/contrib/libsoxr-$1 + git checkout ${IJK_LIBSOXR_COMMIT} -B ijkplayer + cd - +} + +function pull_android_toolchain_cmake() +{ + ANDROID_TOOLCHAIN_CMAKE_UPSTREAM=https://github.com/taka-no-me/android-cmake.git + echo "== pull android toolchain cmake from $ANDROID_TOOLCHAIN_CMAKE_UPSTREAM ==" + sh $TOOLS/pull-repo-base.sh $ANDROID_TOOLCHAIN_CMAKE_UPSTREAM extra/android-cmake +} + +pull_android_toolchain_cmake + +pull_fork "armv5" +pull_fork "armv7a" +pull_fork "arm64" +pull_fork "x86" +pull_fork "x86_64"