[Android] MediaList: extend add() to support parameters
Edward Wang
git at videolan.org
Thu Aug 29 10:58:44 CEST 2013
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Aug 28 22:28:11 2013 +0200| [a25cfd4a2674dda485e9c876a51b6347a276ea78] | committer: Edward Wang
MediaList: extend add() to support parameters
Continued refactoring from LibVLC.readMedia()
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a25cfd4a2674dda485e9c876a51b6347a276ea78
---
vlc-android/jni/libvlcjni-medialist.c | 22 +++++++++++++++++++-
vlc-android/src/org/videolan/libvlc/MediaList.java | 7 +++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/vlc-android/jni/libvlcjni-medialist.c b/vlc-android/jni/libvlcjni-medialist.c
index e577c0d..3628f9e 100644
--- a/vlc-android/jni/libvlcjni-medialist.c
+++ b/vlc-android/jni/libvlcjni-medialist.c
@@ -251,10 +251,30 @@ void Java_org_videolan_libvlc_MediaList_remove(JNIEnv *env, jobject thiz, jint p
libvlc_media_list_unlock(p_ml);
}
-void Java_org_videolan_libvlc_MediaList_add(JNIEnv *env, jobject thiz, jobject libvlcInstance, jstring mrl) {
+void Java_org_videolan_libvlc_MediaList_add(JNIEnv *env, jobject thiz, jobject libvlcInstance, jstring mrl, bool noVideo, bool noOmx) {
libvlc_media_list_t* p_ml = getMediaListFromJava(env, thiz);
const char* p_mrl = (*env)->GetStringUTFChars(env, mrl, NULL);
libvlc_media_t *p_md = libvlc_media_new_location((libvlc_instance_t*)(intptr_t)getLong(env, libvlcInstance, "mLibVlcInstance"), p_mrl);
+ if (!noOmx) {
+ jclass cls = (*env)->GetObjectClass(env, thiz);
+ jmethodID methodId = (*env)->GetMethodID(env, cls, "useIOMX", "()Z");
+ if ((*env)->CallBooleanMethod(env, thiz, methodId)) {
+ /*
+ * Set higher caching values if using iomx decoding, since some omx
+ * decoders have a very high latency, and if the preroll data isn't
+ * enough to make the decoder output a frame, the playback timing gets
+ * started too soon, and every decoded frame appears to be too late.
+ * On Nexus One, the decoder latency seems to be 25 input packets
+ * for 320x170 H.264, a few packets less on higher resolutions.
+ * On Nexus S, the decoder latency seems to be about 7 packets.
+ */
+ libvlc_media_add_option(p_md, ":file-caching=1500");
+ libvlc_media_add_option(p_md, ":network-caching=1500");
+ libvlc_media_add_option(p_md, ":codec=mediacodec,iomx,all");
+ }
+ if (noVideo)
+ libvlc_media_add_option(p_md, ":no-video");
+ }
libvlc_media_list_lock(p_ml);
libvlc_media_list_add_media(p_ml, p_md);
libvlc_media_list_unlock(p_ml);
diff --git a/vlc-android/src/org/videolan/libvlc/MediaList.java b/vlc-android/src/org/videolan/libvlc/MediaList.java
index f61ecc8..4ac851c 100644
--- a/vlc-android/src/org/videolan/libvlc/MediaList.java
+++ b/vlc-android/src/org/videolan/libvlc/MediaList.java
@@ -59,9 +59,12 @@ public class MediaList {
private native void nativeDestroy();
public void add(String mrl) {
- add(mLibVLC, mrl);
+ add(mLibVLC, mrl, false, false);
}
- private native void add(LibVLC libvlc_instance, String mrl);
+ public void add(String mrl, boolean noVideo) {
+ add(mLibVLC, mrl, noVideo, false);
+ }
+ private native void add(LibVLC libvlc_instance, String mrl, boolean noVideo, boolean noOmx);
/**
* Clear the media list. (remove all media)
More information about the Android
mailing list