[Android] [PATCH 02/14] libvlc: move Media flags to LibVLC

Thomas Guillem thomas at gllm.fr
Fri Jan 16 17:12:02 CET 2015


---
 libvlc/src/org/videolan/libvlc/LibVLC.java               | 14 ++++++--------
 libvlc/src/org/videolan/libvlc/Media.java                |  3 ---
 libvlc/src/org/videolan/libvlc/MediaListPlayer.java      |  2 +-
 vlc-android/src/org/videolan/vlc/audio/AudioService.java |  2 +-
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 8632b4a..8e881da 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -56,6 +56,9 @@ public class LibVLC {
     public static final int INPUT_NAV_LEFT = 3;
     public static final int INPUT_NAV_RIGHT = 4;
 
+    public final static int MEDIA_NO_VIDEO   = 0x01;
+    public final static int MEDIA_NO_HWACCEL = 0x02;
+
     private static final String DEFAULT_CODEC_LIST = "mediacodec,iomx,all";
     private static final boolean HAS_WINDOW_VOUT = LibVlcUtil.isGingerbreadOrLater();
 
@@ -340,14 +343,9 @@ public class LibVLC {
         return options.toArray(new String[options.size()]);
     }
 
-    public String[] getMediaOptions(Media media) {
-        boolean noHardwareAcceleration = false;
-        boolean noVideo = false;
-        if (media != null) {
-            final int flags = media.getFlags();
-            noHardwareAcceleration = (flags & Media.FLAG_NO_HWACCEL) != 0;
-            noVideo = (flags & Media.FLAG_NO_VIDEO) != 0;
-        }
+    public String[] getMediaOptions(int flags) {
+        final boolean noHardwareAcceleration = (flags & MEDIA_NO_HWACCEL) != 0;
+        final boolean noVideo = (flags & MEDIA_NO_VIDEO) != 0;
         return getMediaOptions(noHardwareAcceleration, noVideo); 
     }
 
diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
index 02ae924..62ba1e5 100644
--- a/libvlc/src/org/videolan/libvlc/Media.java
+++ b/libvlc/src/org/videolan/libvlc/Media.java
@@ -73,9 +73,6 @@ public class Media implements Parcelable {
     public final static int TYPE_AUDIO = 1;
     public final static int TYPE_GROUP = 2;
 
-    public final static int FLAG_NO_VIDEO   = 0x01;
-    public final static int FLAG_NO_HWACCEL = 0x02;
-
     /** Metadata from libvlc_media */
     protected String mTitle;
     private String mArtist;
diff --git a/libvlc/src/org/videolan/libvlc/MediaListPlayer.java b/libvlc/src/org/videolan/libvlc/MediaListPlayer.java
index 50dc061..a7fa532 100644
--- a/libvlc/src/org/videolan/libvlc/MediaListPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaListPlayer.java
@@ -49,7 +49,7 @@ public class MediaListPlayer {
             return;
 
         final Media media = mMediaList.getMedia(position);
-        String[] options = mLibVLC.getMediaOptions(media);
+        String[] options = mLibVLC.getMediaOptions(media != null ? media.getFlags() : 0);
         mPlayerIndex = position;
         mLibVLC.playMRL(mrl, options);
     }
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index e7eb229..93f8a4b 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -1224,7 +1224,7 @@ public class AudioService extends Service {
                     media = new Media(mLibVLC, location);
                 }
                 if (noVideo)
-                    media.addFlags(Media.FLAG_NO_VIDEO);
+                    media.addFlags(LibVLC.MEDIA_NO_VIDEO);
                 mediaList.add(media);
             }
 
-- 
2.1.3



More information about the Android mailing list