]> git.sesse.net Git - vlc/blob - include/vlc/vlc.h
* Makefile.am: New file version.c, generated at each 'make' command.
[vlc] / include / vlc / vlc.h
1 /*****************************************************************************
2  * vlc.h: global header for vlc
3  *****************************************************************************
4  * Copyright (C) 1998-2004 the VideoLAN team
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  * \defgroup var_type Variable types
51  * These are the different types a vlc variable can have.
52  * @{
53  */
54 #define VLC_VAR_VOID      0x0010
55 #define VLC_VAR_BOOL      0x0020
56 #define VLC_VAR_INTEGER   0x0030
57 #define VLC_VAR_HOTKEY    0x0031
58 #define VLC_VAR_STRING    0x0040
59 #define VLC_VAR_MODULE    0x0041
60 #define VLC_VAR_FILE      0x0042
61 #define VLC_VAR_DIRECTORY 0x0043
62 #define VLC_VAR_VARIABLE  0x0044
63 #define VLC_VAR_FLOAT     0x0050
64 #define VLC_VAR_TIME      0x0060
65 #define VLC_VAR_ADDRESS   0x0070
66 #define VLC_VAR_MUTEX     0x0080
67 #define VLC_VAR_LIST      0x0090
68 /**@}*/
69
70 /**
71  * VLC value structure
72  */
73 typedef union
74 {
75     int             i_int;
76     vlc_bool_t      b_bool;
77     float           f_float;
78     char *          psz_string;
79     void *          p_address;
80     vlc_object_t *  p_object;
81     vlc_list_t *    p_list;
82
83 #if (defined( WIN32 ) || defined( UNDER_CE )) && !defined( __MINGW32__ )
84     signed __int64   i_time;
85 # else
86     signed long long i_time;
87 #endif
88
89     struct { char *psz_name; int i_object_id; } var;
90
91    /* Make sure the structure is at least 64bits */
92     struct { char a, b, c, d, e, f, g, h; } padding;
93
94 } vlc_value_t;
95
96 /**
97  * VLC list structure
98  */
99 struct vlc_list_t
100 {
101     int             i_count;
102     vlc_value_t *   p_values;
103     int *           pi_types;
104
105 };
106
107 /*****************************************************************************
108  * Error values
109  *****************************************************************************/
110 #define VLC_SUCCESS         -0                                   /* No error */
111 #define VLC_ENOMEM          -1                          /* Not enough memory */
112 #define VLC_ETHREAD         -2                               /* Thread error */
113 #define VLC_ETIMEOUT        -3                                    /* Timeout */
114
115 #define VLC_ENOMOD         -10                           /* Module not found */
116
117 #define VLC_ENOOBJ         -20                           /* Object not found */
118 #define VLC_EBADOBJ        -21                            /* Bad object type */
119
120 #define VLC_ENOVAR         -30                         /* Variable not found */
121 #define VLC_EBADVAR        -31                         /* Bad variable value */
122
123 #define VLC_EEXIT         -255                             /* Program exited */
124 #define VLC_EGENERIC      -666                              /* Generic error */
125
126 /*****************************************************************************
127  * Booleans
128  *****************************************************************************/
129 #define VLC_FALSE 0
130 #define VLC_TRUE  1
131
132 /*****************************************************************************
133  * Playlist
134  *****************************************************************************/
135
136 /* Used by VLC_AddTarget() */
137 #define PLAYLIST_INSERT          0x0001
138 #define PLAYLIST_REPLACE         0x0002
139 #define PLAYLIST_APPEND          0x0004
140 #define PLAYLIST_GO              0x0008
141 #define PLAYLIST_CHECK_INSERT    0x0010
142
143 #define PLAYLIST_END           -666
144
145 /*****************************************************************************
146  * Required internal headers
147  *****************************************************************************/
148 #if defined( __VLC__ )
149 #   include "vlc_common.h"
150 #endif
151
152 /*****************************************************************************
153  * Exported libvlc API
154  *****************************************************************************/
155 #if !defined( __VLC__ )
156 /* Otherwise they are declared and exported in vlc_common.h */
157 /**
158  * Retrieve libvlc version
159  *
160  * \return a string containing the libvlc version
161  */
162 char const * VLC_Version ( void );
163
164 /**
165  * Retrieve libvlc compile time
166  *
167  * \return a string containing the libvlc compile time
168  */
169 char const * VLC_CompileTime ( void );
170
171 /**
172  * Retrieve the username of the libvlc builder
173  *
174  * \return a string containing the username of the libvlc builder
175  */
176 char const * VLC_CompileBy ( void );
177
178 /**
179  * Retrieve the host of the libvlc builder
180  *
181  * \return a string containing the host of the libvlc builder
182  */
183 char const * VLC_CompileHost ( void );
184
185 /**
186  * Retrieve the domain name of the host of the libvlc builder
187  *
188  * \return a string containing the domain name of the host of the libvlc builder
189  */
190 char const * VLC_CompileDomain ( void );
191
192 /**
193  * Retrieve libvlc compiler version
194  *
195  * \return a string containing the libvlc compiler version
196  */
197 char const * VLC_Compiler ( void );
198
199 /**
200  * Retrieve libvlc changeset
201  *
202  * \return a string containing the libvlc subversion changeset
203  */
204 char const * VLC_Changeset ( void );
205
206 /**
207  * Return an error string
208  *
209  * \param i_err an error code
210  * \return an error string
211  */
212 char const * VLC_Error ( int i_err );
213
214 #endif /* __VLC__ */
215
216 /**
217  * Initialize libvlc
218  *
219  * This function allocates a vlc_t structure and returns a negative value
220  * in case of failure. Also, the thread system is initialized
221  *
222  * \return vlc object id or an error code
223  */
224 int     VLC_Create( void );
225
226 /**
227  * Initialize a vlc_t structure
228  *
229  * This function initializes a previously allocated vlc_t structure:
230  *  - CPU detection
231  *  - gettext initialization
232  *  - message queue, module bank and playlist initialization
233  *  - configuration and commandline parsing
234  *
235  *  \param i_object a vlc object id
236  *  \param i_argc the number of arguments
237  *  \param ppsz_argv an array of arguments
238  *  \return VLC_SUCCESS on success
239  */
240 int     VLC_Init( int, int, char *[] );
241
242 /**
243  * Add an interface
244  *
245  * This function opens an interface plugin and runs it. If b_block is set
246  * to 0, VLC_AddIntf will return immediately and let the interface run in a
247  * separate thread. If b_block is set to 1, VLC_AddIntf will continue until
248  * user requests to quit.
249  *
250  * \param i_object a vlc object id
251  * \param psz_module a vlc module name of an interface
252  * \param b_block make this interface blocking
253  * \param b_play start playing when the interface is done loading
254  * \return VLC_SUCCESS on success
255  */
256 int     VLC_AddIntf( int, char const *, vlc_bool_t, vlc_bool_t );
257
258 /**
259  * Ask vlc to die
260  *
261  * This function sets p_vlc->b_die to VLC_TRUE, but does not do any other
262  * task. It is your duty to call VLC_CleanUp and VLC_Destroy afterwards.
263  *
264  * \param i_object a vlc object id
265  * \return VLC_SUCCESS on success
266  */
267 int     VLC_Die( int );
268
269 /**
270  * Clean up all the intf, playlist, vout and aout
271  *
272  * This function requests all intf, playlist, vout and aout objects to finish
273  * and CleanUp. Only a blank VLC object should remain after this.
274  *
275  * \note This function was previously called VLC_Stop
276  *
277  * \param i_object a vlc object id
278  * \return VLC_SUCCESS on success
279  */
280 int     VLC_CleanUp( int );
281
282 /**
283  * Destroy all threads and the VLC object
284  *
285  * This function requests the running threads to finish, waits for their
286  * termination, and destroys their structure.
287  * Then it will de-init all VLC object initializations. 
288  *
289  * \param i_object a vlc object id
290  * \return VLC_SUCCESS on success
291  */
292 int     VLC_Destroy( int );
293
294 /**
295  * Set a VLC variable
296  *
297  * This function sets a variable of VLC
298  *
299  * \note Was previously called VLC_Set
300  *
301  * \param i_object a vlc object id
302  * \param psz_var a vlc variable name
303  * \param value a vlc_value_t structure
304  * \return VLC_SUCCESS on success
305  */
306 int     VLC_VariableSet( int, char const *, vlc_value_t );
307
308 /**
309  * Get a VLC variable
310  *
311  * This function gets the value of a variable of VLC
312  * It stores it in the p_value argument
313  *
314  * \note Was previously called VLC_Get
315  *
316  * \param i_object a vlc object id
317  * \param psz_var a vlc variable name
318  * \param p_value a pointer to a vlc_value_t structure
319  * \return VLC_SUCCESS on success
320  */
321 int     VLC_VariableGet( int, char const *, vlc_value_t * );
322
323 /**
324  * Get a VLC variable type
325  *
326  * This function gets the type of a variable of VLC
327  * It stores it in the p_type argument
328  *
329  * \param i_object a vlc object id
330  * \param psz_var a vlc variable name
331  * \param pi_type a pointer to an integer
332  * \return VLC_SUCCESS on success
333  */
334 int     VLC_VariableType( int, char const *, int * );
335
336 /**
337  * Add a target to the current playlist
338  *
339  * This funtion will add a target to the current playlist. If a playlist does
340  * not exist, it will be created.
341  *
342  * \param i_object a vlc object id
343  * \param psz_target the URI of the target to play
344  * \param ppsz_options an array of strings with input options (ie. :input-repeat)
345  * \param i_options the amount of options in the ppsz_options array
346  * \param i_mode the insert mode to insert the target into the playlist (PLAYLIST_* defines)
347  * \param i_pos the position at which to add the new target (PLAYLIST_END for end)
348  * \return VLC_SUCCESS on success
349  */
350 int     VLC_AddTarget( int, char const *, const char **, int, int, int );
351
352 /**
353  * Start the playlist and play the currently selected playlist item
354  *
355  * If there is something in the playlist, and the playlist is not running,
356  * then start the playlist and play the currently selected playlist item.
357  * If an item is currently paused, then resume it.
358  *
359  * \param i_object a vlc object id
360  * \return VLC_SUCCESS on success
361  */
362 int     VLC_Play( int );
363
364 /**
365  * Pause the currently playing item. Resume it if already paused
366  *
367  * If an item is currently playing then pause it.
368  * If the item is already paused, then resume playback.
369  *
370  * \param i_object a vlc object id
371  * \return VLC_SUCCESS on success
372  */
373 int     VLC_Pause( int );
374
375 /**
376  * Stop the playlist
377  *
378  * If an item is currently playing then stop it.
379  * Set the playlist to a stopped state.
380  *
381  * \note This function is new. The old VLC_Stop is now called VLC_CleanUp
382  *
383  * \param i_object a vlc object id
384  * \return VLC_SUCCESS on success
385  */
386 int             VLC_Stop( int );
387
388 /**
389  * Tell if VLC is playing
390  *
391  * If an item is currently playing, it returns
392  * VLC_TRUE, else VLC_FALSE
393  *
394  * \param i_object a vlc object id
395  * \return VLC_TRUE or VLC_FALSE
396  */
397 vlc_bool_t      VLC_IsPlaying( int );
398
399 /**
400  * Get the current position in a input
401  *
402  * Return the current position as a float
403  * This method should be used for time sliders etc
404  * \note For some inputs, this will be unknown.
405  *
406  * \param i_object a vlc object id
407  * \return a float in the range of 0.0 - 1.0
408  */
409 float           VLC_PositionGet( int );
410
411 /**
412  * Set the current position in a input
413  *
414  * Set the current position as a float
415  * This method should be used for time sliders etc
416  * \note For some inputs, this will be unknown.
417  *
418  * \param i_object a vlc object id
419  * \param i_position a float in the range of 0.0 - 1.0
420  * \return a float in the range of 0.0 - 1.0
421  */
422 float           VLC_PositionSet( int, float );
423
424 /**
425  * Get the current position in a input
426  *
427  * Return the current position in seconds from the start.
428  * \note For some inputs, this will be unknown.
429  *
430  * \param i_object a vlc object id
431  * \return the offset from 0:00 in seconds
432  */
433 int             VLC_TimeGet( int );
434
435 /**
436  * Seek to a position in the current input
437  *
438  * Seek i_seconds in the current input. If b_relative is set,
439  * then the seek will be relative to the current position, otherwise
440  * it will seek to i_seconds from the beginning of the input.
441  * \note For some inputs, this will be unknown.
442  *
443  * \param i_object a vlc object id
444  * \param i_seconds seconds from current position or from beginning of input
445  * \param b_relative seek relative from current position
446  * \return VLC_SUCCESS on success
447  */
448 int             VLC_TimeSet( int, int, vlc_bool_t );
449
450 /**
451  * Get the total length of a input
452  *
453  * Return the total length in seconds from the current input.
454  * \note For some inputs, this will be unknown.
455  *
456  * \param i_object a vlc object id
457  * \return the length in seconds
458  */
459 int             VLC_LengthGet( int );
460
461 /**
462  * Play the input faster than realtime
463  *
464  * 2x, 4x, 8x faster than realtime
465  * \note For some inputs, this will be impossible.
466  *
467  * \param i_object a vlc object id
468  * \return the current speedrate
469  */
470 float           VLC_SpeedFaster( int );
471
472 /**
473  * Play the input slower than realtime
474  *
475  * 1/2x, 1/4x, 1/8x slower than realtime
476  * \note For some inputs, this will be impossible.
477  *
478  * \param i_object a vlc object id
479  * \return the current speedrate
480  */
481 float           VLC_SpeedSlower( int );
482
483 /**
484  * Return the current playlist item
485  *
486  * \param i_object a vlc object id
487  * \return the index of the playlistitem that is currently selected for play
488  */
489 int             VLC_PlaylistIndex( int );
490
491 /**
492  * Total amount of items in the playlist
493  *
494  * \param i_object a vlc object id
495  * \return amount of playlist items
496  */
497 int             VLC_PlaylistNumberOfItems( int );
498
499 /**
500  * Next playlist item
501  *
502  * Skip to the next playlistitem and play it.
503  *
504  * \param i_object a vlc object id
505  * \return VLC_SUCCESS on success
506  */
507 int             VLC_PlaylistNext( int );
508
509 /**
510  * Previous playlist item
511  *
512  * Skip to the previous playlistitem and play it.
513  *
514  * \param i_object a vlc object id
515  * \return VLC_SUCCESS on success
516  */
517 int             VLC_PlaylistPrev( int );
518
519 /**
520  * Clear the contents of the playlist
521  *
522  * Completly empty the entire playlist.
523  *
524  * \note Was previously called VLC_ClearPlaylist
525  *
526  * \param i_object a vlc object id
527  * \return VLC_SUCCESS on success
528  */
529 int             VLC_PlaylistClear( int );
530
531 /**
532  * Change the volume
533  *
534  * \param i_object a vlc object id
535  * \param i_volume something in a range from 0-200
536  * \return the new volume (range 0-200 %)
537  */
538 int             VLC_VolumeSet( int, int );
539
540 /**
541  * Get the current volume
542  *
543  * Retrieve the current volume.
544  *
545  * \param i_object a vlc object id
546  * \return the current volume (range 0-200 %)
547  */
548 int             VLC_VolumeGet( int );
549
550 /**
551  * Mute/Unmute the volume
552  *
553  * \param i_object a vlc object id
554  * \return VLC_SUCCESS on success
555  */
556 int            VLC_VolumeMute( int );
557
558 /**
559  * Toggle Fullscreen mode
560  *
561  * Switch between normal and fullscreen video
562  *
563  * \param i_object a vlc object id
564  * \return VLC_SUCCESS on success
565  */
566 int             VLC_FullScreen( int );
567
568
569 # ifdef __cplusplus
570 }
571 # endif
572
573 #endif /* <vlc/vlc.h> */