[Android] [PATCH 1/2] LibVLC: factorize, only one way to know if we use direct rendering
Thomas Guillem
tom at gllm.fr
Wed Oct 8 12:00:02 CEST 2014
From: Thomas Guillem <thomas.guillem at gmail.com>
---
vlc-android/jni/libvlcjni.c | 14 +++++---------
vlc-android/src/org/videolan/libvlc/LibVLC.java | 5 +++++
.../org/videolan/vlc/gui/video/VideoPlayerActivity.java | 4 ++--
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 1e2d7d6..8406a87 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -43,10 +43,6 @@
#define VOUT_ANDROID_SURFACE 0
#define VOUT_OPENGLES2 1
-#define HW_ACCELERATION_DISABLED 0
-#define HW_ACCELERATION_DECODING 1
-#define HW_ACCELERATION_FULL 2
-
#define LOG_TAG "VLC/JNI/main"
#include "log.h"
@@ -270,10 +266,10 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
methodId = (*env)->GetMethodID(env, cls, "isVerboseMode", "()Z");
verbosity = (*env)->CallBooleanMethod(env, thiz, methodId);
- methodId = (*env)->GetMethodID(env, cls, "getHardwareAcceleration", "()I");
- int hardwareAcceleration = (*env)->CallIntMethod(env, thiz, methodId);
+ methodId = (*env)->GetMethodID(env, cls, "isDirectRendering", "()Z");
+ bool direct_rendering = (*env)->CallBooleanMethod(env, thiz, methodId);
/* With the MediaCodec opaque mode we cannot use the OpenGL ES vout. */
- if (hardwareAcceleration == HW_ACCELERATION_FULL)
+ if (direct_rendering)
use_opengles2 = false;
methodId = (*env)->GetMethodID(env, cls, "getCachePath", "()Ljava/lang/String;");
@@ -311,8 +307,8 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
use_opengles2 ? "--vout=gles2" : "--vout=androidsurface",
"--androidsurface-chroma", chromastr != NULL && chromastr[0] != 0 ? chromastr : "RV32",
/* XXX: we can't recover from direct rendering failure */
- (hardwareAcceleration == HW_ACCELERATION_FULL) ? "" : "--no-mediacodec-dr",
- (hardwareAcceleration == HW_ACCELERATION_FULL) ? "" : NO_IOMX_DR,
+ direct_rendering ? "" : "--no-mediacodec-dr",
+ direct_rendering ? "" : NO_IOMX_DR,
/* Reconnect on lost HTTP streams, e.g. network change */
enable_http_reconnect ? "--http-reconnect" : "",
diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index 62a16a9..c30f61c 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -293,6 +293,11 @@ public class LibVLC {
}
}
+
+ public boolean isDirectRendering() {
+ return this.hardwareAcceleration == HW_ACCELERATION_FULL;
+ }
+
public String[] getMediaOptions(boolean noHardwareAcceleration, boolean noVideo) {
if (!noHardwareAcceleration)
noHardwareAcceleration = getHardwareAcceleration() == HW_ACCELERATION_DISABLED;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 02be71b..33a5a1b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -422,7 +422,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
+ Integer.toString(mLibVLC.getHardwareAcceleration()));
/* Only show the subtitles surface when using "Full Acceleration" mode */
- if (mLibVLC.getHardwareAcceleration() == LibVLC.HW_ACCELERATION_FULL)
+ if (mLibVLC.isDirectRendering())
mSubtitlesSurface.setVisibility(View.VISIBLE);
// Signal to LibVLC that the videoPlayerActivity was created, thus the
// SurfaceView is now available for MediaCodec direct rendering.
@@ -2345,7 +2345,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mSubtitlesSurfaceHolder.addCallback(activity.mSubtitlesSurfaceCallback);
/* Only show the subtitles surface when using "Full Acceleration" mode */
- if (mLibVLC != null && mLibVLC.getHardwareAcceleration() == LibVLC.HW_ACCELERATION_FULL)
+ if (mLibVLC != null && mLibVLC.isDirectRendering())
mSubtitlesSurface.setVisibility(View.VISIBLE);
Log.i(TAG, "Secondary display created");
}
--
2.1.0
More information about the Android
mailing list