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>
8 * Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
26 * \defgroup libvlc Libvlc
27 * This is libvlc, the base library of the VLC program.
42 /*****************************************************************************
44 *****************************************************************************/
45 /** defgroup libvlc_exception Exceptions
47 * LibVLC Exceptions handling
51 struct libvlc_exception_t
57 typedef struct libvlc_exception_t libvlc_exception_t;
60 * Initialize an exception structure. This can be called several times to reuse
61 * an exception structure.
62 * \param p_exception the exception to initialize
64 void libvlc_exception_init( libvlc_exception_t *p_exception );
67 * Has an exception been raised ?
68 * \param p_exception the exception to query
69 * \return 0 if no exception raised, 1 else
71 int libvlc_exception_raised( libvlc_exception_t *p_exception );
75 * \param p_exception the exception to raise
76 * \param psz_message the exception message
78 void libvlc_exception_raise( libvlc_exception_t *p_exception, const char *psz_format, ... );
81 * Clear an exception object so it can be reused.
82 * The exception object must be initialized
83 * \param p_exception the exception to clear
85 void libvlc_exception_clear( libvlc_exception_t * );
88 * Get exception message
89 * \param p_exception the exception to query
90 * \return the exception message or NULL if not applicable (exception not raised
93 char* libvlc_exception_get_message( libvlc_exception_t *p_exception );
97 /*****************************************************************************
99 *****************************************************************************/
101 /** defgroup libvlc_core Core
107 /** This structure is opaque. It represents a libvlc instance */
108 typedef struct libvlc_instance_t libvlc_instance_t;
111 * Create an initialized libvlc instance
112 * \param argc the number of arguments
113 * \param argv command-line-type arguments
114 * \param exception an initialized exception pointer
116 libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
119 * Returns a libvlc instance identifier for legacy APIs. Use of this
120 * function is discouraged, you should convert your program to use the
122 * \param p_instance the instance
124 int libvlc_get_vlc_id( libvlc_instance_t *p_instance );
127 * Destroy a libvlc instance.
128 * \param p_instance the instance to destroy
130 void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
134 /*****************************************************************************
136 *****************************************************************************/
137 /** defgroup libvlc_playlist Playlist
139 * LibVLC Playlist handling
146 void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t,
147 libvlc_exception_t * );
150 * Start playing. You can give some additionnal playlist item options
151 * that will be added to the item before playing it.
152 * \param p_instance the instance
153 * \param i_id the item to play. If this is a negative number, the next
154 * item will be selected. Else, the item with the given ID will be played
155 * \param i_options the number of options to add to the item
156 * \param ppsz_options the options to add to the item
157 * \param p_exception an initialized exception
159 void libvlc_playlist_play( libvlc_instance_t*, int, int, char **,
160 libvlc_exception_t * );
163 * Pause a running playlist, resume if it was stopped
164 * \param p_instance the instance to pause
165 * \param p_exception an initialized exception
167 void libvlc_playlist_pause( libvlc_instance_t *, libvlc_exception_t * );
170 * Checks if the playlist is running
171 * \param p_instance the instance
172 * \param p_exception an initialized exception
173 * \return 0 if the playlist is stopped or paused, 1 if it is running
175 int libvlc_playlist_isplaying( libvlc_instance_t *, libvlc_exception_t * );
178 * Get the number of items in the playlist
179 * \param p_instance the instance
180 * \param p_exception an initialized exception
181 * \return the number of items
183 int libvlc_playlist_items_count( libvlc_instance_t *, libvlc_exception_t * );
187 * \param p_instance the instance to stop
188 * \param p_exception an initialized exception
190 void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * );
193 * Go to next playlist item (starts playback if it was stopped)
194 * \param p_instance the instance to use
195 * \param p_exception an initialized exception
197 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * );
200 * Go to previous playlist item (starts playback if it was stopped)
201 * \param p_instance the instance to use
202 * \param p_exception an initialized exception
204 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * );
207 * Remove all playlist items
208 * \param p_instance the instance
209 * \param p_exception an initialized exception
211 void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * );
214 * Add an item at the end of the playlist
215 * If you need more advanced options, \see libvlc_playlist_add_extended
216 * \param p_instance the instance
217 * \param psz_uri the URI to open, using VLC format
218 * \param psz_name a name that you might want to give or NULL
219 * \return the identifier of the new item
221 int libvlc_playlist_add( libvlc_instance_t *, const char *, const char *,
222 libvlc_exception_t * );
225 * Add an item at the end of the playlist, with additional input options
226 * \param p_instance the instance
227 * \param psz_uri the URI to open, using VLC format
228 * \param psz_name a name that you might want to give or NULL
229 * \param i_options the number of options to add
230 * \param ppsz_options strings representing the options to add
231 * \param p_exception an initialized exception
232 * \return the identifier of the new item
234 int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
235 const char *, int, const char **,
236 libvlc_exception_t * );
239 * Delete the playlist item with the given ID.
240 * \param p_instance the instance
241 * \param i_id the id to remove
242 * \param p_exception an initialized exception
245 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
246 libvlc_exception_t * );
248 typedef struct libvlc_input_t libvlc_input_t;
250 /* Get the input that is currently being played by the playlist
251 * \param p_instance the instance to use
252 * \param p_exception an initialized excecption
253 * \return an input object
255 libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
256 libvlc_exception_t * );
260 /*****************************************************************************
262 *****************************************************************************/
263 /** defgroup libvlc_input Input
265 * LibVLC Input handling
269 /** Free an input object
270 * \param p_input the input to free
272 void libvlc_input_free( libvlc_input_t * );
274 /// \bug This might go away ... to be replaced by a broader system
275 vlc_int64_t libvlc_input_get_length ( libvlc_input_t *, libvlc_exception_t *);
276 vlc_int64_t libvlc_input_get_time ( libvlc_input_t *, libvlc_exception_t *);
277 void libvlc_input_set_time ( libvlc_input_t *, vlc_int64_t, libvlc_exception_t *);
278 float libvlc_input_get_position ( libvlc_input_t *, libvlc_exception_t *);
279 void libvlc_input_set_position ( libvlc_input_t *, float, libvlc_exception_t *);
280 vlc_bool_t libvlc_input_will_play ( libvlc_input_t *, libvlc_exception_t *);
281 float libvlc_input_get_rate ( libvlc_input_t *, libvlc_exception_t *);
282 void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *);
283 int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *);
287 /** defgroup libvlc_video Video
289 * LibVLC Video handling
293 typedef int libvlc_drawable_t;
296 * Does this input have a video output ?
297 * \param p_input the input
298 * \param p_exception an initialized exception
300 vlc_bool_t libvlc_input_has_vout ( libvlc_input_t *, libvlc_exception_t *);
301 float libvlc_input_get_fps ( libvlc_input_t *, libvlc_exception_t *);
304 * Toggle fullscreen status on video output
305 * \param p_input the input
306 * \param p_exception an initialized exception
308 void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
311 * Enable or disable fullscreen on a video output
312 * \param p_input the input
313 * \param b_fullscreen boolean for fullscreen status
314 * \param p_exception an initialized exception
316 void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
319 * Get current fullscreen status
320 * \param p_input the input
321 * \param p_exception an initialized exception
322 * \return the fullscreen status (boolean)
324 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
327 * Get current video height
328 * \param p_input the input
329 * \param p_exception an initialized exception
330 * \return the video height
332 int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
335 * Get current video width
336 * \param p_input the input
337 * \param p_exception an initialized exception
338 * \return the video width
340 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
343 * Get current video aspect ratio
344 * \param p_input the input
345 * \param p_exception an initialized exception
346 * \return the video aspect ratio
348 char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
351 * Set new video aspect ratio
352 * \param p_input the input
353 * \param psz_aspect new video aspect-ratio
354 * \param p_exception an initialized exception
356 void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
359 * Take a snapshot of the current video window
360 * \param p_input the input
361 * \param psz_filepath the path where to save the screenshot to
362 * \param p_exception an initialized exception
364 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
366 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
369 * Resize the current video output window
370 * \param p_instance libvlc instance
371 * \param width new width for video output window
372 * \param height new height for video output window
373 * \param p_exception an initialized exception
374 * \return the success status (boolean)
376 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
379 * Downcast to this general type as placeholder for a platform specific one, such as:
381 * CGrafPort on MacOSX,
386 * change the parent for the current the video output
387 * \param p_instance libvlc instance
388 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
389 * \param p_exception an initialized exception
390 * \return the success status (boolean)
392 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
395 * Set the default video output parent
396 * this settings will be used as default for all video outputs
397 * \param p_instance libvlc instance
398 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
399 * \param p_exception an initialized exception
401 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
404 * Set the default video output size
405 * this settings will be used as default for all video outputs
406 * \param p_instance libvlc instance
407 * \param width new width for video drawable
408 * \param height new height for video drawable
409 * \param p_exception an initialized exception
411 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
414 * Downcast to this general type as placeholder for a platform specific one, such as:
416 * CGrafPort on MacOSX,
427 * Set the default video output viewport for a windowless video output (MacOS X only)
428 * this settings will be used as default for all video outputs
429 * \param p_instance libvlc instance
430 * \param view coordinates within video drawable
431 * \param clip coordinates within video drawable
432 * \param p_exception an initialized exception
434 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
440 * defgroup libvlc_vlm VLM
442 * LibVLC VLM handling
446 /** defgroup libvlc_audio Audio
448 * LibVLC Audio handling
454 * \param p_instance libvlc instance
455 * \param p_exception an initialized exception
458 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
461 * Get current mute status
462 * \param p_instance libvlc instance
463 * \param p_exception an initialized exception
464 * \return the mute status (boolean)
466 vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
470 * \param p_instance libvlc instance
471 * \param status If status is VLC_TRUE then mute, otherwise unmute
472 * \param p_exception an initialized exception
475 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
478 * Get current audio level
479 * \param p_instance libvlc instance
480 * \param p_exception an initialized exception
481 * \return the audio level (int)
483 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
486 * Set current audio level
487 * \param p_instance libvlc instance
488 * \param i_volume the volume (int)
489 * \param p_exception an initialized exception
491 void libvlc_audio_set_volume( libvlc_instance_t *, int, libvlc_exception_t *);
494 + * Get current audio track
495 + * \param p_input input instance
496 + * \param p_exception an initialized exception
497 + * \return the audio track (int)
499 int libvlc_audio_get_track( libvlc_input_t *, libvlc_exception_t * );
502 * Set current audio track
503 * \param p_input input instance
504 * \param i_track the track (int)
505 * \param p_exception an initialized exception
507 void libvlc_audio_set_track( libvlc_input_t *, int, libvlc_exception_t * );
510 * Get current audio channel
511 * \param p_instance input instance
512 * \param p_exception an initialized exception
513 * \return the audio channel (int)
515 int libvlc_audio_get_channel( libvlc_instance_t *, libvlc_exception_t * );
518 * Set current audio channel
519 * \param p_instance input instance
520 * \param i_channel the audio channel (int)
521 * \param p_exception an initialized exception
523 void libvlc_audio_set_channel( libvlc_instance_t *, int, libvlc_exception_t * );
529 * Add a broadcast, with one input
530 * \param p_instance the instance
531 * \param psz_name the name of the new broadcast
532 * \param psz_input the input MRL
533 * \param psz_output the output MRL (the parameter to the "sout" variable)
534 * \param i_options number of additional options
535 * \param ppsz_options additional options
536 * \param b_enabled boolean for enabling the new broadcast
537 * \param b_loop Should this broadcast be played in loop ?
538 * \param p_exception an initialized exception
540 void libvlc_vlm_add_broadcast( libvlc_instance_t *, char *, char *, char* ,
541 int, char **, int, int, libvlc_exception_t * );
544 * Delete a media (vod or broadcast)
545 * \param p_instance the instance
546 * \param psz_name the media to delete
547 * \param p_exception an initialized exception
549 void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
552 * Enable or disable a media (vod or broadcast)
553 * \param p_instance the instance
554 * \param psz_name the media to work on
555 * \param b_enabled the new status
556 * \param p_exception an initialized exception
558 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
559 libvlc_exception_t *);
562 * Set the output for a media
563 * \param p_instance the instance
564 * \param psz_name the media to work on
565 * \param psz_output the output MRL (the parameter to the "sout" variable)
566 * \param p_exception an initialized exception
568 void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
569 libvlc_exception_t *);
572 * Set a media's input MRL. This will delete all existing inputs and
573 * add the specified one.
574 * \param p_instance the instance
575 * \param psz_name the media to work on
576 * \param psz_input the input MRL
577 * \param p_exception an initialized exception
579 void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
580 libvlc_exception_t *);
583 * Set output for a media
584 * \param p_instance the instance
585 * \param psz_name the media to work on
586 * \param b_loop the new status
587 * \param p_exception an initialized exception
589 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
590 libvlc_exception_t *);
593 * Edit the parameters of a media. This will delete all existing inputs and
594 * add the specified one.
595 * \param p_instance the instance
596 * \param psz_name the name of the new broadcast
597 * \param psz_input the input MRL
598 * \param psz_output the output MRL (the parameter to the "sout" variable)
599 * \param i_options number of additional options
600 * \param ppsz_options additional options
601 * \param b_enabled boolean for enabling the new broadcast
602 * \param b_loop Should this broadcast be played in loop ?
603 * \param p_exception an initialized exception
605 void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
606 int, char **, int, int, libvlc_exception_t * );
609 * Plays 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 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
617 * Stops the named broadcast.
618 * \param p_instance the instance
619 * \param psz_name the name of the broadcast
620 * \param p_exception an initialized exception
622 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
625 * Pauses the named broadcast.
626 * \param p_instance the instance
627 * \param psz_name the name of the broadcast
628 * \param p_exception an initialized exception
630 void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
633 * Seeks in the named broadcast.
634 * \param p_instance the instance
635 * \param psz_name the name of the broadcast
636 * \param f_percentage the percentage to seek to
637 * \param p_exception an initialized exception
639 void libvlc_vlm_seek_media( libvlc_instance_t *, char *,
640 float, libvlc_exception_t * );
643 * Return information of the named broadcast.
644 * \param p_instance the instance
645 * \param psz_name the name of the broadcast
646 * \param p_exception an initialized exception
648 char* libvlc_vlm_show_media( libvlc_instance_t *, char *, libvlc_exception_t * );
650 #define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
651 returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *, \
652 char *, int , libvlc_exception_t * );
654 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
655 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
656 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
657 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
658 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
659 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
660 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
662 #undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
667 /*****************************************************************************
668 * Message log handling
669 *****************************************************************************/
671 /** defgroup libvlc_log Log
673 * LibVLC Message Logging
677 /** This structure is opaque. It represents a libvlc log instance */
678 typedef struct libvlc_log_t libvlc_log_t;
680 /** This structure is opaque. It represents a libvlc log iterator */
681 typedef struct libvlc_log_iterator_t libvlc_log_iterator_t;
683 typedef struct libvlc_log_message_t
685 unsigned sizeof_msg; /* sizeof() of message structure, must be filled in by user */
686 int i_severity; /* 0=INFO, 1=ERR, 2=WARN, 3=DBG */
687 const char *psz_type; /* module type */
688 const char *psz_name; /* module name */
689 const char *psz_header; /* optional header */
690 const char *psz_message; /* message */
691 } libvlc_log_message_t;
694 * Returns the VLC messaging verbosity level
695 * \param p_instance libvlc instance
696 * \param exception an initialized exception pointer
698 unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e );
701 * Set the VLC messaging verbosity level
702 * \param p_log libvlc log instance
703 * \param exception an initialized exception pointer
705 void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level, libvlc_exception_t *p_e );
708 * Open an instance to VLC message log
709 * \param p_instance libvlc instance
710 * \param exception an initialized exception pointer
712 libvlc_log_t *libvlc_log_open( const libvlc_instance_t *, libvlc_exception_t *);
715 * Close an instance of VLC message log
716 * \param p_log libvlc log instance
717 * \param exception an initialized exception pointer
719 void libvlc_log_close( libvlc_log_t *, libvlc_exception_t *);
722 * Returns the number of messages in log
723 * \param p_log libvlc log instance
724 * \param exception an initialized exception pointer
726 unsigned libvlc_log_count( const libvlc_log_t *, libvlc_exception_t *);
729 * Clear all messages in log
730 * the log should be cleared on a regular basis to avoid clogging
731 * \param p_log libvlc log instance
732 * \param exception an initialized exception pointer
734 void libvlc_log_clear( libvlc_log_t *, libvlc_exception_t *);
737 * Allocate and returns a new iterator to messages in log
738 * \param p_log libvlc log instance
739 * \param exception an initialized exception pointer
741 libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
744 * Releases a previoulsy allocated iterator
745 * \param p_log libvlc log iterator
746 * \param exception an initialized exception pointer
748 void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
751 * Returns whether log iterator has more messages
752 * \param p_log libvlc log iterator
753 * \param exception an initialized exception pointer
755 int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
758 * Returns next log message
759 * the content of message must not be freed
760 * \param p_log libvlc log iterator
761 * \param exception an initialized exception pointer
763 libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
764 struct libvlc_log_message_t *buffer,
765 libvlc_exception_t *p_e );
773 #endif /* <vlc/libvlc.h> */