[Android] add "no-video" when playing as audio, to prevent video decoding when we don 't display it

Sébastien Toque git at videolan.org
Sat May 26 09:39:56 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sat May 26 09:37:14 2012 +0200| [22c75a690e5f66db6e8e8bf15cafd30a1951e3c1] | committer: Sébastien Toque

add "no-video" when playing as audio, to prevent video decoding when we don't display it

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=22c75a690e5f66db6e8e8bf15cafd30a1951e3c1
---

 vlc-android/jni/libvlcjni.c                            |   16 +++++++++-------
 vlc-android/jni/thumbnailer.c                          |    2 +-
 vlc-android/jni/utils.h                                |    2 +-
 vlc-android/src/org/videolan/vlc/AudioService.java     |    6 +++---
 vlc-android/src/org/videolan/vlc/LibVLC.java           |    6 +++---
 .../videolan/vlc/gui/video/VideoPlayerActivity.java    |    2 +-
 6 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 1f93512..fdce905 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -40,7 +40,7 @@
 #define AOUT_AUDIOTRACK_JAVA 1
 #define AOUT_OPENSLES        2
 
-libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring fileLocation, bool noOmx)
+libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring fileLocation, bool noOmx, bool noVideo)
 {
     libvlc_instance_t *libvlc = (libvlc_instance_t*)instance;
     jboolean isCopy;
@@ -67,6 +67,8 @@ libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring file
             libvlc_media_add_option(p_md, ":network-caching=1500");
             libvlc_media_add_option(p_md, ":codec=iomx,all");
         }
+        if (noVideo)
+            libvlc_media_add_option(p_md, ":no-video");
     }
     return p_md;
 }
@@ -436,7 +438,7 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readMediaMeta(JNIEnv *env,
             (*env)->FindClass(env, "java/lang/String"),
             (*env)->NewStringUTF(env, ""));
 
-    libvlc_media_t *m = new_media(instance, env, thiz, mrl, false);
+    libvlc_media_t *m = new_media(instance, env, thiz, mrl, false, false);
     if (!m)
     {
         LOGE("readMediaMeta: Could not create the media!");
@@ -472,13 +474,13 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readMediaMeta(JNIEnv *env,
 }
 
 void Java_org_videolan_vlc_LibVLC_readMedia(JNIEnv *env, jobject thiz,
-                                            jint instance, jstring mrl)
+                                            jint instance, jstring mrl, jboolean novideo)
 {
     /* Release previous media player, if any */
     releaseMediaPlayer(env, thiz);
 
     /* Create a new item */
-    libvlc_media_t *m = new_media(instance, env, thiz, mrl, false);
+    libvlc_media_t *m = new_media(instance, env, thiz, mrl, false, novideo);
     if (!m)
     {
         LOGE("readMedia: Could not create the media!");
@@ -530,7 +532,7 @@ jboolean Java_org_videolan_vlc_LibVLC_hasVideoTrack(JNIEnv *env, jobject thiz,
                                                     jint i_instance, jstring fileLocation)
 {
     /* Create a new item and assign it to the media player. */
-    libvlc_media_t *p_m = new_media(i_instance, env, thiz, fileLocation, false);
+    libvlc_media_t *p_m = new_media(i_instance, env, thiz, fileLocation, false, false);
     if (p_m == NULL)
     {
         LOGE("Could not create the media!");
@@ -577,7 +579,7 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readTracksInfo(JNIEnv *env, jobject th
     }
 
     /* Create a new item and assign it to the media player. */
-    libvlc_media_t *p_m = new_media(instance, env, thiz, mrl, false);
+    libvlc_media_t *p_m = new_media(instance, env, thiz, mrl, false, false);
     if (p_m == NULL)
     {
         LOGE("Could not create the media!");
@@ -667,7 +669,7 @@ jlong Java_org_videolan_vlc_LibVLC_getLengthFromLocation(JNIEnv *env, jobject th
     monitor->length_changed = false;
 
     /* Create a new item and assign it to the media player. */
-    libvlc_media_t *m = new_media(i_instance, env, thiz, fileLocation, false);
+    libvlc_media_t *m = new_media(i_instance, env, thiz, fileLocation, false, false);
     if (m == NULL)
     {
         LOGE("Could not create the media to play!");
diff --git a/vlc-android/jni/thumbnailer.c b/vlc-android/jni/thumbnailer.c
index fab1cad..8c0b660 100644
--- a/vlc-android/jni/thumbnailer.c
+++ b/vlc-android/jni/thumbnailer.c
@@ -133,7 +133,7 @@ jbyteArray Java_org_videolan_vlc_LibVLC_getThumbnail(JNIEnv *env, jobject thiz,
     /* Create a media player playing environment */
     sys->mp = libvlc_media_player_new(libvlc);
 
-    libvlc_media_t *m = new_media(instance, env, thiz, filePath, true);
+    libvlc_media_t *m = new_media(instance, env, thiz, filePath, true, false);
     if (m == NULL)
     {
         LOGE("Could not create the media to play!");
diff --git a/vlc-android/jni/utils.h b/vlc-android/jni/utils.h
index dd22bd2..b1c36f8 100644
--- a/vlc-android/jni/utils.h
+++ b/vlc-android/jni/utils.h
@@ -21,7 +21,7 @@
 #ifndef LIBVLCJNI_UTILS_H
 #define LIBVLCJNI_UTILS_H
 
-libvlc_media_t *new_media(jint libvlc, JNIEnv *env, jobject thiz, jstring filePath, bool noOmx);
+libvlc_media_t *new_media(jint libvlc, JNIEnv *env, jobject thiz, jstring filePath, bool noOmx, bool noVideo);
 
 
 #endif // LIBVLCJNI_UTILS_H
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index af5cfc1..8832d0e 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -292,7 +292,7 @@ public class AudioService extends Service {
                 return;
             }
         }
-        mLibVLC.readMedia(mCurrentMedia.getLocation());
+        mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
         mHandler.sendEmptyMessage(SHOW_PROGRESS);
         showNotification();
         updateWidget(this);
@@ -306,7 +306,7 @@ public class AudioService extends Service {
             mCurrentMedia = mMediaList.get(index - 1);
         else
             return;
-        mLibVLC.readMedia(mCurrentMedia.getLocation());
+        mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
         mHandler.sendEmptyMessage(SHOW_PROGRESS);
         showNotification();
         updateWidget(this);
@@ -483,7 +483,7 @@ public class AudioService extends Service {
             }
 
             if (mCurrentMedia != null)
-                mLibVLC.readMedia(mCurrentMedia.getLocation());
+                mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
             showNotification();
         }
 
diff --git a/vlc-android/src/org/videolan/vlc/LibVLC.java b/vlc-android/src/org/videolan/vlc/LibVLC.java
index c044860..aaefc00 100644
--- a/vlc-android/src/org/videolan/vlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/vlc/LibVLC.java
@@ -221,9 +221,9 @@ public class LibVLC {
     /**
      * Read a media.
      */
-    public void readMedia(String mrl) {
+    public void readMedia(String mrl, boolean novideo) {
         Log.v(TAG, "Reading " + mrl);
-        readMedia(mLibVlcInstance, mrl);
+        readMedia(mLibVlcInstance, mrl, novideo);
     }
 
     public String[] readMediaMeta(String mrl) {
@@ -272,7 +272,7 @@ public class LibVLC {
      * @param instance: the instance of libVLC
      * @param mrl: the media mrl
      */
-    private native void readMedia(int instance, String mrl);
+    private native void readMedia(int instance, String mrl, boolean novideo);
 
     /**
      * Return true if there is currently a running media player.
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 7a70262..023d090 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -807,7 +807,7 @@ public class VideoPlayerActivity extends Activity {
         }
 
         if (location != null && location.length() > 0) {
-            mLibVLC.readMedia(location);
+            mLibVLC.readMedia(location, false);
             if (!mWakeLock.isHeld())
                 mWakeLock.acquire();
 



More information about the Android mailing list