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