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 $
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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 *****************************************************************************/
25 * \defgroup libvlc Libvlc
26 * This is libvlc, the base library of the VLC program.
41 /*****************************************************************************
43 *****************************************************************************/
44 /** defgroup libvlc_exception Exceptions
46 * LibVLC Exceptions handling
50 struct libvlc_exception_t
55 typedef struct libvlc_exception_t libvlc_exception_t;
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
62 void libvlc_exception_init( libvlc_exception_t *p_exception );
65 * Has an exception been raised ?
66 * \param p_exception the exception to query
67 * \return 0 if no exception raised, 1 else
69 int libvlc_exception_raised( libvlc_exception_t *p_exception );
73 * \param p_exception the exception to raise
74 * \param psz_message the exception message
76 void libvlc_exception_raise( libvlc_exception_t *p_exception, const char *psz_format, ... );
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
83 void libvlc_exception_clear( libvlc_exception_t * );
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
91 char* libvlc_exception_get_message( libvlc_exception_t *p_exception );
95 /*****************************************************************************
97 *****************************************************************************/
99 /** defgroup libvlc_core Core
105 /** This structure is opaque. It represents a libvlc instance */
106 typedef struct libvlc_instance_t libvlc_instance_t;
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
114 libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
117 * Returns a libvlc instance identifier for legacy APIs. Use of this
118 * function is discouraged, you should convert your program to use the
120 * \param p_instance the instance
122 int libvlc_get_vlc_id( libvlc_instance_t *p_instance );
125 * Destroy a libvlc instance.
126 * \param p_instance the instance to destroy
128 void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
132 /*****************************************************************************
134 *****************************************************************************/
135 /** defgroup libvlc_playlist Playlist
137 * LibVLC Playlist handling
144 void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * );
147 * Start playing. You can give some additionnal playlist item options
148 * that will be added to the item before playing it.
149 * \param p_instance the instance
150 * \param i_id the item to play. If this is a negative number, the next
151 * item will be selected. Else, the item with the given ID will be played
152 * \param i_options the number of options to add to the item
153 * \param ppsz_options the options to add to the item
154 * \param p_exception an initialized exception
156 void libvlc_playlist_play( libvlc_instance_t*, int, int, char **,
157 libvlc_exception_t * );
160 * Pause a running playlist, resume if it was stopped
161 * \param p_instance the instance to pause
162 * \param p_exception an initialized exception
164 void libvlc_playlist_pause( libvlc_instance_t *, libvlc_exception_t * );
167 * Checks if the playlist is running
168 * \param p_instance the instance
169 * \param p_exception an initialized exception
170 * \return 0 if the playlist is stopped or paused, 1 if it is running
172 int libvlc_playlist_isplaying( libvlc_instance_t *, libvlc_exception_t * );
175 * Get the number of items in the playlist
176 * \param p_instance the instance
177 * \param p_exception an initialized exception
178 * \return the number of items
180 int libvlc_playlist_items_count( libvlc_instance_t *, libvlc_exception_t * );
184 * \param p_instance the instance to stop
185 * \param p_exception an initialized exception
187 void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * );
190 * Go to next playlist item (starts playback if it was stopped)
191 * \param p_instance the instance to use
192 * \param p_exception an initialized exception
194 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * );
197 * Go to previous playlist item (starts playback if it was stopped)
198 * \param p_instance the instance to use
199 * \param p_exception an initialized exception
201 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * );
204 * Remove all playlist items
205 * \param p_instance the instance
206 * \param p_exception an initialized exception
208 void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * );
211 * Add an item at the end of the playlist
212 * If you need more advanced options, \see libvlc_playlist_add_extended
213 * \param p_instance the instance
214 * \param psz_uri the URI to open, using VLC format
215 * \param psz_name a name that you might want to give or NULL
216 * \return the identifier of the new item
218 int libvlc_playlist_add( libvlc_instance_t *, const char *, const char *,
219 libvlc_exception_t * );
222 * Add an item at the end of the playlist, with additional input options
223 * \param p_instance the instance
224 * \param psz_uri the URI to open, using VLC format
225 * \param psz_name a name that you might want to give or NULL
226 * \param i_options the number of options to add
227 * \param ppsz_options strings representing the options to add
228 * \param p_exception an initialized exception
229 * \return the identifier of the new item
231 int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
232 const char *, int, const char **,
233 libvlc_exception_t * );
236 * Delete the playlist item with the given ID.
237 * \param p_instance the instance
238 * \param i_id the id to remove
239 * \param p_exception an initialized exception
242 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
243 libvlc_exception_t * );
245 typedef struct libvlc_input_t libvlc_input_t;
247 /* Get the input that is currently being played by the playlist
248 * \param p_instance the instance to use
249 * \param p_exception an initialized excecption
250 * \return an input object
252 libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
253 libvlc_exception_t * );
257 /*****************************************************************************
259 *****************************************************************************/
260 /** defgroup libvlc_input Input
262 * LibVLC Input handling
266 /** Free an input object
267 * \param p_input the input to free
269 void libvlc_input_free( libvlc_input_t * );
271 /// \bug This might go away ... to be replaced by a broader system
272 vlc_int64_t libvlc_input_get_length ( libvlc_input_t *, libvlc_exception_t *);
273 vlc_int64_t libvlc_input_get_time ( libvlc_input_t *, libvlc_exception_t *);
274 void libvlc_input_set_time ( libvlc_input_t *, vlc_int64_t, libvlc_exception_t *);
275 float libvlc_input_get_position ( libvlc_input_t *, libvlc_exception_t *);
276 void libvlc_input_set_position ( libvlc_input_t *, float, libvlc_exception_t *);
277 vlc_bool_t libvlc_input_will_play ( libvlc_input_t *, libvlc_exception_t *);
278 float libvlc_input_get_rate ( libvlc_input_t *, libvlc_exception_t *);
279 void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *);
280 int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *);
284 /** defgroup libvlc_video Video
286 * LibVLC Video handling
290 typedef int libvlc_drawable_t;
293 * Does this input have a video output ?
294 * \param p_input the input
295 * \param p_exception an initialized exception
297 vlc_bool_t libvlc_input_has_vout ( libvlc_input_t *, libvlc_exception_t *);
298 float libvlc_input_get_fps ( libvlc_input_t *, libvlc_exception_t *);
301 * Toggle fullscreen status on video output
302 * \param p_input the input
303 * \param p_exception an initialized exception
305 void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
308 * Enable or disable fullscreen on a video output
309 * \param p_input the input
310 * \param b_fullscreen boolean for fullscreen status
311 * \param p_exception an initialized exception
313 void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
316 * Get current fullscreen status
317 * \param p_input the input
318 * \param p_exception an initialized exception
319 * \return the fullscreen status (boolean)
321 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
324 * Get current video height
325 * \param p_input the input
326 * \param p_exception an initialized exception
327 * \return the video height
329 int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
332 * Get current video width
333 * \param p_input the input
334 * \param p_exception an initialized exception
335 * \return the video width
337 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
340 * Get current video aspect ratio
341 * \param p_input the input
342 * \param p_exception an initialized exception
343 * \return the video aspect ratio
345 char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
348 * Set new video aspect ratio
349 * \param p_input the input
350 * \param psz_aspect new video aspect-ratio
351 * \param p_exception an initialized exception
353 void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
356 * Take a snapshot of the current video window
357 * \param p_input the input
358 * \param psz_filepath the path where to save the screenshot to
359 * \param p_exception an initialized exception
361 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
363 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
366 * Resize the current video output window
367 * \param p_instance libvlc instance
368 * \param width new width for video output window
369 * \param height new height for video output window
370 * \param p_exception an initialized exception
371 * \return the mute status (boolean)
373 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
376 * Downcast to this general type as placeholder for a platform specific one, such as:
378 * CGrafPort on MacOSX,
383 * change the parent for the current the video output
384 * \param p_instance libvlc instance
385 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
386 * \param p_exception an initialized exception
387 * \return the mute status (boolean)
389 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
392 * Set the default video output parent
393 * this settings will be used as default for all video outputs
394 * \param p_instance libvlc instance
395 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
396 * \param p_exception an initialized exception
398 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
401 * Set the default video output size
402 * this settings will be used as default for all video outputs
403 * \param p_instance libvlc instance
404 * \param width new width for video drawable
405 * \param height new height for video drawable
406 * \param p_exception an initialized exception
408 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
411 * Downcast to this general type as placeholder for a platform specific one, such as:
413 * CGrafPort on MacOSX,
424 * Set the default video output viewport for a windowless video output (MacOS X only)
425 * this settings will be used as default for all video outputs
426 * \param p_instance libvlc instance
427 * \param view coordinates within video drawable
428 * \param clip coordinates within video drawable
429 * \param p_exception an initialized exception
431 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
437 * defgroup libvlc_vlm VLM
439 * LibVLC VLM handling
443 /** defgroup libvlc_audio Audio
445 * LibVLC Audio handling
451 * \param p_instance libvlc instance
452 * \param p_exception an initialized exception
455 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
458 * Get current mute status
459 * \param p_instance libvlc instance
460 * \param p_exception an initialized exception
461 * \return the mute status (boolean)
463 vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
467 * \param p_instance libvlc instance
468 * \param status If status is VLC_TRUE then mute, otherwise unmute
469 * \param p_exception an initialized exception
472 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
475 * Get current audio level
476 * \param p_instance libvlc instance
477 * \param p_exception an initialized exception
478 * \return the audio level (int)
480 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
483 * Set current audio level
484 * \param p_instance libvlc instance
485 * \param i_volume the volume (int)
486 * \param p_exception an initialized exception
489 void libvlc_audio_set_volume( libvlc_instance_t *, int , libvlc_exception_t *);
495 * Add a broadcast, with one input
496 * \param p_instance the instance
497 * \param psz_name the name of the new broadcast
498 * \param psz_input the input MRL
499 * \param psz_output the output MRL (the parameter to the "sout" variable)
500 * \param i_options number of additional options
501 * \param ppsz_options additional options
502 * \param b_enabled boolean for enabling the new broadcast
503 * \param b_loop Should this broadcast be played in loop ?
504 * \param p_exception an initialized exception
506 void libvlc_vlm_add_broadcast( libvlc_instance_t *, char *, char *, char* ,
507 int, char **, int, int, libvlc_exception_t * );
510 * Delete a media (vod or broadcast)
511 * \param p_instance the instance
512 * \param psz_name the media to delete
513 * \param p_exception an initialized exception
515 void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
518 * Enable or disable a media (vod or broadcast)
519 * \param p_instance the instance
520 * \param psz_name the media to work on
521 * \param b_enabled the new status
522 * \param p_exception an initialized exception
524 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
525 libvlc_exception_t *);
528 * Set the output for a media
529 * \param p_instance the instance
530 * \param psz_name the media to work on
531 * \param psz_output the output MRL (the parameter to the "sout" variable)
532 * \param p_exception an initialized exception
534 void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
535 libvlc_exception_t *);
538 * Set a media's input MRL. This will delete all existing inputs and
539 * add the specified one.
540 * \param p_instance the instance
541 * \param psz_name the media to work on
542 * \param psz_input the input MRL
543 * \param p_exception an initialized exception
545 void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
546 libvlc_exception_t *);
549 * Set output for a media
550 * \param p_instance the instance
551 * \param psz_name the media to work on
552 * \param b_loop the new status
553 * \param p_exception an initialized exception
555 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
556 libvlc_exception_t *);
559 * Edit the parameters of a media. This will delete all existing inputs and
560 * add the specified one.
561 * \param p_instance the instance
562 * \param psz_name the name of the new broadcast
563 * \param psz_input the input MRL
564 * \param psz_output the output MRL (the parameter to the "sout" variable)
565 * \param i_options number of additional options
566 * \param ppsz_options additional options
567 * \param b_enabled boolean for enabling the new broadcast
568 * \param b_loop Should this broadcast be played in loop ?
569 * \param p_exception an initialized exception
571 void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
572 int, char **, int, int, libvlc_exception_t * );
575 * Plays the named broadcast.
576 * \param p_instance the instance
577 * \param psz_name the name of the broadcast
578 * \param p_exception an initialized exception
580 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
583 * Stops the named broadcast.
584 * \param p_instance the instance
585 * \param psz_name the name of the broadcast
586 * \param p_exception an initialized exception
588 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
591 * Pauses the named broadcast.
592 * \param p_instance the instance
593 * \param psz_name the name of the broadcast
594 * \param p_exception an initialized exception
596 void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
599 * Seeks in the named broadcast.
600 * \param p_instance the instance
601 * \param psz_name the name of the broadcast
602 * \param f_percentage the percentage to seek to
603 * \param p_exception an initialized exception
605 void libvlc_vlm_seek_media( libvlc_instance_t *, char *,
606 float, libvlc_exception_t * );
609 * Return information of the named broadcast.
610 * \param p_instance the instance
611 * \param psz_name the name of the broadcast
612 * \param p_exception an initialized exception
614 char* libvlc_vlm_show_media( libvlc_instance_t *, char *, libvlc_exception_t * );
616 #define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
617 returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *, \
618 char *, int , libvlc_exception_t * );
620 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
621 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
622 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
623 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
624 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
625 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
626 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
628 #undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
633 /*****************************************************************************
634 * Message log handling
635 *****************************************************************************/
637 /** defgroup libvlc_log Log
639 * LibVLC Message Logging
643 /** This structure is opaque. It represents a libvlc log instance */
644 typedef struct libvlc_log_t libvlc_log_t;
646 /** This structure is opaque. It represents a libvlc log iterator */
647 typedef struct libvlc_log_iterator_t libvlc_log_iterator_t;
649 typedef struct libvlc_log_message_t
651 unsigned sizeof_msg; /* sizeof() of message structure, must be filled in by user */
652 int i_severity; /* 0=INFO, 1=ERR, 2=WARN, 3=DBG */
653 const char *psz_type; /* module type */
654 const char *psz_name; /* module name */
655 const char *psz_header; /* optional header */
656 const char *psz_message; /* message */
657 } libvlc_log_message_t;
660 * Returns the VLC messaging verbosity level
661 * \param p_instance libvlc instance
662 * \param exception an initialized exception pointer
664 unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e );
667 * Set the VLC messaging verbosity level
668 * \param p_log libvlc log instance
669 * \param exception an initialized exception pointer
671 void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level, libvlc_exception_t *p_e );
674 * Open an instance to VLC message log
675 * \param p_instance libvlc instance
676 * \param exception an initialized exception pointer
678 libvlc_log_t *libvlc_log_open( const libvlc_instance_t *, libvlc_exception_t *);
681 * Close an instance of VLC message log
682 * \param p_log libvlc log instance
683 * \param exception an initialized exception pointer
685 void libvlc_log_close( libvlc_log_t *, libvlc_exception_t *);
688 * Returns the number of messages in log
689 * \param p_log libvlc log instance
690 * \param exception an initialized exception pointer
692 unsigned libvlc_log_count( const libvlc_log_t *, libvlc_exception_t *);
695 * Clear all messages in log
696 * the log should be cleared on a regular basis to avoid clogging
697 * \param p_log libvlc log instance
698 * \param exception an initialized exception pointer
700 void libvlc_log_clear( libvlc_log_t *, libvlc_exception_t *);
703 * Allocate and returns a new iterator to messages in log
704 * \param p_log libvlc log instance
705 * \param exception an initialized exception pointer
707 libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
710 * Releases a previoulsy allocated iterator
711 * \param p_log libvlc log iterator
712 * \param exception an initialized exception pointer
714 void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
717 * Returns whether log iterator has more messages
718 * \param p_log libvlc log iterator
719 * \param exception an initialized exception pointer
721 int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
724 * Returns next log message
725 * the content of message must not be freed
726 * \param p_log libvlc log iterator
727 * \param exception an initialized exception pointer
729 libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
730 struct libvlc_log_message_t *buffer,
731 libvlc_exception_t *p_e );
739 #endif /* <vlc/libvlc.h> */