]> git.sesse.net Git - vlc/blobdiff - include/vlc_playlist.h
protect from null options param, and finalize added
[vlc] / include / vlc_playlist.h
index 9845fc1ed005b2857301bf0e4dc2bd82b85ae507..8df2897c9ad63f48e3059feafc5d86df280c4293 100644 (file)
 extern "C" {
 # endif
 
-#include <assert.h>
 #include <vlc_input.h>
 #include <vlc_events.h>
+#include <vlc_services_discovery.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t);
-TYPEDEF_ARRAY(input_item_t*, input_item_array_t);
 
 /**
  * \file
@@ -120,7 +119,7 @@ TYPEDEF_ARRAY(input_item_t*, input_item_array_t);
  * will maybe become useful again when we merge VLM;
  *
  * To delete an item, use playlist_DeleteFromInput( input_id ) which will
- * remove all occurences of the input in both trees
+ * remove all occurrences of the input in both trees
  *
  * @{
  */
@@ -158,33 +157,24 @@ struct playlist_item_t
 typedef enum
 { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
 
-
-struct services_discovery_t
-{
-    VLC_COMMON_MEMBERS
-    char *              psz_module;
-    module_t *          p_module;
-
-    char *              psz_localized_name; /* Accessed through Setters for non class function */
-    vlc_event_manager_t event_manager;      /* Accessed through Setters for non class function */
-
-    services_discovery_sys_t *p_sys;
-    void (*pf_run) ( services_discovery_t *);
-};
-
 /** Structure containing information about the playlist */
 struct playlist_t
 {
     VLC_COMMON_MEMBERS
-    struct playlist_internal_t * p_internal; /**< Internal members */
+
+    struct playlist_services_discovery_support_t {
+        /* the playlist items for category and onelevel */
+        playlist_item_t*    p_cat;
+        playlist_item_t*    p_one;
+        services_discovery_t * p_sd; /**< Loaded service discovery modules */
+    } ** pp_sds;
+    int                   i_sds;   /**< Number of service discovery modules */
 
     int                   i_enabled; /**< How many items are enabled ? */
 
     playlist_item_array_t items; /**< Arrays of items */
     playlist_item_array_t all_items; /**< Array of items and nodes */
 
-    input_item_array_t    input_items; /**< Array of input items */
-
     playlist_item_array_t current; /**< Items currently being played */
     int                   i_current_index; /**< Index in current array */
     /** Reset current item array */
@@ -192,7 +182,6 @@ struct playlist_t
     mtime_t               last_rebuild_date;
 
     int                   i_last_playlist_id; /**< Last id to an item */
-    int                   i_last_input_id ; /**< Last id on an input */
 
     /* Predefined items */
     playlist_item_t *     p_root_category; /**< Root of category tree */
@@ -242,11 +231,6 @@ struct playlist_t
                                            when processing the request */
         vlc_mutex_t         lock;     /**< Lock to protect request */
     } request;
-
-    // Playlist-unrelated fields
-    interaction_t       *p_interaction;    /**< Interaction manager */
-    input_thread_t      *p_stats_computer; /**< Input thread computing stats */
-    global_stats_t      *p_stats;          /**< Global statistics */
 };
 
 /** Helper to add an item */
@@ -266,6 +250,9 @@ struct playlist_add_t
 #define SORT_DURATION 6
 #define SORT_TITLE_NUMERIC 7
 #define SORT_ALBUM 8
+#define SORT_TRACK_NUMBER 9
+#define SORT_DESCRIPTION 10
+#define SORT_RATING 11
 
 #define ORDER_NORMAL 0
 #define ORDER_REVERSE 1
@@ -275,18 +262,16 @@ struct playlist_add_t
  *****************************************************************************/
 
 /* Helpers */
-#define PL_LOCK vlc_object_lock( p_playlist );
-#define PL_UNLOCK vlc_object_unlock( p_playlist );
+#define PL_LOCK vlc_object_lock( p_playlist )
+#define PL_UNLOCK vlc_object_unlock( p_playlist )
 
 #define pl_Get( a ) a->p_libvlc->p_playlist
+
+VLC_EXPORT( playlist_t *, __pl_Yield, ( vlc_object_t * ) );
 #define pl_Yield( a ) __pl_Yield( VLC_OBJECT(a) )
-static inline playlist_t *__pl_Yield( vlc_object_t *p_this )
-{
-    assert( p_this->p_libvlc->p_playlist );
-    vlc_object_yield( p_this->p_libvlc->p_playlist );
-    return p_this->p_libvlc->p_playlist;
-}
-#define pl_Release(a) vlc_object_release( a->p_libvlc->p_playlist );
+
+VLC_EXPORT( void, __pl_Release, ( vlc_object_t * ) );
+#define pl_Release(a) __pl_Release( VLC_OBJECT(a) )
 
 /* Playlist control */
 #define playlist_Play(p) playlist_Control(p,PLAYLIST_PLAY, VLC_FALSE )
@@ -395,11 +380,10 @@ VLC_EXPORT( int, playlist_LiveSearchUpdate, (playlist_t *, playlist_item_t *, co
 /********************************************************
  * Tree management
  ********************************************************/
-VLC_EXPORT(void, playlist_NodeDump, ( playlist_t *p_playlist, playlist_item_t *p_item, int i_level ) );
 VLC_EXPORT( int, playlist_NodeChildrenCount, (playlist_t *,playlist_item_t* ) );
 
 /* Node management */
-VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags ) );
+VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags, input_item_t * ) );
 VLC_EXPORT( int, playlist_NodeAppend, (playlist_t *,playlist_item_t*,playlist_item_t *) );
 VLC_EXPORT( int, playlist_NodeInsert, (playlist_t *,playlist_item_t*,playlist_item_t *, int) );
 VLC_EXPORT( int, playlist_NodeRemoveItem, (playlist_t *,playlist_item_t*,playlist_item_t *) );
@@ -412,33 +396,6 @@ VLC_EXPORT( playlist_item_t *, playlist_GetNextLeaf, ( playlist_t *p_playlist, p
 VLC_EXPORT( playlist_item_t *, playlist_GetPrevLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, vlc_bool_t b_ena, vlc_bool_t b_unplayed ) );
 VLC_EXPORT( playlist_item_t *, playlist_GetLastLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root ) );
 
-/***********************************************************************
- * Service Discovery
- ***********************************************************************/
-
-/* Get the services discovery modules names to use in Create(), in a null
- * terminated string array. Array and string must be freed after use. */
-VLC_EXPORT( char **, services_discovery_GetServicesNames, ( vlc_object_t * p_super ) );
-
-/* Creation of a service_discovery object */
-VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) );
-VLC_EXPORT( void,                   services_discovery_Destroy, ( services_discovery_t * p_this ) );
-VLC_EXPORT( int,                    services_discovery_Start, ( services_discovery_t * p_this ) );
-VLC_EXPORT( void,                   services_discovery_Stop, ( services_discovery_t * p_this ) );
-
-/* Read info from discovery object */
-VLC_EXPORT( char *,                 services_discovery_GetLocalizedName, ( services_discovery_t * p_this ) );
-
-/* Receive event notification (prefered way to get new items) */
-VLC_EXPORT( vlc_event_manager_t *,  services_discovery_EventManager, ( services_discovery_t * p_this ) );
-
-/* Used by services_discovery to post update about their items */
-VLC_EXPORT( void,                   services_discovery_SetLocalizedName, ( services_discovery_t * p_this, const char * ) );
-    /* About the psz_category, it is a legacy way to add info to the item,
-     * for more options, directly set the (meta) data on the input item */
-VLC_EXPORT( void,                   services_discovery_AddItem, ( services_discovery_t * p_this, input_item_t * p_item, const char * psz_category ) );
-VLC_EXPORT( void,                   services_discovery_RemoveItem, ( services_discovery_t * p_this, input_item_t * p_item ) );
-
 /***********************************************************************
  * Inline functions
  ***********************************************************************/
@@ -448,7 +405,9 @@ static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file)
     char psz_uri[256+10];
     input_item_t *p_input;
     snprintf( psz_uri, 256+9, "file/://%s", psz_file );
-    p_input = input_ItemNewExt( p_playlist, psz_uri, psz_file, 0, NULL, -1 );
+    const char *const psz_option = "meta-file";
+    p_input = input_ItemNewExt( p_playlist, psz_uri, psz_file,
+                                1, &psz_option, -1 );
     playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND, PLAYLIST_END,
                        VLC_TRUE, VLC_FALSE );
     input_Read( p_playlist, p_input, VLC_TRUE );