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
143 void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * );
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
154 void libvlc_playlist_play( libvlc_instance_t*, int, int, char **,
155 libvlc_exception_t * );
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
162 void libvlc_playlist_pause( libvlc_instance_t *, libvlc_exception_t * );
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
170 int libvlc_playlist_isplaying( libvlc_instance_t *, libvlc_exception_t * );
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
178 int libvlc_playlist_items_count( libvlc_instance_t *, libvlc_exception_t * );
182 * \param p_instance the instance to stop
183 * \param p_exception an initialized exception
185 void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * );
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
192 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * );
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
199 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * );
202 * Remove all playlist items
203 * \param p_instance the instance
204 * \param p_exception an initialized exception
206 void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * );
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
216 int libvlc_playlist_add( libvlc_instance_t *, const char *, const char *,
217 libvlc_exception_t * );
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
229 int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
230 const char *, int, const char **,
231 libvlc_exception_t * );
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
240 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
241 libvlc_exception_t * );
243 typedef struct libvlc_input_t libvlc_input_t;
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
250 libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
251 libvlc_exception_t * );
255 /*****************************************************************************
257 *****************************************************************************/
258 /** defgroup libvlc_input Input
260 * LibVLC Input handling
264 /** Free an input object
265 * \param p_input the input to free
267 void libvlc_input_free( libvlc_input_t * );
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 *);
282 /** defgroup libvlc_video Video
284 * LibVLC Video handling
289 * Does this input have a video output ?
290 * \param p_input the input
291 * \param p_exception an initialized exception
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 *);
297 * Toggle fullscreen status on video output
298 * \param p_input the input
299 * \param p_exception an initialized exception
301 void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
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
309 void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
312 * Get current fullscreen status
313 * \param p_input the input
314 * \param p_exception an initialized exception
315 * \return the fullscreen status (boolean)
317 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
320 * Get current video height
321 * \param p_input the input
322 * \param p_exception an initialized exception
323 * \return the video height
325 int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
328 * Get current video width
329 * \param p_input the input
330 * \param p_exception an initialized exception
331 * \return the video width
333 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
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
341 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
343 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
347 * Resize the current 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)
354 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
357 * Downcast to this general type as placeholder for a platform specific one, such as:
359 * CGrafPort on MacOSX,
362 typedef int libvlc_drawable_t;
365 * change the parent for the current the video output
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)
371 int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
374 * Set the default video output parent
375 * this settings will be used as default for all video outputs
376 * \param p_instance libvlc instance
377 * \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
378 * \param p_exception an initialized exception
380 void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
383 * Set the default video output size
384 * this settings will be used as default for all video outputs
385 * \param p_instance libvlc instance
386 * \param width new width for video drawable
387 * \param height new height for video drawable
388 * \param p_exception an initialized exception
390 void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
393 * Downcast to this general type as placeholder for a platform specific one, such as:
395 * CGrafPort on MacOSX,
406 * Set the default video output viewport for a windowless video output (MacOS X only)
407 * this settings will be used as default for all video outputs
408 * \param p_instance libvlc instance
409 * \param view coordinates within video drawable
410 * \param clip coordinates within video drawable
411 * \param p_exception an initialized exception
413 void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
419 * defgroup libvlc_vlm VLM
421 * LibVLC VLM handling
425 /** defgroup libvlc_audio Audio
427 * LibVLC Audio handling
433 * \param p_instance libvlc instance
434 * \param p_exception an initialized exception
437 void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
440 * Get current mute status
441 * \param p_instance libvlc instance
442 * \param p_exception an initialized exception
443 * \return the mute status (boolean)
445 vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
449 * \param p_instance libvlc instance
450 * \param status If status is VLC_TRUE then mute, otherwise unmute
451 * \param p_exception an initialized exception
454 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
458 * Get current audio level
459 * \param p_instance libvlc instance
460 * \param p_exception an initialized exception
461 * \return the audio level (int)
463 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
467 * Set current audio level
468 * \param p_instance libvlc instance
469 * \param i_volume the volume (int)
470 * \param p_exception an initialized exception
473 void libvlc_audio_set_volume( libvlc_instance_t *, int , libvlc_exception_t *);
479 * Add a broadcast, with one input
480 * \param p_instance the instance
481 * \param psz_name the name of the new broadcast
482 * \param psz_input the input MRL
483 * \param psz_output the output MRL (the parameter to the "sout" variable)
484 * \param i_options number of additional options
485 * \param ppsz_options additional options
486 * \param b_enabled boolean for enabling the new broadcast
487 * \param b_loop Should this broadcast be played in loop ?
488 * \param p_exception an initialized exception
490 void libvlc_vlm_add_broadcast( libvlc_instance_t *, char *, char *, char* ,
491 int, char **, int, int, libvlc_exception_t * );
494 * Delete a media (vod or broadcast)
495 * \param p_instance the instance
496 * \param psz_name the media to delete
497 * \param p_exception an initialized exception
499 void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
502 * Enable or disable a media (vod or broadcast)
503 * \param p_instance the instance
504 * \param psz_name the media to work on
505 * \param b_enabled the new status
506 * \param p_exception an initialized exception
508 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
509 libvlc_exception_t *);
512 * Set the output for a media
513 * \param p_instance the instance
514 * \param psz_name the media to work on
515 * \param psz_output the output MRL (the parameter to the "sout" variable)
516 * \param p_exception an initialized exception
518 void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
519 libvlc_exception_t *);
522 * Set a media's input MRL. This will delete all existing inputs and
523 * add the specified one.
524 * \param p_instance the instance
525 * \param psz_name the media to work on
526 * \param psz_input the input MRL
527 * \param p_exception an initialized exception
529 void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
530 libvlc_exception_t *);
533 * Set output for a media
534 * \param p_instance the instance
535 * \param psz_name the media to work on
536 * \param b_loop the new status
537 * \param p_exception an initialized exception
539 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
540 libvlc_exception_t *);
546 * Edit the parameters of a media. This will delete all existing inputs and
547 * add the specified one.
548 * \param p_instance the instance
549 * \param psz_name the name of the new broadcast
550 * \param psz_input the input MRL
551 * \param psz_output the output MRL (the parameter to the "sout" variable)
552 * \param i_options number of additional options
553 * \param ppsz_options additional options
554 * \param b_enabled boolean for enabling the new broadcast
555 * \param b_loop Should this broadcast be played in loop ?
556 * \param p_exception an initialized exception
558 void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
559 int, char **, int, int, libvlc_exception_t * );
562 * Plays the named broadcast.
563 * \param p_instance the instance
564 * \param psz_name the name of the broadcast
565 * \param p_exception an initialized exception
567 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
570 * Stops the named broadcast.
571 * \param p_instance the instance
572 * \param psz_name the name of the broadcast
573 * \param p_exception an initialized exception
575 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
579 * Pauses the named broadcast.
580 * \param p_instance the instance
581 * \param psz_name the name of the broadcast
582 * \param p_exception an initialized exception
584 void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
587 * Seeks in the named broadcast.
588 * \param p_instance the instance
589 * \param psz_name the name of the broadcast
590 * \param f_percentage the percentage to seek to
591 * \param p_exception an initialized exception
593 void libvlc_vlm_seek_media( libvlc_instance_t *, char *,
594 float, libvlc_exception_t * );
597 * Return information of the named broadcast.
598 * \param p_instance the instance
599 * \param psz_name the name of the broadcast
600 * \param p_exception an initialized exception
602 char* libvlc_vlm_show_media( libvlc_instance_t *, char *, libvlc_exception_t * );
604 #define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
605 returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *, \
606 char *, int , libvlc_exception_t * );
608 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
609 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
610 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
611 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
612 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
613 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
614 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
616 #undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
621 /*****************************************************************************
622 * Message log handling
623 *****************************************************************************/
625 /** defgroup libvlc_log Log
627 * LibVLC Message Logging
631 /** This structure is opaque. It represents a libvlc log instance */
632 typedef struct libvlc_log_t libvlc_log_t;
634 /** This structure is opaque. It represents a libvlc log iterator */
635 typedef struct libvlc_log_iterator_t libvlc_log_iterator_t;
637 typedef struct libvlc_log_message_t
639 unsigned sizeof_msg; /* sizeof() of message structure, must be filled in by user */
640 int i_severity; /* 0=INFO, 1=ERR, 2=WARN, 3=DBG */
641 const char *psz_type; /* module type */
642 const char *psz_name; /* module name */
643 const char *psz_header; /* optional header */
644 const char *psz_message; /* message */
645 } libvlc_log_message_t;
647 * Returns the VLC messaging verbosity level
648 * \param p_instance libvlc instance
649 * \param exception an initialized exception pointer
651 unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e );
654 * Set the VLC messaging verbosity level
655 * \param p_log libvlc log instance
656 * \param exception an initialized exception pointer
658 void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level, libvlc_exception_t *p_e );
661 * Open an instance to VLC message log
662 * \param p_instance libvlc instance
663 * \param exception an initialized exception pointer
665 libvlc_log_t *libvlc_log_open( const libvlc_instance_t *, libvlc_exception_t *);
668 * Close an instance of VLC message log
669 * \param p_log libvlc log instance
670 * \param exception an initialized exception pointer
672 void libvlc_log_close( libvlc_log_t *, libvlc_exception_t *);
675 * Returns the number of messages in log
676 * \param p_log libvlc log instance
677 * \param exception an initialized exception pointer
679 unsigned libvlc_log_count( const libvlc_log_t *, libvlc_exception_t *);
682 * Clear all messages in log
683 * the log should be cleared on a regular basis to avoid clogging
684 * \param p_log libvlc log instance
685 * \param exception an initialized exception pointer
687 void libvlc_log_clear( libvlc_log_t *, libvlc_exception_t *);
690 * Allocate and returns a new iterator to messages in log
691 * \param p_log libvlc log instance
692 * \param exception an initialized exception pointer
694 libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
697 * Releases a previoulsy allocated iterator
698 * \param p_log libvlc log iterator
699 * \param exception an initialized exception pointer
701 void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
704 * Returns whether log iterator has more messages
705 * \param p_log libvlc log iterator
706 * \param exception an initialized exception pointer
708 int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
711 * Returns next log message
712 * the content of message must not be freed
713 * \param p_log libvlc log iterator
714 * \param exception an initialized exception pointer
716 libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
717 struct libvlc_log_message_t *buffer,
718 libvlc_exception_t *p_e );
726 #endif /* <vlc/libvlc.h> */