]> git.sesse.net Git - vlc/blob - include/vlc_playlist.h
b9e8eaf83cee4cbe044f13fea4ba22cdb94d9c4b
[vlc] / include / vlc_playlist.h
1 /*****************************************************************************
2  * vlc_playlist.h : Playlist functions
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
5  * $Id: vlc_playlist.h,v 1.13 2003/09/08 12:02:16 zorglub Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /**
25  *  \file
26  *  This file contain structures and function prototypes related
27  *  to the playlist in vlc
28  */
29
30 /**
31  * \defgroup vlc_playlist Playlist
32  * Brief description. Longer description
33  * @{
34  */
35
36 /**
37  * playlist item
38  * \see playlist_t
39  */
40 struct playlist_item_t
41 {
42     char *     psz_name;       /**< text describing this item */
43     char *     psz_uri;        /**< mrl of this item */
44     mtime_t    i_duration;     /**< A hint about the duration of this
45                                 * item, in miliseconds*/
46     char **    ppsz_options;   /**< options passed with the :foo=bar syntax */
47     int        i_options;      /**< number of items in the
48                                 * ppsz_options array */
49     int        i_type;         /**< unused yet */
50     int        i_status;       /**< unused yet */
51     vlc_bool_t b_autodeletion; /**< Indicates wether this item is to
52                                 * be deleted after playback. True mean
53                                 * that this item is to be deleted
54                                 * after playback, false otherwise */
55 };
56
57 /**
58  * Playlist status
59  */
60 typedef enum { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
61
62 /**
63  * Structure containing information about the playlist
64  */
65 struct playlist_t
66 {
67     VLC_COMMON_MEMBERS
68 /**
69    \name playlist_t
70    These members are uniq to playlist_t
71 */
72 /*@{*/
73     int                   i_index;  /**< current index into the playlist */
74     playlist_status_t     i_status; /**< current status of playlist */
75     int                   i_size;   /**< total size of the list */
76
77     playlist_item_t **    pp_items; /**< array of pointers to the
78                                      * playlist items */
79
80     input_thread_t *      p_input;  /**< the input thread ascosiated
81                                      * with the current item */
82     /*@}*/
83 };
84
85 #define SORT_NORMAL 0
86 #define SORT_REVERSE 1
87
88 /*****************************************************************************
89  * Prototypes
90  *****************************************************************************/
91 #define playlist_Create(a) __playlist_Create(VLC_OBJECT(a))
92 playlist_t * __playlist_Create   ( vlc_object_t * );
93 void           playlist_Destroy  ( playlist_t * );
94
95 #define playlist_Play(p) playlist_Command(p,PLAYLIST_PLAY,0)
96 #define playlist_Pause(p) playlist_Command(p,PLAYLIST_PAUSE,0)
97 #define playlist_Stop(p) playlist_Command(p,PLAYLIST_STOP,0)
98 #define playlist_Next(p) playlist_Command(p,PLAYLIST_SKIP,1)
99 #define playlist_Prev(p) playlist_Command(p,PLAYLIST_SKIP,-1)
100 #define playlist_Skip(p,i) playlist_Command(p,PLAYLIST_SKIP,i)
101 #define playlist_Goto(p,i) playlist_Command(p,PLAYLIST_GOTO,i)
102 VLC_EXPORT( void, playlist_Command, ( playlist_t *, playlist_command_t, int ) );
103
104 VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char **, int, int, int ) );
105 VLC_EXPORT( int,  playlist_AddExt,    ( playlist_t *, const char *, const char *, mtime_t, const char **, int, int, int ) );
106 VLC_EXPORT( int,  playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) );
107 VLC_EXPORT( int,  playlist_Delete, ( playlist_t *, int ) );
108 VLC_EXPORT( int,  playlist_Sort, ( playlist_t *, int) );
109 VLC_EXPORT( int,  playlist_Move, ( playlist_t *, int, int ) );
110 VLC_EXPORT( int,  playlist_LoadFile, ( playlist_t *, const char * ) );
111 VLC_EXPORT( int,  playlist_SaveFile, ( playlist_t *, const char * ) );
112
113 /**
114  *  tell if a playlist is currently playing.
115  *  \param p_playlist the playlist to check
116  *  \return true if playlist is playing, false otherwise
117  */
118 static inline vlc_bool_t playlist_IsPlaying( playlist_t * p_playlist )
119 {
120     vlc_bool_t b_playing;
121
122     vlc_mutex_lock( &p_playlist->object_lock );
123     b_playing = p_playlist->i_status == PLAYLIST_RUNNING; 
124     vlc_mutex_unlock( &p_playlist->object_lock );
125
126     return( b_playing );
127 }
128
129 /**
130  *  tell if a playlist is currently empty
131  *  \param p_playlist the playlist to check
132  *  \return true if the playlist is empty, false otherwise
133  */
134 static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
135 {
136     vlc_bool_t b_empty;
137
138     vlc_mutex_lock( &p_playlist->object_lock );
139     b_empty = p_playlist->i_size == 0;
140     vlc_mutex_unlock( &p_playlist->object_lock );
141
142     return( b_empty );
143 }
144
145 /**
146  * @}
147  */