Commit 309e5757 authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

use android_window vout starting gingerbread

This vout always use subtitle surface.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4ba706d3
......@@ -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",
......
......@@ -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() {
......
......@@ -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>
......
......@@ -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>
......@@ -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>
......@@ -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>
......@@ -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");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment