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