Returns FFmpeg version bundled within the library natively. + * + * @return FFmpeg version + */ + native static String getNativeFFmpegVersion(); + + /** + *
Returns MobileFFmpeg library version natively. + * + * @return MobileFFmpeg version + */ + native static String getNativeVersion(); + + /** + *
Synchronously executes FFmpeg natively with arguments provided. + * + * @param arguments FFmpeg command options/arguments as string array + * @return zero on successful execution, 255 on user cancel and non-zero on error + */ + native static int nativeExecute(final String[] arguments); + + /** + *
Cancels an ongoing operation natively. + * + *
This function does not wait for termination to complete and returns immediately. + */ + native static void nativeCancel(); + } diff --git a/android/app/src/main/java/com/arthenica/mobileffmpeg/FFmpeg.java b/android/app/src/main/java/com/arthenica/mobileffmpeg/FFmpeg.java index 4574e01c2..4501d89f7 100644 --- a/android/app/src/main/java/com/arthenica/mobileffmpeg/FFmpeg.java +++ b/android/app/src/main/java/com/arthenica/mobileffmpeg/FFmpeg.java @@ -37,8 +37,6 @@ public class FFmpeg { public static final int RETURN_CODE_CANCEL = 255; static { - System.loadLibrary("mobileffmpeg"); - AbiDetect.class.getName(); Config.class.getName(); } @@ -54,14 +52,18 @@ private FFmpeg() { * * @return FFmpeg version */ - public native static String getFFmpegVersion(); + public static String getFFmpegVersion() { + return Config.getNativeFFmpegVersion(); + } /** *
Returns MobileFFmpeg library version. * * @return MobileFFmpeg version */ - public native static String getVersion(); + public static String getVersion() { + return Config.getNativeVersion(); + } /** *
Synchronously executes FFmpeg with arguments provided. @@ -69,7 +71,9 @@ private FFmpeg() { * @param arguments FFmpeg command options/arguments as string array * @return zero on successful execution, 255 on user cancel and non-zero on error */ - public native static int execute(final String[] arguments); + public static int execute(final String[] arguments) { + return Config.nativeExecute(arguments); + } /** *
Synchronously executes FFmpeg with arguments provided. @@ -86,6 +90,8 @@ public static int execute(final String arguments) { * *
This function does not wait for termination to complete and returns immediately. */ - public native static void cancel(); + public static void cancel() { + Config.nativeCancel(); + } } diff --git a/android/jni/Android.mk b/android/jni/Android.mk index e31589448..0b8efb250 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -25,19 +25,10 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_ARM_MODE := $(MY_ARM_MODE) LOCAL_MODULE := mobileffmpeg -LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c +LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include LOCAL_LDLIBS := -llog -lz -landroid -LOCAL_SHARED_LIBRARIES := c++_shared mobileffmpeg-config -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_ARM_MODE := $(MY_ARM_MODE) -LOCAL_MODULE := mobileffmpeg-config -LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg_config.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c -LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include -LOCAL_LDLIBS := -llog -lz -landroid -LOCAL_SHARED_LIBRARIES := libavfilter libavformat libavcodec libavutil libswresample libavdevice libswscale +LOCAL_SHARED_LIBRARIES := c++_shared libavfilter libavformat libavcodec libavutil libswresample libavdevice libswscale include $(BUILD_SHARED_LIBRARY) ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) @@ -45,11 +36,11 @@ ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) include $(CLEAR_VARS) LOCAL_ARM_MODE := $(MY_ARM_MODE) - LOCAL_MODULE := mobileffmpeg-config-armv7a-neon - LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg_config.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c + LOCAL_MODULE := mobileffmpeg-armv7a-neon + LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include LOCAL_LDLIBS := -llog -lz -landroid - LOCAL_SHARED_LIBRARIES := libavcodec-neon libavfilter-neon libswscale-neon libavformat libavutil libswresample libavdevice + LOCAL_SHARED_LIBRARIES := c++_shared libavcodec-neon libavfilter-neon libswscale-neon libavformat libavutil libswresample libavdevice LOCAL_ARM_NEON := true include $(BUILD_SHARED_LIBRARY) diff --git a/android/test-app/build.gradle b/android/test-app/build.gradle index 2413d77b4..e297ad611 100644 --- a/android/test-app/build.gradle +++ b/android/test-app/build.gradle @@ -20,7 +20,8 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.arthenica:mobile-ffmpeg-full:2.1' + // implementation 'com.arthenica:mobile-ffmpeg-full:2.1' + implementation project(':app') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'