00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef VLC_PLAYLIST_H_
00025 #define VLC_PLAYLIST_H_
00026
00027 # ifdef __cplusplus
00028 extern "C" {
00029 # endif
00030
00031 #include <vlc_input.h>
00032 #include <vlc_events.h>
00033 #include <vlc_services_discovery.h>
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036
00037 TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t);
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 struct playlist_export_t
00125 {
00126 char *psz_filename;
00127 FILE *p_file;
00128 playlist_item_t *p_root;
00129 };
00130
00131
00132 struct playlist_item_t
00133 {
00134 input_item_t *p_input;
00135
00136 int i_children;
00137 playlist_item_t **pp_children;
00138 playlist_item_t *p_parent;
00139
00140 int i_id;
00141 uint8_t i_flags;
00142 playlist_t *p_playlist;
00143 };
00144
00145 #define PLAYLIST_SAVE_FLAG 0x0001
00146 #define PLAYLIST_SKIP_FLAG 0x0002
00147 #define PLAYLIST_DBL_FLAG 0x0004
00148 #define PLAYLIST_RO_FLAG 0x0008
00149 #define PLAYLIST_REMOVE_FLAG 0x0010
00150 #define PLAYLIST_EXPANDED_FLAG 0x0020
00151
00152
00153 typedef enum
00154 { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
00155
00156
00157 struct playlist_t
00158 {
00159 VLC_COMMON_MEMBERS
00160
00161 struct playlist_services_discovery_support_t {
00162
00163 playlist_item_t* p_cat;
00164 playlist_item_t* p_one;
00165 services_discovery_t * p_sd;
00166 } ** pp_sds;
00167 int i_sds;
00168
00169 playlist_item_array_t items;
00170 playlist_item_array_t all_items;
00171 playlist_item_array_t items_to_delete;
00172
00173
00174 playlist_item_array_t current;
00175 int i_current_index;
00176
00177 bool b_reset_currently_playing;
00178 mtime_t last_rebuild_date;
00179
00180 int i_last_playlist_id;
00181
00182
00183 playlist_item_t * p_root_category;
00184 playlist_item_t * p_root_onelevel;
00185 playlist_item_t * p_local_category;
00186 playlist_item_t * p_ml_category;
00187 playlist_item_t * p_local_onelevel;
00188 playlist_item_t * p_ml_onelevel;
00189
00190 bool b_tree;
00191
00192 bool b_doing_ml;
00193
00194 bool b_auto_preparse;
00195
00196
00197 input_thread_t * p_input;
00198
00199 int i_sort;
00200 int i_order;
00201 mtime_t gc_date;
00202 bool b_cant_sleep;
00203 playlist_preparse_t *p_preparse;
00204 playlist_fetcher_t *p_fetcher;
00205
00206 struct {
00207
00208
00209 playlist_status_t i_status;
00210 playlist_item_t * p_item;
00211 playlist_item_t * p_node;
00212 } status;
00213
00214 struct {
00215
00216 playlist_status_t i_status;
00217 playlist_item_t * p_node;
00218 playlist_item_t * p_item;
00219
00220 int i_skip;
00221
00222 bool b_request;
00223
00224
00225 vlc_mutex_t lock;
00226 } request;
00227 };
00228
00229
00230 struct playlist_add_t
00231 {
00232 int i_node;
00233 int i_item;
00234 int i_position;
00235 };
00236
00237 #define SORT_ID 0
00238 #define SORT_TITLE 1
00239 #define SORT_TITLE_NODES_FIRST 2
00240 #define SORT_ARTIST 3
00241 #define SORT_GENRE 4
00242 #define SORT_RANDOM 5
00243 #define SORT_DURATION 6
00244 #define SORT_TITLE_NUMERIC 7
00245 #define SORT_ALBUM 8
00246 #define SORT_TRACK_NUMBER 9
00247 #define SORT_DESCRIPTION 10
00248 #define SORT_RATING 11
00249
00250 #define ORDER_NORMAL 0
00251 #define ORDER_REVERSE 1
00252
00253
00254 #define PLAYLIST_INSERT 0x0001
00255 #define PLAYLIST_APPEND 0x0002
00256 #define PLAYLIST_GO 0x0004
00257 #define PLAYLIST_PREPARSE 0x0008
00258 #define PLAYLIST_SPREPARSE 0x0010
00259 #define PLAYLIST_NO_REBUILD 0x0020
00260
00261 #define PLAYLIST_END -666
00262
00263 enum pl_locked_state
00264 {
00265 pl_Locked = true,
00266 pl_Unlocked = false
00267 };
00268
00269
00270
00271
00272
00273
00274 #define PL_LOCK vlc_object_lock( p_playlist )
00275 #define PL_UNLOCK vlc_object_unlock( p_playlist )
00276
00277 VLC_EXPORT( playlist_t *, __pl_Yield, ( vlc_object_t * ) );
00278 #define pl_Yield( a ) __pl_Yield( VLC_OBJECT(a) )
00279
00280 VLC_EXPORT( void, __pl_Release, ( vlc_object_t * ) );
00281 #define pl_Release(a) __pl_Release( VLC_OBJECT(a) )
00282
00283
00284 #define playlist_Play(p) playlist_Control(p,PLAYLIST_PLAY, pl_Unlocked )
00285 #define playlist_Pause(p) playlist_Control(p,PLAYLIST_PAUSE, pl_Unlocked )
00286 #define playlist_Stop(p) playlist_Control(p,PLAYLIST_STOP, pl_Unlocked )
00287 #define playlist_Next(p) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, 1)
00288 #define playlist_Prev(p) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, -1)
00289 #define playlist_Skip(p,i) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, i)
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 VLC_EXPORT( int, playlist_Control, ( playlist_t *p_playlist, int i_query, bool b_locked, ... ) );
00302
00303
00304
00305 VLC_EXPORT( input_thread_t *, playlist_CurrentInput, ( playlist_t *p_playlist ) );
00306
00307
00308
00309
00310 VLC_EXPORT( void, playlist_Clear, ( playlist_t *, bool ) );
00311
00312
00313 VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t *) );
00314
00315
00316 VLC_EXPORT( int, playlist_PreparseEnqueueItem, (playlist_t *, playlist_item_t *) );
00317
00318 VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *) );
00319
00320
00321
00322
00323 VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
00324
00325 VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
00326
00327 VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
00328
00329
00330 VLC_EXPORT( int, playlist_TreeMove, ( playlist_t *, playlist_item_t *, playlist_item_t *, int ) );
00331 VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 VLC_EXPORT( int, playlist_Export, ( playlist_t *p_playlist, const char *psz_name, playlist_item_t *p_export_root, const char *psz_type ) );
00342
00343
00344
00345
00346
00347
00348
00349 VLC_EXPORT( playlist_item_t* , playlist_ItemNewWithType, ( playlist_t *,const char *,const char *, int , const char *const *, int, int) );
00350
00351
00352
00353
00354
00355
00356
00357 #define playlist_ItemNew( a , b, c ) \
00358 playlist_ItemNewWithType( VLC_OBJECT(a) , b , c, 0, NULL, -1, 0 )
00359
00360
00361
00362 VLC_EXPORT( int, playlist_DeleteFromInput, ( playlist_t *, int, bool ) );
00363
00364
00365 VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, const char * ) );
00366
00367
00368 VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int, bool, bool ) );
00369 VLC_EXPORT( int, playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char *const *,int, bool, bool ) );
00370 VLC_EXPORT( int, playlist_AddInput, ( playlist_t *, input_item_t *, int, int, bool, bool ) );
00371 VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int*, bool ) );
00372
00373
00374 VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *, bool) );
00375
00376
00377 VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int, bool ) );
00378 VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInput, (playlist_t *,input_item_t *, bool ) );
00379 VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInputId, (playlist_t *, int, playlist_item_t *) );
00380
00381 VLC_EXPORT( int, playlist_LiveSearchUpdate, (playlist_t *, playlist_item_t *, const char *) );
00382
00383
00384
00385
00386 VLC_EXPORT( int, playlist_NodeChildrenCount, (playlist_t *,playlist_item_t* ) );
00387
00388
00389 VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags, input_item_t * ) );
00390 VLC_EXPORT( int, playlist_NodeAppend, (playlist_t *,playlist_item_t*,playlist_item_t *) );
00391 VLC_EXPORT( int, playlist_NodeInsert, (playlist_t *,playlist_item_t*,playlist_item_t *, int) );
00392 VLC_EXPORT( int, playlist_NodeRemoveItem, (playlist_t *,playlist_item_t*,playlist_item_t *) );
00393 VLC_EXPORT( playlist_item_t *, playlist_ChildSearchName, (playlist_item_t*, const char* ) );
00394 VLC_EXPORT( int, playlist_NodeDelete, ( playlist_t *, playlist_item_t *, bool , bool ) );
00395 VLC_EXPORT( int, playlist_NodeEmpty, ( playlist_t *, playlist_item_t *, bool ) );
00396 VLC_EXPORT( void, playlist_NodesPairCreate, (playlist_t *, const char *, playlist_item_t **, playlist_item_t **, bool ) );
00397 VLC_EXPORT( playlist_item_t *, playlist_GetPreferredNode, ( playlist_t *p_playlist, playlist_item_t *p_node ) );
00398 VLC_EXPORT( playlist_item_t *, playlist_GetNextLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed ) );
00399 VLC_EXPORT( playlist_item_t *, playlist_GetPrevLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed ) );
00400 VLC_EXPORT( playlist_item_t *, playlist_GetLastLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root ) );
00401
00402
00403
00404
00405
00406 static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file)
00407 {
00408 char psz_uri[256+10];
00409 input_item_t *p_input;
00410 snprintf( psz_uri, 256+9, "file/://%s", psz_file );
00411 const char *const psz_option = "meta-file";
00412 p_input = input_ItemNewExt( p_playlist, psz_uri, psz_file,
00413 1, &psz_option, -1 );
00414 playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND, PLAYLIST_END,
00415 true, false );
00416 input_Read( p_playlist, p_input, true );
00417 return VLC_SUCCESS;
00418 }
00419
00420
00421 #define pl_CurrentInput(a) __pl_CurrentInput( VLC_OBJECT(a) )
00422 static inline input_thread_t * __pl_CurrentInput( vlc_object_t * p_this )
00423 {
00424 playlist_t * p_playlist = pl_Yield( p_this );
00425 if( !p_playlist ) return NULL;
00426 input_thread_t * p_input = playlist_CurrentInput( p_playlist );
00427 pl_Release( p_this );
00428 return p_input;
00429 }
00430
00431
00432 #define playlist_IsPlaying( pl ) ( pl->status.i_status == PLAYLIST_RUNNING && \
00433 !(pl->request.b_request && pl->request.i_status == PLAYLIST_STOPPED) )
00434
00435 #define playlist_IsStopped( pl ) ( pl->status.i_status == PLAYLIST_STOPPED || \
00436 (pl->request.b_request && pl->request.i_status == PLAYLIST_STOPPED) )
00437
00438
00439 #define playlist_IsEmpty( pl ) ( pl->items.i_size == 0 )
00440
00441
00442 #define playlist_CurrentSize( pl ) pl->current.i_size
00443
00444
00445 #define playlist_CurrentId( pl ) pl->status.p_item->i_id
00446
00447
00448 #define playlist_Signal( p_playlist ) vlc_object_signal( p_playlist )
00449
00450
00451 # ifdef __cplusplus
00452 }
00453 # endif
00454
00455 #endif