Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add libsrt compile support for Android and mac #14

Merged
merged 4 commits into from Jan 12, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -2,3 +2,4 @@ build
ffmpeg-*
libsoxr-*
openssl-*
libsrt-*
@@ -0,0 +1,103 @@
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Zhang Rui <bbcallen@gmail.com>
#
# 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-libsrt.sh armv5|armv7a|arm64|x86|x86_64"
echo " compile-libsrt.sh all|all32"
echo " compile-libsrt.sh all64"
echo " compile-libsrt.sh clean"
echo " compile-libsrt.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-libsrt.sh armv7a
;;
armv5|armv7a|arm64|x86|x86_64)
echo_archs $FF_TARGET
sh tools/do-compile-libsrt.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-libsrt.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-libsrt.sh $ARCH
done
echo_nextstep_help
;;
clean)
echo_archs FF_ACT_ARCHS_64
for ARCH in $FF_ACT_ARCHS_ALL
do
if [ -d libsrt-$ARCH ]; then
cd libsrt-$ARCH && git clean -xdf && cd -
fi
done
rm -rf ./build/libsrt-*
;;
check)
echo_archs FF_ACT_ARCHS_ALL
;;
*)
echo_usage
exit 1
;;
esac
@@ -40,7 +40,7 @@ fi


FF_BUILD_ROOT=`pwd`
FF_ANDROID_PLATFORM=android-9
FF_ANDROID_PLATFORM=android-14


FF_BUILD_NAME=
@@ -52,6 +52,9 @@ FF_DEP_OPENSSL_LIB=
FF_DEP_LIBSOXR_INC=
FF_DEP_LIBSOXR_LIB=

FF_DEP_LIBSRT_INC=
FF_DEP_LIBSRT_LIB=

FF_CFG_FLAGS=

FF_EXTRA_CFLAGS=
@@ -79,6 +82,7 @@ if [ "$FF_ARCH" = "armv7a" ]; then
FF_BUILD_NAME=ffmpeg-armv7a
FF_BUILD_NAME_OPENSSL=openssl-armv7a
FF_BUILD_NAME_LIBSOXR=libsoxr-armv7a
FF_BUILD_NAME_LIBSRT=libsrt-armv7a
FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

FF_CROSS_PREFIX=arm-linux-androideabi
@@ -97,6 +101,7 @@ elif [ "$FF_ARCH" = "armv5" ]; then
FF_BUILD_NAME=ffmpeg-armv5
FF_BUILD_NAME_OPENSSL=openssl-armv5
FF_BUILD_NAME_LIBSOXR=libsoxr-armv5
FF_BUILD_NAME_LIBSRT=libsrt-armv5
FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

FF_CROSS_PREFIX=arm-linux-androideabi
@@ -113,6 +118,7 @@ elif [ "$FF_ARCH" = "x86" ]; then
FF_BUILD_NAME=ffmpeg-x86
FF_BUILD_NAME_OPENSSL=openssl-x86
FF_BUILD_NAME_LIBSOXR=libsoxr-x86
FF_BUILD_NAME_LIBSRT=libsrt-x86
FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

FF_CROSS_PREFIX=i686-linux-android
@@ -131,6 +137,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_BUILD_NAME_LIBSRT=libsrt-x86_64
FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

FF_CROSS_PREFIX=x86_64-linux-android
@@ -149,6 +156,7 @@ elif [ "$FF_ARCH" = "arm64" ]; then
FF_BUILD_NAME=ffmpeg-arm64
FF_BUILD_NAME_OPENSSL=openssl-arm64
FF_BUILD_NAME_LIBSOXR=libsoxr-arm64
FF_BUILD_NAME_LIBSRT=libsrt-arm64
FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

FF_CROSS_PREFIX=aarch64-linux-android
@@ -158,7 +166,6 @@ elif [ "$FF_ARCH" = "arm64" ]; then

FF_EXTRA_CFLAGS="$FF_EXTRA_CFLAGS"
FF_EXTRA_LDFLAGS="$FF_EXTRA_LDFLAGS"

FF_ASSEMBLER_SUB_DIRS="aarch64 neon"

else
@@ -175,15 +182,20 @@ if [ ! -d $FF_SOURCE ]; then
exit 1
fi

FF_TOOLCHAIN_PATH=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/toolchain
FF_TOOLCHAIN_PATH=$FF_BUILD_ROOT/build/toolchain-$FF_ARCH
FF_MAKE_TOOLCHAIN_FLAGS="$FF_MAKE_TOOLCHAIN_FLAGS --install-dir=$FF_TOOLCHAIN_PATH"

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
FF_PREFIX=$FF_BUILD_ROOT/build/output-$FF_ARCH

FF_DEP_OPENSSL_INC=$FF_PREFIX/include
FF_DEP_OPENSSL_LIB=$FF_PREFIX/lib

FF_DEP_LIBSOXR_INC=$FF_PREFIX/include
FF_DEP_LIBSOXR_LIB=$FF_PREFIX/lib

FF_DEP_LIBSRT_INC=$FF_PREFIX/include
FF_DEP_LIBSRT_LIB=$FF_PREFIX/lib

case "$UNAME_S" in
CYGWIN_NT-*)
@@ -214,7 +226,7 @@ echo "[*] check ffmpeg env"
echo "--------------------"
export PATH=$FF_TOOLCHAIN_PATH/bin/:$PATH
#export CC="ccache ${FF_CROSS_PREFIX}-gcc"
export CC="${FF_CROSS_PREFIX}-gcc"
export CC=${FF_CROSS_PREFIX}-gcc
export LD=${FF_CROSS_PREFIX}-ld
export AR=${FF_CROSS_PREFIX}-ar
export STRIP=${FF_CROSS_PREFIX}-strip
@@ -258,6 +270,19 @@ if [ -f "${FF_DEP_LIBSOXR_LIB}/libsoxr.a" ]; then
FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_LIBSOXR_LIB} -lsoxr"
fi

if [ -f "${FF_DEP_LIBSRT_LIB}/libsrt.a" ]; then
echo "libsrt detected"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-libsrt"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-protocol=libsrt"

FF_CFLAGS="$FF_CFLAGS -I${FF_DEP_LIBSRT_INC}"
FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_LIBSRT_LIB} -lsrt -lc -lm -ldl -lcrypto -lssl -lstdc++"
fi

export PKG_CONFIG_PATH="${FF_PREFIX}/lib/pkgconfig"

FF_CFG_FLAGS="$FF_CFG_FLAGS --pkgconfigdir=${FF_PREFIX}/lib/pkgconfig"

FF_CFG_FLAGS="$FF_CFG_FLAGS $COMMON_FF_CFG_FLAGS"

#--------------------
@@ -269,6 +294,7 @@ FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-prefix=${FF_CROSS_PREFIX}-"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-cross-compile"
FF_CFG_FLAGS="$FF_CFG_FLAGS --target-os=linux"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-pic"
FF_CFG_FLAGS="$FF_CFG_FLAGS --pkg-config=pkg-config"
# FF_CFG_FLAGS="$FF_CFG_FLAGS --disable-symver"

if [ "$FF_ARCH" = "x86" ]; then
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.