From cdacdd91f8b399335ca7579ea3e8a7f656dd0858 Mon Sep 17 00:00:00 2001 From: Adrien Beraud <adrien.beraud@savoirfairelinux.com> Date: Sun, 14 May 2017 13:28:24 -0400 Subject: [PATCH] ffmpeg: setup jni on load Allows to make use of ffmpeg MediaCodec hardware accelerators. This patch requires ffmpeg to be built with the JNI module (see related patch in the daemon). Change-Id: If6454a5f27f895ef14ba8d378bae7c29ed87c8ad Reviewed-by: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com> --- build-daemon.sh | 1 + .../libringclient/src/main/jni/ringservice.c.template | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/build-daemon.sh b/build-daemon.sh index 017dcf757..252afd0a0 100755 --- a/build-daemon.sh +++ b/build-daemon.sh @@ -274,6 +274,7 @@ mkdir -p ${LIBRING_JNI_DIR} ${NDK_TOOLCHAIN_PATH}/clang++ --shared -Wall -Wextra ${ANDROID_APP_DIR}/libringclient/src/main/jni/ring_wrapper.cpp \ ${RING_BUILD_DIR}/src/.libs/libring.a \ -static-libstdc++ \ + -I${RING_SRC_DIR}/contrib/${TARGET_TUPLE}/include \ -I${RING_SRC_DIR}/src -L${RING_SRC_DIR}/contrib/${TARGET_TUPLE}/lib \ ${STRIP_ARG} --std=c++11 \ ${STATIC_LIBS_ALL} \ diff --git a/ring-android/libringclient/src/main/jni/ringservice.c.template b/ring-android/libringclient/src/main/jni/ringservice.c.template index 61c4e6126..564f340a7 100644 --- a/ring-android/libringclient/src/main/jni/ringservice.c.template +++ b/ring-android/libringclient/src/main/jni/ringservice.c.template @@ -1,4 +1,7 @@ #include "logger.h" +extern "C" { +#include "libavcodec/jni.h" +} JavaVM *gJavaVM; const char *kringservicePath = "cx/ring/daemon/RingserviceJNI"; @@ -18,6 +21,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { RING_INFO("JNI_OnLoad"); + if (av_jni_set_java_vm(vm, reserved)) { + RING_ERR("JNI_OnLoad: av_jni_set_java_vm failed"); + } + //Assume it is c++ r = vm->GetEnv ((void **) &env, JNI_VERSION_1_6); if (r != JNI_OK) { -- GitLab