[vlc-devel] [PATCH 12/12] use android_window vout starting gingerbread
Thomas Guillem
thomas at gllm.fr
Fri Nov 14 17:10:27 CET 2014
This vout always use subtitle surface.
---
libvlc/jni/libvlcjni.c | 8 +++++---
libvlc/src/org/videolan/libvlc/LibVLC.java | 10 ++++++++++
vlc-android/res/layout-land/player_remote_control.xml | 3 +--
vlc-android/res/layout/player.xml | 5 ++---
vlc-android/res/layout/player_remote.xml | 5 ++---
vlc-android/res/layout/player_remote_control.xml | 5 ++---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 12 ++++--------
7 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 1ab151c..6b28667 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -42,6 +42,7 @@
#define VOUT_ANDROID_SURFACE 0
#define VOUT_OPENGLES2 1
+#define VOUT_ANDROID_WINDOW 2
#define LOG_TAG "VLC/JNI/main"
#include "log.h"
@@ -258,7 +259,7 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
bool use_opensles = (*env)->CallIntMethod(env, thiz, methodId) == AOUT_OPENSLES;
methodId = (*env)->GetMethodID(env, cls, "getVout", "()I");
- bool use_opengles2 = (*env)->CallIntMethod(env, thiz, methodId) == VOUT_OPENGLES2;
+ int vout = (*env)->CallIntMethod(env, thiz, methodId);
methodId = (*env)->GetMethodID(env, cls, "timeStretchingEnabled", "()Z");
bool enable_time_stretch = (*env)->CallBooleanMethod(env, thiz, methodId);
@@ -300,7 +301,7 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
bool direct_rendering = (*env)->CallBooleanMethod(env, thiz, methodId);
/* With the MediaCodec opaque mode we cannot use the OpenGL ES vout. */
if (direct_rendering)
- use_opengles2 = false;
+ vout = VOUT_ANDROID_WINDOW;
methodId = (*env)->GetMethodID(env, cls, "getCachePath", "()Ljava/lang/String;");
jstring cachePath = (*env)->CallObjectMethod(env, thiz, methodId);
@@ -334,7 +335,8 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
/* Android video API is a mess */
- use_opengles2 ? "--vout=gles2" : "--vout=androidsurface",
+ vout == VOUT_ANDROID_WINDOW ? "--vout=androidwindow" :
+ (vout == VOUT_OPENGLES2 ? "--vout=gles2" : "--vout=androidsurface"),
"--androidsurface-chroma", chromastr != NULL && chromastr[0] != 0 ? chromastr : "RV32",
/* XXX: we can't recover from direct rendering failure */
direct_rendering ? "" : "--no-mediacodec-dr",
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 1e31ca1..ce9a568 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -37,6 +37,7 @@ public class LibVLC {
public static final int VOUT_ANDROID_SURFACE = 0;
public static final int VOUT_OPEGLES2 = 1;
+ public static final int VOUT_ANDROID_WINDOW = 2;
public static final int HW_ACCELERATION_AUTOMATIC = -1;
public static final int HW_ACCELERATION_DISABLED = 0;
@@ -56,6 +57,7 @@ public class LibVLC {
public static final int INPUT_NAV_RIGHT = 4;
private static final String DEFAULT_CODEC_LIST = "mediacodec,iomx,all";
+ private static final boolean HAS_WINDOW_VOUT = LibVlcUtil.isGingerbreadOrLater();
private static LibVLC sInstance;
@@ -343,6 +345,8 @@ public class LibVLC {
}
public boolean isDirectRendering() {
+ if (!HAS_WINDOW_VOUT)
+ return false;
if (devHardwareDecoder != DEV_HW_DECODER_AUTOMATIC) {
return (this.devHardwareDecoder == DEV_HW_DECODER_OMX_DR ||
this.devHardwareDecoder == DEV_HW_DECODER_MEDIACODEC_DR);
@@ -407,6 +411,12 @@ public class LibVLC {
this.vout = VOUT_ANDROID_SURFACE;
else
this.vout = vout;
+ if (this.vout == VOUT_ANDROID_SURFACE && HAS_WINDOW_VOUT)
+ this.vout = VOUT_ANDROID_WINDOW;
+ }
+
+ public boolean useCompatSurface() {
+ return this.vout != VOUT_ANDROID_WINDOW;
}
public boolean timeStretchingEnabled() {
diff --git a/vlc-android/res/layout-land/player_remote_control.xml b/vlc-android/res/layout-land/player_remote_control.xml
index 91a762c..bc527b8 100644
--- a/vlc-android/res/layout-land/player_remote_control.xml
+++ b/vlc-android/res/layout-land/player_remote_control.xml
@@ -28,8 +28,7 @@
<SurfaceView
android:id="@+id/subtitles_surface"
android:layout_width="1dp"
- android:layout_height="1dp"
- android:visibility="invisible" />
+ android:layout_height="1dp" />
</FrameLayout>
</FrameLayout>
diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 0c279d3..6442575 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -26,8 +26,7 @@
<SurfaceView
android:id="@+id/subtitles_surface"
android:layout_width="1dp"
- android:layout_height="1dp"
- android:visibility="invisible" />
+ android:layout_height="1dp" />
</FrameLayout>
</FrameLayout>
@@ -205,4 +204,4 @@
</RelativeLayout>
</RelativeLayout>
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/vlc-android/res/layout/player_remote.xml b/vlc-android/res/layout/player_remote.xml
index 3ae2744..545594e 100644
--- a/vlc-android/res/layout/player_remote.xml
+++ b/vlc-android/res/layout/player_remote.xml
@@ -28,8 +28,7 @@
<SurfaceView
android:id="@+id/remote_subtitles_surface"
android:layout_width="1dp"
- android:layout_height="1dp"
- android:visibility="invisible" />
+ android:layout_height="1dp" />
</FrameLayout>
</FrameLayout>
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/vlc-android/res/layout/player_remote_control.xml b/vlc-android/res/layout/player_remote_control.xml
index 95d0570..28ce4e4 100644
--- a/vlc-android/res/layout/player_remote_control.xml
+++ b/vlc-android/res/layout/player_remote_control.xml
@@ -28,8 +28,7 @@
<SurfaceView
android:id="@+id/subtitles_surface"
android:layout_width="1dp"
- android:layout_height="1dp"
- android:visibility="invisible" />
+ android:layout_height="1dp" />
</FrameLayout>
</FrameLayout>
@@ -232,4 +231,4 @@
</RelativeLayout>
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
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 eb7448e..d485298 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -393,6 +393,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
mSubtitlesSurfaceHolder.setFormat(PixelFormat.TRANSLUCENT);
+ if (mLibVLC.useCompatSurface())
+ mSubtitlesSurfaceView.setVisibility(View.GONE);
if (mPresentation == null) {
mSurfaceHolder.addCallback(mSurfaceCallback);
mSubtitlesSurfaceHolder.addCallback(mSubtitlesSurfaceCallback);
@@ -430,9 +432,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
"Hardware acceleration mode: "
+ Integer.toString(mLibVLC.getHardwareAcceleration()));
- /* Only show the subtitles surface when using "Full Acceleration" mode */
- if (mLibVLC.isDirectRendering())
- mSubtitlesSurfaceView.setVisibility(View.VISIBLE);
// Signal to LibVLC that the videoPlayerActivity was created, thus the
// SurfaceView is now available for MediaCodec direct rendering.
mLibVLC.eventVideoPlayerActivityCreated(true);
@@ -1206,7 +1205,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mDisabledHardwareAcceleration = true;
mPreviousHardwareAccelerationMode = mLibVLC.getHardwareAcceleration();
mLibVLC.setHardwareAcceleration(LibVLC.HW_ACCELERATION_DISABLED);
- mSubtitlesSurfaceView.setVisibility(View.INVISIBLE);
loadMedia();
}
})
@@ -2533,10 +2531,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mSubtitlesSurfaceHolder.setFormat(PixelFormat.TRANSLUCENT);
mSubtitlesSurfaceHolder.addCallback(activity.mSubtitlesSurfaceCallback);
- /* Only show the subtitles surface when using "Full Acceleration" mode */
- if (mLibVLC != null && mLibVLC.isDirectRendering())
- mSubtitlesSurfaceView.setVisibility(View.VISIBLE);
-
+ if (mLibVLC.useCompatSurface())
+ mSubtitlesSurfaceView.setVisibility(View.GONE);
Log.i(TAG, "Secondary display created");
}
}
--
2.1.1
More information about the vlc-devel
mailing list