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
56 typedef struct libvlc_exception_t libvlc_exception_t;
59 * Initialize an exception structure. This can be called several times to reuse
60 * an exception structure.
61 * \param p_exception the exception to initialize
63 void libvlc_exception_init( libvlc_exception_t *p_exception );
66 * Has an exception been raised ?
67 * \param p_exception the exception to query
68 * \return 0 if no exception raised, 1 else
70 int libvlc_exception_raised( libvlc_exception_t *p_exception );
74 * \param p_exception the exception to raise
75 * \param psz_message the exception message
77 void libvlc_exception_raise( libvlc_exception_t *p_exception, const char *psz_format, ... );
80 * Clear an exception object so it can be reused.
81 * The exception object must be initialized
82 * \param p_exception the exception to clear
84 void libvlc_exception_clear( libvlc_exception_t * );
87 * Get exception message
88 * \param p_exception the exception to query
89 * \return the exception message or NULL if not applicable (exception not raised
92 char* libvlc_exception_get_message( libvlc_exception_t *p_exception );
96 /*****************************************************************************
98 *****************************************************************************/
100 /** defgroup libvlc_core Core
106 /** This structure is opaque. It represents a libvlc instance */
107 typedef struct libvlc_instance_t libvlc_instance_t;
110 * Create an initialized libvlc instance
111 * \param argc the number of arguments
112 * \param argv command-line-type arguments
113 * \param exception an initialized exception pointer
115 libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
118 * Returns a libvlc instance identifier for legacy APIs. Use of this
119 * function is discouraged, you should convert your program to use the
121 * \param p_instance the instance
123 int libvlc_get_vlc_id( libvlc_instance_t *p_instance );
126 * Destroy a libvlc instance.
127 * \param p_instance the instance to destroy
129 void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
133 /*****************************************************************************
135 *****************************************************************************/
136 /** defgroup libvlc_playlist Playlist
138 * LibVLC Playlist handling
145 void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * );
148 * Start playing. You can give some additionnal playlist item options
149 * that will be added to the item before playing it.
150 * \param p_instance the instance
151 * \param i_id the item to play. If this is a negative number, the next
152 * item will be selected. Else, the item with the given ID will be played
153 * \param i_options the number of options to add to the item
154 * \param ppsz_options the options to add to the item
155 * \param p_exception an initialized exception
157 void libvlc_playlist_play( libvlc_instance_t*, int, int, char **,
158 libvlc_exception_t * );
161 * Pause a running playlist, resume if it was stopped
162 * \param p_instance the instance to pause
163 * \param p_exception an initialized exception
165 void libvlc_playlist_pause( libvlc_instance_t *, libvlc_exception_t * );
168 * Checks if the playlist is running
169 * \param p_instance the instance
170 * \param p_exception an initialized exception
171 * \return 0 if the playlist is stopped or paused, 1 if it is running
173 int libvlc_playlist_isplaying( libvlc_instance_t *, libvlc_exception_t * );
176 * Get the number of items in the playlist
177 * \param p_instance the instance
178 * \param p_exception an initialized exception
179 * \return the number of items
181 int libvlc_playlist_items_count( libvlc_instance_t *, libvlc_exception_t * );
185 * \param p_instance the instance to stop
186 * \param p_exception an initialized exception
188 void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * );
191 * Go to next playlist item (starts playback if it was stopped)
192 * \param p_instance the instance to use
193 * \param p_exception an initialized exception
195 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * );
198 * Go to previous playlist item (starts playback if it was stopped)
199 * \param p_instance the instance to use
200 * \param p_exception an initialized exception
202 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * );
205 * Remove all playlist items
206 * \param p_instance the instance
207 * \param p_exception an initialized exception
209 void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * );
212 * Add an item at the end of the playlist
213 * If you need more advanced options, \see libvlc_playlist_add_extended
214 * \param p_instance the instance
215 * \param psz_uri the URI to open, using VLC format
216 * \param psz_name a name that you might want to give or NULL
217 * \return the identifier of the new item
219 int libvlc_playlist_add( libvlc_instance_t *, const char *, const char *,
220 libvlc_exception_t * );
223 * Add an item at the end of the playlist, with additional input options
224 * \param p_instance the instance
225 * \param psz_uri the URI to open, using VLC format
226 * \param psz_name a name that you might want to give or NULL
227 * \param i_options the number of options to add
228 * \param ppsz_options strings representing the options to add
229 * \param p_exception an initialized exception
230 * \return the identifier of the new item
232 int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
233 const char *, int, const char **,
234 libvlc_exception_t * );
237 * Delete the playlist item with the given ID.
238 * \param p_instance the instance
239 * \param i_id the id to remove
240 * \param p_exception an initialized exception
243 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
244 libvlc_exception_t * );
246 typedef struct libvlc_input_t libvlc_input_t;
248 /* Get the input that is currently being played by the playlist
249 * \param p_instance the instance to use
250 * \param p_exception an initialized excecption
251 * \return an input object
253 libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
254 libvlc_exception_t * );
258 /*****************************************************************************
260 *****************************************************************************/
261 /** defgroup libvlc_input Input
263 * LibVLC Input handling
267 /** Free an input object
268 * \param p_input the input to free
270 void libvlc_input_free( libvlc_input_t * );
272 /// \bug This might go away ... to be replaced by a broader system
273 vlc_int64_t libvlc_input_get_length ( libvlc_input_t *, libvlc_exception_t *);
274 vlc_int64_t libvlc_input_get_time ( libvlc_input_t *, libvlc_exception_t *);
275 void libvlc_input_set_time ( libvlc_input_t *, vlc_int64_t, libvlc_exception_t *);
276 float libvlc_input_get_position ( libvlc_input_t *, libvlc_exception_t *);
277 void libvlc_input_set_position ( libvlc_input_t *, float, libvlc_exception_t *);
278 vlc_bool_t libvlc_input_will_play ( libvlc_input_t *, libvlc_exception_t *);
279 float libvlc_input_get_rate ( libvlc_input_t *, libvlc_exception_t *);
280 void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *);
281 int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *);
285 /** defgroup libvlc_video Video
287 * LibVLC Video handling
291 typedef int libvlc_drawable_t;
294 * Does this input have a video output ?
295 * \param p_input the input
296 * \param p_exception an initialized exception
298 vlc_bool_t libvlc_input_has_vout ( libvlc_input_t *, libvlc_exception_t *);
299 float libvlc_input_get_fps ( libvlc_input_t *, libvlc_exception_t *);
302 * Toggle fullscreen status on video output
303 * \param p_input the input
304 * \param p_exception an initialized exception
306 void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
309 * Enable or disable fullscreen on a video output
310 * \param p_input the input
311 * \param b_fullscreen boolean for fullscreen status
312 * \param p_exception an initialized exception
314 void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
317 * Get current fullscreen status
318 * \param p_input the input
319 * \param p_exception an initialized exception
320 * \return the fullscreen status (boolean)
322 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
325 * Get current video height
326 * \param p_input the input
327 * \param p_exception an initialized exception
328 * \return the video height
330 int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
333 * Get current video width
334 * \param p_input the input
335 * \param p_exception an initialized exception
336 * \return the video width
338 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
341 * Get current video aspect ratio
342 * \param p_input the input
343 * \param p_exception an initialized exception
344 * \return the video aspect ratio
346 char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
349 * Set new video aspect ratio
350 * \param p_input the input
351 * \param psz_aspect new video aspect-ratio
352 * \param p_exception an initialized exception
354 void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
357 * Take a snapshot of the current video window
358 * \param p_input the input
359 * \param psz_filepath the path where to save the screenshot to
360 * \param p_exception an initialized exception
362 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
364 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
367 * Resize the current video output window
368 * \param p_instance libvlc instance
369 * \param width new width for video output window
370 * \param height new height for video output window
371 * \param p_exception an initialized exception
372 * \return the mute status (boolean)
374 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
377 * Downcast to this general type as placeholder for a platform specific one, such as:
379 * CGrafPort on MacOSX,
384 * change the parent for the current the video output
385 * \param p_instance libvlc instance
386 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
387 * \param p_exception an initialized exception
388 * \return the mute status (boolean)
390 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
393 * Set the default video output parent
394 * this settings will be used as default for all video outputs
395 * \param p_instance libvlc instance
396 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
397 * \param p_exception an initialized exception
399 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
402 * Set the default video output size
403 * this settings will be used as default for all video outputs
404 * \param p_instance libvlc instance
405 * \param width new width for video drawable
406 * \param height new height for video drawable
407 * \param p_exception an initialized exception
409 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
412 * Downcast to this general type as placeholder for a platform specific one, such as:
414 * CGrafPort on MacOSX,
425 * Set the default video output viewport for a windowless video output (MacOS X only)
426 * this settings will be used as default for all video outputs
427 * \param p_instance libvlc instance
428 * \param view coordinates within video drawable
429 * \param clip coordinates within video drawable
430 * \param p_exception an initialized exception
432 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
438 * defgroup libvlc_vlm VLM
440 * LibVLC VLM handling
444 /** defgroup libvlc_audio Audio
446 * LibVLC Audio handling
452 * \param p_instance libvlc instance
453 * \param p_exception an initialized exception
456 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
459 * Get current mute status
460 * \param p_instance libvlc instance
461 * \param p_exception an initialized exception
462 * \return the mute status (boolean)
464 vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
468 * \param p_instance libvlc instance
469 * \param status If status is VLC_TRUE then mute, otherwise unmute
470 * \param p_exception an initialized exception
473 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
476 * Get current audio level
477 * \param p_instance libvlc instance
478 * \param p_exception an initialized exception
479 * \return the audio level (int)
481 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
484 * Set current audio level
485 * \param p_instance libvlc instance
486 * \param i_volume the volume (int)
487 * \param p_exception an initialized exception
490 void libvlc_audio_set_volume( libvlc_instance_t *, int, libvlc_exception_t *);
493 * Get current audio track
494 * \param p_instance libvlc instance
495 * \param p_exception an initialized exception
496 * \return the audio track (int)
498 int libvlc_audio_get_track( libvlc_instance_t *, libvlc_exception_t * );
501 * Set current audio track
502 * \param p_instance libvlc instance
503 * \param i_track the track (int)
504 * \param p_exception an initialized exception
507 void libvlc_audio_set_track( libvlc_instance_t *, int, libvlc_exception_t * );
510 * Get current audio channel
511 * \param p_instance libvlc instance
512 * \param p_exception an initialized exception
513 * \return the audio channel (char *)
515 char *libvlc_audio_get_channel( libvlc_instance_t *, libvlc_exception_t * );
518 * Set current audio track
519 * \param p_instance libvlc instance
520 * \param psz_channel the audio channel (char *)
521 * \param p_exception an initialized exception
524 void libvlc_audio_set_channel( libvlc_instance_t *, char *, libvlc_exception_t * );
530 * Add a broadcast, with one input
531 * \param p_instance the instance
532 * \param psz_name the name of the new broadcast
533 * \param psz_input the input MRL
534 * \param psz_output the output MRL (the parameter to the "sout" variable)
535 * \param i_options number of additional options
536 * \param ppsz_options additional options
537 * \param b_enabled boolean for enabling the new broadcast
538 * \param b_loop Should this broadcast be played in loop ?
539 * \param p_exception an initialized exception
541 void libvlc_vlm_add_broadcast( libvlc_instance_t *, char *, char *, char* ,
542 int, char **, int, int, libvlc_exception_t * );
545 * Delete a media (vod or broadcast)
546 * \param p_instance the instance
547 * \param psz_name the media to delete
548 * \param p_exception an initialized exception
550 void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
553 * Enable or disable a media (vod or broadcast)
554 * \param p_instance the instance
555 * \param psz_name the media to work on
556 * \param b_enabled the new status
557 * \param p_exception an initialized exception
559 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
560 libvlc_exception_t *);
563 * Set the output for a media
564 * \param p_instance the instance
565 * \param psz_name the media to work on
566 * \param psz_output the output MRL (the parameter to the "sout" variable)
567 * \param p_exception an initialized exception
569 void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
570 libvlc_exception_t *);
573 * Set a media's input MRL. This will delete all existing inputs and
574 * add the specified one.
575 * \param p_instance the instance
576 * \param psz_name the media to work on
577 * \param psz_input the input MRL
578 * \param p_exception an initialized exception
580 void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
581 libvlc_exception_t *);
584 * Set output for a media
585 * \param p_instance the instance
586 * \param psz_name the media to work on
587 * \param b_loop the new status
588 * \param p_exception an initialized exception
590 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
591 libvlc_exception_t *);
594 * Edit the parameters of a media. This will delete all existing inputs and
595 * add the specified one.
596 * \param p_instance the instance
597 * \param psz_name the name of the new broadcast
598 * \param psz_input the input MRL
599 * \param psz_output the output MRL (the parameter to the "sout" variable)
600 * \param i_options number of additional options
601 * \param ppsz_options additional options
602 * \param b_enabled boolean for enabling the new broadcast
603 * \param b_loop Should this broadcast be played in loop ?
604 * \param p_exception an initialized exception
606 void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
607 int, char **, int, int, libvlc_exception_t * );
610 * Plays the named broadcast.
611 * \param p_instance the instance
612 * \param psz_name the name of the broadcast
613 * \param p_exception an initialized exception
615 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
618 * Stops the named broadcast.
619 * \param p_instance the instance
620 * \param psz_name the name of the broadcast
621 * \param p_exception an initialized exception
623 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
626 * Pauses the named broadcast.
627 * \param p_instance the instance
628 * \param psz_name the name of the broadcast
629 * \param p_exception an initialized exception
631 void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
634 * Seeks in the named broadcast.
635 * \param p_instance the instance
636 * \param psz_name the name of the broadcast
637 * \param f_percentage the percentage to seek to
638 * \param p_exception an initialized exception
640 void libvlc_vlm_seek_media( libvlc_instance_t *, char *,
641 float, libvlc_exception_t * );
644 * Return information of the named broadcast.
645 * \param p_instance the instance
646 * \param psz_name the name of the broadcast
647 * \param p_exception an initialized exception
649 char* libvlc_vlm_show_media( libvlc_instance_t *, char *, libvlc_exception_t * );
651 #define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
652 returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *, \
653 char *, int , libvlc_exception_t * );
655 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
656 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
657 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
658 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
659 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
660 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
661 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
663 #undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
668 /*****************************************************************************
669 * Message log handling
670 *****************************************************************************/
672 /** defgroup libvlc_log Log
674 * LibVLC Message Logging
678 /** This structure is opaque. It represents a libvlc log instance */
679 typedef struct libvlc_log_t libvlc_log_t;
681 /** This structure is opaque. It represents a libvlc log iterator */
682 typedef struct libvlc_log_iterator_t libvlc_log_iterator_t;
684 typedef struct libvlc_log_message_t
686 unsigned sizeof_msg; /* sizeof() of message structure, must be filled in by user */
687 int i_severity; /* 0=INFO, 1=ERR, 2=WARN, 3=DBG */
688 const char *psz_type; /* module type */
689 const char *psz_name; /* module name */
690 const char *psz_header; /* optional header */
691 const char *psz_message; /* message */
692 } libvlc_log_message_t;
695 * Returns the VLC messaging verbosity level
696 * \param p_instance libvlc instance
697 * \param exception an initialized exception pointer
699 unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e );
702 * Set the VLC messaging verbosity level
703 * \param p_log libvlc log instance
704 * \param exception an initialized exception pointer
706 void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level, libvlc_exception_t *p_e );
709 * Open an instance to VLC message log
710 * \param p_instance libvlc instance
711 * \param exception an initialized exception pointer
713 libvlc_log_t *libvlc_log_open( const libvlc_instance_t *, libvlc_exception_t *);
716 * Close an instance of VLC message log
717 * \param p_log libvlc log instance
718 * \param exception an initialized exception pointer
720 void libvlc_log_close( libvlc_log_t *, libvlc_exception_t *);
723 * Returns the number of messages in log
724 * \param p_log libvlc log instance
725 * \param exception an initialized exception pointer
727 unsigned libvlc_log_count( const libvlc_log_t *, libvlc_exception_t *);
730 * Clear all messages in log
731 * the log should be cleared on a regular basis to avoid clogging
732 * \param p_log libvlc log instance
733 * \param exception an initialized exception pointer
735 void libvlc_log_clear( libvlc_log_t *, libvlc_exception_t *);
738 * Allocate and returns a new iterator to messages in log
739 * \param p_log libvlc log instance
740 * \param exception an initialized exception pointer
742 libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
745 * Releases a previoulsy allocated iterator
746 * \param p_log libvlc log iterator
747 * \param exception an initialized exception pointer
749 void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
752 * Returns whether log iterator has more messages
753 * \param p_log libvlc log iterator
754 * \param exception an initialized exception pointer
756 int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
759 * Returns next log message
760 * the content of message must not be freed
761 * \param p_log libvlc log iterator
762 * \param exception an initialized exception pointer
764 libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
765 struct libvlc_log_message_t *buffer,
766 libvlc_exception_t *p_e );
774 #endif /* <vlc/libvlc.h> */