]> git.sesse.net Git - vlc/commitdiff
libvlc: Implement media_list_view, which will be used to present/access/edit the...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 20 Sep 2007 09:08:03 +0000 (09:08 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 20 Sep 2007 09:08:03 +0000 (09:08 +0000)
include/vlc/libvlc.h
include/vlc/libvlc_structures.h
src/Makefile.am
src/control/libvlc_internal.h
src/control/media_list_view.c [new file with mode: 0644]

index 85b2b0dbfc9a737a4026a37d781346aa1952c02b..6fd9953852275ff62639824493a5debcdae4de1e 100644 (file)
@@ -500,8 +500,44 @@ VLC_PUBLIC_API libvlc_event_manager_t *
                                     libvlc_exception_t * );
 /** @} */
 
+
+/*****************************************************************************
+ * Media List View
+ *****************************************************************************/
+/** defgroup libvlc_media_list_view MediaListView
+ * \ingroup libvlc
+ * LibVLC Media List View
+ * @{ */
+
+VLC_PUBLIC_API int
+    libvlc_media_list_view_count(  libvlc_media_list_view_t * p_mlv,
+                                   libvlc_exception_t * p_e );
+
+VLC_PUBLIC_API libvlc_media_descriptor_t *
+    libvlc_media_list_view_item_at_index(  libvlc_media_list_view_t * p_mlv,
+                                           int index,
+                                           libvlc_exception_t * p_e );
+
+VLC_PUBLIC_API int
+    libvlc_media_list_view_index_of_item(  libvlc_media_list_view_t * p_mlv,
+                                           libvlc_media_descriptor_t * p_md,
+                                           libvlc_exception_t * p_e );
+
+VLC_PUBLIC_API void
+    libvlc_media_list_view_insert_at_index(  libvlc_media_list_view_t * p_mlv,
+                                             libvlc_media_descriptor_t * p_md,
+                                             int index,
+                                             libvlc_exception_t * p_e );
+
+VLC_PUBLIC_API void
+    libvlc_media_list_view_add_item(  libvlc_media_list_view_t * p_mlv,
+                                      libvlc_media_descriptor_t * p_md,
+                                      libvlc_exception_t * p_e );
+
+/** @} */
+
 /*****************************************************************************
- * Dynamic Media List
+ * Dynamic Media List (Deprecated)
  *****************************************************************************/
 /** defgroup libvlc_media_list MediaList
  * \ingroup libvlc
index 56e83c622f51d56c7d6a9a9e30ad84be3ada220d..4fde11324b384d407fedd45ebfc048a673e707fa 100644 (file)
@@ -132,6 +132,7 @@ typedef struct libvlc_media_instance_t libvlc_media_instance_t;
  */
 
 typedef struct libvlc_media_list_t libvlc_media_list_t;
+typedef struct libvlc_media_list_view_t libvlc_media_list_view_t;
 
 /**@} */
 
index 7e9888a5889b4cb7f9fdb9808f612f33368508da..4755adf4d7d878fd681c6ac95ea6555028444e76 100644 (file)
@@ -327,6 +327,7 @@ SOURCES_libvlc_control = \
        control/media_list.c \
        control/media_list_path.h \
        control/media_list_player.c \
+       control/media_list_view.c \
        control/media_library.c \
        control/mediacontrol_internal.h \
        control/mediacontrol_core.c \
index 56c519e2732adde4967417068991f5de28c6a1e4..dd2f64d3ca80a3ff0b82b52dbefbc39f836cfa90 100644 (file)
@@ -113,6 +113,43 @@ struct libvlc_media_list_t
     libvlc_media_list_t *       p_flat_mlist;
 };
 
+/* A way to see a media list */
+struct libvlc_media_list_view_t
+{
+    libvlc_event_manager_t *    p_event_manager;
+    libvlc_instance_t *         p_libvlc_instance;
+    int                         i_refcount;
+    vlc_mutex_t                 object_lock;
+    
+    libvlc_media_list_t *       p_mlist;
+
+    void *                      this_view_data;
+
+    /* Accessors */
+    int (*pf_count)( struct libvlc_media_list_view_t * p_mlv,
+                      libvlc_exception_t * );
+    libvlc_media_descriptor_t *
+        (*pf_item_at_index)( struct libvlc_media_list_view_t * p_mlv,
+                              int index,
+                              libvlc_exception_t * );
+    int  (*pf_index_of_item)( struct libvlc_media_list_view_t * p_mlv,
+                              libvlc_media_descriptor_t * p_md,
+                              libvlc_exception_t * );
+
+    /* Setters */
+    void (*pf_insert_at_index)( struct libvlc_media_list_view_t * p_mlv,
+                                     libvlc_media_descriptor_t * p_md,
+                                     int index,
+                                     libvlc_exception_t * );
+    void (*pf_remove_at_index)( struct libvlc_media_list_view_t * p_mlv,
+                                     int index,
+                                     libvlc_exception_t * );
+    void (*pf_add_item)( struct libvlc_media_list_view_t * p_mlv,
+                         libvlc_media_descriptor_t * p_md,
+                         libvlc_exception_t * );
+        
+};
+
 struct libvlc_dynamic_media_list_t
 {
     libvlc_instance_t *     p_libvlc_instance;
diff --git a/src/control/media_list_view.c b/src/control/media_list_view.c
new file mode 100644 (file)
index 0000000..e75d786
--- /dev/null
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * flat_media_list.c: libvlc flat media list functions. (extension to
+ * media_list.c).
+ *****************************************************************************
+ * Copyright (C) 2007 the VideoLAN team
+ * $Id: flat_media_list.c 21287 2007-08-20 01:28:12Z pdherbemont $
+ *
+ * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "libvlc_internal.h"
+#include <vlc/libvlc.h>
+#include <assert.h>
+#include "vlc_arrays.h"
+
+//#define DEBUG_FLAT_LIST
+
+#ifdef DEBUG_FLAT_LIST
+# define trace( fmt, ... ) printf( "%s(): " fmt, __FUNCTION__, ##__VA_ARGS__ )
+#else
+# define trace( ... )
+#endif
+
+/*
+ * Private functions
+ */
+
+/*
+ * Public libvlc functions
+ */
+
+/* Limited to four args, because it should be enough */
+
+#define AN_SELECT( collapser, dec1, dec2, dec3, dec4, p, ...) p
+#define ARGS(...) AN_SELECT( collapser, ##__VA_ARGS__, \
+                                              (p_mlv, arg1, arg2, arg3, arg4, p_e), \
+                                              (p_mlv, arg1, arg2, arg3, p_e), \
+                                              (p_mlv, arg1, arg2, p_e), \
+                                              (p_mlv, arg1, p_e), (p_mlv, p_e) )
+
+#define MEDIA_LIST_VIEW_FUNCTION( name, ret_type, default_ret_value, /* Params */ ... ) \
+    ret_type \
+    libvlc_media_list_view_##name( libvlc_media_list_view_t * p_mlv, \
+                                  ##__VA_ARGS__, \
+                                  libvlc_exception_t * p_e ) \
+    { \
+        if( p_mlv->pf_##name ) \
+            return p_mlv->pf_##name ARGS(__VA_ARGS__) ; \
+        libvlc_exception_raise( p_e, "No '" #name "' method in this media_list_view" ); \
+        return default_ret_value;\
+    }
+
+#define MEDIA_LIST_VIEW_FUNCTION_VOID_RET( name, /* Params */ ... ) \
+    void \
+    libvlc_media_list_view_##name( libvlc_media_list_view_t * p_mlv, \
+                                  ##__VA_ARGS__, \
+                                  libvlc_exception_t * p_e ) \
+    { \
+        if( p_mlv->pf_##name ) \
+        { \
+            p_mlv->pf_##name ARGS(__VA_ARGS__) ; \
+            return; \
+        } \
+        libvlc_exception_raise( p_e, "No '" #name "' method in this media_list_view" ); \
+    }
+
+
+MEDIA_LIST_VIEW_FUNCTION( count, int, 0 )
+MEDIA_LIST_VIEW_FUNCTION( item_at_index, libvlc_media_descriptor_t *, NULL, int arg1 )
+MEDIA_LIST_VIEW_FUNCTION( index_of_item, int, -1, libvlc_media_descriptor_t * arg1 )
+
+MEDIA_LIST_VIEW_FUNCTION_VOID_RET( insert_at_index, libvlc_media_descriptor_t * arg1, int arg2 )
+MEDIA_LIST_VIEW_FUNCTION_VOID_RET( remove_at_index, int arg1 )
+MEDIA_LIST_VIEW_FUNCTION_VOID_RET( add_item, libvlc_media_descriptor_t * arg1 )
+