]> git.sesse.net Git - vlc/blob - include/vlc/libvlc.h
- added input state & input rate in control APIs
[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 *);
129
130 /** @}*/
131
132 /*****************************************************************************
133  * Playlist
134  *****************************************************************************/
135 /** defgroup libvlc_playlist Playlist
136  * \ingroup libvlc
137  * LibVLC Playlist handling
138  * @{
139  */
140
141 /**
142  * Start playing. You can give some additionnal playlist item options
143  * that will be added to the item before playing it.
144  * \param p_instance the instance
145  * \param i_id the item to play. If this is a negative number, the next
146  * item will be selected. Else, the item with the given ID will be played
147  * \param i_options the number of options to add to the item
148  * \param ppsz_options the options to add to the item
149  * \param p_exception an initialized exception
150  */
151 void libvlc_playlist_play( libvlc_instance_t*, int, int, char **,
152                            libvlc_exception_t * );
153
154 /**
155  * Pause a running playlist, resume if it was stopped
156  * \param p_instance the instance to pause
157  * \param p_exception an initialized exception
158  */
159 void libvlc_playlist_pause( libvlc_instance_t *, libvlc_exception_t * );
160
161 /**
162  * Checks if the playlist is running
163  * \param p_instance the instance
164  * \param p_exception an initialized exception
165  * \return 0 if the playlist is stopped or paused, 1 if it is running
166  */
167 int libvlc_playlist_isplaying( libvlc_instance_t *, libvlc_exception_t * );
168
169 /**
170  * Get the number of items in the playlist
171  * \param p_instance the instance
172  * \param p_exception an initialized exception
173  * \return the number of items
174  */
175 int libvlc_playlist_items_count( libvlc_instance_t *, libvlc_exception_t * );
176
177 /**
178  * Stop playing
179  * \param p_instance the instance to stop
180  * \param p_exception an initialized exception
181  */
182 void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * );
183
184 /**
185  * Go to next playlist item (starts playback if it was stopped)
186  * \param p_instance the instance to use
187  * \param p_exception an initialized exception
188  */
189 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * );
190
191 /**
192  * Go to previous playlist item (starts playback if it was stopped)
193  * \param p_instance the instance to use
194  * \param p_exception an initialized exception
195  */
196 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * );
197
198 /**
199  * Remove all playlist items
200  * \param p_instance the instance
201  * \param p_exception an initialized exception
202  */
203 void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * );
204
205 /**
206  * Add an item at the end of the playlist
207  * If you need more advanced options, \see libvlc_playlist_add_extended
208  * \param p_instance the instance
209  * \param psz_uri the URI to open, using VLC format
210  * \param psz_name a name that you might want to give or NULL
211  * \return the identifier of the new item
212  */
213 int libvlc_playlist_add( libvlc_instance_t *, const char *, const char *,
214                          libvlc_exception_t * );
215
216 /**
217  * Add an item at the end of the playlist, with additional input options
218  * \param p_instance the instance
219  * \param psz_uri the URI to open, using VLC format
220  * \param psz_name a name that you might want to give or NULL
221  * \param i_options the number of options to add
222  * \param ppsz_options strings representing the options to add
223  * \param p_exception an initialized exception
224  * \return the identifier of the new item
225  */
226 int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
227                                   const char *, int, const char **,
228                                   libvlc_exception_t * );
229
230 /** 
231  * Delete the playlist item with the given ID.
232  * \param p_instance the instance
233  * \param i_id the id to remove
234  * \param p_exception an initialized exception
235  * \return
236  */
237 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
238                                  libvlc_exception_t * );
239     
240 typedef struct libvlc_input_t libvlc_input_t;
241
242 /* Get the input that is currently being played by the playlist
243  * \param p_instance the instance to use
244  * \param p_exception an initialized excecption
245  * \return an input object
246  */
247 libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
248                                            libvlc_exception_t * );
249
250 /** @}*/
251
252 /*****************************************************************************
253  * Input
254  *****************************************************************************/
255 /** defgroup libvlc_input Input
256  * \ingroup libvlc
257  * LibVLC Input handling
258  * @{
259  */
260
261 /** Free an input object
262  * \param p_input the input to free
263  */
264 void libvlc_input_free( libvlc_input_t * );
265
266 /// \bug This might go away ... to be replaced by a broader system
267 vlc_int64_t libvlc_input_get_length     ( libvlc_input_t *, libvlc_exception_t *);
268 vlc_int64_t libvlc_input_get_time       ( libvlc_input_t *, libvlc_exception_t *);
269 void        libvlc_input_set_time       ( libvlc_input_t *, vlc_int64_t, libvlc_exception_t *);
270 float       libvlc_input_get_position   ( libvlc_input_t *, libvlc_exception_t *);
271 void        libvlc_input_set_position   ( libvlc_input_t *, float, libvlc_exception_t *);
272 vlc_bool_t  libvlc_input_will_play      ( libvlc_input_t *, libvlc_exception_t *);
273 float       libvlc_input_get_rate       ( libvlc_input_t *, libvlc_exception_t *);
274 void        libvlc_input_set_rate       ( libvlc_input_t *, float, libvlc_exception_t *);
275 int         libvlc_input_get_state      ( libvlc_input_t *, libvlc_exception_t *);
276         
277 /** @} */
278
279 /** defgroup libvlc_video Video
280  * \ingroup libvlc
281  * LibVLC Video handling
282  * @{
283  */
284
285 /**
286  * Does this input have a video output ?
287  * \param p_input the input
288  * \param p_exception an initialized exception
289  */
290 vlc_bool_t  libvlc_input_has_vout       ( libvlc_input_t *, libvlc_exception_t *);
291 float       libvlc_input_get_fps        ( libvlc_input_t *, libvlc_exception_t *);
292
293 /**
294  * Toggle fullscreen status on video output
295  * \param p_input the input
296  * \param p_exception an initialized exception
297  */
298 void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
299
300 /**
301  * Enable or disable fullscreen on a video output
302  * \param p_input the input
303  * \param b_fullscreen boolean for fullscreen status
304  * \param p_exception an initialized exception
305  */
306 void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
307
308 /**
309  * Get current fullscreen status
310  * \param p_input the input
311  * \param p_exception an initialized exception
312  * \return the fullscreen status (boolean)
313  */
314 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
315     
316 /**
317  * Get current video height
318  * \param p_input the input
319  * \param p_exception an initialized exception
320  * \return the video height
321  */
322 int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
323
324 /**
325  * Get current video width
326  * \param p_input the input
327  * \param p_exception an initialized exception
328  * \return the video width
329  */
330 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
331
332 /**
333  * Take a snapshot of the current video window
334  * \param p_input the input
335  * \param psz_filepath the path where to save the screenshot to
336  * \param p_exception an initialized exception
337  */
338 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
339     
340 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
341
342     
343 /**
344  * Resize the video output window
345  * \param p_instance libvlc instance
346  * \param width new width for video output window
347  * \param height new height for video output window
348  * \param p_exception an initialized exception
349  * \return the mute status (boolean)
350  */
351 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
352     
353 /**
354 * Downcast to this general type as placeholder for a platform specific one, such as:
355 *  Drawable on X11,
356 *  CGrafPort on MacOSX,
357 *  HWND on win32
358 */
359 typedef int libvlc_drawable_t;
360
361 /**
362  * change the video output parent
363  * \param p_instance libvlc instance
364  * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
365  * \param p_exception an initialized exception
366  * \return the mute status (boolean)
367  */
368 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
369
370 /**
371  * Set the video output parent
372  * \param p_instance libvlc instance
373  * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
374  * \param p_exception an initialized exception
375  */
376 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
377
378 /**
379  * Set the video output size
380  * \param p_instance libvlc instance
381  * \param width new width for video drawable
382  * \param height new height for video drawable
383  * \param p_exception an initialized exception
384  */
385 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
386
387 /**
388 * Downcast to this general type as placeholder for a platform specific one, such as:
389 *  Drawable on X11,
390 *  CGrafPort on MacOSX,
391 *  HWND on win32
392 */
393 typedef struct
394 {
395     int top, left;
396     int bottom, right;
397 }
398 libvlc_rectangle_t;
399
400 /**
401  * Set the video output viewport for a windowless video output (MacOS X only)
402  * \param p_instance libvlc instance
403  * \param view coordinates within video drawable
404  * \param clip coordinates within video drawable
405  * \param p_exception an initialized exception
406  */
407 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
408
409
410 /** @} */
411
412 /**
413  * defgroup libvlc_vlm VLM
414  * \ingroup libvlc
415  * LibVLC VLM handling
416  * @{
417  */
418
419 /** defgroup libvlc_audio Audio
420  * \ingroup libvlc
421  * LibVLC Audio handling
422  * @{
423  */
424
425 /**
426  * Toggle mute status
427  * \param p_instance libvlc instance
428  * \param p_exception an initialized exception
429  * \return void
430  */
431 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
432
433 /**
434  * Get current mute status
435  * \param p_instance libvlc instance
436  * \param p_exception an initialized exception
437  * \return the mute status (boolean)
438  */
439 vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
440
441 /**
442  * Set mute status
443  * \param p_instance libvlc instance
444  * \param status If status is VLC_TRUE then mute, otherwise unmute
445  * \param p_exception an initialized exception
446  * \return void
447  */
448 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
449
450
451 /**
452  * Get current audio level
453  * \param p_instance libvlc instance
454  * \param p_exception an initialized exception
455  * \return the audio level (int)
456  */
457 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
458
459
460 /**
461  * Set current audio level
462  * \param p_instance libvlc instance
463  * \param i_volume the volume (int)
464  * \param p_exception an initialized exception
465  * \return void
466  */
467 void libvlc_audio_set_volume( libvlc_instance_t *, int , libvlc_exception_t *);
468
469 /** @} */
470
471
472 /**
473  * Add a broadcast, with one input
474  * \param p_instance the instance
475  * \param psz_name the name of the new broadcast
476  * \param psz_input the input MRL
477  * \param psz_output the output MRL (the parameter to the "sout" variable)
478  * \param i_options number of additional options
479  * \param ppsz_options additional options
480  * \param b_enabled boolean for enabling the new broadcast
481  * \param b_loop Should this broadcast be played in loop ?
482  * \param p_exception an initialized exception
483  */
484 void libvlc_vlm_add_broadcast( libvlc_instance_t *, char *, char *, char* ,
485                                int, char **, int, int, libvlc_exception_t * );
486
487 /**
488  * Delete a media (vod or broadcast)
489  * \param p_instance the instance
490  * \param psz_name the media to delete
491  * \param p_exception an initialized exception
492  */
493 void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
494
495 /**
496  * Enable or disable a media (vod or broadcast)
497  * \param p_instance the instance
498  * \param psz_name the media to work on
499  * \param b_enabled the new status
500  * \param p_exception an initialized exception
501  */
502 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
503                              libvlc_exception_t *);
504
505 /**
506  * Set the output for a media
507  * \param p_instance the instance
508  * \param psz_name the media to work on
509  * \param psz_output the output MRL (the parameter to the "sout" variable)
510  * \param p_exception an initialized exception
511  */
512 void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
513                             libvlc_exception_t *);
514
515 /**
516  * Set a media's input MRL. This will delete all existing inputs and
517  * add the specified one.
518  * \param p_instance the instance
519  * \param psz_name the media to work on
520  * \param psz_input the input MRL
521  * \param p_exception an initialized exception
522  */
523 void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
524                            libvlc_exception_t *);
525
526 /**
527  * Set output for a media
528  * \param p_instance the instance
529  * \param psz_name the media to work on
530  * \param b_loop the new status
531  * \param p_exception an initialized exception
532  */
533 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
534                           libvlc_exception_t *);
535
536
537
538
539 /**
540  * Edit the parameters of a media. This will delete all existing inputs and
541  * add the specified one.
542  * \param p_instance the instance
543  * \param psz_name the name of the new broadcast
544  * \param psz_input the input MRL
545  * \param psz_output the output MRL (the parameter to the "sout" variable)
546  * \param i_options number of additional options
547  * \param ppsz_options additional options
548  * \param b_enabled boolean for enabling the new broadcast
549  * \param b_loop Should this broadcast be played in loop ?
550  * \param p_exception an initialized exception
551  */
552 void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
553                               int, char **, int, int, libvlc_exception_t * );
554
555 /**
556  * Plays the named broadcast.
557  * \param p_instance the instance
558  * \param psz_name the name of the broadcast
559  * \param p_exception an initialized exception
560  */ 
561 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
562
563 /**
564  * Stops the named broadcast.
565  * \param p_instance the instance
566  * \param psz_name the name of the broadcast
567  * \param p_exception an initialized exception
568  */ 
569 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
570
571     
572 /**
573  * Pauses the named broadcast.
574  * \param p_instance the instance
575  * \param psz_name the name of the broadcast
576  * \param p_exception an initialized exception
577  */ 
578 void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
579     
580     
581
582 /** @} */
583 /** @} */
584
585 # ifdef __cplusplus
586 }
587 # endif
588
589 #endif /* <vlc/libvlc.h> */