[Android] Preferences: add an option to select the OpenGL ES 2.0 vout.
Adrien Maglo
git at videolan.org
Fri Nov 8 14:14:17 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Wed Nov 6 14:44:39 2013 +0100| [e720bd0bac3a79fe0865d6c2d9773ee949c69bf6] | committer: Adrien Maglo
Preferences: add an option to select the OpenGL ES 2.0 vout.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e720bd0bac3a79fe0865d6c2d9773ee949c69bf6
---
vlc-android/jni/libvlcjni.c | 7 +++++++
vlc-android/res/values/strings.xml | 18 ++++++++++++++++++
vlc-android/res/xml/preferences.xml | 5 +++++
vlc-android/src/org/videolan/libvlc/LibVLC.java | 15 +++++++++++++++
vlc-android/src/org/videolan/vlc/Util.java | 8 ++++++++
.../org/videolan/vlc/gui/PreferencesActivity.java | 9 +++++++++
6 files changed, 62 insertions(+)
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 7b244e6..29ffcb9 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -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);
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 8c32c56..e7182e2 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -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>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 2043074..0c7b564 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -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"
diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index 884065b..30b023f 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -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;
}
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index cbc5266..d8eec0c 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -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);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index 9f12592..1e0343c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -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")
More information about the Android
mailing list