playlist_internal.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * playlist_internal.h : Playlist internals
00003  *****************************************************************************
00004  * Copyright (C) 1999-2008 VLC authors and VideoLAN
00005  * $Id: ba1bfb09275a288b4015d709341e6c5e6bb9fe88 $
00006  *
00007  * Authors: Samuel Hocevar <sam@zoy.org>
00008  *          Clément Stenac <zorglub@videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify it
00011  * under the terms of the GNU Lesser General Public License as published by
00012  * the Free Software Foundation; either version 2.1 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  * GNU Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public License
00021  * along with this program; if not, write to the Free Software Foundation,
00022  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef __LIBVLC_PLAYLIST_INTERNAL_H
00026 # define __LIBVLC_PLAYLIST_INTERNAL_H 1
00027 
00028 /**
00029  *  \file
00030  *  This file contain internal structures and function prototypes related
00031  *  to the playlist in vlc
00032  *
00033  * \defgroup vlc_playlist Playlist
00034  * @{
00035  */
00036 
00037 #include "input/input_interface.h"
00038 #include <assert.h>
00039 
00040 #include "art.h"
00041 #include "fetcher.h"
00042 #include "preparser.h"
00043 
00044 typedef struct vlc_sd_internal_t vlc_sd_internal_t;
00045 
00046 typedef struct playlist_private_t
00047 {
00048     playlist_t           public_data;
00049     playlist_preparser_t *p_preparser;  /**< Preparser data */
00050     playlist_fetcher_t   *p_fetcher;    /**< Meta and art fetcher data */
00051 
00052     playlist_item_array_t items_to_delete; /**< Array of items and nodes to
00053             delete... At the very end. This sucks. */
00054 
00055     vlc_sd_internal_t   **pp_sds;
00056     int                   i_sds;   /**< Number of service discovery modules */
00057     input_thread_t *      p_input;  /**< the input thread associated
00058                                      * with the current item */
00059     input_resource_t *   p_input_resource; /**< input resources */
00060     struct {
00061         /* Current status. These fields are readonly, only the playlist
00062          * main loop can touch it*/
00063         playlist_status_t   i_status;  /**< Current status of playlist */
00064         playlist_item_t *   p_item; /**< Currently playing/active item */
00065         playlist_item_t *   p_node; /**< Current node to play from */
00066     } status;
00067 
00068     struct {
00069         /* Request. Use this to give orders to the playlist main loop  */
00070         playlist_status_t   i_status; /**< requested playlist status */
00071         playlist_item_t *   p_node;   /**< requested node to play from */
00072         playlist_item_t *   p_item;   /**< requested item to play in the node */
00073 
00074         int                 i_skip;   /**< Number of items to skip */
00075 
00076         bool          b_request;/**< Set to true by the requester
00077                                            The playlist sets it back to false
00078                                            when processing the request */
00079         vlc_mutex_t         lock;     /**< Lock to protect request */
00080     } request;
00081 
00082     vlc_thread_t thread; /**< engine thread */
00083     vlc_mutex_t lock; /**< dah big playlist global lock */
00084     vlc_cond_t signal; /**< wakes up the playlist engine thread */
00085 
00086     int      i_last_playlist_id; /**< Last id to an item */
00087     bool     b_reset_currently_playing; /** Reset current item array */
00088 
00089     bool     b_tree; /**< Display as a tree */
00090     bool     b_doing_ml; /**< Doing media library stuff  get quicker */
00091     bool     b_auto_preparse;
00092     mtime_t  last_rebuild_date;
00093 
00094 } playlist_private_t;
00095 
00096 #define pl_priv( pl ) ((playlist_private_t *)(pl))
00097 
00098 /*****************************************************************************
00099  * Prototypes
00100  *****************************************************************************/
00101 
00102 /* Creation/Deletion */
00103 playlist_t *playlist_Create( vlc_object_t * );
00104 void playlist_Destroy( playlist_t * );
00105 
00106 /* */
00107 void playlist_Activate( playlist_t * );
00108 void playlist_Deactivate( playlist_t * );
00109 void pl_Deactivate (libvlc_int_t *);
00110 
00111 /* */
00112 playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
00113                                             input_item_t *p_input );
00114 
00115 /* Engine */
00116 playlist_item_t * get_current_status_item( playlist_t * p_playlist);
00117 playlist_item_t * get_current_status_node( playlist_t * p_playlist );
00118 void set_current_status_item( playlist_t *, playlist_item_t * );
00119 void set_current_status_node( playlist_t *, playlist_item_t * );
00120 
00121 /* Load/Save */
00122 int playlist_MLLoad( playlist_t *p_playlist );
00123 int playlist_MLDump( playlist_t *p_playlist );
00124 
00125 /**********************************************************************
00126  * Item management
00127  **********************************************************************/
00128 
00129 void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
00130                              int i_node_id, bool b_signal );
00131 
00132 playlist_item_t * playlist_NodeAddInput( playlist_t *, input_item_t *,
00133         playlist_item_t *,int , int, bool );
00134 
00135 int playlist_InsertInputItemTree ( playlist_t *,
00136         playlist_item_t *, input_item_node_t *, int, bool );
00137 
00138 /* Tree walking */
00139 playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
00140                                 input_item_t *p_input, playlist_item_t *p_root,
00141                                 bool );
00142 
00143 int playlist_DeleteFromInputInParent( playlist_t *, input_item_t *,
00144                                       playlist_item_t *, bool );
00145 int playlist_DeleteFromItemId( playlist_t*, int );
00146 int playlist_ItemRelease( playlist_item_t * );
00147 
00148 int playlist_NodeEmpty( playlist_t *, playlist_item_t *, bool );
00149 int playlist_DeleteItem( playlist_t * p_playlist, playlist_item_t *, bool);
00150 
00151 
00152 /**
00153  * @}
00154  */
00155 
00156 #define PLAYLIST_DEBUG 1
00157 //#undef PLAYLIST_DEBUG2
00158 
00159 #ifdef PLAYLIST_DEBUG
00160  #define PL_DEBUG( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
00161  #ifdef PLAYLIST_DEBUG2
00162   #define PL_DEBUG2( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
00163  #else
00164   #define PL_DEBUG2( msg, args... ) {}
00165  #endif
00166 #else
00167  #define PL_DEBUG( msg, args ... ) {}
00168  #define PL_DEBUG2( msg, args... ) {}
00169 #endif
00170 
00171 #define PLI_NAME( p ) p && p->p_input ? p->p_input->psz_name : "null"
00172 
00173 #define PL_LOCK_IF( cond ) pl_lock_if( p_playlist, cond )
00174 static inline void pl_lock_if( playlist_t * p_playlist, bool cond )
00175 {
00176     if( cond ) PL_LOCK; else PL_ASSERT_LOCKED;
00177 }
00178 
00179 #define PL_UNLOCK_IF( cond ) pl_unlock_if( p_playlist, cond )
00180 static inline void pl_unlock_if( playlist_t * p_playlist, bool cond )
00181 {
00182     if( cond ) PL_UNLOCK;
00183 }
00184 
00185 #endif /* !__LIBVLC_PLAYLIST_INTERNAL_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines