2 * GeeXboX libplayer: a multimedia A/V abstraction layer API.
3 * Copyright (C) 2006-2008 Benjamin Zores <ben@geexbox.org>
4 * Copyright (C) 2007-2008 Mathieu Schroeter <mathieu.schroeter@gamesover.ch>
6 * This file is part of libplayer.
8 * libplayer is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * libplayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with libplayer; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * GeeXboX libplayer public API header.
35 * libplayer is a multimedia A/V abstraction layer API. Its goal is to
36 * interact with Enna Media Center.
38 * libplayer provides a generic A/V API that relies on various multimedia
39 * player for Linux systems. It currently supports
40 * <a href="http://www.mplayerhq.hu">MPlayer</a> (through slave-mode), <a
41 * href="http://www.xinehq.de">xine</a>, <a href="http://www.videolan.org">
42 * VLC</a> and <a href="http://www.gstreamer.org">GStreamer</a>.
44 * Its main goal is to provide an unique API that player frontends can use
45 * to control any kind of multimedia player underneath. For example, it
46 * provides a library to easily control MPlayer famous slave-mode.
48 * \section mtlevel MT-Level
49 * Most functions in this API are indicated as being MT-Safe in multithreaded
50 * applications. That is right <b>only</b> if the functions are used
51 * concurrently with the same (#player_t) controller. Else, unexpected
52 * behaviours can appear.
57 #if 0 /* avoid EMACS indent */
60 #endif /* __cplusplus */
64 # define pl_unused __attribute__((unused))
70 #define PL_STRINGIFY(s) #s
71 #define PL_TOSTRING(s) PL_STRINGIFY(s)
73 #define PL_VERSION_INT(a, b, c) (a << 16 | b << 8 | c)
74 #define PL_VERSION_DOT(a, b, c) a ##.## b ##.## c
75 #define PL_VERSION(a, b, c) PL_VERSION_DOT(a, b, c)
77 #define LIBPLAYER_VERSION_MAJOR 2
78 #define LIBPLAYER_VERSION_MINOR 0
79 #define LIBPLAYER_VERSION_MICRO 0
81 #define LIBPLAYER_VERSION_INT PL_VERSION_INT(LIBPLAYER_VERSION_MAJOR, \
82 LIBPLAYER_VERSION_MINOR, \
83 LIBPLAYER_VERSION_MICRO)
84 #define LIBPLAYER_VERSION PL_VERSION(LIBPLAYER_VERSION_MAJOR, \
85 LIBPLAYER_VERSION_MINOR, \
86 LIBPLAYER_VERSION_MICRO)
87 #define LIBPLAYER_VERSION_STR PL_TOSTRING(LIBPLAYER_VERSION)
88 #define LIBPLAYER_BUILD LIBPLAYER_VERSION_INT
91 #include <sys/types.h>
94 * \brief Return LIBPLAYER_VERSION_INT constant.
96 unsigned int libplayer_version (void);
99 /***************************************************************************/
101 /* Player (Un)Initialization */
102 /* Mandatory for all operations below */
104 /***************************************************************************/
107 * \brief Player controller.
109 * This controls a multimedia player.
111 typedef struct player_s player_t;
113 /** \brief Player types. */
114 typedef enum player_type {
118 PLAYER_TYPE_GSTREAMER,
122 /** \brief Player video outputs. */
123 typedef enum player_vo {
136 /** \brief Player audio outputs. */
137 typedef enum player_ao {
145 /** \brief Player events. */
146 typedef enum player_event {
147 PLAYER_EVENT_UNKNOWN,
148 PLAYER_EVENT_PLAYBACK_START,
149 PLAYER_EVENT_PLAYBACK_STOP,
150 PLAYER_EVENT_PLAYBACK_FINISHED,
151 PLAYER_EVENT_PLAYLIST_FINISHED,
152 PLAYER_EVENT_PLAYBACK_PAUSE,
153 PLAYER_EVENT_PLAYBACK_UNPAUSE,
156 /** \brief Player verbosity. */
158 PLAYER_MSG_NONE, /* no error messages */
159 PLAYER_MSG_VERBOSE, /* super-verbose mode: mostly for debugging */
160 PLAYER_MSG_INFO, /* working operations */
161 PLAYER_MSG_WARNING, /* harmless failures */
162 PLAYER_MSG_ERROR, /* may result in hazardous behavior */
163 PLAYER_MSG_CRITICAL, /* prevents lib from working */
164 } player_verbosity_level_t;
167 PLAYER_QUALITY_NORMAL, /* normal picture quality */
168 PLAYER_QUALITY_LOW, /* slightly degraded picture for fastest playback */
169 PLAYER_QUALITY_LOWEST, /* degraded picture, suitable for low-end CPU */
170 } player_quality_level_t;
172 /** \brief Parameters for player_init() .*/
173 typedef struct player_init_param_s {
174 /** Audio output driver. */
176 /** Video output driver. */
178 /** Window ID to attach the video (X Window). */
181 /** Public event callback. */
182 int (*event_cb) (player_event_t e, void *data);
183 /** User data for event callback. */
187 * Display to use with X11 video outputs.
189 * The string has to follow the same rules that the DISPLAY environment
190 * variable. If \p display is NULL, then the environment variable is
195 /** Picture decoding quality. */
196 player_quality_level_t quality;
198 } player_init_param_t;
201 * \name Player (Un)Initialization.
206 * \brief Initialization of a new player controller.
208 * Multiple player controllers can be initialized with any wrappers.
209 * The same Window ID can be used to attach their video.
211 * For a description of each parameters supported by this function:
212 * \see ::player_init_param_t
214 * When a parameter in \p param is 0 (or NULL), its default value is used.
215 * If \p param is NULL, then all default values are forced for all parameters.
217 * Wrappers supported (even partially):
218 * GStreamer, MPlayer, VLC, xine
220 * \param[in] type Type of wrapper to load.
221 * \param[in] verbosity Level of verbosity to set.
222 * \param[in] param Parameters, NULL for default values.
223 * \return Player controller, NULL otherwise.
225 player_t *player_init (player_type_t type, player_verbosity_level_t verbosity,
226 player_init_param_t *param);
229 * \brief Uninitialization of a player controller.
231 * All MRL objects in the internal playlist will be freed.
233 * Wrappers supported (even partially):
234 * GStreamer, MPlayer, VLC, xine
236 * \warning Must be used only as the last player function for a controller.
237 * \param[in] player Player controller.
239 void player_uninit (player_t *player);
242 * \brief Set verbosity level.
244 * Wrappers supported (even partially):
247 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
248 * \param[in] player Player controller.
249 * \param[in] level Level of verbosity to set.
251 void player_set_verbosity (player_t *player, player_verbosity_level_t level);
257 /***************************************************************************/
259 /* Media Resource Locater (MRL) Helpers */
260 /* MRLs can have multiple types and are used to define a stream */
262 /***************************************************************************/
267 * This handles an audio, video or image resource.
269 typedef struct mrl_s mrl_t;
271 /** \brief MRL types. */
272 typedef enum mrl_type {
280 * Support by wrappers
282 * GStreamer MPlayer VLC xine
283 * ------------ ------------ ------------ ------------
285 /** \brief MRL resources. */
286 typedef enum mrl_resource {
287 MRL_RESOURCE_UNKNOWN,
290 MRL_RESOURCE_FIFO, /* NO NO NO NO */
291 MRL_RESOURCE_FILE, /* NO YES YES YES */
292 MRL_RESOURCE_STDIN, /* NO NO NO NO */
295 MRL_RESOURCE_CDDA, /* NO YES NO NO */
296 MRL_RESOURCE_CDDB, /* NO YES NO NO */
299 MRL_RESOURCE_DVD, /* NO YES YES YES */
300 MRL_RESOURCE_DVDNAV, /* NO YES YES YES */
301 MRL_RESOURCE_VCD, /* NO YES NO NO */
303 /* Radio/Television */
304 MRL_RESOURCE_DVB, /* NO YES NO NO */
305 MRL_RESOURCE_PVR, /* NO NO NO NO */
306 MRL_RESOURCE_RADIO, /* NO YES NO NO */
307 MRL_RESOURCE_TV, /* NO YES NO NO */
308 MRL_RESOURCE_VDR, /* NO NO NO YES */
310 /* Network Streams */
311 MRL_RESOURCE_FTP, /* NO YES YES NO */
312 MRL_RESOURCE_HTTP, /* NO YES YES YES */
313 MRL_RESOURCE_MMS, /* NO YES YES YES */
314 MRL_RESOURCE_NETVDR, /* NO NO NO YES */
315 MRL_RESOURCE_RTP, /* NO YES YES YES */
316 MRL_RESOURCE_RTSP, /* NO YES YES NO */
317 MRL_RESOURCE_SMB, /* NO YES YES NO */
318 MRL_RESOURCE_TCP, /* NO NO NO YES */
319 MRL_RESOURCE_UDP, /* NO YES YES YES */
320 MRL_RESOURCE_UNSV, /* NO YES YES NO */
323 /** \brief Arguments for local streams. */
324 typedef struct mrl_resource_local_args_s {
325 char *location; /* NO YES YES YES */
326 int playlist; /* NO NO NO NO */
327 } mrl_resource_local_args_t;
329 /** \brief Arguments for audio CD. */
330 typedef struct mrl_resource_cd_args_s {
331 char *device; /* NO YES NO NO */
332 uint8_t speed; /* NO YES NO NO */
333 uint8_t track_start; /* NO YES NO NO */
334 uint8_t track_end; /* NO YES NO NO */
335 } mrl_resource_cd_args_t;
337 /** \brief Arguments for video discs. */
338 typedef struct mrl_resource_videodisc_args_s {
339 char *device; /* NO YES YES YES */
340 uint8_t speed; /* NO NO NO NO */
341 uint8_t angle; /* NO YES YES NO */
342 uint8_t title_start; /* NO YES YES YES */
343 uint8_t title_end; /* NO YES NO NO */
344 uint8_t chapter_start; /* NO NO YES NO */
345 uint8_t chapter_end; /* NO NO NO NO */
346 uint8_t track_start; /* NO YES NO NO */
347 uint8_t track_end; /* NO NO NO NO */
348 char *audio_lang; /* NO NO NO NO */
349 char *sub_lang; /* NO NO NO NO */
350 uint8_t sub_cc; /* NO NO NO NO */
351 } mrl_resource_videodisc_args_t;
353 /** \brief Arguments for radio/tv streams. */
354 typedef struct mrl_resource_tv_args_s {
355 char *device; /* NO NO NO YES */
356 char *driver; /* NO NO NO YES */
357 char *channel; /* NO YES NO NO */
358 uint8_t input; /* NO YES NO NO */
359 int width; /* NO NO NO NO */
360 int height; /* NO NO NO NO */
361 int fps; /* NO NO NO NO */
362 char *output_format; /* NO NO NO NO */
363 char *norm; /* NO YES NO NO */
364 } mrl_resource_tv_args_t;
366 /** \brief Arguments for network streams. */
367 typedef struct mrl_resource_network_args_s {
368 char *url; /* NO YES NO YES */
369 char *username; /* NO YES NO NO */
370 char *password; /* NO YES NO NO */
371 char *user_agent; /* NO NO NO NO */
372 } mrl_resource_network_args_t;
374 /** \brief Snapshot image file type. */
375 typedef enum mrl_snapshot {
376 MRL_SNAPSHOT_JPG, /* NO YES NO NO */
377 MRL_SNAPSHOT_PNG, /* NO YES NO NO */
378 MRL_SNAPSHOT_PPM, /* NO YES NO NO */
379 MRL_SNAPSHOT_TGA, /* NO NO NO NO */
382 /** \brief MRL metadata. */
383 typedef enum mrl_metadata_type {
390 MRL_METADATA_COMMENT,
391 } mrl_metadata_type_t;
393 /** \brief MRL CDDA/CDDB metadata. */
394 typedef enum mrl_metadata_cd_type {
395 MRL_METADATA_CD_DISCID,
396 MRL_METADATA_CD_TRACKS,
397 } mrl_metadata_cd_type_t;
399 /** \brief MRL DVD/DVDNAV metadata. */
400 typedef enum mrl_metadata_dvd_type {
401 MRL_METADATA_DVD_TITLE_CHAPTERS,
402 MRL_METADATA_DVD_TITLE_ANGLES,
403 MRL_METADATA_DVD_TITLE_LENGTH,
404 } mrl_metadata_dvd_type_t;
406 /** \brief MRL properties. */
407 typedef enum mrl_properties_type {
408 MRL_PROPERTY_SEEKABLE,
410 MRL_PROPERTY_AUDIO_BITRATE,
411 MRL_PROPERTY_AUDIO_BITS,
412 MRL_PROPERTY_AUDIO_CHANNELS,
413 MRL_PROPERTY_AUDIO_SAMPLERATE,
414 MRL_PROPERTY_VIDEO_BITRATE,
415 MRL_PROPERTY_VIDEO_WIDTH,
416 MRL_PROPERTY_VIDEO_HEIGHT,
417 MRL_PROPERTY_VIDEO_ASPECT,
418 MRL_PROPERTY_VIDEO_CHANNELS,
419 MRL_PROPERTY_VIDEO_STREAMS,
420 MRL_PROPERTY_VIDEO_FRAMEDURATION,
421 } mrl_properties_type_t;
423 #define PLAYER_VIDEO_ASPECT_RATIO_MULT 10000.0 /* *10000 */
424 #define PLAYER_VIDEO_FRAMEDURATION_RATIO_DIV 90000.0 /* 1/90000 sec */
427 * \name Media Resource Locater (MRL) Helpers.
432 * \brief Create a new MRL object.
434 * This function can be slow when the stream is not (fastly) reachable.
436 * The argument \p args and the strings provided with \p args must be
437 * allocated dynamically. The pointers are freed by libplayer when a mrl
438 * is no longer available.
440 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
441 * \param[in] player Player controller.
442 * \param[in] res Resource type.
443 * \param[in] args Arguments specific to the resource type.
444 * \return MRL object, NULL otherwise.
446 mrl_t *mrl_new (player_t *player, mrl_resource_t res, void *args);
449 * \brief Add a subtitle file to a MRL object.
451 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
452 * \param[in] player Player controller.
453 * \param[in] mrl MRL object, NULL for current.
454 * \param[in] subtitle Location of the subtitle file to be added.
456 void mrl_add_subtitle (player_t *player, mrl_t *mrl, char *subtitle);
459 * \brief Free a MRL object.
461 * Never use this function when the MRL (or a linked MRL) is set in the
462 * playlist of a player controller.
464 * \warning Must be used only as the last mrl function for one MRL object.
465 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
466 * \param[in] player Player controller.
467 * \param[in] mrl MRL object.
469 void mrl_free (player_t *player, mrl_t *mrl);
472 * \brief Get type of the stream.
474 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
475 * \param[in] player Player controller.
476 * \param[in] mrl MRL object, NULL for current.
477 * \return Type of MRL object.
479 mrl_type_t mrl_get_type (player_t *player, mrl_t *mrl);
482 * \brief Get resource of the stream.
484 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
485 * \param[in] player Player controller.
486 * \param[in] mrl MRL object, NULL for current.
487 * \return Resource of MRL object.
489 mrl_resource_t mrl_get_resource (player_t *player, mrl_t *mrl);
492 * \brief Get metadata of the stream.
494 * This function can be slow when the stream is not (fastly) reachable.
496 * Wrappers supported (even partially):
499 * \warning The returned pointer must be freed when no longer used.
500 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
501 * \param[in] player Player controller.
502 * \param[in] mrl MRL object, NULL for current.
503 * \param[in] m Type of metadata to get.
504 * \return Metadata string, NULL otherwise.
506 char *mrl_get_metadata (player_t *player, mrl_t *mrl, mrl_metadata_type_t m);
509 * \brief Get metadata of a track with CDDA/CDDB MRL object.
511 * This function can be slow when the stream is not (fastly) reachable.
513 * Wrappers supported (even partially):
516 * \warning The returned pointer must be freed when no longer used.
517 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
518 * \param[in] player Player controller.
519 * \param[in] mrl MRL object, NULL for current.
520 * \param[in] trackid Track ID on the CD.
521 * \param[out] length Length of the track (millisecond).
522 * \return Title of the track (CDDB only), NULL otherwise.
524 char *mrl_get_metadata_cd_track (player_t *player,
525 mrl_t *mrl, int trackid, uint32_t *length);
528 * \brief Get metadata of a CDDA/CDDB MRL object.
530 * This function can be slow when the stream is not (fastly) reachable.
532 * Wrappers supported (even partially):
535 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
536 * \param[in] player Player controller.
537 * \param[in] mrl MRL object, NULL for current.
538 * \param[in] m Type of metadata to get.
539 * \return Metadata value.
541 uint32_t mrl_get_metadata_cd (player_t *player,
542 mrl_t *mrl, mrl_metadata_cd_type_t m);
545 * \brief Get metadata of a title with DVD/DVDNAV MRL object.
547 * This function can be slow when the stream is not (fastly) reachable.
549 * Wrappers supported (even partially):
552 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
553 * \param[in] player Player controller.
554 * \param[in] mrl MRL object, NULL for current.
555 * \param[in] titleid Title ID on the DVD.
556 * \param[in] m Type of metadata to get.
557 * \return Metadata value.
559 uint32_t mrl_get_metadata_dvd_title (player_t *player, mrl_t *mrl,
560 int titleid, mrl_metadata_dvd_type_t m);
563 * \brief Get metadata of a DVD/DVDNAV MRL object.
565 * This function can be slow when the stream is not (fastly) reachable.
567 * Wrappers supported (even partially):
570 * \warning The returned pointer must be freed when no longer used.
571 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
572 * \param[in] player Player controller.
573 * \param[in] mrl MRL object, NULL for current.
574 * \param[out] titles How many titles on the DVD.
575 * \return Volume ID, NULL otherwise.
577 char *mrl_get_metadata_dvd (player_t *player, mrl_t *mrl, uint8_t *titles);
580 * \brief Get subtitle metadata of the MRL object.
582 * This function can be slow when the stream is not (fastly) reachable.
584 * The \p pos argument is the position of the subtitle in the internal list
585 * of libplayer. The first subtitle begins with 1.
586 * \p id returned by this function can be used with player_subtitle_select().
588 * Wrappers supported (even partially):
591 * \warning The pointers (\p name and \p lang) must be freed when no longer used.
592 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
593 * \param[in] player Player controller.
594 * \param[in] mrl MRL object, NULL for current.
595 * \param[in] pos Position of the subtitle.
596 * \param[out] id ID of the subtitle, NULL to ignore.
597 * \param[out] name Name of the subtitle, NULL to ignore.
598 * \param[out] lang Language of the subtitle, NULL to ignore.
599 * \return 1 for success, 0 if the subtitle is not available.
601 int mrl_get_metadata_subtitle (player_t *player, mrl_t *mrl, int pos,
602 uint32_t *id, char **name, char **lang);
605 * \brief Get the number of available subtitles.
607 * This function can be slow when the stream is not (fastly) reachable.
609 * Wrappers supported (even partially):
612 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
613 * \param[in] player Player controller.
614 * \param[in] mrl MRL object, NULL for current.
615 * \return Number of subtitles.
617 uint32_t mrl_get_metadata_subtitle_nb (player_t *player, mrl_t *mrl);
620 * \brief Get audio metadata of the MRL object.
622 * This function can be slow when the stream is not (fastly) reachable.
624 * The \p pos argument is the position of the audio stream in the internal list
625 * of libplayer. The first audio stream begins with 1.
626 * \p id returned by this function can be used with player_audio_select().
628 * Wrappers supported (even partially):
631 * \warning The pointers (\p name and \p lang) must be freed when no longer used.
632 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
633 * \param[in] player Player controller.
634 * \param[in] mrl MRL object, NULL for current.
635 * \param[in] pos Position of the audio stream.
636 * \param[out] id ID of the audio stream, NULL to ignore.
637 * \param[out] name Name of the audio stream, NULL to ignore.
638 * \param[out] lang Language of the audio stream, NULL to ignore.
639 * \return 1 for success, 0 if the audio stream is not available.
641 int mrl_get_metadata_audio (player_t *player, mrl_t *mrl, int pos,
642 uint32_t *id, char **name, char **lang);
645 * \brief Get the number of available audio streams.
647 * This function can be slow when the stream is not (fastly) reachable.
649 * Wrappers supported (even partially):
652 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
653 * \param[in] player Player controller.
654 * \param[in] mrl MRL object, NULL for current.
655 * \return Number of audio streams.
657 uint32_t mrl_get_metadata_audio_nb (player_t *player, mrl_t *mrl);
660 * \brief Get property of the stream.
662 * Wrappers supported (even partially):
665 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
666 * \param[in] player Player controller.
667 * \param[in] mrl MRL object, NULL for current.
668 * \param[in] p Type of property.
669 * \return Property value.
671 uint32_t mrl_get_property (player_t *player,
672 mrl_t *mrl, mrl_properties_type_t p);
675 * \brief Get audio codec name of the stream.
677 * Wrappers supported (even partially):
680 * \warning The returned pointer must be freed when no longer used.
681 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
682 * \param[in] player Player controller.
683 * \param[in] mrl MRL object, NULL for current.
684 * \return Audio codec name, NULL otherwise.
686 char *mrl_get_audio_codec (player_t *player, mrl_t *mrl);
689 * \brief Get video codec name of the stream.
691 * Wrappers supported (even partially):
694 * \warning The returned pointer must be freed when no longer used.
695 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
696 * \param[in] player Player controller.
697 * \param[in] mrl MRL object, NULL for current.
698 * \return Video codec name, NULL otherwise.
700 char *mrl_get_video_codec (player_t *player, mrl_t *mrl);
703 * \brief Get size of the resource.
705 * Wrappers supported (even partially):
708 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
709 * \param[in] player Player controller.
710 * \param[in] mrl MRL object, NULL for current.
711 * \return Size of the stream (bytes).
713 off_t mrl_get_size (player_t *player, mrl_t *mrl);
716 * \brief Take a video snapshot.
718 * One frame at the \p pos (in second) is saved to \p dst.
720 * Wrappers supported (even partially):
723 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
724 * \param[in] player Player controller.
725 * \param[in] mrl MRL object, NULL for current.
726 * \param[in] pos Time position (second).
727 * \param[in] t Image file type.
728 * \param[in] dst Destination file, NULL for default filename
729 * in the current directory.
731 void mrl_video_snapshot (player_t *player, mrl_t *mrl,
732 int pos, mrl_snapshot_t t, const char *dst);
738 /***************************************************************************/
740 /* Player to MRL connection */
742 /***************************************************************************/
744 /** \brief Player MRL add mode. */
745 typedef enum player_mrl_add {
751 * \name Player to MRL connection.
756 * \brief Get current MRL set in the internal playlist.
758 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
759 * \param[in] player Player controller.
760 * \return MRL object.
762 mrl_t *player_mrl_get_current (player_t *player);
765 * \brief Set MRL object in the internal playlist.
767 * If a MRL was already set in the playlist, then the current is freed and
768 * replaced by the new MRL object.
770 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
771 * \param[in] player Player controller.
772 * \param[in] mrl MRL object to set.
774 void player_mrl_set (player_t *player, mrl_t *mrl);
777 * \brief Append MRL object in the internal playlist.
779 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
780 * \param[in] player Player controller.
781 * \param[in] mrl MRL object to append.
782 * \param[in] when Just append, or append and go to the end to play.
784 void player_mrl_append (player_t *player, mrl_t *mrl, player_mrl_add_t when);
787 * \brief Remove current MRL object in the internal playlist.
789 * Current MRL object is freed on the way.
791 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
792 * \param[in] player Player controller.
794 void player_mrl_remove (player_t *player);
797 * \brief Remove all MRL objects in the internal playlist.
799 * All MRL objects are freed on the way.
801 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
802 * \param[in] player Player controller.
804 void player_mrl_remove_all (player_t *player);
807 * \brief Go the the previous MRL object in the internal playlist.
809 * Playback is started if a previous MRL object exists.
811 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
812 * \param[in] player Player controller.
814 void player_mrl_previous (player_t *player);
817 * \brief Go the the next MRL object in the internal playlist.
819 * Playback is started if a next MRL object exists.
821 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
822 * \param[in] player Player controller.
824 void player_mrl_next (player_t *player);
830 /***************************************************************************/
832 /* Player tuning & properties */
834 /***************************************************************************/
836 /** \brief Player playback mode. */
837 typedef enum player_pb {
838 PLAYER_PB_SINGLE = 0,
842 /** \brief Player loop mode. */
843 typedef enum player_loop {
844 PLAYER_LOOP_DISABLE = 0,
846 PLAYER_LOOP_PLAYLIST,
849 /** \brief Player frame dropping mode. */
850 typedef enum player_framedrop {
851 PLAYER_FRAMEDROP_DISABLE,
852 PLAYER_FRAMEDROP_SOFT,
853 PLAYER_FRAMEDROP_HARD,
854 } player_framedrop_t;
856 /** \brief Player X11 window flags. */
857 typedef enum player_x_window_flags {
858 PLAYER_X_WINDOW_AUTO = 0,
859 PLAYER_X_WINDOW_X = (1 << 0),
860 PLAYER_X_WINDOW_Y = (1 << 1),
861 PLAYER_X_WINDOW_W = (1 << 2),
862 PLAYER_X_WINDOW_H = (1 << 3),
863 } player_x_window_flags_t;
866 * \name Player tuning & properties.
871 * \brief Get current time position in the current stream.
873 * Wrappers supported (even partially):
876 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
877 * \param[in] player Player controller.
878 * \return Time position (millisecond).
880 int player_get_time_pos (player_t *player);
883 * \brief Get percent position in the current stream.
885 * Wrapper supported (even partially):
888 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
889 * \param[in] player Player controller.
890 * \return Percent position.
892 int player_get_percent_pos (player_t *player);
895 * \brief Set playback mode.
897 * If the playback mode is set to PLAYER_PB_AUTO, then loop and shuffle can
898 * be used with the internal playlist. By default, AUTO will just going
899 * to the next available MRL object in the playlist and start a new playback.
901 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
902 * \param[in] player Player controller.
903 * \param[in] pb Mode to use.
905 void player_set_playback (player_t *player, player_pb_t pb);
908 * \brief Set loop mode and value.
910 * Only enabled if playback mode is auto, see player_set_playback().
912 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
913 * \param[in] player Player controller.
914 * \param[in] loop Mode to use (one element or the whole playlist).
915 * \param[in] value How many loops, negative for infinite.
917 void player_set_loop (player_t *player, player_loop_t loop, int value);
920 * \brief Shuffle playback in the internal playlist.
922 * Only enabled if playback mode is auto, see player_set_playback().
924 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
925 * \param[in] player Player controller.
926 * \param[in] value Different of 0 to enable.
928 void player_set_shuffle (player_t *player, int value);
931 * \brief Set frame dropping with video playback.
933 * Wrappers supported (even partially):
936 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
937 * \param[in] player Player controller.
938 * \param[in] fd Frame dropping type to set.
940 void player_set_framedrop (player_t *player, player_framedrop_t fd);
943 * \brief Set the mouse position to the player.
945 * The main goal is to select buttons in DVD menu. The coordinates are
946 * relative to the top-left corner of the root window. The root window is
947 * \p winid passed with player_init().
949 * Wrappers supported (even partially):
952 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
953 * \param[in] player Player controller.
954 * \param[in] x X coordinate (pixel).
955 * \param[in] y Y coordinate (pixel).
957 void player_set_mouse_position (player_t *player, int x, int y);
960 * \brief Set properties of X11 window handled by libplayer.
962 * Origin to the top-left corner.
964 * Wrappers supported (even partially):
967 * \warning Only usable with video outputs X11 compliant.
968 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
969 * \param[in] player Player controller.
970 * \param[in] x X coordinate (pixel).
971 * \param[in] y Y coordinate (pixel).
972 * \param[in] w Width (pixel).
973 * \param[in] h Height (pixel).
974 * \param[in] flags Flags to select properties to change.
976 void player_x_window_set_properties (player_t *player,
977 int x, int y, int w, int h, int flags);
980 * \brief Show a text on the On-screen Display.
982 * Coordinates are not usable with MPlayer wrapper. The text is always shown
983 * from the top-left corner.
985 * Wrappers supported (even partially):
988 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
989 * \param[in] player Player controller.
990 * \param[in] text Text to show on the OSD.
991 * \param[in] x X coordinate (pixel).
992 * \param[in] y Y coordinate (pixel).
993 * \param[in] duration Duration (millisecond).
995 void player_osd_show_text (player_t *player,
996 const char *text, int x, int y, int duration);
999 * \brief Enable/disable On-screen Display.
1001 * With the MPlayer wrapper, this function must be called after every
1002 * player_playback_start() if OSD must be disabled.
1004 * Wrappers supported (even partially):
1007 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1008 * \param[in] player Player controller.
1009 * \param[in] value Different of 0 to enable.
1011 void player_osd_state (player_t *player, int value);
1017 /***************************************************************************/
1019 /* Playback related controls */
1021 /***************************************************************************/
1023 /** \brief Player playback state. */
1024 typedef enum player_pb_state {
1025 PLAYER_PB_STATE_IDLE,
1026 PLAYER_PB_STATE_PAUSE,
1027 PLAYER_PB_STATE_PLAY,
1028 } player_pb_state_t;
1030 /** \brief Player playback seek mode. */
1031 typedef enum player_pb_seek {
1032 PLAYER_PB_SEEK_RELATIVE,
1033 PLAYER_PB_SEEK_ABSOLUTE,
1034 PLAYER_PB_SEEK_PERCENT,
1038 * \name Playback related controls.
1043 * \brief Get current playback state.
1045 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1046 * \param[in] player Player controller.
1047 * \return Playback state.
1049 player_pb_state_t player_playback_get_state (player_t *player);
1052 * \brief Start a new playback.
1054 * The playback is always started from the beginning.
1056 * Wrappers supported (even partially):
1057 * GStreamer, MPlayer, VLC, xine
1059 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1060 * \param[in] player Player controller.
1062 void player_playback_start (player_t *player);
1065 * \brief Stop playback.
1067 * Wrappers supported (even partially):
1068 * GStreamer, MPlayer, VLC, xine
1070 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1071 * \param[in] player Player controller.
1073 void player_playback_stop (player_t *player);
1076 * \brief Pause and unpause playback.
1078 * Wrappers supported (even partially):
1079 * MPlayer, VLC, xine
1081 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1082 * \param[in] player Player controller.
1084 void player_playback_pause (player_t *player);
1087 * \brief Seek in the stream.
1089 * Wrappers supported (even partially):
1090 * MPlayer, VLC, xine
1092 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1093 * \param[in] player Player controller.
1094 * \param[in] value Value for seeking (millisecond or percent).
1095 * \param[in] seek Seeking mode.
1097 void player_playback_seek (player_t *player, int value, player_pb_seek_t seek);
1100 * \brief Seek chapter in the stream.
1102 * Wrappers supported (even partially):
1105 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1106 * \param[in] player Player controller.
1107 * \param[in] value Value for seeking.
1108 * \param[in] absolute Mode, 0 for relative.
1110 void player_playback_seek_chapter (player_t *player, int value, int absolute);
1113 * \brief Change playback speed.
1115 * This function can't be used to play in backward.
1117 * Wrappers supported (even partially):
1118 * MPlayer, xine, VLC
1120 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1121 * \param[in] player Player controller.
1122 * \param[in] value Factor of playback speed to set.
1124 void player_playback_speed (player_t *player, float value);
1130 /***************************************************************************/
1132 /* Audio related controls */
1134 /***************************************************************************/
1136 /** \brief Player mute state. */
1137 typedef enum player_mute {
1138 PLAYER_MUTE_UNKNOWN,
1144 * \name Audio related controls.
1149 * \brief Get current volume.
1151 * Wrappers supported (even partially):
1152 * MPlayer, VLC, xine
1154 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1155 * \param[in] player Player controller.
1156 * \return Volume (percent).
1158 int player_audio_volume_get (player_t *player);
1161 * \brief Set volume.
1163 * Wrappers supported (even partially):
1164 * MPlayer, VLC, xine
1166 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1167 * \param[in] player Player controller.
1168 * \param[in] value Volume to set (percent).
1170 void player_audio_volume_set (player_t *player, int value);
1173 * \brief Get mute state.
1175 * Wrappers supported (even partially):
1176 * MPlayer, VLC, xine
1178 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1179 * \param[in] player Player controller.
1180 * \return Mute state.
1182 player_mute_t player_audio_mute_get (player_t *player);
1185 * \brief Set mute state.
1187 * Wrappers supported (even partially):
1188 * MPlayer, VLC, xine
1190 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1191 * \param[in] player Player controller.
1192 * \param[in] value Mute state to set.
1194 void player_audio_mute_set (player_t *player, player_mute_t value);
1197 * \brief Set audio delay.
1199 * Only useful with video files to set delay between audio and video streams.
1201 * Wrappers supported (even partially):
1204 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1205 * \param[in] player Player controller.
1206 * \param[in] value Delay to set (millisecond).
1207 * \param[in] absolute Mode, 0 for relative.
1209 void player_audio_set_delay (player_t *player, int value, int absolute);
1212 * \brief Select audio ID.
1214 * Wrappers supported (even partially):
1217 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1218 * \param[in] player Player controller.
1219 * \param[in] audio_id ID of the audio stream to select.
1221 void player_audio_select (player_t *player, int audio_id);
1224 * \brief Select the previous audio ID.
1226 * It stays on the same audio ID if no previous stream exists.
1228 * Wrappers supported (even partially):
1231 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1232 * \param[in] player Player controller.
1234 void player_audio_prev (player_t *player);
1237 * \brief Select the next audio ID.
1239 * It stays on the same audio ID if no next stream exists.
1241 * Wrappers supported (even partially):
1244 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1245 * \param[in] player Player controller.
1247 void player_audio_next (player_t *player);
1253 /***************************************************************************/
1255 /* Video related controls */
1257 /***************************************************************************/
1259 /** \brief Player video aspect. */
1260 typedef enum player_video_aspect {
1261 PLAYER_VIDEO_ASPECT_BRIGHTNESS,
1262 PLAYER_VIDEO_ASPECT_CONTRAST,
1263 PLAYER_VIDEO_ASPECT_GAMMA,
1264 PLAYER_VIDEO_ASPECT_HUE,
1265 PLAYER_VIDEO_ASPECT_SATURATION,
1266 } player_video_aspect_t;
1269 * \name Video related controls.
1274 * \brief Set video aspect.
1276 * Wrappers supported (even partially):
1279 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1280 * \param[in] player Player controller.
1281 * \param[in] aspect Aspect to change.
1282 * \param[in] value Value for aspect to set.
1283 * \param[in] absolute Mode, 0 for relative.
1285 void player_video_set_aspect (player_t *player, player_video_aspect_t aspect,
1286 int8_t value, int absolute);
1289 * \brief Set video panscan.
1291 * Wrappers supported (even partially):
1294 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1295 * \param[in] player Player controller.
1296 * \param[in] value Value for panscan to set.
1297 * \param[in] absolute Mode, 0 for relative.
1299 void player_video_set_panscan (player_t *player, int8_t value, int absolute);
1302 * \brief Set video aspect ratio.
1304 * Wrappers supported (even partially):
1305 * MPlayer, VLC, xine
1307 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1308 * \param[in] player Player controller.
1309 * \param[in] value Ratio to set.
1311 void player_video_set_aspect_ratio (player_t *player, float value);
1317 /***************************************************************************/
1319 /* Subtitles related controls */
1321 /***************************************************************************/
1323 /** \brief Player subtitle alignment. */
1324 typedef enum player_sub_alignment {
1325 PLAYER_SUB_ALIGNMENT_TOP,
1326 PLAYER_SUB_ALIGNMENT_CENTER,
1327 PLAYER_SUB_ALIGNMENT_BOTTOM,
1328 } player_sub_alignment_t;
1331 * \name Subtitles related controls.
1336 * \brief Set subtitle delay.
1338 * Only useful with video files to set delay between audio stream and
1341 * Wrappers supported (even partially):
1344 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1345 * \param[in] player Player controller.
1346 * \param[in] value Delay to set (millisecond).
1348 void player_subtitle_set_delay (player_t *player, int value);
1351 * \brief Set subtitle alignment.
1353 * Wrappers supported (even partially):
1356 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1357 * \param[in] player Player controller.
1358 * \param[in] a Alignment to set.
1360 void player_subtitle_set_alignment (player_t *player,
1361 player_sub_alignment_t a);
1364 * \brief Set subtitle position.
1366 * Wrappers supported (even partially):
1369 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1370 * \param[in] player Player controller.
1371 * \param[in] value Position to set.
1373 void player_subtitle_set_position (player_t *player, int value);
1376 * \brief Set subtitle visibility.
1378 * Wrappers supported (even partially):
1381 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1382 * \param[in] player Player controller.
1383 * \param[in] value Different of 0 to view the subtitles.
1385 void player_subtitle_set_visibility (player_t *player, int value);
1388 * \brief Set subtitle scale.
1390 * Wrappers supported (even partially):
1393 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1394 * \param[in] player Player controller.
1395 * \param[in] value Scale to set.
1396 * \param[in] absolute Mode, 0 for relative.
1398 void player_subtitle_scale (player_t *player, int value, int absolute);
1401 * \brief Select subtitle ID.
1403 * Wrappers supported (even partially):
1406 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1407 * \param[in] player Player controller.
1408 * \param[in] sub_id ID of the subtitle to select.
1410 void player_subtitle_select (player_t *player, int sub_id);
1413 * \brief Select the previous subtitle ID.
1415 * It stays on the same subtitle ID if no previous subtitle exists.
1417 * Wrappers supported (even partially):
1420 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1421 * \param[in] player Player controller.
1423 void player_subtitle_prev (player_t *player);
1426 * \brief Select the next subtitle ID.
1428 * It stays on the same subtitle ID if no next subtitle exists.
1430 * Wrappers supported (even partially):
1433 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1434 * \param[in] player Player controller.
1436 void player_subtitle_next (player_t *player);
1442 /***************************************************************************/
1444 /* DVD specific controls */
1446 /***************************************************************************/
1448 /** \brief Player DVDnav commands. */
1449 typedef enum player_dvdnav {
1452 PLAYER_DVDNAV_RIGHT,
1455 PLAYER_DVDNAV_SELECT,
1456 PLAYER_DVDNAV_PREVMENU,
1457 PLAYER_DVDNAV_MOUSECLICK,
1461 * \name DVD specific controls.
1466 * \brief DVD Navigation commands.
1468 * Wrappers supported (even partially):
1471 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1472 * \param[in] player Player controller.
1473 * \param[in] value Command to send.
1475 void player_dvd_nav (player_t *player, player_dvdnav_t value);
1478 * \brief Select DVD angle.
1480 * Wrappers supported (even partially):
1483 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1484 * \param[in] player Player controller.
1485 * \param[in] angle Angle to select.
1487 void player_dvd_angle_select (player_t *player, int angle);
1490 * \brief Select the previous DVD angle.
1492 * It stays on the same if no previous angle exists.
1494 * Wrappers supported (even partially):
1497 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1498 * \param[in] player Player controller.
1500 void player_dvd_angle_prev (player_t *player);
1503 * \brief Select the next DVD angle.
1505 * It stays on the same if no next angle exists.
1507 * Wrappers supported (even partially):
1510 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1511 * \param[in] player Player controller.
1513 void player_dvd_angle_next (player_t *player);
1516 * \brief Select DVD title.
1518 * Wrappers supported (even partially):
1521 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1522 * \param[in] player Player controller.
1523 * \param[in] title Title to select.
1525 void player_dvd_title_select (player_t *player, int title);
1528 * \brief Select the previous DVD title.
1530 * It stays on the same if no previous title exists.
1532 * Wrappers supported (even partially):
1535 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1536 * \param[in] player Player controller.
1538 void player_dvd_title_prev (player_t *player);
1541 * \brief Select the next DVD title.
1543 * It stays on the same if no next title exists.
1545 * Wrappers supported (even partially):
1548 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1549 * \param[in] player Player controller.
1551 void player_dvd_title_next (player_t *player);
1557 /***************************************************************************/
1559 /* TV/DVB specific controls */
1561 /***************************************************************************/
1564 * \name TV/DVB specific controls.
1569 * \brief Select TV channel.
1571 * Wrappers supported (even partially):
1574 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1575 * \param[in] player Player controller.
1576 * \param[in] channel Channel to select.
1578 void player_tv_channel_select (player_t *player, const char *channel);
1581 * \brief Select the previous TV channel.
1583 * It stays on the same if no previous channel exists.
1585 * Wrappers supported (even partially):
1588 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1589 * \param[in] player Player controller.
1591 void player_tv_channel_prev (player_t *player);
1594 * \brief Select the next TV channel.
1596 * It stays on the same if no next channel exists.
1598 * Wrappers supported (even partially):
1601 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1602 * \param[in] player Player controller.
1604 void player_tv_channel_next (player_t *player);
1610 /***************************************************************************/
1612 /* Radio specific controls */
1614 /***************************************************************************/
1617 * \name Radio specific controls.
1622 * \brief Select radio channel.
1624 * Wrappers supported (even partially):
1627 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1628 * \param[in] player Player controller.
1629 * \param[in] channel Channel to select.
1631 void player_radio_channel_select (player_t *player, const char *channel);
1634 * \brief Select the previous radio channel.
1636 * It stays on the same if no previous channel exists.
1638 * Wrappers supported (even partially):
1641 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1642 * \param[in] player Player controller.
1644 void player_radio_channel_prev (player_t *player);
1647 * \brief Select the next radio channel.
1649 * It stays on the same if no next channel exists.
1651 * Wrappers supported (even partially):
1654 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1655 * \param[in] player Player controller.
1657 void player_radio_channel_next (player_t *player);
1663 /***************************************************************************/
1665 /* VDR specific controls */
1667 /***************************************************************************/
1669 /** \brief Player VDR commands. */
1670 typedef enum player_vdr {
1677 PLAYER_VDR_CHANNELPLUS,
1678 PLAYER_VDR_CHANNELMINUS,
1690 PLAYER_VDR_SCHEDULE,
1691 PLAYER_VDR_CHANNELS,
1693 PLAYER_VDR_RECORDINGS,
1696 PLAYER_VDR_COMMANDS,
1717 PLAYER_VDR_VOLMINUS,
1721 PLAYER_VDR_CHANNELPREVIOUS,
1723 PLAYER_VDR_PREVIOUS,
1724 PLAYER_VDR_SUBTITLES,
1728 * \name VDR specific controls.
1733 * \brief VDR commands.
1735 * Wrappers supported (even partially):
1738 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1739 * \param[in] player Player controller.
1740 * \param[in] value Command to send.
1742 void player_vdr (player_t *player, player_vdr_t value);
1748 /***************************************************************************/
1750 /* Global libplayer functions */
1752 /***************************************************************************/
1755 * \name Global libplayer functions.
1760 * \brief Test if a wrapper is enabled.
1762 * \warning MT-Safe in multithreaded applications.
1763 * \param[in] type Player type.
1764 * \return 1 if enabled, 0 otherwise.
1766 int libplayer_wrapper_enabled (player_type_t type);
1769 * \brief Test if a resource is supported by a wrapper.
1771 * \warning MT-Safe in multithreaded applications.
1772 * \param[in] type Player type.
1773 * \param[in] res Resource type.
1774 * \return 1 if supported, 0 otherwise.
1776 int libplayer_wrapper_supported_res (player_type_t type, mrl_resource_t res);
1783 #if 0 /* avoid EMACS indent */
1787 #endif /* __cplusplus */
1789 #endif /* PLAYER_H */