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 {
134 /** \brief Player audio outputs. */
135 typedef enum player_ao {
143 /** \brief Player events. */
144 typedef enum player_event {
145 PLAYER_EVENT_UNKNOWN,
146 PLAYER_EVENT_PLAYBACK_START,
147 PLAYER_EVENT_PLAYBACK_STOP,
148 PLAYER_EVENT_PLAYBACK_FINISHED,
149 PLAYER_EVENT_PLAYLIST_FINISHED,
150 PLAYER_EVENT_PLAYBACK_PAUSE,
151 PLAYER_EVENT_PLAYBACK_UNPAUSE,
154 /** \brief Player verbosity. */
156 PLAYER_MSG_NONE, /* no error messages */
157 PLAYER_MSG_VERBOSE, /* super-verbose mode: mostly for debugging */
158 PLAYER_MSG_INFO, /* working operations */
159 PLAYER_MSG_WARNING, /* harmless failures */
160 PLAYER_MSG_ERROR, /* may result in hazardous behavior */
161 PLAYER_MSG_CRITICAL, /* prevents lib from working */
162 } player_verbosity_level_t;
164 /** \brief Parameters for player_init() .*/
165 typedef struct player_init_param_s {
166 /** Audio output driver. */
168 /** Video output driver. */
170 /** Window ID to attach the video (X Window). */
173 /** Public event callback. */
174 int (*event_cb) (player_event_t e, void *data);
175 /** User data for event callback. */
179 * Display to use with X11 video outputs.
181 * The string has to follow the same rules that the DISPLAY environment
182 * variable. If \p display is NULL, then the environment variable is
187 } player_init_param_t;
190 * \name Player (Un)Initialization.
195 * \brief Initialization of a new player controller.
197 * Multiple player controllers can be initialized with any wrappers.
198 * The same Window ID can be used to attach their video.
200 * For a description of each parameters supported by this function:
201 * \see ::player_init_param_t
203 * When a parameter in \p param is 0 (or NULL), its default value is used.
204 * If \p param is NULL, then all default values are forced for all parameters.
206 * Wrappers supported (even partially):
207 * GStreamer, MPlayer, VLC, xine
209 * \param[in] type Type of wrapper to load.
210 * \param[in] verbosity Level of verbosity to set.
211 * \param[in] param Parameters, NULL for default values.
212 * \return Player controller, NULL otherwise.
214 player_t *player_init (player_type_t type, player_verbosity_level_t verbosity,
215 player_init_param_t *param);
218 * \brief Uninitialization of a player controller.
220 * All MRL objects in the internal playlist will be freed.
222 * Wrappers supported (even partially):
223 * GStreamer, MPlayer, VLC, xine
225 * \warning Must be used only as the last player function for a controller.
226 * \param[in] player Player controller.
228 void player_uninit (player_t *player);
231 * \brief Set verbosity level.
233 * Wrappers supported (even partially):
236 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
237 * \param[in] player Player controller.
238 * \param[in] level Level of verbosity to set.
240 void player_set_verbosity (player_t *player, player_verbosity_level_t level);
246 /***************************************************************************/
248 /* Media Resource Locater (MRL) Helpers */
249 /* MRLs can have multiple types and are used to define a stream */
251 /***************************************************************************/
256 * This handles an audio, video or image resource.
258 typedef struct mrl_s mrl_t;
260 /** \brief MRL types. */
261 typedef enum mrl_type {
269 * Support by wrappers
271 * GStreamer MPlayer VLC xine
272 * ------------ ------------ ------------ ------------
274 /** \brief MRL resources. */
275 typedef enum mrl_resource {
276 MRL_RESOURCE_UNKNOWN,
279 MRL_RESOURCE_FIFO, /* NO NO NO NO */
280 MRL_RESOURCE_FILE, /* NO YES YES YES */
281 MRL_RESOURCE_STDIN, /* NO NO NO NO */
284 MRL_RESOURCE_CDDA, /* NO YES NO NO */
285 MRL_RESOURCE_CDDB, /* NO YES NO NO */
288 MRL_RESOURCE_DVD, /* NO YES NO YES */
289 MRL_RESOURCE_DVDNAV, /* NO YES NO YES */
290 MRL_RESOURCE_VCD, /* NO YES NO NO */
292 /* Radio/Television */
293 MRL_RESOURCE_DVB, /* NO NO NO NO */
294 MRL_RESOURCE_PVR, /* NO NO NO NO */
295 MRL_RESOURCE_RADIO, /* NO YES NO NO */
296 MRL_RESOURCE_TV, /* NO YES NO NO */
297 MRL_RESOURCE_VDR, /* NO NO NO YES */
299 /* Network Streams */
300 MRL_RESOURCE_FTP, /* NO YES YES NO */
301 MRL_RESOURCE_HTTP, /* NO YES YES YES */
302 MRL_RESOURCE_MMS, /* NO YES YES YES */
303 MRL_RESOURCE_NETVDR, /* NO NO NO YES */
304 MRL_RESOURCE_RTP, /* NO YES YES YES */
305 MRL_RESOURCE_RTSP, /* NO YES YES NO */
306 MRL_RESOURCE_SMB, /* NO YES YES NO */
307 MRL_RESOURCE_TCP, /* NO NO NO YES */
308 MRL_RESOURCE_UDP, /* NO YES YES YES */
309 MRL_RESOURCE_UNSV, /* NO YES YES NO */
312 /** \brief Arguments for local streams. */
313 typedef struct mrl_resource_local_args_s {
314 char *location; /* NO YES YES YES */
315 int playlist; /* NO NO NO NO */
316 } mrl_resource_local_args_t;
318 /** \brief Arguments for audio CD. */
319 typedef struct mrl_resource_cd_args_s {
320 char *device; /* NO YES NO NO */
321 uint8_t speed; /* NO YES NO NO */
322 uint8_t track_start; /* NO YES NO NO */
323 uint8_t track_end; /* NO YES NO NO */
324 } mrl_resource_cd_args_t;
326 /** \brief Arguments for video discs. */
327 typedef struct mrl_resource_videodisc_args_s {
328 char *device; /* NO YES NO YES */
329 uint8_t speed; /* NO NO NO NO */
330 uint8_t angle; /* NO YES NO NO */
331 uint8_t title_start; /* NO YES NO YES */
332 uint8_t title_end; /* NO YES NO NO */
333 uint8_t chapter_start; /* NO NO NO NO */
334 uint8_t chapter_end; /* NO NO NO NO */
335 uint8_t track_start; /* NO YES NO NO */
336 uint8_t track_end; /* NO NO NO NO */
337 char *audio_lang; /* NO NO NO NO */
338 char *sub_lang; /* NO NO NO NO */
339 uint8_t sub_cc; /* NO NO NO NO */
340 } mrl_resource_videodisc_args_t;
342 /** \brief Arguments for radio/tv streams. */
343 typedef struct mrl_resource_tv_args_s {
344 char *device; /* NO NO NO YES */
345 char *driver; /* NO NO NO YES */
346 char *channel; /* NO YES NO NO */
347 uint8_t input; /* NO YES NO NO */
348 int width; /* NO NO NO NO */
349 int height; /* NO NO NO NO */
350 int fps; /* NO NO NO NO */
351 char *output_format; /* NO NO NO NO */
352 char *norm; /* NO YES NO NO */
353 } mrl_resource_tv_args_t;
355 /** \brief Arguments for network streams. */
356 typedef struct mrl_resource_network_args_s {
357 char *url; /* NO YES NO YES */
358 char *username; /* NO YES NO NO */
359 char *password; /* NO YES NO NO */
360 char *user_agent; /* NO NO NO NO */
361 } mrl_resource_network_args_t;
363 /** \brief Snapshot image file type. */
364 typedef enum mrl_snapshot {
365 MRL_SNAPSHOT_JPG, /* NO YES NO NO */
366 MRL_SNAPSHOT_PNG, /* NO YES NO NO */
367 MRL_SNAPSHOT_PPM, /* NO YES NO NO */
368 MRL_SNAPSHOT_TGA, /* NO NO NO NO */
371 /** \brief MRL metadata. */
372 typedef enum mrl_metadata_type {
379 MRL_METADATA_COMMENT,
380 } mrl_metadata_type_t;
382 /** \brief MRL CDDA/CDDB metadata. */
383 typedef enum mrl_metadata_cd_type {
384 MRL_METADATA_CD_DISCID,
385 MRL_METADATA_CD_TRACKS,
386 } mrl_metadata_cd_type_t;
388 /** \brief MRL DVD/DVDNAV metadata. */
389 typedef enum mrl_metadata_dvd_type {
390 MRL_METADATA_DVD_TITLE_CHAPTERS,
391 MRL_METADATA_DVD_TITLE_ANGLES,
392 MRL_METADATA_DVD_TITLE_LENGTH,
393 } mrl_metadata_dvd_type_t;
395 /** \brief MRL properties. */
396 typedef enum mrl_properties_type {
397 MRL_PROPERTY_SEEKABLE,
399 MRL_PROPERTY_AUDIO_BITRATE,
400 MRL_PROPERTY_AUDIO_BITS,
401 MRL_PROPERTY_AUDIO_CHANNELS,
402 MRL_PROPERTY_AUDIO_SAMPLERATE,
403 MRL_PROPERTY_VIDEO_BITRATE,
404 MRL_PROPERTY_VIDEO_WIDTH,
405 MRL_PROPERTY_VIDEO_HEIGHT,
406 MRL_PROPERTY_VIDEO_ASPECT,
407 MRL_PROPERTY_VIDEO_CHANNELS,
408 MRL_PROPERTY_VIDEO_STREAMS,
409 MRL_PROPERTY_VIDEO_FRAMEDURATION,
410 } mrl_properties_type_t;
412 #define PLAYER_VIDEO_ASPECT_RATIO_MULT 10000.0 /* *10000 */
413 #define PLAYER_VIDEO_FRAMEDURATION_RATIO_DIV 90000.0 /* 1/90000 sec */
416 * \name Media Resource Locater (MRL) Helpers.
421 * \brief Create a new MRL object.
423 * This function can be slow when the stream is not (fastly) reachable.
425 * The argument \p args and the strings provided with \p args must be
426 * allocated dynamically. The pointers are freed by libplayer when a mrl
427 * is no longer available.
429 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
430 * \param[in] player Player controller.
431 * \param[in] res Resource type.
432 * \param[in] args Arguments specific to the resource type.
433 * \return MRL object, NULL otherwise.
435 mrl_t *mrl_new (player_t *player, mrl_resource_t res, void *args);
438 * \brief Add a subtitle file to a MRL object.
440 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
441 * \param[in] player Player controller.
442 * \param[in] mrl MRL object, NULL for current.
443 * \param[in] subtitle Location of the subtitle file to be added.
445 void mrl_add_subtitle (player_t *player, mrl_t *mrl, char *subtitle);
448 * \brief Free a MRL object.
450 * Never use this function when the MRL (or a linked MRL) is set in the
451 * playlist of a player controller.
453 * \warning Must be used only as the last mrl function for one MRL object.
454 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
455 * \param[in] player Player controller.
456 * \param[in] mrl MRL object.
458 void mrl_free (player_t *player, mrl_t *mrl);
461 * \brief Get type of the stream.
463 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
464 * \param[in] player Player controller.
465 * \param[in] mrl MRL object, NULL for current.
466 * \return Type of MRL object.
468 mrl_type_t mrl_get_type (player_t *player, mrl_t *mrl);
471 * \brief Get resource of the stream.
473 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
474 * \param[in] player Player controller.
475 * \param[in] mrl MRL object, NULL for current.
476 * \return Resource of MRL object.
478 mrl_resource_t mrl_get_resource (player_t *player, mrl_t *mrl);
481 * \brief Get metadata of the stream.
483 * This function can be slow when the stream is not (fastly) reachable.
485 * Wrappers supported (even partially):
488 * \warning The returned pointer must be freed when no longer used.
489 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
490 * \param[in] player Player controller.
491 * \param[in] mrl MRL object, NULL for current.
492 * \param[in] m Type of metadata to get.
493 * \return Metadata string, NULL otherwise.
495 char *mrl_get_metadata (player_t *player, mrl_t *mrl, mrl_metadata_type_t m);
498 * \brief Get metadata of a track with CDDA/CDDB MRL object.
500 * This function can be slow when the stream is not (fastly) reachable.
502 * Wrappers supported (even partially):
505 * \warning The returned pointer must be freed when no longer used.
506 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
507 * \param[in] player Player controller.
508 * \param[in] mrl MRL object, NULL for current.
509 * \param[in] trackid Track ID on the CD.
510 * \param[out] length Length of the track (millisecond).
511 * \return Title of the track (CDDB only), NULL otherwise.
513 char *mrl_get_metadata_cd_track (player_t *player,
514 mrl_t *mrl, int trackid, uint32_t *length);
517 * \brief Get metadata of a CDDA/CDDB MRL object.
519 * This function can be slow when the stream is not (fastly) reachable.
521 * Wrappers supported (even partially):
524 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
525 * \param[in] player Player controller.
526 * \param[in] mrl MRL object, NULL for current.
527 * \param[in] m Type of metadata to get.
528 * \return Metadata value.
530 uint32_t mrl_get_metadata_cd (player_t *player,
531 mrl_t *mrl, mrl_metadata_cd_type_t m);
534 * \brief Get metadata of a title with DVD/DVDNAV MRL object.
536 * This function can be slow when the stream is not (fastly) reachable.
538 * Wrappers supported (even partially):
541 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
542 * \param[in] player Player controller.
543 * \param[in] mrl MRL object, NULL for current.
544 * \param[in] titleid Title ID on the DVD.
545 * \param[in] m Type of metadata to get.
546 * \return Metadata value.
548 uint32_t mrl_get_metadata_dvd_title (player_t *player, mrl_t *mrl,
549 int titleid, mrl_metadata_dvd_type_t m);
552 * \brief Get metadata of a DVD/DVDNAV MRL object.
554 * This function can be slow when the stream is not (fastly) reachable.
556 * Wrappers supported (even partially):
559 * \warning The returned pointer must be freed when no longer used.
560 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
561 * \param[in] player Player controller.
562 * \param[in] mrl MRL object, NULL for current.
563 * \param[out] titles How many titles on the DVD.
564 * \return Volume ID, NULL otherwise.
566 char *mrl_get_metadata_dvd (player_t *player, mrl_t *mrl, uint8_t *titles);
569 * \brief Get subtitle metadata of the MRL object.
571 * This function can be slow when the stream is not (fastly) reachable.
573 * The \p pos argument is the position of the subtitle in the internal list
574 * of libplayer. The first subtitle begins with 1.
575 * \p id returned by this function can be used with player_subtitle_select().
577 * Wrappers supported (even partially):
580 * \warning The pointers (\p name and \p lang) must be freed when no longer used.
581 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
582 * \param[in] player Player controller.
583 * \param[in] mrl MRL object, NULL for current.
584 * \param[in] pos Position of the subtitle.
585 * \param[out] id ID of the subtitle, NULL to ignore.
586 * \param[out] name Name of the subtitle, NULL to ignore.
587 * \param[out] lang Language of the subtitle, NULL to ignore.
588 * \return 1 for success, 0 if the subtitle is not available.
590 int mrl_get_metadata_subtitle (player_t *player, mrl_t *mrl, int pos,
591 uint32_t *id, char **name, char **lang);
594 * \brief Get the number of available subtitles.
596 * This function can be slow when the stream is not (fastly) reachable.
598 * Wrappers supported (even partially):
601 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
602 * \param[in] player Player controller.
603 * \param[in] mrl MRL object, NULL for current.
604 * \return Number of subtitles.
606 uint32_t mrl_get_metadata_subtitle_nb (player_t *player, mrl_t *mrl);
609 * \brief Get audio metadata of the MRL object.
611 * This function can be slow when the stream is not (fastly) reachable.
613 * The \p pos argument is the position of the audio stream in the internal list
614 * of libplayer. The first audio stream begins with 1.
615 * \p id returned by this function can be used with player_audio_select().
617 * Wrappers supported (even partially):
620 * \warning The pointers (\p name and \p lang) must be freed when no longer used.
621 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
622 * \param[in] player Player controller.
623 * \param[in] mrl MRL object, NULL for current.
624 * \param[in] pos Position of the audio stream.
625 * \param[out] id ID of the audio stream, NULL to ignore.
626 * \param[out] name Name of the audio stream, NULL to ignore.
627 * \param[out] lang Language of the audio stream, NULL to ignore.
628 * \return 1 for success, 0 if the audio stream is not available.
630 int mrl_get_metadata_audio (player_t *player, mrl_t *mrl, int pos,
631 uint32_t *id, char **name, char **lang);
634 * \brief Get the number of available audio streams.
636 * This function can be slow when the stream is not (fastly) reachable.
638 * Wrappers supported (even partially):
641 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
642 * \param[in] player Player controller.
643 * \param[in] mrl MRL object, NULL for current.
644 * \return Number of audio streams.
646 uint32_t mrl_get_metadata_audio_nb (player_t *player, mrl_t *mrl);
649 * \brief Get property of the stream.
651 * Wrappers supported (even partially):
654 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
655 * \param[in] player Player controller.
656 * \param[in] mrl MRL object, NULL for current.
657 * \param[in] p Type of property.
658 * \return Property value.
660 uint32_t mrl_get_property (player_t *player,
661 mrl_t *mrl, mrl_properties_type_t p);
664 * \brief Get audio codec name of the stream.
666 * Wrappers supported (even partially):
669 * \warning The returned pointer must be freed when no longer used.
670 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
671 * \param[in] player Player controller.
672 * \param[in] mrl MRL object, NULL for current.
673 * \return Audio codec name, NULL otherwise.
675 char *mrl_get_audio_codec (player_t *player, mrl_t *mrl);
678 * \brief Get video codec name of the stream.
680 * Wrappers supported (even partially):
683 * \warning The returned pointer must be freed when no longer used.
684 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
685 * \param[in] player Player controller.
686 * \param[in] mrl MRL object, NULL for current.
687 * \return Video codec name, NULL otherwise.
689 char *mrl_get_video_codec (player_t *player, mrl_t *mrl);
692 * \brief Get size of the resource.
694 * Wrappers supported (even partially):
697 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
698 * \param[in] player Player controller.
699 * \param[in] mrl MRL object, NULL for current.
700 * \return Size of the stream (bytes).
702 off_t mrl_get_size (player_t *player, mrl_t *mrl);
705 * \brief Take a video snapshot.
707 * One frame at the \p pos (in second) is saved to \p dst.
709 * Wrappers supported (even partially):
712 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
713 * \param[in] player Player controller.
714 * \param[in] mrl MRL object, NULL for current.
715 * \param[in] pos Time position (second).
716 * \param[in] t Image file type.
717 * \param[in] dst Destination file, NULL for default filename
718 * in the current directory.
720 void mrl_video_snapshot (player_t *player, mrl_t *mrl,
721 int pos, mrl_snapshot_t t, const char *dst);
727 /***************************************************************************/
729 /* Player to MRL connection */
731 /***************************************************************************/
733 /** \brief Player MRL add mode. */
734 typedef enum player_mrl_add {
740 * \name Player to MRL connection.
745 * \brief Get current MRL set in the internal playlist.
747 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
748 * \param[in] player Player controller.
749 * \return MRL object.
751 mrl_t *player_mrl_get_current (player_t *player);
754 * \brief Set MRL object in the internal playlist.
756 * If a MRL was already set in the playlist, then the current is freed and
757 * replaced by the new MRL object.
759 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
760 * \param[in] player Player controller.
761 * \param[in] mrl MRL object to set.
763 void player_mrl_set (player_t *player, mrl_t *mrl);
766 * \brief Append MRL object in the internal playlist.
768 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
769 * \param[in] player Player controller.
770 * \param[in] mrl MRL object to append.
771 * \param[in] when Just append, or append and go to the end to play.
773 void player_mrl_append (player_t *player, mrl_t *mrl, player_mrl_add_t when);
776 * \brief Remove current MRL object in the internal playlist.
778 * Current MRL object is freed on the way.
780 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
781 * \param[in] player Player controller.
783 void player_mrl_remove (player_t *player);
786 * \brief Remove all MRL objects in the internal playlist.
788 * All MRL objects are freed on the way.
790 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
791 * \param[in] player Player controller.
793 void player_mrl_remove_all (player_t *player);
796 * \brief Go the the previous MRL object in the internal playlist.
798 * Playback is started if a previous MRL object exists.
800 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
801 * \param[in] player Player controller.
803 void player_mrl_previous (player_t *player);
806 * \brief Go the the next MRL object in the internal playlist.
808 * Playback is started if a next MRL object exists.
810 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
811 * \param[in] player Player controller.
813 void player_mrl_next (player_t *player);
819 /***************************************************************************/
821 /* Player tuning & properties */
823 /***************************************************************************/
825 /** \brief Player playback mode. */
826 typedef enum player_pb {
827 PLAYER_PB_SINGLE = 0,
831 /** \brief Player loop mode. */
832 typedef enum player_loop {
833 PLAYER_LOOP_DISABLE = 0,
835 PLAYER_LOOP_PLAYLIST,
838 /** \brief Player frame dropping mode. */
839 typedef enum player_framedrop {
840 PLAYER_FRAMEDROP_DISABLE,
841 PLAYER_FRAMEDROP_SOFT,
842 PLAYER_FRAMEDROP_HARD,
843 } player_framedrop_t;
845 /** \brief Player X11 window flags. */
846 typedef enum player_x_window_flags {
847 PLAYER_X_WINDOW_AUTO = 0,
848 PLAYER_X_WINDOW_X = (1 << 0),
849 PLAYER_X_WINDOW_Y = (1 << 1),
850 PLAYER_X_WINDOW_W = (1 << 2),
851 PLAYER_X_WINDOW_H = (1 << 3),
852 } player_x_window_flags_t;
855 * \name Player tuning & properties.
860 * \brief Get current time position in the current stream.
862 * Wrappers supported (even partially):
865 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
866 * \param[in] player Player controller.
867 * \return Time position (millisecond).
869 int player_get_time_pos (player_t *player);
872 * \brief Get percent position in the current stream.
874 * Wrapper supported (even partially):
877 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
878 * \param[in] player Player controller.
879 * \return Percent position.
881 int player_get_percent_pos (player_t *player);
884 * \brief Set playback mode.
886 * If the playback mode is set to PLAYER_PB_AUTO, then loop and shuffle can
887 * be used with the internal playlist. By default, AUTO will just going
888 * to the next available MRL object in the playlist and start a new playback.
890 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
891 * \param[in] player Player controller.
892 * \param[in] pb Mode to use.
894 void player_set_playback (player_t *player, player_pb_t pb);
897 * \brief Set loop mode and value.
899 * Only enabled if playback mode is auto, see player_set_playback().
901 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
902 * \param[in] player Player controller.
903 * \param[in] loop Mode to use (one element or the whole playlist).
904 * \param[in] value How many loops, negative for infinite.
906 void player_set_loop (player_t *player, player_loop_t loop, int value);
909 * \brief Shuffle playback in the internal playlist.
911 * Only enabled if playback mode is auto, see player_set_playback().
913 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
914 * \param[in] player Player controller.
915 * \param[in] value Different of 0 to enable.
917 void player_set_shuffle (player_t *player, int value);
920 * \brief Set frame dropping with video playback.
922 * Wrappers supported (even partially):
925 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
926 * \param[in] player Player controller.
927 * \param[in] fd Frame dropping type to set.
929 void player_set_framedrop (player_t *player, player_framedrop_t fd);
932 * \brief Set the mouse position to the player.
934 * The main goal is to select buttons in DVD menu. The coordinates are
935 * relative to the top-left corner of the root window. The root window is
936 * \p winid passed with player_init().
938 * Wrappers supported (even partially):
941 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
942 * \param[in] player Player controller.
943 * \param[in] x X coordinate (pixel).
944 * \param[in] y Y coordinate (pixel).
946 void player_set_mouse_position (player_t *player, int x, int y);
949 * \brief Set properties of X11 window handled by libplayer.
951 * Origin to the top-left corner.
953 * Wrappers supported (even partially):
956 * \warning Only usable with video outputs X11 compliant.
957 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
958 * \param[in] player Player controller.
959 * \param[in] x X coordinate (pixel).
960 * \param[in] y Y coordinate (pixel).
961 * \param[in] w Width (pixel).
962 * \param[in] h Height (pixel).
963 * \param[in] flags Flags to select properties to change.
965 void player_x_window_set_properties (player_t *player,
966 int x, int y, int w, int h, int flags);
969 * \brief Show a text on the On-screen Display.
971 * Coordinates are not usable with MPlayer wrapper. The text is always shown
972 * from the top-left corner.
974 * Wrappers supported (even partially):
977 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
978 * \param[in] player Player controller.
979 * \param[in] text Text to show on the OSD.
980 * \param[in] x X coordinate (pixel).
981 * \param[in] y Y coordinate (pixel).
982 * \param[in] duration Duration (millisecond).
984 void player_osd_show_text (player_t *player,
985 const char *text, int x, int y, int duration);
988 * \brief Enable/disable On-screen Display.
990 * With the MPlayer wrapper, this function must be called after every
991 * player_playback_start() if OSD must be disabled.
993 * Wrappers supported (even partially):
996 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
997 * \param[in] player Player controller.
998 * \param[in] value Different of 0 to enable.
1000 void player_osd_state (player_t *player, int value);
1006 /***************************************************************************/
1008 /* Playback related controls */
1010 /***************************************************************************/
1012 /** \brief Player playback state. */
1013 typedef enum player_pb_state {
1014 PLAYER_PB_STATE_IDLE,
1015 PLAYER_PB_STATE_PAUSE,
1016 PLAYER_PB_STATE_PLAY,
1017 } player_pb_state_t;
1019 /** \brief Player playback seek mode. */
1020 typedef enum player_pb_seek {
1021 PLAYER_PB_SEEK_RELATIVE,
1022 PLAYER_PB_SEEK_ABSOLUTE,
1023 PLAYER_PB_SEEK_PERCENT,
1027 * \name Playback related controls.
1032 * \brief Get current playback state.
1034 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1035 * \param[in] player Player controller.
1036 * \return Playback state.
1038 player_pb_state_t player_playback_get_state (player_t *player);
1041 * \brief Start a new playback.
1043 * The playback is always started from the beginning.
1045 * Wrappers supported (even partially):
1046 * GStreamer, MPlayer, VLC, xine
1048 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1049 * \param[in] player Player controller.
1051 void player_playback_start (player_t *player);
1054 * \brief Stop playback.
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_stop (player_t *player);
1065 * \brief Pause and unpause playback.
1067 * Wrappers supported (even partially):
1068 * MPlayer, VLC, xine
1070 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1071 * \param[in] player Player controller.
1073 void player_playback_pause (player_t *player);
1076 * \brief Seek in the stream.
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.
1083 * \param[in] value Value for seeking (second or percent).
1084 * \param[in] seek Seeking mode.
1086 void player_playback_seek (player_t *player, int value, player_pb_seek_t seek);
1089 * \brief Seek chapter in the stream.
1091 * Wrappers supported (even partially):
1094 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1095 * \param[in] player Player controller.
1096 * \param[in] value Value for seeking.
1097 * \param[in] absolute Mode, 0 for relative.
1099 void player_playback_seek_chapter (player_t *player, int value, int absolute);
1102 * \brief Change playback speed.
1104 * This function can't be used to play in backward.
1106 * Wrappers supported (even partially):
1107 * MPlayer, xine, VLC
1109 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1110 * \param[in] player Player controller.
1111 * \param[in] value Factor of playback speed to set.
1113 void player_playback_speed (player_t *player, float value);
1119 /***************************************************************************/
1121 /* Audio related controls */
1123 /***************************************************************************/
1125 /** \brief Player mute state. */
1126 typedef enum player_mute {
1127 PLAYER_MUTE_UNKNOWN,
1133 * \name Audio related controls.
1138 * \brief Get current volume.
1140 * Wrappers supported (even partially):
1141 * MPlayer, VLC, xine
1143 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1144 * \param[in] player Player controller.
1145 * \return Volume (percent).
1147 int player_audio_volume_get (player_t *player);
1150 * \brief Set volume.
1152 * Wrappers supported (even partially):
1153 * MPlayer, VLC, xine
1155 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1156 * \param[in] player Player controller.
1157 * \param[in] value Volume to set (percent).
1159 void player_audio_volume_set (player_t *player, int value);
1162 * \brief Get mute state.
1164 * Wrappers supported (even partially):
1165 * MPlayer, VLC, xine
1167 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1168 * \param[in] player Player controller.
1169 * \return Mute state.
1171 player_mute_t player_audio_mute_get (player_t *player);
1174 * \brief Set mute state.
1176 * Wrappers supported (even partially):
1177 * MPlayer, VLC, xine
1179 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1180 * \param[in] player Player controller.
1181 * \param[in] value Mute state to set.
1183 void player_audio_mute_set (player_t *player, player_mute_t value);
1186 * \brief Set audio delay.
1188 * Only useful with video files to set delay between audio and video streams.
1190 * Wrappers supported (even partially):
1193 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1194 * \param[in] player Player controller.
1195 * \param[in] value Delay to set (millisecond).
1196 * \param[in] absolute Mode, 0 for relative.
1198 void player_audio_set_delay (player_t *player, int value, int absolute);
1201 * \brief Select audio ID.
1203 * Wrappers supported (even partially):
1206 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1207 * \param[in] player Player controller.
1208 * \param[in] audio_id ID of the audio stream to select.
1210 void player_audio_select (player_t *player, int audio_id);
1213 * \brief Select the previous audio ID.
1215 * It stays on the same audio ID if no previous stream exists.
1217 * Wrappers supported (even partially):
1220 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1221 * \param[in] player Player controller.
1223 void player_audio_prev (player_t *player);
1226 * \brief Select the next audio ID.
1228 * It stays on the same audio ID if no next stream exists.
1230 * Wrappers supported (even partially):
1233 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1234 * \param[in] player Player controller.
1236 void player_audio_next (player_t *player);
1242 /***************************************************************************/
1244 /* Video related controls */
1246 /***************************************************************************/
1248 /** \brief Player video aspect. */
1249 typedef enum player_video_aspect {
1250 PLAYER_VIDEO_ASPECT_BRIGHTNESS,
1251 PLAYER_VIDEO_ASPECT_CONTRAST,
1252 PLAYER_VIDEO_ASPECT_GAMMA,
1253 PLAYER_VIDEO_ASPECT_HUE,
1254 PLAYER_VIDEO_ASPECT_SATURATION,
1255 } player_video_aspect_t;
1258 * \name Video related controls.
1263 * \brief Set video aspect.
1265 * Wrappers supported (even partially):
1268 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1269 * \param[in] player Player controller.
1270 * \param[in] aspect Aspect to change.
1271 * \param[in] value Value for aspect to set.
1272 * \param[in] absolute Mode, 0 for relative.
1274 void player_video_set_aspect (player_t *player, player_video_aspect_t aspect,
1275 int8_t value, int absolute);
1278 * \brief Set video panscan.
1280 * Wrappers supported (even partially):
1283 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1284 * \param[in] player Player controller.
1285 * \param[in] value Value for panscan to set.
1286 * \param[in] absolute Mode, 0 for relative.
1288 void player_video_set_panscan (player_t *player, int8_t value, int absolute);
1291 * \brief Set video aspect ratio.
1293 * Wrappers supported (even partially):
1294 * MPlayer, VLC, xine
1296 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1297 * \param[in] player Player controller.
1298 * \param[in] value Ratio to set.
1300 void player_video_set_aspect_ratio (player_t *player, float value);
1306 /***************************************************************************/
1308 /* Subtitles related controls */
1310 /***************************************************************************/
1312 /** \brief Player subtitle alignment. */
1313 typedef enum player_sub_alignment {
1314 PLAYER_SUB_ALIGNMENT_TOP,
1315 PLAYER_SUB_ALIGNMENT_CENTER,
1316 PLAYER_SUB_ALIGNMENT_BOTTOM,
1317 } player_sub_alignment_t;
1320 * \name Subtitles related controls.
1325 * \brief Set subtitle delay.
1327 * Only useful with video files to set delay between audio stream and
1330 * Wrappers supported (even partially):
1333 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1334 * \param[in] player Player controller.
1335 * \param[in] value Delay to set (millisecond).
1337 void player_subtitle_set_delay (player_t *player, int value);
1340 * \brief Set subtitle alignment.
1342 * Wrappers supported (even partially):
1345 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1346 * \param[in] player Player controller.
1347 * \param[in] a Alignment to set.
1349 void player_subtitle_set_alignment (player_t *player,
1350 player_sub_alignment_t a);
1353 * \brief Set subtitle position.
1355 * Wrappers supported (even partially):
1358 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1359 * \param[in] player Player controller.
1360 * \param[in] value Position to set.
1362 void player_subtitle_set_position (player_t *player, int value);
1365 * \brief Set subtitle visibility.
1367 * Wrappers supported (even partially):
1370 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1371 * \param[in] player Player controller.
1372 * \param[in] value Different of 0 to view the subtitles.
1374 void player_subtitle_set_visibility (player_t *player, int value);
1377 * \brief Set subtitle scale.
1379 * Wrappers supported (even partially):
1382 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1383 * \param[in] player Player controller.
1384 * \param[in] value Scale to set.
1385 * \param[in] absolute Mode, 0 for relative.
1387 void player_subtitle_scale (player_t *player, int value, int absolute);
1390 * \brief Select subtitle ID.
1392 * Wrappers supported (even partially):
1395 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1396 * \param[in] player Player controller.
1397 * \param[in] sub_id ID of the subtitle to select.
1399 void player_subtitle_select (player_t *player, int sub_id);
1402 * \brief Select the previous subtitle ID.
1404 * It stays on the same subtitle ID if no previous subtitle exists.
1406 * Wrappers supported (even partially):
1409 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1410 * \param[in] player Player controller.
1412 void player_subtitle_prev (player_t *player);
1415 * \brief Select the next subtitle ID.
1417 * It stays on the same subtitle ID if no next subtitle exists.
1419 * Wrappers supported (even partially):
1422 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1423 * \param[in] player Player controller.
1425 void player_subtitle_next (player_t *player);
1431 /***************************************************************************/
1433 /* DVD specific controls */
1435 /***************************************************************************/
1437 /** \brief Player DVDnav commands. */
1438 typedef enum player_dvdnav {
1441 PLAYER_DVDNAV_RIGHT,
1444 PLAYER_DVDNAV_SELECT,
1445 PLAYER_DVDNAV_PREVMENU,
1446 PLAYER_DVDNAV_MOUSECLICK,
1450 * \name DVD specific controls.
1455 * \brief DVD Navigation commands.
1457 * Wrappers supported (even partially):
1460 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1461 * \param[in] player Player controller.
1462 * \param[in] value Command to send.
1464 void player_dvd_nav (player_t *player, player_dvdnav_t value);
1467 * \brief Select DVD angle.
1469 * Wrappers supported (even partially):
1472 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1473 * \param[in] player Player controller.
1474 * \param[in] angle Angle to select.
1476 void player_dvd_angle_select (player_t *player, int angle);
1479 * \brief Select the previous DVD angle.
1481 * It stays on the same if no previous angle exists.
1483 * Wrappers supported (even partially):
1486 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1487 * \param[in] player Player controller.
1489 void player_dvd_angle_prev (player_t *player);
1492 * \brief Select the next DVD angle.
1494 * It stays on the same if no next angle exists.
1496 * Wrappers supported (even partially):
1499 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1500 * \param[in] player Player controller.
1502 void player_dvd_angle_next (player_t *player);
1505 * \brief Select DVD title.
1507 * Wrappers supported (even partially):
1510 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1511 * \param[in] player Player controller.
1512 * \param[in] title Title to select.
1514 void player_dvd_title_select (player_t *player, int title);
1517 * \brief Select the previous DVD title.
1519 * It stays on the same if no previous title exists.
1521 * Wrappers supported (even partially):
1524 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1525 * \param[in] player Player controller.
1527 void player_dvd_title_prev (player_t *player);
1530 * \brief Select the next DVD title.
1532 * It stays on the same if no next title exists.
1534 * Wrappers supported (even partially):
1537 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1538 * \param[in] player Player controller.
1540 void player_dvd_title_next (player_t *player);
1546 /***************************************************************************/
1548 /* TV/DVB specific controls */
1550 /***************************************************************************/
1553 * \name TV/DVB specific controls.
1558 * \brief Select TV channel.
1560 * Wrappers supported (even partially):
1563 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1564 * \param[in] player Player controller.
1565 * \param[in] channel Channel to select.
1567 void player_tv_channel_select (player_t *player, const char *channel);
1570 * \brief Select the previous TV channel.
1572 * It stays on the same if no previous channel exists.
1574 * Wrappers supported (even partially):
1577 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1578 * \param[in] player Player controller.
1580 void player_tv_channel_prev (player_t *player);
1583 * \brief Select the next TV channel.
1585 * It stays on the same if no next channel exists.
1587 * Wrappers supported (even partially):
1590 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1591 * \param[in] player Player controller.
1593 void player_tv_channel_next (player_t *player);
1599 /***************************************************************************/
1601 /* Radio specific controls */
1603 /***************************************************************************/
1606 * \name Radio specific controls.
1611 * \brief Select radio channel.
1613 * Wrappers supported (even partially):
1616 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1617 * \param[in] player Player controller.
1618 * \param[in] channel Channel to select.
1620 void player_radio_channel_select (player_t *player, const char *channel);
1623 * \brief Select the previous radio channel.
1625 * It stays on the same if no previous channel exists.
1627 * Wrappers supported (even partially):
1630 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1631 * \param[in] player Player controller.
1633 void player_radio_channel_prev (player_t *player);
1636 * \brief Select the next radio channel.
1638 * It stays on the same if no next channel exists.
1640 * Wrappers supported (even partially):
1643 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1644 * \param[in] player Player controller.
1646 void player_radio_channel_next (player_t *player);
1652 /***************************************************************************/
1654 /* VDR specific controls */
1656 /***************************************************************************/
1658 /** \brief Player VDR commands. */
1659 typedef enum player_vdr {
1666 PLAYER_VDR_CHANNELPLUS,
1667 PLAYER_VDR_CHANNELMINUS,
1679 PLAYER_VDR_SCHEDULE,
1680 PLAYER_VDR_CHANNELS,
1682 PLAYER_VDR_RECORDINGS,
1685 PLAYER_VDR_COMMANDS,
1706 PLAYER_VDR_VOLMINUS,
1710 PLAYER_VDR_CHANNELPREVIOUS,
1712 PLAYER_VDR_PREVIOUS,
1713 PLAYER_VDR_SUBTITLES,
1717 * \name VDR specific controls.
1722 * \brief VDR commands.
1724 * Wrappers supported (even partially):
1727 * \warning MT-Safe in multithreaded applications (see \ref mtlevel).
1728 * \param[in] player Player controller.
1729 * \param[in] value Command to send.
1731 void player_vdr (player_t *player, player_vdr_t value);
1737 /***************************************************************************/
1739 /* Global libplayer functions */
1741 /***************************************************************************/
1744 * \name Global libplayer functions.
1749 * \brief Test if a wrapper is enabled.
1751 * \warning MT-Safe in multithreaded applications.
1752 * \param[in] type Player type.
1753 * \return 1 if enabled, 0 otherwise.
1755 int libplayer_wrapper_enabled (player_type_t type);
1758 * \brief Test if a resource is supported by a wrapper.
1760 * \warning MT-Safe in multithreaded applications.
1761 * \param[in] type Player type.
1762 * \param[in] res Resource type.
1763 * \return 1 if supported, 0 otherwise.
1765 int libplayer_wrapper_supported_res (player_type_t type, mrl_resource_t res);
1772 #if 0 /* avoid EMACS indent */
1776 #endif /* __cplusplus */
1778 #endif /* PLAYER_H */