]> git.sesse.net Git - vlc/blob - include/vlc/vlc.h
NOTE: libvlc API changes
[vlc] / include / vlc / vlc.h
1 /*****************************************************************************
2  * vlc.h: global header for vlc
3  *****************************************************************************
4  * Copyright (C) 1998-2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Vincent Seguin <seguin@via.ecp.fr>
8  *          Samuel Hocevar <sam@zoy.org>
9  *          Gildas Bazin <gbazin@netcourrier.com>
10  *          Derk-Jan Hartman <hartman at videolan dot org>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26
27 /**
28  * \defgroup libvlc Libvlc
29  * This is libvlc, the base library of the VLC program.
30  *
31  * @{
32  */
33
34
35 #ifndef _VLC_VLC_H
36 #define _VLC_VLC_H 1
37
38 # ifdef __cplusplus
39 extern "C" {
40 # endif
41
42 /*****************************************************************************
43  * Our custom types
44  *****************************************************************************/
45 typedef int vlc_bool_t;
46 typedef struct vlc_list_t vlc_list_t;
47 typedef struct vlc_object_t vlc_object_t;
48
49 /**
50  * VLC value structure
51  */
52 typedef union
53 {
54     int             i_int;
55     vlc_bool_t      b_bool;
56     float           f_float;
57     char *          psz_string;
58     void *          p_address;
59     vlc_object_t *  p_object;
60     vlc_list_t *    p_list;
61
62 #if defined( WIN32 ) && !defined( __MINGW32__ )
63     signed __int64   i_time;
64 # else
65     signed long long i_time;
66 #endif
67
68     struct { char *psz_name; int i_object_id; } var;
69
70    /* Make sure the structure is at least 64bits */
71     struct { char a, b, c, d, e, f, g, h; } padding;
72
73 } vlc_value_t;
74
75 /**
76  * VLC list structure
77  */
78 struct vlc_list_t
79 {
80     int             i_count;
81     vlc_value_t *   p_values;
82     int *           pi_types;
83
84 };
85
86 /*****************************************************************************
87  * Error values
88  *****************************************************************************/
89 #define VLC_SUCCESS         -0                                   /* No error */
90 #define VLC_ENOMEM          -1                          /* Not enough memory */
91 #define VLC_ETHREAD         -2                               /* Thread error */
92 #define VLC_ETIMEOUT        -3                                    /* Timeout */
93
94 #define VLC_ENOMOD         -10                           /* Module not found */
95
96 #define VLC_ENOOBJ         -20                           /* Object not found */
97 #define VLC_EBADOBJ        -21                            /* Bad object type */
98
99 #define VLC_ENOVAR         -30                         /* Variable not found */
100 #define VLC_EBADVAR        -31                         /* Bad variable value */
101
102 #define VLC_EEXIT         -255                             /* Program exited */
103 #define VLC_EGENERIC      -666                              /* Generic error */
104
105 /*****************************************************************************
106  * Booleans
107  *****************************************************************************/
108 #define VLC_FALSE 0
109 #define VLC_TRUE  1
110
111 /*****************************************************************************
112  * Playlist
113  *****************************************************************************/
114
115 /* Used by VLC_AddTarget() */
116 #define PLAYLIST_INSERT          0x0001
117 #define PLAYLIST_REPLACE         0x0002
118 #define PLAYLIST_APPEND          0x0004
119 #define PLAYLIST_GO              0x0008
120 #define PLAYLIST_CHECK_INSERT    0x0010
121
122 #define PLAYLIST_END           -666
123
124 /*****************************************************************************
125  * Required internal headers
126  *****************************************************************************/
127 #if defined( __VLC__ )
128 #   include "vlc_common.h"
129 #endif
130
131 /*****************************************************************************
132  * Exported libvlc API
133  *****************************************************************************/
134
135 /**
136  * Retrieve libvlc version
137  *
138  * \return a string containing the libvlc version
139  */
140 char const * VLC_Version ( void );
141
142 /**
143  * Return an error string
144  *
145  * \param i_err an error code
146  * \return an error string
147  */
148 char const * VLC_Error ( int i_err );
149
150 /**
151  * Initialize libvlc
152  *
153  * This function allocates a vlc_t structure and returns a negative value
154  * in case of failure. Also, the thread system is initialized
155  *
156  * \return vlc object id or an error code
157  */
158 int     VLC_Create       ( void );
159
160 /**
161  * Initialize a vlc_t structure
162  *
163  * This function initializes a previously allocated vlc_t structure:
164  *  - CPU detection
165  *  - gettext initialization
166  *  - message queue, module bank and playlist initialization
167  *  - configuration and commandline parsing
168  *
169  *  \param i_object a vlc object id
170  *  \param i_argc the number of arguments
171  *  \param ppsz_argv an array of arguments
172  *  \return VLC_SUCCESS on success
173  */
174 int     VLC_Init         ( int, int, char *[] );
175
176 /**
177  * Add an interface
178  *
179  * This function opens an interface plugin and runs it. If b_block is set
180  * to 0, VLC_AddIntf will return immediately and let the interface run in a
181  * separate thread. If b_block is set to 1, VLC_AddIntf will continue until
182  * user requests to quit.
183  *
184  * \param i_object a vlc object id
185  * \param psz_module a vlc module name of an interface
186  * \param b_block make this interface blocking
187  * \param b_play start playing when the interface is done loading
188  * \return VLC_SUCCESS on success
189  */
190 int     VLC_AddIntf      ( int, char const *, vlc_bool_t, vlc_bool_t );
191
192 /**
193  * Ask vlc to die
194  *
195  * This function sets p_vlc->b_die to VLC_TRUE, but does not do any other
196  * task. It is your duty to call VLC_CleanUp and VLC_Destroy afterwards.
197  *
198  * \param i_object a vlc object id
199  * \return VLC_SUCCESS on success
200  */
201 int     VLC_Die          ( int );
202
203 /**
204  * Clean up all the intf, playlist, vout and aout
205  *
206  * This function requests all intf, playlist, vout and aout objects to finish
207  * and CleanUp. Only a blank VLC object should remain after this.
208  *
209  * \param i_object a vlc object id
210  * \return VLC_SUCCESS on success
211  */
212 int     VLC_CleanUp      ( int );
213
214 /**
215  * Destroy all threads and the VLC object
216  *
217  * This function requests the running threads to finish, waits for their
218  * termination, and destroys their structure.
219  * Then it will de-init all VLC object initializations. 
220  *
221  * \param i_object a vlc object id
222  * \return VLC_SUCCESS on success
223  */
224 int     VLC_Destroy      ( int );
225
226 /**
227  * Set a VLC variable
228  *
229  * This function sets a variable of VLC
230  *
231  * \param i_object a vlc object id
232  * \param psz_var a vlc variable name
233  * \param value a vlc_value_t structure
234  * \return VLC_SUCCESS on success
235  */
236 int     VLC_Set          ( int, char const *, vlc_value_t );
237
238 /**
239  * Get a VLC variable
240  *
241  * This function gets the value of a variable of VLC
242  * It stores it in the p_value argument
243  *
244  * \param i_object a vlc object id
245  * \param psz_var a vlc variable name
246  * \param p_value a pointer to a vlc_value_t structure
247  * \return VLC_SUCCESS on success
248  */
249 int     VLC_Get          ( int, char const *, vlc_value_t * );
250
251 /**
252  * Add a target to the current playlist
253  *
254  * This funtion will add a target to the current playlist. If a playlist does
255  * not exist, it will be created.
256  *
257  * \param i_object a vlc object id
258  * \param psz_target the URI of the target to play
259  * \param ppsz_options an array of strings with input options (ie. :input-repeat)
260  * \param i_options the amount of options in the ppsz_options array
261  * \param i_mode the insert mode to insert the target into the playlist (PLAYLIST_* defines)
262  * \param i_pos the position at which to add the new target (PLAYLIST_END for end)
263  * \return VLC_SUCCESS on success
264  */
265 int     VLC_AddTarget    ( int, char const *, const char **, int, int, int );
266
267 /**
268  * Start the playlist and play the currently selected playlist item
269  *
270  * If there is something in the playlist, and the playlist is not running,
271  * then start the playlist and play the currently selected playlist item.
272  * If an item is currently paused, then resume it.
273  *
274  * \param i_object a vlc object id
275  * \return VLC_SUCCESS on success
276  */
277 int     VLC_Play         ( int );
278
279 /**
280  * Pause the currently playing item. Resume it if already paused
281  *
282  * If an item is currently playing then pause it.
283  * If the item is already paused, then resume playback.
284  *
285  * \param i_object a vlc object id
286  * \return VLC_SUCCESS on success
287  */
288 int     VLC_Pause        ( int );
289
290 /**
291  * Stop the playlist
292  *
293  * If an item is currently playing then stop it.
294  * Set the playlist to a stopped state.
295  *
296  * \param i_object a vlc object id
297  * \return VLC_SUCCESS on success
298  */
299 int     VLC_Stop         ( int );
300
301 /**
302  * Stop the playlist
303  *
304  * If an item is currently playing then stop it.
305  * Set the playlist to a stopped state.
306  *
307  * \param i_object a vlc object id
308  * \return VLC_SUCCESS on success
309  */
310 vlc_bool_t VLC_IsPlaying ( int );
311
312 /**
313  * Clear the contents of the playlist
314  *
315  * Completly empty the entire playlist.
316  *
317  * \param i_object a vlc object id
318  * \return VLC_SUCCESS on success
319  */
320 int     VLC_ClearPlaylist( int );
321
322 /**
323  * Toggle Fullscreen mode
324  *
325  * Switch between normal and fullscreen video
326  *
327  * \param i_object a vlc object id
328  * \return VLC_SUCCESS on success
329  */
330 int     VLC_FullScreen   ( int );
331
332
333 # ifdef __cplusplus
334 }
335 # endif
336
337 #endif /* <vlc/vlc.h> */