rtmp编译so

环境:

win7 、ndk-r10e

1 下载rtmp源码。

$ git clone git://git.ffmpeg.org/rtmpdump
Cloning into 'rtmpdump'...
remote: Counting objects: 2604, done.
remote: Compressing objects: 100% (965/965), done.
remote: Total 2604 (delta 1962), reused 2149 (delta 1638)
Receiving objects: 100% (2604/2604), 807.14 KiB | 208.00 KiB/s, done.
Resolving deltas: 100% (1962/1962), done.

生成rtmpdump目录,其目录下文件:

rtmp编译so_第1张图片

2 配置

将除librtmp目录的文件删除,创建jni文件夹,将librtmp文件夹拷入jni目录。由于librtmp依赖于openssl,所以我将编译好的libssl.so和libcrypto.so拷入该目录下。创建Android.mk文件和Application.mk文件。


Application.mk内容

APP_ABI  :=  armeabi-v7a
Android.mk内容

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

include $(CLEAR_VARS)
LOCAL_MODULE    := crypto
LOCAL_SRC_FILES := libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
###########################################
include $(CLEAR_VARS)
LOCAL_MODULE    := ssl
LOCAL_SRC_FILES := libssl.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/openssl
include $(PREBUILT_SHARED_LIBRARY)
###########################################

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
		librtmp/amf.c      \
		librtmp/hashswf.c  \
		librtmp/log.c      \
		librtmp/parseurl.c \
		librtmp/rtmp.c

LOCAL_LDLIBS    += -lm -llog -lz
LOCAL_CFLAGS +=  -D__STDC_CONSTANT_MACROS

LOCAL_C_INCLUDES :=                    		\
		$(LOCAL_PATH)                   \
		$(LOCAL_PATH)/include

LOCAL_MODULE:= librtmp

LOCAL_STATIC_LIBRARIES := \
			crypto \
			ssl


LOCAL_MODULE_TAGS:= optional

include $(BUILD_SHARED_LIBRARY)

整体目录:

rtmp编译so_第2张图片


3 进入到工程目录下编译

ndk-build

rtmp编译so_第3张图片

在rtmpdump\libs\armeabi-v7a目录下生成三个so


你可能感兴趣的:(Android,基础)