[android] Initial implementation for MediaCodec

This commit is contained in:
CamilleLaVey
2026-07-07 19:01:42 -04:00
parent 6a3f885e46
commit a1b7cd51b4
4 changed files with 23 additions and 0 deletions
+4
View File
@@ -123,6 +123,10 @@ namespace Common::Android {
return owned.env;
}
JavaVM *GetJavaVM() {
return s_java_vm;
}
jclass GetNativeLibraryClass() {
return s_native_library_class;
}
+1
View File
@@ -12,6 +12,7 @@
namespace Common::Android {
JNIEnv* GetEnvForThread();
JavaVM* GetJavaVM();
/**
* Starts a new thread to run JNI. Intended to be used when you must run JNI from a fiber.
+13
View File
@@ -19,8 +19,16 @@ extern "C" {
#endif
#include <libavutil/hwcontext.h>
#if defined(__ANDROID__)
#include <libavcodec/jni.h>
#endif
}
#if defined(__ANDROID__)
#include "common/android/id_cache.h"
#endif
namespace FFmpeg {
namespace {
@@ -290,6 +298,11 @@ bool DecodeApi::Initialize(Tegra::Host1x::NvdecCommon::VideoCodec codec) {
// Enable GPU decoding if requested.
if (Settings::values.nvdec_emulation.GetValue() == Settings::NvdecEmulation::Gpu) {
#if defined(__ANDROID__)
static const int jni_vm_result =
av_jni_set_java_vm(Common::Android::GetJavaVM(), nullptr);
(void)jni_vm_result;
#endif
m_hardware_context.emplace();
m_hardware_context->InitializeForDecoder(*m_decoder_context, *m_decoder);
}