]> git.sesse.net Git - vlc/blob - include/vlc_playlist.h
common.*: add common routine to eliminate palette from pixmap.
[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.18 2003/12/03 21:58:42 sigmunau 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 item */
45     char **    ppsz_options;   /**< options passed with the :foo=bar syntax */
46     int        i_options;      /**< number of items in the
47                                 * ppsz_options array */
48     int        i_type;         /**< unused yet */
49     int        i_status;       /**< unused yet */
50     vlc_bool_t b_autodeletion; /**< Indicates whther this item is to
51                                 * be deleted after playback. True mean
52                                 * that this item is to be deleted
53                                 * after playback, false otherwise */
54     vlc_bool_t b_enabled;      /**< Indicates whether this item is to be
55                                 * played or skipped */
56
57     int        i_group;         /**< unused yet */
58     char *     psz_author;     /**< Author */
59 };
60
61 struct playlist_group_t
62 {
63     char *   psz_name;        /**< name of the group */
64     int      i_id;            /**< Identifier for the group */
65 };
66
67 /**
68  * Playlist status
69  */
70 typedef enum { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
71
72 /**
73  * Structure containing information about the playlist
74  */
75 struct playlist_t
76 {
77     VLC_COMMON_MEMBERS
78 /**
79    \name playlist_t
80    These members are uniq to playlist_t
81 */
82 /*@{*/
83     int                   i_index;  /**< current index into the playlist */
84     playlist_status_t     i_status; /**< current status of playlist */
85     int                   i_size;   /**< total size of the list */
86     int                   i_enabled; /**< How many items are enabled ? */
87     playlist_item_t **    pp_items; /**< array of pointers to the
88                                      * playlist items */
89     int                   i_groups; /**< How many groups are in the playlist */
90     playlist_group_t **   pp_groups;/**< array of pointers to the playlist
91                                      * groups */
92     int                   i_max_id; /**< Maximal group id given */
93     input_thread_t *      p_input;  /**< the input thread ascosiated
94                                      * with the current item */
95     /*@}*/
96 };
97
98 #define SORT_TITLE 0
99 #define SORT_AUTHOR 1
100 #define SORT_GROUP 2
101 #define SORT_RANDOM 3
102
103 #define SORT_NORMAL 0
104 #define SORT_REVERSE 1
105
106 #define PLAYLIST_TYPE_MANUAL 1
107 #define PLAYLIST_TYPE_SAP 2
108
109 /*****************************************************************************
110  * Prototypes
111  *****************************************************************************/
112 #define playlist_Create(a) __playlist_Create(VLC_OBJECT(a))
113 playlist_t * __playlist_Create   ( vlc_object_t * );
114 void           playlist_Destroy  ( playlist_t * );
115
116 #define playlist_Play(p) playlist_Command(p,PLAYLIST_PLAY,0)
117 #define playlist_Pause(p) playlist_Command(p,PLAYLIST_PAUSE,0)
118 #define playlist_Stop(p) playlist_Command(p,PLAYLIST_STOP,0)
119 #define playlist_Next(p) playlist_Command(p,PLAYLIST_SKIP,1)
120 #define playlist_Prev(p) playlist_Command(p,PLAYLIST_SKIP,-1)
121 #define playlist_Skip(p,i) playlist_Command(p,PLAYLIST_SKIP,i)
122 #define playlist_Goto(p,i) playlist_Command(p,PLAYLIST_GOTO,i)
123 VLC_EXPORT( void, playlist_Command, ( playlist_t *, playlist_command_t, int ) );
124
125 VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char **, int, int, int ) );
126 VLC_EXPORT( int,  playlist_AddExt,    ( playlist_t *, const char *, const char *, mtime_t, const char **, int, int, int ) );
127 VLC_EXPORT( int,  playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) );
128 VLC_EXPORT( int,  playlist_Delete, ( playlist_t *, int ) );
129 VLC_EXPORT( int,  playlist_Disable, ( playlist_t *, int ) );
130 VLC_EXPORT( int,  playlist_Enable, ( playlist_t *, int ) );
131 VLC_EXPORT( int,  playlist_DisableGroup, ( playlist_t *, int ) );
132 VLC_EXPORT( int,  playlist_EnableGroup, ( playlist_t *, int ) );
133
134 VLC_EXPORT( playlist_group_t *, playlist_CreateGroup, (playlist_t *, char* ) );
135 VLC_EXPORT( int, playlist_DeleteGroup, (playlist_t *, int ) );
136 VLC_EXPORT( char *, playlist_FindGroup, (playlist_t *, int ) );
137 VLC_EXPORT( int, playlist_GroupToId, (playlist_t *, char * ) );
138
139 #define playlist_SortTitle(p, i) playlist_Sort( p, SORT_TITLE, i)
140 #define playlist_SortAuthor(p, i) playlist_Sort( p, SORT_AUTHOR, i)
141 #define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i)
142
143 VLC_EXPORT( int,  playlist_Sort, ( playlist_t *, int, int) );
144
145 VLC_EXPORT( int,  playlist_Move, ( playlist_t *, int, int ) );
146 VLC_EXPORT( int,  playlist_LoadFile, ( playlist_t *, const char * ) );
147 VLC_EXPORT( int,  playlist_SaveFile, ( playlist_t *, const char * ) );
148
149 /**
150  *  tell if a playlist is currently playing.
151  *  \param p_playlist the playlist to check
152  *  \return true if playlist is playing, false otherwise
153  */
154 static inline vlc_bool_t playlist_IsPlaying( playlist_t * p_playlist )
155 {
156     vlc_bool_t b_playing;
157
158     vlc_mutex_lock( &p_playlist->object_lock );
159     b_playing = p_playlist->i_status == PLAYLIST_RUNNING; 
160     vlc_mutex_unlock( &p_playlist->object_lock );
161
162     return( b_playing );
163 }
164
165 /**
166  *  tell if a playlist is currently empty
167  *  \param p_playlist the playlist to check
168  *  \return true if the playlist is empty, false otherwise
169  */
170 static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
171 {
172     vlc_bool_t b_empty;
173
174     vlc_mutex_lock( &p_playlist->object_lock );
175     b_empty = p_playlist->i_size == 0;
176     vlc_mutex_unlock( &p_playlist->object_lock );
177
178     return( b_empty );
179 }
180
181 /**
182  * @}
183  */