[Android] libvlc: MediaPlayer: remove hasVideoTracks

Thomas Guillem git at videolan.org
Thu May 28 15:34:09 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu May 28 14:44:01 2015 +0200| [c5617558937361aec37825442a62d9e0e53ca2d7] | committer: Thomas Guillem

libvlc: MediaPlayer: remove hasVideoTracks

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c5617558937361aec37825442a62d9e0e53ca2d7
---

 libvlc/jni/libvlcjni-track.c                    |   83 -----------------------
 libvlc/src/org/videolan/libvlc/MediaPlayer.java |    5 --
 2 files changed, 88 deletions(-)

diff --git a/libvlc/jni/libvlcjni-track.c b/libvlc/jni/libvlcjni-track.c
index 0f5afa9..1443ff9 100644
--- a/libvlc/jni/libvlcjni-track.c
+++ b/libvlc/jni/libvlcjni-track.c
@@ -22,89 +22,6 @@
 
 #include "libvlcjni-vlcobject.h"
 
-struct length_change_monitor {
-    pthread_mutex_t doneMutex;
-    pthread_cond_t doneCondVar;
-    bool length_changed;
-};
-
-static void length_changed_callback(const libvlc_event_t *ev, void *data)
-{
-    struct length_change_monitor *monitor = data;
-    pthread_mutex_lock(&monitor->doneMutex);
-    monitor->length_changed = true;
-    pthread_cond_signal(&monitor->doneCondVar);
-    pthread_mutex_unlock(&monitor->doneMutex);
-}
-
-/* TODO: REWORK */
-jboolean
-Java_org_videolan_libvlc_MediaPlayer_hasVideoTrack(JNIEnv *env, jobject thiz,
-                                                   jstring fileLocation)
-{
-    /* Create a new item and assign it to the media player. */
-    libvlc_media_t *p_m = new_media(env, thiz, fileLocation, false, false);
-    if (p_m == NULL)
-    {
-        LOGE("Could not create the media!");
-        return JNI_FALSE;
-    }
-
-    /* Get the tracks information of the media. */
-    libvlc_media_parse(p_m);
-
-    libvlc_media_player_t* p_mp = libvlc_media_player_new_from_media(p_m);
-    libvlc_media_player_set_video_title_display(p_mp, libvlc_position_disable, 0);
-
-    struct length_change_monitor* monitor;
-    monitor = malloc(sizeof(struct length_change_monitor));
-    if (!monitor) return 0;
-
-    /* Initialize pthread variables. */
-    pthread_mutex_init(&monitor->doneMutex, NULL);
-    pthread_cond_init(&monitor->doneCondVar, NULL);
-    monitor->length_changed = false;
-
-    libvlc_event_manager_t *ev = libvlc_media_player_event_manager(p_mp);
-    libvlc_event_attach(ev, libvlc_MediaPlayerLengthChanged, length_changed_callback, monitor);
-    libvlc_media_player_play( p_mp );
-
-    pthread_mutex_lock(&monitor->doneMutex);
-
-    struct timespec deadline;
-    clock_gettime(CLOCK_REALTIME, &deadline);
-    deadline.tv_sec += 2; /* If "VLC can't open the file", return */
-    int mp_alive = 1;
-    while( !monitor->length_changed && mp_alive ) {
-        pthread_cond_timedwait(&monitor->doneCondVar, &monitor->doneMutex, &deadline);
-        mp_alive = libvlc_media_player_will_play(p_mp);
-    }
-    pthread_mutex_unlock(&monitor->doneMutex);
-
-    int i_nbTracks;
-    if( mp_alive )
-        i_nbTracks = libvlc_video_get_track_count(p_mp);
-    else
-        i_nbTracks = -1;
-    LOGI("Number of video tracks: %d",i_nbTracks);
-
-    libvlc_event_detach(ev, libvlc_MediaPlayerLengthChanged, length_changed_callback, monitor);
-    libvlc_media_player_stop(p_mp);
-    libvlc_media_player_release(p_mp);
-    libvlc_media_release(p_m);
-
-    pthread_mutex_destroy(&monitor->doneMutex);
-    pthread_cond_destroy(&monitor->doneCondVar);
-    free(monitor);
-
-    if(i_nbTracks > 0)
-        return JNI_TRUE;
-    else if(i_nbTracks < 0)
-        (*env)->ThrowNew(env, (*env)->FindClass(env, "java/io/IOException"), "VLC can't open the file");
-    else
-        return JNI_FALSE;
-}
-
 jint
 Java_org_videolan_libvlc_MediaPlayer_getAudioTracksCount(JNIEnv *env,
                                                          jobject thiz)
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 902d6f4..28db82e 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -214,11 +214,6 @@ public class MediaPlayer extends VLCObject {
     public native int getTitleCount();
     public native void playerNavigate(int navigate);
 
-    /**
-     * Return true if there is a video track in the file
-     */
-    public native boolean hasVideoTrack(String mrl) throws java.io.IOException;
-
     public native int getAudioTracksCount();
 
     public native Map<Integer,String> getAudioTrackDescription();



More information about the Android mailing list