Loading...
Searching...
No Matches
ffmpegkit_abidetect.c
Go to the documentation of this file.
/*
* Copyright (c) 2018-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cpu-features.h"
#include "fftools_ffmpeg.h"
#include "ffmpegkit_abidetect.h"
const char *abiDetectClassName = "com/arthenica/ffmpegkit/AbiDetect";
JNINativeMethod abiDetectMethods[] = {
{"getNativeAbi", "()Ljava/lang/String;", (void*) Java_com_arthenica_ffmpegkit_AbiDetect_getNativeAbi},
{"getNativeCpuAbi", "()Ljava/lang/String;", (void*) Java_com_arthenica_ffmpegkit_AbiDetect_getNativeCpuAbi},
{"isNativeLTSBuild", "()Z", (void*) Java_com_arthenica_ffmpegkit_AbiDetect_isNativeLTSBuild},
{"getNativeBuildConf", "()Ljava/lang/String;", (void*) Java_com_arthenica_ffmpegkit_AbiDetect_getNativeBuildConf}
};
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
LOGE("OnLoad failed to GetEnv for class %s.\n", abiDetectClassName);
return JNI_FALSE;
}
jclass abiDetectClass = (*env)->FindClass(env, abiDetectClassName);
if (abiDetectClass == NULL) {
LOGE("OnLoad failed to FindClass %s.\n", abiDetectClassName);
return JNI_FALSE;
}
if ((*env)->RegisterNatives(env, abiDetectClass, abiDetectMethods, 4) < 0) {
LOGE("OnLoad failed to RegisterNatives for class %s.\n", abiDetectClassName);
return JNI_FALSE;
}
return JNI_VERSION_1_6;
}
JNIEXPORT jstring JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_getNativeAbi(JNIEnv *env, jclass object) {
#ifdef FFMPEG_KIT_ARM_V7A
return (*env)->NewStringUTF(env, "arm-v7a");
#elif FFMPEG_KIT_ARM64_V8A
return (*env)->NewStringUTF(env, "arm64-v8a");
#elif FFMPEG_KIT_X86
return (*env)->NewStringUTF(env, "x86");
#elif FFMPEG_KIT_X86_64
return (*env)->NewStringUTF(env, "x86_64");
#else
return (*env)->NewStringUTF(env, "unknown");
#endif
}
JNIEXPORT jstring JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_getNativeCpuAbi(JNIEnv *env, jclass object) {
AndroidCpuFamily family = android_getCpuFamily();
if (family == ANDROID_CPU_FAMILY_ARM) {
uint64_t features = android_getCpuFeatures();
if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) {
if (features & ANDROID_CPU_ARM_FEATURE_NEON) {
return (*env)->NewStringUTF(env, ABI_ARMV7A_NEON);
} else {
return (*env)->NewStringUTF(env, ABI_ARMV7A);
}
} else {
return (*env)->NewStringUTF(env, ABI_ARM);
}
} else if (family == ANDROID_CPU_FAMILY_ARM64) {
return (*env)->NewStringUTF(env, ABI_ARM64_V8A);
} else if (family == ANDROID_CPU_FAMILY_X86) {
return (*env)->NewStringUTF(env, ABI_X86);
} else if (family == ANDROID_CPU_FAMILY_X86_64) {
return (*env)->NewStringUTF(env, ABI_X86_64);
} else {
return (*env)->NewStringUTF(env, ABI_UNKNOWN);
}
}
JNIEXPORT jboolean JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_isNativeLTSBuild(JNIEnv *env, jclass object) {
#if defined(FFMPEG_KIT_LTS)
return JNI_TRUE;
#else
return JNI_FALSE;
#endif
}
JNIEXPORT jstring JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_getNativeBuildConf(JNIEnv *env, jclass object) {
return (*env)->NewStringUTF(env, FFMPEG_CONFIGURATION);
}
LOGE
#define LOGE(...)
Definition ffmpegkit.h:48
Java_com_arthenica_ffmpegkit_AbiDetect_getNativeAbi
JNIEXPORT jstring JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_getNativeAbi(JNIEnv *env, jclass object)
Definition ffmpegkit_abidetect.c:70
Java_com_arthenica_ffmpegkit_AbiDetect_getNativeBuildConf
JNIEXPORT jstring JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_getNativeBuildConf(JNIEnv *env, jclass object)
Definition ffmpegkit_abidetect.c:142
Java_com_arthenica_ffmpegkit_AbiDetect_isNativeLTSBuild
JNIEXPORT jboolean JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_isNativeLTSBuild(JNIEnv *env, jclass object)
Definition ffmpegkit_abidetect.c:127
abiDetectClassName
const char * abiDetectClassName
Definition ffmpegkit_abidetect.c:25
JNI_OnLoad
jint JNI_OnLoad(JavaVM *vm, void *reserved)
Definition ffmpegkit_abidetect.c:42
abiDetectMethods
JNINativeMethod abiDetectMethods[]
Definition ffmpegkit_abidetect.c:28
Java_com_arthenica_ffmpegkit_AbiDetect_getNativeCpuAbi
JNIEXPORT jstring JNICALL Java_com_arthenica_ffmpegkit_AbiDetect_getNativeCpuAbi(JNIEnv *env, jclass object)
Definition ffmpegkit_abidetect.c:93
ffmpegkit_abidetect.h
ABI_X86_64
#define ABI_X86_64
Definition ffmpegkit_abidetect.h:39
ABI_ARM
#define ABI_ARM
Definition ffmpegkit_abidetect.h:33
ABI_ARMV7A_NEON
#define ABI_ARMV7A_NEON
Definition ffmpegkit_abidetect.h:27
ABI_X86
#define ABI_X86
Definition ffmpegkit_abidetect.h:36
ABI_UNKNOWN
#define ABI_UNKNOWN
Definition ffmpegkit_abidetect.h:45
ABI_ARM64_V8A
#define ABI_ARM64_V8A
Definition ffmpegkit_abidetect.h:42
ABI_ARMV7A
#define ABI_ARMV7A
Definition ffmpegkit_abidetect.h:30
fftools_ffmpeg.h