]> git.sesse.net Git - vlc/blob - include/vlc/libvlc.h
Add a method to set playlist in loop mode.
[vlc] / include / vlc / libvlc.h
1 /*****************************************************************************
2  * libvlc.h:  libvlc_* new external API
3  *****************************************************************************
4  * Copyright (C) 1998-2005 the VideoLAN team
5  * $Id: vlc.h 13701 2005-12-12 17:58:56Z zorglub $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /**
25  * \defgroup libvlc Libvlc
26  * This is libvlc, the base library of the VLC program.
27  *
28  * @{
29  */
30
31
32 #ifndef _LIBVLC_H
33 #define _LIBVLC_H 1
34
35 #include <vlc/vlc.h>
36
37 # ifdef __cplusplus
38 extern "C" {
39 # endif
40
41 /*****************************************************************************
42  * Exception handling
43  *****************************************************************************/
44 /** defgroup libvlc_exception Exceptions
45  * \ingroup libvlc
46  * LibVLC Exceptions handling
47  * @{
48  */
49
50 struct libvlc_exception_t
51 {
52     int b_raised;
53     char *psz_message;
54 };
55 typedef struct libvlc_exception_t libvlc_exception_t;
56
57 /**
58  * Initialize an exception structure. This can be called several times to reuse
59  * an exception structure.
60  * \param p_exception the exception to initialize
61  */
62 void libvlc_exception_init( libvlc_exception_t *p_exception );
63
64 /**
65  * Has an exception been raised ?
66  * \param p_exception the exception to query
67  * \return 0 if no exception raised, 1 else
68  */
69 int libvlc_exception_raised( libvlc_exception_t *p_exception );
70
71 /**
72  * Raise an exception
73  * \param p_exception the exception to raise
74  * \param psz_message the exception message
75  */
76 void libvlc_exception_raise( libvlc_exception_t *p_exception, char *psz_format, ... );
77
78 /**
79  * Clear an exception object so it can be reused.
80  * The exception object must be initialized
81  * \param p_exception the exception to clear
82  */
83 void libvlc_exception_clear( libvlc_exception_t * );
84
85 /**
86  * Get exception message
87  * \param p_exception the exception to query
88  * \return the exception message or NULL if not applicable (exception not raised
89  * for example)
90  */
91 char* libvlc_exception_get_message( libvlc_exception_t *p_exception );
92
93 /**@} */
94
95 /*****************************************************************************
96  * Core handling
97  *****************************************************************************/
98
99 /** defgroup libvlc_core Core
100  * \ingroup libvlc
101  * LibVLC Core
102  * @{
103  */
104
105 /** This structure is opaque. It represents a libvlc instance */
106 typedef struct libvlc_instance_t libvlc_instance_t;
107
108 /**
109  * Create an initialized libvlc instance
110  * \param argc the number of arguments
111  * \param argv command-line-type arguments
112  * \param exception an initialized exception pointer
113  */
114 libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
115
116 /**
117  * Returns a libvlc instance identifier for legacy APIs. Use of this
118  * function is discouraged, you should convert your program to use the
119  * new API.
120  * \param p_instance the instance
121  */
122 int libvlc_get_vlc_id( libvlc_instance_t *p_instance );
123
124 /**
125  * Destroy a libvlc instance.
126  * \param p_instance the instance to destroy
127  */
128 void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
129
130 /** @}*/
131
132 /*****************************************************************************
133  * Playlist
134  *****************************************************************************/
135 /** defgroup libvlc_playlist Playlist
136  * \ingroup libvlc
137  * LibVLC Playlist handling
138  * @{
139  */
140 /**
141  * Set loop variable
142  */
143 void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * );
144 /**
145  * Start playing. You can give some additionnal playlist item options
146  * that will be added to the item before playing it.
147  * \param p_instance the instance
148  * \param i_id the item to play. If this is a negative number, the next
149  * item will be selected. Else, the item with the given ID will be played
150  * \param i_options the number of options to add to the item
151  * \param ppsz_options the options to add to the item
152  * \param p_exception an initialized exception
153  */
154 void libvlc_playlist_play( libvlc_instance_t*, int, int, char **,
155                            libvlc_exception_t * );
156
157 /**
158  * Pause a running playlist, resume if it was stopped
159  * \param p_instance the instance to pause
160  * \param p_exception an initialized exception
161  */
162 void libvlc_playlist_pause( libvlc_instance_t *, libvlc_exception_t * );
163
164 /**
165  * Checks if the playlist is running
166  * \param p_instance the instance
167  * \param p_exception an initialized exception
168  * \return 0 if the playlist is stopped or paused, 1 if it is running
169  */
170 int libvlc_playlist_isplaying( libvlc_instance_t *, libvlc_exception_t * );
171
172 /**
173  * Get the number of items in the playlist
174  * \param p_instance the instance
175  * \param p_exception an initialized exception
176  * \return the number of items
177  */
178 int libvlc_playlist_items_count( libvlc_instance_t *, libvlc_exception_t * );
179
180 /**
181  * Stop playing
182  * \param p_instance the instance to stop
183  * \param p_exception an initialized exception
184  */
185 void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * );
186
187 /**
188  * Go to next playlist item (starts playback if it was stopped)
189  * \param p_instance the instance to use
190  * \param p_exception an initialized exception
191  */
192 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * );
193
194 /**
195  * Go to previous playlist item (starts playback if it was stopped)
196  * \param p_instance the instance to use
197  * \param p_exception an initialized exception
198  */
199 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * );
200
201 /**
202  * Remove all playlist items
203  * \param p_instance the instance
204  * \param p_exception an initialized exception
205  */
206 void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * );
207
208 /**
209  * Add an item at the end of the playlist
210  * If you need more advanced options, \see libvlc_playlist_add_extended
211  * \param p_instance the instance
212  * \param psz_uri the URI to open, using VLC format
213  * \param psz_name a name that you might want to give or NULL
214  * \return the identifier of the new item
215  */
216 int libvlc_playlist_add( libvlc_instance_t *, const char *, const char *,
217                          libvlc_exception_t * );
218
219 /**
220  * Add an item at the end of the playlist, with additional input options
221  * \param p_instance the instance
222  * \param psz_uri the URI to open, using VLC format
223  * \param psz_name a name that you might want to give or NULL
224  * \param i_options the number of options to add
225  * \param ppsz_options strings representing the options to add
226  * \param p_exception an initialized exception
227  * \return the identifier of the new item
228  */
229 int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
230                                   const char *, int, const char **,
231                                   libvlc_exception_t * );
232
233 /** 
234  * Delete the playlist item with the given ID.
235  * \param p_instance the instance
236  * \param i_id the id to remove
237  * \param p_exception an initialized exception
238  * \return
239  */
240 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
241                                  libvlc_exception_t * );
242     
243 typedef struct libvlc_input_t libvlc_input_t;
244
245 /* Get the input that is currently being played by the playlist
246  * \param p_instance the instance to use
247  * \param p_exception an initialized excecption
248  * \return an input object
249  */
250 libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
251                                            libvlc_exception_t * );
252
253 /** @}*/
254
255 /*****************************************************************************
256  * Input
257  *****************************************************************************/
258 /** defgroup libvlc_input Input
259  * \ingroup libvlc
260  * LibVLC Input handling
261  * @{
262  */
263
264 /** Free an input object
265  * \param p_input the input to free
266  */
267 void libvlc_input_free( libvlc_input_t * );
268
269 /// \bug This might go away ... to be replaced by a broader system
270 vlc_int64_t libvlc_input_get_length     ( libvlc_input_t *, libvlc_exception_t *);
271 vlc_int64_t libvlc_input_get_time       ( libvlc_input_t *, libvlc_exception_t *);
272 void        libvlc_input_set_time       ( libvlc_input_t *, vlc_int64_t, libvlc_exception_t *);
273 float       libvlc_input_get_position   ( libvlc_input_t *, libvlc_exception_t *);
274 void        libvlc_input_set_position   ( libvlc_input_t *, float, libvlc_exception_t *);
275 vlc_bool_t  libvlc_input_will_play      ( libvlc_input_t *, libvlc_exception_t *);
276 float       libvlc_input_get_rate       ( libvlc_input_t *, libvlc_exception_t *);
277 void        libvlc_input_set_rate       ( libvlc_input_t *, float, libvlc_exception_t *);
278 int         libvlc_input_get_state      ( libvlc_input_t *, libvlc_exception_t *);
279         
280 /** @} */
281
282 /** defgroup libvlc_video Video
283  * \ingroup libvlc
284  * LibVLC Video handling
285  * @{
286  */
287
288 /**
289  * Does this input have a video output ?
290  * \param p_input the input
291  * \param p_exception an initialized exception
292  */
293 vlc_bool_t  libvlc_input_has_vout       ( libvlc_input_t *, libvlc_exception_t *);
294 float       libvlc_input_get_fps        ( libvlc_input_t *, libvlc_exception_t *);
295
296 /**
297  * Toggle fullscreen status on video output
298  * \param p_input the input
299  * \param p_exception an initialized exception
300  */
301 void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
302
303 /**
304  * Enable or disable fullscreen on a video output
305  * \param p_input the input
306  * \param b_fullscreen boolean for fullscreen status
307  * \param p_exception an initialized exception
308  */
309 void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
310
311 /**
312  * Get current fullscreen status
313  * \param p_input the input
314  * \param p_exception an initialized exception
315  * \return the fullscreen status (boolean)
316  */
317 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
318     
319 /**
320  * Get current video height
321  * \param p_input the input
322  * \param p_exception an initialized exception
323  * \return the video height
324  */
325 int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
326
327 /**
328  * Get current video width
329  * \param p_input the input
330  * \param p_exception an initialized exception
331  * \return the video width
332  */
333 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
334
335 /**
336  * Take a snapshot of the current video window
337  * \param p_input the input
338  * \param psz_filepath the path where to save the screenshot to
339  * \param p_exception an initialized exception
340  */
341 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
342     
343 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
344
345     
346 /**
347  * Resize the video output window
348  * \param p_instance libvlc instance
349  * \param width new width for video output window
350  * \param height new height for video output window
351  * \param p_exception an initialized exception
352  * \return the mute status (boolean)
353  */
354 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
355     
356 /**
357 * Downcast to this general type as placeholder for a platform specific one, such as:
358 *  Drawable on X11,
359 *  CGrafPort on MacOSX,
360 *  HWND on win32
361 */
362 typedef int libvlc_drawable_t;
363
364 /**
365  * change the video output parent
366  * \param p_instance libvlc instance
367  * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
368  * \param p_exception an initialized exception
369  * \return the mute status (boolean)
370  */
371 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
372
373 /**
374  * Set the video output parent
375  * \param p_instance libvlc instance
376  * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
377  * \param p_exception an initialized exception
378  */
379 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
380
381 /**
382  * Set the video output size
383  * \param p_instance libvlc instance
384  * \param width new width for video drawable
385  * \param height new height for video drawable
386  * \param p_exception an initialized exception
387  */
388 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
389
390 /**
391 * Downcast to this general type as placeholder for a platform specific one, such as:
392 *  Drawable on X11,
393 *  CGrafPort on MacOSX,
394 *  HWND on win32
395 */
396 typedef struct
397 {
398     int top, left;
399     int bottom, right;
400 }
401 libvlc_rectangle_t;
402
403 /**
404  * Set the video output viewport for a windowless video output (MacOS X only)
405  * \param p_instance libvlc instance
406  * \param view coordinates within video drawable
407  * \param clip coordinates within video drawable
408  * \param p_exception an initialized exception
409  */
410 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
411
412
413 /** @} */
414
415 /**
416  * defgroup libvlc_vlm VLM
417  * \ingroup libvlc
418  * LibVLC VLM handling
419  * @{
420  */
421
422 /** defgroup libvlc_audio Audio
423  * \ingroup libvlc
424  * LibVLC Audio handling
425  * @{
426  */
427
428 /**
429  * Toggle mute status
430  * \param p_instance libvlc instance
431  * \param p_exception an initialized exception
432  * \return void
433  */
434 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
435
436 /**
437  * Get current mute status
438  * \param p_instance libvlc instance
439  * \param p_exception an initialized exception
440  * \return the mute status (boolean)
441  */
442 vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
443
444 /**
445  * Set mute status
446  * \param p_instance libvlc instance
447  * \param status If status is VLC_TRUE then mute, otherwise unmute
448  * \param p_exception an initialized exception
449  * \return void
450  */
451 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
452
453
454 /**
455  * Get current audio level
456  * \param p_instance libvlc instance
457  * \param p_exception an initialized exception
458  * \return the audio level (int)
459  */
460 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
461
462
463 /**
464  * Set current audio level
465  * \param p_instance libvlc instance
466  * \param i_volume the volume (int)
467  * \param p_exception an initialized exception
468  * \return void
469  */
470 void libvlc_audio_set_volume( libvlc_instance_t *, int , libvlc_exception_t *);
471
472 /** @} */
473
474
475 /**
476  * Add a broadcast, with one input
477  * \param p_instance the instance
478  * \param psz_name the name of the new broadcast
479  * \param psz_input the input MRL
480  * \param psz_output the output MRL (the parameter to the "sout" variable)
481  * \param i_options number of additional options
482  * \param ppsz_options additional options
483  * \param b_enabled boolean for enabling the new broadcast
484  * \param b_loop Should this broadcast be played in loop ?
485  * \param p_exception an initialized exception
486  */
487 void libvlc_vlm_add_broadcast( libvlc_instance_t *, char *, char *, char* ,
488                                int, char **, int, int, libvlc_exception_t * );
489
490 /**
491  * Delete a media (vod or broadcast)
492  * \param p_instance the instance
493  * \param psz_name the media to delete
494  * \param p_exception an initialized exception
495  */
496 void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
497
498 /**
499  * Enable or disable a media (vod or broadcast)
500  * \param p_instance the instance
501  * \param psz_name the media to work on
502  * \param b_enabled the new status
503  * \param p_exception an initialized exception
504  */
505 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
506                              libvlc_exception_t *);
507
508 /**
509  * Set the output for a media
510  * \param p_instance the instance
511  * \param psz_name the media to work on
512  * \param psz_output the output MRL (the parameter to the "sout" variable)
513  * \param p_exception an initialized exception
514  */
515 void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
516                             libvlc_exception_t *);
517
518 /**
519  * Set a media's input MRL. This will delete all existing inputs and
520  * add the specified one.
521  * \param p_instance the instance
522  * \param psz_name the media to work on
523  * \param psz_input the input MRL
524  * \param p_exception an initialized exception
525  */
526 void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
527                            libvlc_exception_t *);
528
529 /**
530  * Set output for a media
531  * \param p_instance the instance
532  * \param psz_name the media to work on
533  * \param b_loop the new status
534  * \param p_exception an initialized exception
535  */
536 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
537                           libvlc_exception_t *);
538
539
540
541
542 /**
543  * Edit the parameters of a media. This will delete all existing inputs and
544  * add the specified one.
545  * \param p_instance the instance
546  * \param psz_name the name of the new broadcast
547  * \param psz_input the input MRL
548  * \param psz_output the output MRL (the parameter to the "sout" variable)
549  * \param i_options number of additional options
550  * \param ppsz_options additional options
551  * \param b_enabled boolean for enabling the new broadcast
552  * \param b_loop Should this broadcast be played in loop ?
553  * \param p_exception an initialized exception
554  */
555 void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
556                               int, char **, int, int, libvlc_exception_t * );
557
558 /**
559  * Plays the named broadcast.
560  * \param p_instance the instance
561  * \param psz_name the name of the broadcast
562  * \param p_exception an initialized exception
563  */ 
564 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
565
566 /**
567  * Stops the named broadcast.
568  * \param p_instance the instance
569  * \param psz_name the name of the broadcast
570  * \param p_exception an initialized exception
571  */ 
572 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
573
574     
575 /**
576  * Pauses the named broadcast.
577  * \param p_instance the instance
578  * \param psz_name the name of the broadcast
579  * \param p_exception an initialized exception
580  */ 
581 void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
582     
583     
584
585 /** @} */
586 /** @} */
587
588 # ifdef __cplusplus
589 }
590 # endif
591
592 #endif /* <vlc/libvlc.h> */