1乏奥、下載 x264的源代碼 (http://www.videolan.org/developers/x264.html)
git clone git://git.videolan.org/x264.git
2、編寫編譯腳本
NDK_ROOT=/root/android/android-ndk-r15b
SYSROOT=$NDK_ROOT/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
function build_one
{
./configure \
--prefix=$PREFIX \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--sysroot=$SYSROOT \
--host=arm-linux \
--enable-pic \
--enable-static \
--disable-asm \
--disable-shared \
--disable-cli
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
build_one
3亥曹、編譯
cd x264
chmod u+x build_android.sh
./build_android.sh
4邓了、下載 faac 的源代碼 (http://www.audiocoding.com/downloads.html)
wget https://nchc.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
5、編寫編譯腳本
#!/bash/bin
CPU=arm
NDK_ROOT=/root/android/android-ndk-r15b
export PLATFORM=$NDK_ROOT/platforms/android-9/arch-arm
export PREBUILT=$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
export PREFIX="$(pwd)/android/arm"
export CROSS_COMPILE=$PREBUILT/arm-linux-androideabi-
export CFLAGS="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300"
export CPPFLAGS="$CFLAGS"
export CFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
export CXX="${CROSS_COMPILE}g++ --sysroot=${PLATFORM}"
export LDFLAGS="$LDFLAGS"
export CC="${CROSS_COMPILE}gcc --sysroot=${PLATFORM}"
export NM="${CROSS_COMPILE}nm"
export STRIP="${CROSS_COMPILE}strip"
export RANLIB="${CROSS_COMPILE}ranlib"
export AR="${CROSS_COMPILE}ar"
./configure --program-prefix=$PREFIX --without-mp4v2 --host=arm-linux
mkdir -p $PREFIX/lib
cp ./libfaac/.libs/*.a $PREFIX/lib
cp ./libfaac/.libs/*.so $PREFIX/lib
mkdir -p $PREFIX/include
cp ./include/*.h $PREFIX/include
6媳瞪、編譯
chmod u+x build_android.sh
./build_android.sh
7骗炉、rtmpdump 源代碼下載
wget http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz
8、直接使用 as 編譯 rtmpdump
拷貝解壓后的 librtmp 到 cpp 文件夾蛇受,在librtmp中新建 CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
# close openssl
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_CRYPTO")
file(GLOB RTMP_SRC *.c)
add_library(rtmp
STATIC
${RTMP_SRC}
)
9句葵、在 app 目錄下的 CMakeLists.txt 關(guān)聯(lián) librtmp/CMakeLists.txt
add_subdirectory(src/main/cpp/librtmp)