Commit e720bd0b authored by Adrien Maglo's avatar Adrien Maglo

Preferences: add an option to select the OpenGL ES 2.0 vout.

parent 82036e0c
......@@ -38,6 +38,9 @@
#include "aout.h"
#include "utils.h"
#define VOUT_ANDROID_SURFACE 0
#define VOUT_OPENGLES2 1
#define LOG_TAG "VLC/JNI/main"
#include "log.h"
......@@ -209,6 +212,9 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
jmethodID methodId = (*env)->GetMethodID(env, cls, "getAout", "()I");
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;
methodId = (*env)->GetMethodID(env, cls, "timeStretchingEnabled", "()Z");
bool enable_time_stretch = (*env)->CallBooleanMethod(env, thiz, methodId);
......@@ -263,6 +269,7 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
"--avcodec-skip-idct", enable_frame_skip ? "2" : "0",
(networkCaching > 0) ? networkCachingstr : "",
use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
use_opengles2 ? "--vout=gles2" : "--vout=androidsurface",
"--androidsurface-chroma", chromastr != NULL && chromastr[0] != 0 ? chromastr : "RV32",
};
libvlc_instance_t *instance = libvlc_new(sizeof(argv) / sizeof(*argv), argv);
......
......@@ -385,5 +385,23 @@
<item>RGB 16-bit</item>
<item>YUV</item>
</string-array>
<string-array name="vouts_values">
<item >0</item>
<item >1</item>
</string-array>
<string-array name="vouts_values_froyo">
<item >0</item>
</string-array>
<string-array name="vouts">
<item >@string/vout_android_surface</item>
<item >@string/vout_opengles2</item>
</string-array>
<string-array name="vouts_froyo">
<item >@string/vout_android_surface</item>
</string-array>
<string name="vout">Video output</string>
<string name="vout_summary">Change the method that VLC uses to output video.</string>
<string name="vout_android_surface">Android surface</string>
<string name="vout_opengles2">OpenGL ES 2.0</string>
</resources>
......@@ -101,6 +101,11 @@
android:summary="@string/aout_summary"
android:title="@string/aout" />
<ListPreference
android:key="vout"
android:summary="@string/vout_summary"
android:title="@string/vout" />
<EditTextPreference
android:key="network_caching"
android:summary="@string/network_caching_summary"
......
......@@ -34,6 +34,9 @@ public class LibVLC {
public static final int AOUT_AUDIOTRACK = 1;
public static final int AOUT_OPENSLES = 2;
public static final int VOUT_ANDROID_SURFACE = 0;
public static final int VOUT_OPEGLES2 = 1;
private static LibVLC sInstance;
/** libVLC instance C pointer */
......@@ -58,6 +61,7 @@ public class LibVLC {
private boolean iomx = false;
private String subtitlesEncoding = "";
private int aout = LibVlcUtil.isGingerbreadOrLater() ? AOUT_OPENSLES : AOUT_AUDIOTRACK_JAVA;
private int vout = VOUT_ANDROID_SURFACE;
private boolean timeStretching = false;
private int deblocking = -1;
private String chroma = "";
......@@ -239,6 +243,17 @@ public class LibVLC {
this.aout = aout;
}
public int getVout() {
return vout;
}
public void setVout(int vout) {
if (vout < 0)
this.vout = VOUT_ANDROID_SURFACE;
else
this.vout = vout;
}
public boolean timeStretchingEnabled() {
return timeStretching;
}
......
......@@ -129,6 +129,13 @@ public class Util {
catch (NumberFormatException nfe) {
aout = -1;
}
int vout;
try {
vout = Integer.parseInt(pref.getString("vout", "-1"));
}
catch (NumberFormatException nfe) {
vout = -1;
}
int deblocking;
try {
deblocking = Integer.parseInt(pref.getString("deblocking", "-1"));
......@@ -142,6 +149,7 @@ public class Util {
else if(networkCaching < 0)
networkCaching = 0;
instance.setAout(aout);
instance.setVout(vout);
instance.setDeblocking(deblocking);
instance.setNetworkCaching(networkCaching);
}
......
......@@ -181,6 +181,14 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
aoutPref.setValue(Util.isGingerbreadOrLater()
? "2"/*AOUT_OPENSLES*/
: "0"/*AOUT_AUDIOTRACK_JAVA*/);
// Video output
ListPreference voutPref = (ListPreference) findPreference("vout");
int voutEntriesId = Util.isGingerbreadOrLater() ? R.array.vouts : R.array.vouts_froyo;
int voutEntriesIdValues = Util.isGingerbreadOrLater() ? R.array.vouts_values : R.array.vouts_values_froyo;
voutPref.setEntries(voutEntriesId);
voutPref.setEntryValues(voutEntriesIdValues);
if (voutPref.getValue() == null)
voutPref.setValue("0" /* VOUT_ANDROID_SURFACE */);
// Set locale
EditTextPreference setLocalePref = (EditTextPreference) findPreference("set_locale");
setLocalePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
......@@ -220,6 +228,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
if(key.equalsIgnoreCase("enable_iomx")
|| key.equalsIgnoreCase("subtitles_text_encoding")
|| key.equalsIgnoreCase("aout")
|| key.equalsIgnoreCase("vout")
|| key.equalsIgnoreCase("chroma_format")
|| key.equalsIgnoreCase("deblocking")
|| key.equalsIgnoreCase("enable_frame_skip")
......
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