81fa4f5cad59af6cc8025390c79ae569.png

1.下载源码

git clone git://git.ffmpeg.org/rtmpdump

2.ndk生成toolchain

/Users/arikes/Third/Android/ndk/android-ndk-r10e/build/tools/make-standalone-toolchain.sh --platform=android-19 --install-dir=/Users/arikes/Third/Android/tmp/android-19-toolchain


ps:
Error:Unable to auto-config arch from toolchain
A.先看看你的ndk支持编译哪些cpu
~/android-ndk$ ls toolchains/
aarch64-linux-android-4.9        mipsel-linux-android-4.8
aarch64-linux-android-clang3.4   mipsel-linux-android-4.9
aarch64-linux-android-clang3.5   mipsel-linux-android-clang3.4
arm-linux-androideabi-4.6        mipsel-linux-android-clang3.5
arm-linux-androideabi-4.8        renderscript
arm-linux-androideabi-4.9        x86-4.6
arm-linux-androideabi-clang3.4   x86-4.8
arm-linux-androideabi-clang3.5   x86-4.9
llvm-3.4                         x86_64-4.9
llvm-3.5                         x86_64-clang3.4
mips64el-linux-android-4.9       x86_64-clang3.5
mips64el-linux-android-clang3.4  x86-clang3.4
mips64el-linux-android-clang3.5  x86-clang3.5
mipsel-linux-android-4.6

b.编辑 make-standalone-toolchain.sh,找到并修改 TOOLCHAIN_NAME= 为TOOLCHAIN_NAME=arm-linux-androideabi-4.9

//最后实际上没有使用上述toolchain

3.开始准备编译工程

3.1 新建一个jni目录,目录结构如上。然后将下载RTMPDump的头文件(.h)拷贝到include中,将.c文件拷贝到src中。

3.2 然后需要在jni目录下新建Android.mk和Application.mk文件

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := librtmp
LOCAL_SRC_FILES := 
    src/amf.c 
    src/hashswf.c 
    src/log.c 
    src/parseurl.c 
    src/rtmp.c 

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_CFLAGS := -Wall -O2 -DSYS=posix -DNO_CRYPTO
TARGET_PLATFORM := android-23

### librtmp library ###
### shared library use the first line
### static library use the second line
### !!! only one line can be used !!! ###

include $(BUILD_SHARED_LIBRARY)
#include $(BUILD_STATIC_LIBRARY)

Application.mk

APP_ABI := all

3.3 到此就配置完成了在rtmp的根目录下执行

[root@MiWiFi-R2D-srv home]# ndk-build

3.4 具体使用参考如下:

https://www.jianshu.com/p/3ee9e5e4d630

参考:

librtmp开源库与android平台编译记录_LinChengChun的博客-CSDN博客​blog.csdn.net
bf933e7dfc2b2865ddb08849fe9250ac.png
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐