Experimental MPV player backend Related to #14, #22, & #85 You can switch to MPV in advanced settings and toggle using hardware decoding or not. This uses code and buildscripts from https://github.com/mpv-android/mpv-android, plus other third party libraries to build MPV
38 lines
950 B
C++
38 lines
950 B
C++
#include <jni.h>
|
|
|
|
#include <mpv/client.h>
|
|
|
|
#include "jni_utils.h"
|
|
#include "log.h"
|
|
#include "globals.h"
|
|
|
|
extern "C" {
|
|
jni_func(void, attachSurface, jobject surface_);
|
|
jni_func(void, detachSurface);
|
|
};
|
|
|
|
static jobject surface;
|
|
|
|
jni_func(void, attachSurface, jobject surface_) {
|
|
CHECK_MPV_INIT();
|
|
|
|
surface = env->NewGlobalRef(surface_);
|
|
if (!surface)
|
|
die("invalid surface provided");
|
|
int64_t wid = reinterpret_cast<intptr_t>(surface);
|
|
int result = mpv_set_option(g_mpv, "wid", MPV_FORMAT_INT64, &wid);
|
|
if (result < 0)
|
|
ALOGE("mpv_set_option(wid) returned error %s", mpv_error_string(result));
|
|
}
|
|
|
|
jni_func(void, detachSurface) {
|
|
CHECK_MPV_INIT();
|
|
|
|
int64_t wid = 0;
|
|
int result = mpv_set_option(g_mpv, "wid", MPV_FORMAT_INT64, &wid);
|
|
if (result < 0)
|
|
ALOGE("mpv_set_option(wid) returned error %s", mpv_error_string(result));
|
|
|
|
env->DeleteGlobalRef(surface);
|
|
surface = NULL;
|
|
}
|