audiotrack: avoid cast, use proper type
[vlc.git] / include / vlc_player.h
blob601605de867612227ffb9f61f5f734f6ac25524b
1 /*****************************************************************************
2 * vlc_player.h: player interface
3 *****************************************************************************
4 * Copyright (C) 2018 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifndef VLC_PLAYER_H
22 #define VLC_PLAYER_H 1
24 #include <vlc_input.h>
25 #include <vlc_aout.h>
27 /**
28 * @defgroup vlc_player Player
29 * @ingroup input
30 * VLC Player API
31 * @brief
32 @dot
33 digraph player_states {
34 label="Player state diagram";
35 new [style="invis"];
36 started [label="Started" URL="@ref VLC_PLAYER_STATE_STARTED"];
37 playing [label="Playing" URL="@ref VLC_PLAYER_STATE_PLAYING"];
38 paused [label="Paused" URL="@ref VLC_PLAYER_STATE_PAUSED"];
39 stopping [label="Stopping" URL="@ref VLC_PLAYER_STATE_STOPPING"];
40 stopped [label="Stopped" URL="@ref VLC_PLAYER_STATE_STOPPED"];
41 new -> stopped [label="vlc_player_New()" URL="@ref vlc_player_New" fontcolor="green3"];
42 started -> playing [style="dashed" label=<<i>internal transition</i>>];
43 started -> stopping [label="vlc_player_Stop()" URL="@ref vlc_player_Stop" fontcolor="red"];
44 playing -> paused [label="vlc_player_Pause()" URL="@ref vlc_player_Pause" fontcolor="blue"];
45 paused -> playing [label="vlc_player_Resume()" URL="@ref vlc_player_Resume" fontcolor="blue3"];
46 paused -> stopping [label="vlc_player_Stop()" URL="@ref vlc_player_Stop" fontcolor="red"];
47 playing -> stopping [label="vlc_player_Stop()" URL="@ref vlc_player_Stop" fontcolor="red"];
48 stopping -> stopped [style="dashed" label=<<i>internal transition</i>>];
49 stopped -> started [label="vlc_player_Start()" URL="@ref vlc_player_Start" fontcolor="darkgreen"];
51 @enddot
52 * @{
53 * @file
54 * VLC Player API
57 /**
58 * @defgroup vlc_player__instance Player instance
59 * @{
62 /**
63 * Player opaque structure.
65 typedef struct vlc_player_t vlc_player_t;
67 /**
68 * Player lock type (normal or reentrant)
70 enum vlc_player_lock_type
72 /**
73 * Normal lock
75 * If the player is already locked, subsequent calls to vlc_player_Lock()
76 * will deadlock.
78 VLC_PLAYER_LOCK_NORMAL,
80 /**
81 * Reentrant lock
83 * If the player is already locked, subsequent calls to vlc_player_Lock()
84 * will still succeed. To unlock the player, one call to
85 * vlc_player_Unlock() per vlc_player_Lock() is necessary.
87 VLC_PLAYER_LOCK_REENTRANT,
90 /**
91 * Action when the player is stopped
93 * @see vlc_player_SetMediaStoppedAction()
95 enum vlc_player_media_stopped_action {
96 /** Continue (or stop if there is no next media), default behavior */
97 VLC_PLAYER_MEDIA_STOPPED_CONTINUE,
98 /** Pause when reaching the end of file */
99 VLC_PLAYER_MEDIA_STOPPED_PAUSE,
100 /** Stop, even if there is a next media to play */
101 VLC_PLAYER_MEDIA_STOPPED_STOP,
102 /** Exit VLC */
103 VLC_PLAYER_MEDIA_STOPPED_EXIT,
107 * Callbacks for the owner of the player.
109 * These callbacks are needed to control the player flow (via the
110 * vlc_playlist_t as a owner for example). It can only be set when creating the
111 * player via vlc_player_New().
113 * All callbacks are called with the player locked (cf. vlc_player_Lock()), and
114 * from any thread (even the current one).
116 struct vlc_player_media_provider
119 * Called when the player requires a new media
121 * @note The returned media must be already held with input_item_Hold()
123 * @param player locked player instance
124 * @param data opaque pointer set from vlc_player_New()
125 * @return the next media to play, held by the callee with input_item_Hold()
127 input_item_t *(*get_next)(vlc_player_t *player, void *data);
131 * Create a new player instance
133 * @param parent parent VLC object
134 * @param media_provider pointer to a media_provider structure or NULL, the
135 * structure must be valid during the lifetime of the player
136 * @param media_provider_data opaque data used by provider callbacks
137 * @return a pointer to a valid player instance or NULL in case of error
139 VLC_API vlc_player_t *
140 vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,
141 const struct vlc_player_media_provider *media_provider,
142 void *media_provider_data);
145 * Delete a player instance
147 * This function stop any playback previously started and wait for their
148 * termination.
150 * @warning Blocking function if the player state is not STOPPED, don't call it
151 * from an UI thread in that case.
153 * @param player unlocked player instance created by vlc_player_New()
155 VLC_API void
156 vlc_player_Delete(vlc_player_t *player);
159 * Lock the player.
161 * All player functions (except vlc_player_Delete()) need to be called while
162 * the player lock is held.
164 * @param player unlocked player instance
166 VLC_API void
167 vlc_player_Lock(vlc_player_t *player);
170 * Unlock the player
172 * @param player locked player instance
174 VLC_API void
175 vlc_player_Unlock(vlc_player_t *player);
178 * Wait on a condition variable
180 * This call allow users to use their own condition with the player mutex.
182 * @param player locked player instance
183 * @param cond external condition
185 VLC_API void
186 vlc_player_CondWait(vlc_player_t *player, vlc_cond_t *cond);
189 * Setup an action when a media is stopped
191 * @param player locked player instance
192 * @param action action to do when a media is stopped
194 VLC_API void
195 vlc_player_SetMediaStoppedAction(vlc_player_t *player,
196 enum vlc_player_media_stopped_action action);
199 * Ask to start in a paused state
201 * This function can be used before vlc_player_Start()
203 * @param player locked player instance
204 * @param start_paused true to start in a paused state, false to cancel it
206 VLC_API void
207 vlc_player_SetStartPaused(vlc_player_t *player, bool start_paused);
210 * Enable or disable pause on cork event
212 * If enabled, the player will automatically pause and resume on cork events.
213 * In that case, cork events won't be propagated via callbacks.
214 * @see vlc_player_cbs.on_cork_changed
216 * @param player locked player instance
217 * @param enabled true to enable
219 VLC_API void
220 vlc_player_SetPauseOnCork(vlc_player_t *player, bool enabled);
222 /** @} vlc_player__instance */
225 * @defgroup vlc_player__playback Playback control
226 * @{
230 * State of the player
232 * During a normal playback (no errors), the user is expected to receive all
233 * events in the following order: STARTED, PLAYING, STOPPING, STOPPED.
235 * @note When playing more than one media in a row, the player stay at the
236 * PLAYING state when doing the transition from the current media to the next
237 * media (that can be gapless). This means that STOPPING, STOPPED states (for
238 * the current media) and STARTED, PLAYING states (for the next one) won't be
239 * sent. Nevertheless, the vlc_player_cbs.on_current_media_changed callback
240 * will be called during this transition.
242 enum vlc_player_state
245 * The player is stopped
247 * Initial state, or triggered by an internal transition from the STOPPING
248 * state.
250 VLC_PLAYER_STATE_STOPPED,
253 * The player is started
255 * Triggered by vlc_player_Start()
257 VLC_PLAYER_STATE_STARTED,
260 * The player is playing
262 * Triggered by vlc_player_Resume() or by an internal transition from the
263 * STARTED state.
265 VLC_PLAYER_STATE_PLAYING,
268 * The player is paused
270 * Triggered by vlc_player_Pause().
272 VLC_PLAYER_STATE_PAUSED,
275 * The player is stopping
277 * Triggered by vlc_player_Stop(), vlc_player_SetCurrentMedia() or by an
278 * internal transition (when the media reach the end of file for example).
280 VLC_PLAYER_STATE_STOPPING,
284 * Error of the player
286 * @see vlc_player_GetError()
288 enum vlc_player_error
290 VLC_PLAYER_ERROR_NONE,
291 VLC_PLAYER_ERROR_GENERIC,
295 * Seek speed type
297 * @see vlc_player_SeekByPos()
298 * @see vlc_player_SeekByTime()
300 enum vlc_player_seek_speed
302 /** Do a precise seek */
303 VLC_PLAYER_SEEK_PRECISE,
304 /** Do a fast seek */
305 VLC_PLAYER_SEEK_FAST,
309 * Player seek/delay directive
311 * @see vlc_player_SeekByPos()
312 * @see vlc_player_SeekByTime()
313 * @see vlc_player_SetCategoryDelay()
315 enum vlc_player_whence
317 /** Given time/position */
318 VLC_PLAYER_WHENCE_ABSOLUTE,
319 /** The current position +/- the given time/position */
320 VLC_PLAYER_WHENCE_RELATIVE,
324 * Menu (VCD/DVD/BD) and viewpoint navigations
326 * @see vlc_player_Navigate()
328 enum vlc_player_nav
330 /** Activate the navigation item selected */
331 VLC_PLAYER_NAV_ACTIVATE,
332 /** Select a navigation item above or move the viewpoint up */
333 VLC_PLAYER_NAV_UP,
334 /** Select a navigation item under or move the viewpoint down */
335 VLC_PLAYER_NAV_DOWN,
336 /** Select a navigation item on the left or move the viewpoint left */
337 VLC_PLAYER_NAV_LEFT,
338 /** Select a navigation item on the right or move the viewpoint right */
339 VLC_PLAYER_NAV_RIGHT,
340 /** Activate the popup Menu (for BD) */
341 VLC_PLAYER_NAV_POPUP,
342 /** Activate disc Root Menu */
343 VLC_PLAYER_NAV_MENU,
347 * A to B loop state
349 enum vlc_player_abloop
351 VLC_PLAYER_ABLOOP_NONE,
352 VLC_PLAYER_ABLOOP_A,
353 VLC_PLAYER_ABLOOP_B,
356 /** Player capability: can seek */
357 #define VLC_PLAYER_CAP_SEEK (1<<0)
358 /** Player capability: can pause */
359 #define VLC_PLAYER_CAP_PAUSE (1<<1)
360 /** Player capability: can change the rate */
361 #define VLC_PLAYER_CAP_CHANGE_RATE (1<<2)
362 /** Player capability: can seek back */
363 #define VLC_PLAYER_CAP_REWIND (1<<3)
365 /** Player teletext key: Red */
366 #define VLC_PLAYER_TELETEXT_KEY_RED ('r' << 16)
367 /** Player teletext key: Green */
368 #define VLC_PLAYER_TELETEXT_KEY_GREEN ('g' << 16)
369 /** Player teletext key: Yellow */
370 #define VLC_PLAYER_TELETEXT_KEY_YELLOW ('y' << 16)
371 /** Player teletext key: Blue */
372 #define VLC_PLAYER_TELETEXT_KEY_BLUE ('b' << 16)
373 /** Player teletext key: Index */
374 #define VLC_PLAYER_TELETEXT_KEY_INDEX ('i' << 16)
376 enum vlc_player_restore_playback_pos
378 VLC_PLAYER_RESTORE_PLAYBACK_POS_NEVER,
379 VLC_PLAYER_RESTORE_PLAYBACK_POS_ASK,
380 VLC_PLAYER_RESTORE_PLAYBACK_POS_ALWAYS,
384 * Set the current media
386 * This function replaces the current and next medias.
388 * @note A successful call will always result of
389 * vlc_player_cbs.on_current_media_changed being called. This function is not
390 * blocking. If a media is currently being played, this media will be stopped
391 * and the requested media will be set after.
393 * @warning This function is either synchronous (if the player state is
394 * STOPPED) or asynchronous. In the later case, vlc_player_GetCurrentMedia()
395 * will return the old media, even after this call, and until the
396 * vlc_player_cbs.on_current_media_changed is called.
398 * @param player locked player instance
399 * @param media new media to play (will be held by the player)
400 * @return VLC_SUCCESS or a VLC error code
402 VLC_API int
403 vlc_player_SetCurrentMedia(vlc_player_t *player, input_item_t *media);
406 * Get the current played media.
408 * @see vlc_player_cbs.on_current_media_changed
410 * @param player locked player instance
411 * @return a valid media or NULL (if no media is set)
413 VLC_API input_item_t *
414 vlc_player_GetCurrentMedia(vlc_player_t *player);
417 * Helper that hold the current media
419 static inline input_item_t *
420 vlc_player_HoldCurrentMedia(vlc_player_t *player)
422 input_item_t *item = vlc_player_GetCurrentMedia(player);
423 return item ? input_item_Hold(item) : NULL;
427 * Invalidate the next media.
429 * This function can be used to invalidate the media returned by the
430 * vlc_player_media_provider.get_next callback. This can be used when the next
431 * item from a playlist was changed by the user.
433 * Calling this function will trigger the
434 * vlc_player_media_provider.get_next callback to be called again.
436 * @param player locked player instance
438 VLC_API void
439 vlc_player_InvalidateNextMedia(vlc_player_t *player);
442 * Start the playback of the current media.
444 * @param player locked player instance
445 * @return VLC_SUCCESS or a VLC error code
447 VLC_API int
448 vlc_player_Start(vlc_player_t *player);
451 * Stop the playback of the current media
453 * @note This function is asynchronous. In case of success, the user should wait
454 * for the STOPPED state event to know when the stop is finished.
456 * @param player locked player instance
457 * @return VLC_SUCCESS if the player is being stopped, VLC_EGENERIC otherwise
458 * (no-op)
460 VLC_API int
461 vlc_player_Stop(vlc_player_t *player);
464 * Pause the playback
466 * @param player locked player instance
468 VLC_API void
469 vlc_player_Pause(vlc_player_t *player);
472 * Resume the playback from a pause
474 * @param player locked player instance
476 VLC_API void
477 vlc_player_Resume(vlc_player_t *player);
480 * Pause and display the next video frame
482 * @param player locked player instance
484 VLC_API void
485 vlc_player_NextVideoFrame(vlc_player_t *player);
488 * Get the state of the player
490 * @note Since all players actions are asynchronous, this function won't
491 * reflect the new state immediately. Wait for the
492 * vlc_players_cbs.on_state_changed event to be notified.
494 * @see vlc_player_state
495 * @see vlc_player_cbs.on_state_changed
497 * @param player locked player instance
498 * @return the current player state
500 VLC_API enum vlc_player_state
501 vlc_player_GetState(vlc_player_t *player);
504 * Get the error state of the player
506 * @see vlc_player_cbs.on_capabilities_changed
508 * @param player locked player instance
509 * @return the current error state
511 VLC_API enum vlc_player_error
512 vlc_player_GetError(vlc_player_t *player);
515 * Helper to get the started state
517 static inline bool
518 vlc_player_IsStarted(vlc_player_t *player)
520 switch (vlc_player_GetState(player))
522 case VLC_PLAYER_STATE_STARTED:
523 case VLC_PLAYER_STATE_PLAYING:
524 case VLC_PLAYER_STATE_PAUSED:
525 return true;
526 default:
527 return false;
532 * Helper to get the paused state
534 static inline bool
535 vlc_player_IsPaused(vlc_player_t *player)
537 return vlc_player_GetState(player) == VLC_PLAYER_STATE_PAUSED;
541 * Helper to toggle the pause state
543 static inline void
544 vlc_player_TogglePause(vlc_player_t *player)
546 if (vlc_player_IsStarted(player))
548 if (vlc_player_IsPaused(player))
549 vlc_player_Resume(player);
550 else
551 vlc_player_Pause(player);
556 * Get the player capabilities
558 * @see vlc_player_cbs.on_capabilities_changed
560 * @param player locked player instance
561 * @return the player capabilities, a bitwise mask of @ref VLC_PLAYER_CAP_SEEK,
562 * @ref VLC_PLAYER_CAP_PAUSE, @ref VLC_PLAYER_CAP_CHANGE_RATE, @ref
563 * VLC_PLAYER_CAP_REWIND
565 VLC_API int
566 vlc_player_GetCapabilities(vlc_player_t *player);
569 * Helper to get the seek capability
571 static inline bool
572 vlc_player_CanSeek(vlc_player_t *player)
574 return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_SEEK;
578 * Helper to get the pause capability
580 static inline bool
581 vlc_player_CanPause(vlc_player_t *player)
583 return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_PAUSE;
587 * Helper to get the change-rate capability
589 static inline bool
590 vlc_player_CanChangeRate(vlc_player_t *player)
592 return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_CHANGE_RATE;
596 * Helper to get the rewindable capability
598 static inline bool
599 vlc_player_CanRewind(vlc_player_t *player)
601 return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_REWIND;
605 * Get the rate of the player
607 * @see vlc_player_cbs.on_rate_changed
609 * @param player locked player instance
610 * @return rate of the player (< 1.f is slower, > 1.f is faster)
612 VLC_API float
613 vlc_player_GetRate(vlc_player_t *player);
616 * Change the rate of the player
618 * @note The rate is saved across several medias
620 * @param player locked player instance
621 * @param rate new rate (< 1.f is slower, > 1.f is faster)
623 VLC_API void
624 vlc_player_ChangeRate(vlc_player_t *player, float rate);
627 * Increment the rate of the player (faster)
629 * @param player locked player instance
631 VLC_API void
632 vlc_player_IncrementRate(vlc_player_t *player);
635 * Decrement the rate of the player (Slower)
637 * @param player locked player instance
639 VLC_API void
640 vlc_player_DecrementRate(vlc_player_t *player);
643 * Get the length of the current media
645 * @note A started and playing media doesn't have necessarily a valid length.
647 * @see vlc_player_cbs.on_length_changed
649 * @param player locked player instance
650 * @return a valid length or VLC_TICK_INVALID (if no media is set,
651 * playback is not yet started or in case of error)
653 VLC_API vlc_tick_t
654 vlc_player_GetLength(vlc_player_t *player);
657 * Get the time of the current media
659 * @note A started and playing media doesn't have necessarily a valid time.
661 * @see vlc_player_cbs.on_position_changed
663 * @param player locked player instance
664 * @return a valid time or VLC_TICK_INVALID (if no media is set, the media
665 * doesn't have any time, if playback is not yet started or in case of error)
667 VLC_API vlc_tick_t
668 vlc_player_GetTime(vlc_player_t *player);
671 * Get the position of the current media
673 * @see vlc_player_cbs.on_position_changed
675 * @param player locked player instance
676 * @return a valid position in the range [0.f;1.f] or -1.f (if no media is
677 * set,if playback is not yet started or in case of error)
679 VLC_API float
680 vlc_player_GetPosition(vlc_player_t *player);
683 * Seek the current media by position
685 * @note This function can be called before vlc_player_Start() in order to set
686 * a starting position.
688 * @param player locked player instance
689 * @param position position in the range [0.f;1.f]
690 * @param speed precise of fast
691 * @param whence absolute or relative
693 VLC_API void
694 vlc_player_SeekByPos(vlc_player_t *player, float position,
695 enum vlc_player_seek_speed speed,
696 enum vlc_player_whence whence);
699 * Seek the current media by time
701 * @note This function can be called before vlc_player_Start() in order to set
702 * a starting position.
704 * @warning This function has an effect only if the media has a valid length.
706 * @param player locked player instance
707 * @param time a time in the range [0;length]
708 * @param speed precise of fast
709 * @param whence absolute or relative
711 VLC_API void
712 vlc_player_SeekByTime(vlc_player_t *player, vlc_tick_t time,
713 enum vlc_player_seek_speed speed,
714 enum vlc_player_whence whence);
717 * Helper to set the absolute position precisely
719 static inline void
720 vlc_player_SetPosition(vlc_player_t *player, float position)
722 vlc_player_SeekByPos(player, position, VLC_PLAYER_SEEK_PRECISE,
723 VLC_PLAYER_WHENCE_ABSOLUTE);
727 * Helper to set the absolute position fast
729 static inline void
730 vlc_player_SetPositionFast(vlc_player_t *player, float position)
732 vlc_player_SeekByPos(player, position, VLC_PLAYER_SEEK_FAST,
733 VLC_PLAYER_WHENCE_ABSOLUTE);
737 * Helper to jump the position precisely
739 static inline void
740 vlc_player_JumpPos(vlc_player_t *player, float jumppos)
742 /* No fask seek for jumps. Indeed, jumps can seek to the current position
743 * if not precise enough or if the jump value is too small. */
744 vlc_player_SeekByPos(player, jumppos, VLC_PLAYER_SEEK_PRECISE,
745 VLC_PLAYER_WHENCE_RELATIVE);
749 * Helper to set the absolute time precisely
751 static inline void
752 vlc_player_SetTime(vlc_player_t *player, vlc_tick_t time)
754 vlc_player_SeekByTime(player, time, VLC_PLAYER_SEEK_PRECISE,
755 VLC_PLAYER_WHENCE_ABSOLUTE);
759 * Helper to set the absolute time fast
761 static inline void
762 vlc_player_SetTimeFast(vlc_player_t *player, vlc_tick_t time)
764 vlc_player_SeekByTime(player, time, VLC_PLAYER_SEEK_FAST,
765 VLC_PLAYER_WHENCE_ABSOLUTE);
769 * Helper to jump the time precisely
771 static inline void
772 vlc_player_JumpTime(vlc_player_t *player, vlc_tick_t jumptime)
774 /* No fask seek for jumps. Indeed, jumps can seek to the current position
775 * if not precise enough or if the jump value is too small. */
776 vlc_player_SeekByTime(player, jumptime, VLC_PLAYER_SEEK_PRECISE,
777 VLC_PLAYER_WHENCE_RELATIVE);
781 * Display the player position on the vout OSD
783 * @param player locked player instance
785 VLC_API void
786 vlc_player_DisplayPosition(vlc_player_t *player);
789 * Enable A to B loop of the current media
791 * This function need to be called 2 times with VLC_PLAYER_ABLOOP_A and
792 * VLC_PLAYER_ABLOOP_B to setup an A to B loop. It current the current
793 * time/position when called. The B time must be higher than the A time.
795 * @param player locked player instance
796 * @return VLC_SUCCESS or a VLC error code
798 VLC_API int
799 vlc_player_SetAtoBLoop(vlc_player_t *player, enum vlc_player_abloop abloop);
802 * Get the A to B loop status
804 * @note If the returned status is VLC_PLAYER_ABLOOP_A, then a_time and a_pos
805 * will be valid. If the returned status is VLC_PLAYER_ABLOOP_B, then all
806 * output parameters are valid. If the returned status is
807 * VLC_PLAYER_ABLOOP_NONE, then all output parameters are invalid.
809 * @see vlc_player_cbs.on_atobloop_changed
811 * @param player locked player instance
812 * @param a_time A time or VLC_TICK_INVALID (if the media doesn't have valid
813 * times)
814 * @param a_pos A position
815 * @param b_time B time or VLC_TICK_INVALID (if the media doesn't have valid
816 * times)
817 * @param b_pos B position
818 * @return A to B loop status
820 VLC_API enum vlc_player_abloop
821 vlc_player_GetAtoBLoop(vlc_player_t *player, vlc_tick_t *a_time, float *a_pos,
822 vlc_tick_t *b_time, float *b_pos);
825 * Navigate (for DVD/Bluray menus or viewpoint)
827 * @param player locked player instance
828 * @param nav navigation key
830 VLC_API void
831 vlc_player_Navigate(vlc_player_t *player, enum vlc_player_nav nav);
834 * Update the viewpoint
836 * @param player locked player instance
837 * @param viewpoint the viewpoint value
838 * @param whence absolute or relative
839 * @return VLC_SUCCESS or a VLC error code
841 VLC_API void
842 vlc_player_UpdateViewpoint(vlc_player_t *player,
843 const vlc_viewpoint_t *viewpoint,
844 enum vlc_player_whence whence);
847 * Check if the playing is recording
849 * @see vlc_player_cbs.on_recording_changed
851 * @param player locked player instance
852 * @return true if the player is recording
854 VLC_API bool
855 vlc_player_IsRecording(vlc_player_t *player);
858 * Enable or disable recording for the current media
860 * @note A successful call will trigger the vlc_player_cbs.on_recording_changed
861 * event.
863 * @param player locked player instance
864 * @param enabled true to enable recording
866 VLC_API void
867 vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enabled);
870 * Helper to toggle the recording state
872 static inline void
873 vlc_player_ToggleRecording(vlc_player_t *player)
875 vlc_player_SetRecordingEnabled(player, !vlc_player_IsRecording(player));
879 * Add an associated (or external) media to the current media
881 * @param player locked player instance
882 * @param cat AUDIO_ES or SPU_ES
883 * @param uri absolute uri of the external media
884 * @param select true to select the track of this external media
885 * @param notify true to notify the OSD
886 * @param check_ext true to check subtitles extension
888 VLC_API int
889 vlc_player_AddAssociatedMedia(vlc_player_t *player,
890 enum es_format_category_e cat, const char *uri,
891 bool select, bool notify, bool check_ext);
894 * Get the signal quality and strength of the current media
896 * @param player locked player instance
898 VLC_API int
899 vlc_player_GetSignal(vlc_player_t *player, float *quality, float *strength);
902 * Get the statistics of the current media
904 * @warning The returned pointer becomes invalid when the player is unlocked.
905 * The referenced structure can be safely copied.
907 * @see vlc_player_cbs.on_statistics_changed
909 * @param player locked player instance
910 * @return pointer to the player stats structure or NULL
912 VLC_API const struct input_stats_t *
913 vlc_player_GetStatistics(vlc_player_t *player);
916 * Restore the previous playback position of the current media
918 VLC_API void
919 vlc_player_RestorePlaybackPos(vlc_player_t *player);
922 * Get the V4L2 object used to do controls
924 * @param player locked player instance
925 * @return the V4L2 object or NULL if not any. This object must be used with
926 * the player lock held.
928 VLC_API vlc_object_t *
929 vlc_player_GetV4l2Object(vlc_player_t *player) VLC_DEPRECATED;
931 /** @} vlc_player__playback */
934 * @defgroup vlc_player__titles Title and chapter control
935 * @{
939 * Player chapter structure
941 struct vlc_player_chapter
943 /** Chapter name, always valid */
944 const char *name;
945 /** Position of this chapter */
946 vlc_tick_t time;
949 /** vlc_player_title.flags: The title is a menu. */
950 #define VLC_PLAYER_TITLE_MENU 0x01
951 /** vlc_player_title.flags: The title is interactive. */
952 #define VLC_PLAYER_TITLE_INTERACTIVE 0x02
954 /** Player title structure */
955 struct vlc_player_title
957 /** Title name, always valid */
958 const char *name;
959 /** Length of the title */
960 vlc_tick_t length;
961 /** Bit flag of @ref VLC_PLAYER_TITLE_MENU and @ref
962 * VLC_PLAYER_TITLE_INTERACTIVE */
963 unsigned flags;
964 /** Number of chapters, can be 0 */
965 size_t chapter_count;
966 /** Array of chapters, can be NULL */
967 const struct vlc_player_chapter *chapters;
971 * Opaque structure representing a list of @ref vlc_player_title.
973 * @see vlc_player_GetTitleList()
974 * @see vlc_player_title_list_GetCount()
975 * @see vlc_player_title_list_GetAt()
977 typedef struct vlc_player_title_list vlc_player_title_list;
980 * Hold the title list of the player
982 * This function can be used to pass this title list from a callback to an
983 * other thread.
985 * @see vlc_player_cbs.on_titles_changed
987 * @return the same instance
989 VLC_API vlc_player_title_list *
990 vlc_player_title_list_Hold(vlc_player_title_list *titles);
993 * Release of previously held title list
995 VLC_API void
996 vlc_player_title_list_Release(vlc_player_title_list *titles);
999 * Get the number of title of a list
1001 VLC_API size_t
1002 vlc_player_title_list_GetCount(vlc_player_title_list *titles);
1005 * Get the title at a given index
1007 * @param idx index in the range [0; count[
1008 * @return a valid title (can't be NULL)
1010 VLC_API const struct vlc_player_title *
1011 vlc_player_title_list_GetAt(vlc_player_title_list *titles, size_t idx);
1014 * Get the title list of the current media
1016 * @see vlc_player_cbs.on_titles_changed
1018 * @param player locked player instance
1020 VLC_API vlc_player_title_list *
1021 vlc_player_GetTitleList(vlc_player_t *player);
1024 * Get the selected title index for the current media
1026 * @see vlc_player_cbs.on_title_selection_changed
1028 * @param player locked player instance
1030 VLC_API ssize_t
1031 vlc_player_GetSelectedTitleIdx(vlc_player_t *player);
1034 * Helper to get the current selected title
1036 static inline const struct vlc_player_title *
1037 vlc_player_GetSelectedTitle(vlc_player_t *player)
1039 vlc_player_title_list *titles = vlc_player_GetTitleList(player);
1040 if (!titles)
1041 return NULL;
1042 ssize_t selected_idx = vlc_player_GetSelectedTitleIdx(player);
1043 if (selected_idx < 0)
1044 return NULL;
1045 return vlc_player_title_list_GetAt(titles, selected_idx);
1049 * Select a title index for the current media
1051 * @note A successful call will trigger the
1052 * vlc_player_cbs.on_title_selection_changed event.
1054 * @see vlc_player_title_list_GetAt()
1055 * @see vlc_player_title_list_GetCount()
1057 * @param player locked player instance
1058 * @param index valid index in the range [0;count[
1060 VLC_API void
1061 vlc_player_SelectTitleIdx(vlc_player_t *player, size_t index);
1064 * Select a title for the current media
1066 * @note A successful call will trigger the
1067 * vlc_player_cbs.on_title_selection_changed event.
1069 * @see vlc_player_title_list_GetAt()
1070 * @see vlc_player_title_list_GetCount()
1072 * @param player locked player instance
1073 * @param title a valid title coming from the vlc_player_title_list
1075 VLC_API void
1076 vlc_player_SelectTitle(vlc_player_t *player,
1077 const struct vlc_player_title *title);
1080 * Select a chapter for the current media
1082 * @note A successful call will trigger the
1083 * vlc_player_cbs.on_chapter_selection_changed event.
1085 * @param player locked player instance
1086 * @param title the selected title
1087 * @param chapter_idx index from vlc_player_title.chapters
1089 VLC_API void
1090 vlc_player_SelectChapter(vlc_player_t *player,
1091 const struct vlc_player_title *title,
1092 size_t chapter_idx);
1095 * Select the next title for the current media
1097 * @see vlc_player_SelectTitleIdx()
1099 VLC_API void
1100 vlc_player_SelectNextTitle(vlc_player_t *player);
1103 * Select the previous title for the current media
1105 * @see vlc_player_SelectTitleIdx()
1107 VLC_API void
1108 vlc_player_SelectPrevTitle(vlc_player_t *player);
1111 * Get the selected chapter index for the current media
1113 * @see vlc_player_cbs.on_chapter_selection_changed
1115 * @param player locked player instance
1117 VLC_API ssize_t
1118 vlc_player_GetSelectedChapterIdx(vlc_player_t *player);
1121 * Helper to get the current selected chapter
1123 static inline const struct vlc_player_chapter *
1124 vlc_player_GetSelectedChapter(vlc_player_t *player)
1126 const struct vlc_player_title *title = vlc_player_GetSelectedTitle(player);
1127 if (!title || !title->chapter_count)
1128 return NULL;
1129 ssize_t chapter_idx = vlc_player_GetSelectedChapterIdx(player);
1130 return chapter_idx >= 0 ? &title->chapters[chapter_idx] : NULL;
1134 * Select a chapter index for the current media
1136 * @note A successful call will trigger the
1137 * vlc_player_cbs.on_chaper_selection_changed event.
1139 * @see vlc_player_title.chapters
1141 * @param player locked player instance
1142 * @param index valid index in the range [0;vlc_player_title.chapter_count[
1144 VLC_API void
1145 vlc_player_SelectChapterIdx(vlc_player_t *player, size_t index);
1148 * Select the next chapter for the current media
1150 * @see vlc_player_SelectChapterIdx()
1152 VLC_API void
1153 vlc_player_SelectNextChapter(vlc_player_t *player);
1156 * Select the previous chapter for the current media
1158 * @see vlc_player_SelectChapterIdx()
1160 VLC_API void
1161 vlc_player_SelectPrevChapter(vlc_player_t *player);
1163 /** @} vlc_player__titles */
1166 * @defgroup vlc_player__programs Program control
1167 * @{
1171 * Player program structure.
1173 struct vlc_player_program
1175 /** Id used for vlc_player_SelectProgram() */
1176 int group_id;
1177 /** Program name, always valid */
1178 const char *name;
1179 /** True if the program is selected */
1180 bool selected;
1181 /** True if the program is scrambled */
1182 bool scrambled;
1186 * Duplicate a program
1188 * This function can be used to pass a program from a callback to an other
1189 * context.
1191 * @see vlc_player_cbs.on_program_list_changed
1193 * @return a duplicated program or NULL on allocation error
1195 VLC_API struct vlc_player_program *
1196 vlc_player_program_Dup(const struct vlc_player_program *prgm);
1199 * Delete a duplicated program
1201 VLC_API void
1202 vlc_player_program_Delete(struct vlc_player_program *prgm);
1205 * Get the number of programs
1207 * @warning The returned size becomes invalid when the player is unlocked.
1209 * @param player locked player instance
1210 * @return number of programs, or 0 (in case of error, or if the media is not
1211 * started)
1213 VLC_API size_t
1214 vlc_player_GetProgramCount(vlc_player_t *player);
1217 * Get the program at a specific index
1219 * @warning The behaviour is undefined if the index is not valid.
1221 * @warning The returned pointer becomes invalid when the player is unlocked.
1222 * The referenced structure can be safely copied with vlc_player_program_Dup().
1224 * @param player locked player instance
1225 * @param index valid index in the range [0; count[
1226 * @return a valid program (can't be NULL if vlc_player_GetProgramCount()
1227 * returned a valid count)
1229 VLC_API const struct vlc_player_program *
1230 vlc_player_GetProgramAt(vlc_player_t *player, size_t index);
1233 * Get a program from an ES group identifier
1235 * @param player locked player instance
1236 * @param group_id a program ID (retrieved from
1237 * vlc_player_cbs.on_program_list_changed or vlc_player_GetProgramAt())
1238 * @return a valid program or NULL (if the program was terminated by the
1239 * playback thread)
1241 VLC_API const struct vlc_player_program *
1242 vlc_player_GetProgram(vlc_player_t *player, int group_id);
1245 * Select a program from an ES group identifier
1247 * @param player locked player instance
1248 * @param group_id a program ID (retrieved from
1249 * vlc_player_cbs.on_program_list_changed or vlc_player_GetProgramAt())
1251 VLC_API void
1252 vlc_player_SelectProgram(vlc_player_t *player, int group_id);
1255 * Select the next program
1257 * @param player locked player instance
1259 VLC_API void
1260 vlc_player_SelectNextProgram(vlc_player_t *player);
1263 * Select the previous program
1265 * @param player locked player instance
1267 VLC_API void
1268 vlc_player_SelectPrevProgram(vlc_player_t *player);
1271 * Helper to get the current selected program
1273 static inline const struct vlc_player_program *
1274 vlc_player_GetSelectedProgram(vlc_player_t *player)
1276 size_t count = vlc_player_GetProgramCount(player);
1277 for (size_t i = 0; i < count; ++i)
1279 const struct vlc_player_program *program =
1280 vlc_player_GetProgramAt(player, i);
1281 assert(program);
1282 if (program->selected)
1283 return program;
1285 return NULL;
1288 /** @} vlc_player__programs */
1291 * @defgroup vlc_player__tracks Tracks control
1292 * @{
1296 * Player selection policy
1298 * @see vlc_player_SelectEsId()
1300 enum vlc_player_select_policy
1303 * Only one track per category is selected. Selecting a track with this
1304 * policy will disable all other tracks for the same category.
1306 VLC_PLAYER_SELECT_EXCLUSIVE,
1308 * Select multiple tracks for one category.
1310 * Only one audio track can be selected at a time.
1311 * Two subtitle tracks can be selected simultaneously.
1312 * Multiple video tracks can be selected simultaneously.
1314 VLC_PLAYER_SELECT_SIMULTANEOUS,
1318 * Player track structure.
1320 * A track is a representation of an ES identifier at a given time. Once the
1321 * player is unlocked, all content except the es_id pointer can be updated.
1323 * @see vlc_player_cbs.on_track_list_changed
1324 * @see vlc_player_GetTrack
1326 struct vlc_player_track
1328 /** Id used for any player actions, like vlc_player_SelectEsId() */
1329 vlc_es_id_t *es_id;
1330 /** Track name, always valid */
1331 const char *name;
1332 /** Es format */
1333 es_format_t fmt;
1334 /** True if the track is selected */
1335 bool selected;
1339 * Duplicate a track
1341 * This function can be used to pass a track from a callback to an other
1342 * context. The es_id will be held by the duplicated track.
1344 * @warning The returned track won't be updated if the original one is modified
1345 * by the player.
1347 * @see vlc_player_cbs.on_track_list_changed
1349 * @return a duplicated track or NULL on allocation error
1351 VLC_API struct vlc_player_track *
1352 vlc_player_track_Dup(const struct vlc_player_track *track);
1355 * Delete a duplicated track
1357 VLC_API void
1358 vlc_player_track_Delete(struct vlc_player_track *track);
1361 * Get the number of tracks for an ES category
1363 * @warning The returned size becomes invalid when the player is unlocked.
1365 * @param player locked player instance
1366 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1367 * @return number of tracks, or 0 (in case of error, or if the media is not
1368 * started)
1370 VLC_API size_t
1371 vlc_player_GetTrackCount(vlc_player_t *player, enum es_format_category_e cat);
1374 * Get the track at a specific index for an ES category
1376 * @warning The behaviour is undefined if the index is not valid.
1378 * @warning The returned pointer becomes invalid when the player is unlocked.
1379 * The referenced structure can be safely copied with vlc_player_track_Dup().
1381 * @param player locked player instance
1382 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1383 * @param index valid index in the range [0; count[
1384 * @return a valid track (can't be NULL if vlc_player_GetTrackCount() returned
1385 * a valid count)
1387 VLC_API const struct vlc_player_track *
1388 vlc_player_GetTrackAt(vlc_player_t *player, enum es_format_category_e cat,
1389 size_t index);
1392 * Helper to get the video track count
1394 static inline size_t
1395 vlc_player_GetVideoTrackCount(vlc_player_t *player)
1397 return vlc_player_GetTrackCount(player, VIDEO_ES);
1401 * Helper to get a video track at a specific index
1403 static inline const struct vlc_player_track *
1404 vlc_player_GetVideoTrackAt(vlc_player_t *player, size_t index)
1406 return vlc_player_GetTrackAt(player, VIDEO_ES, index);
1410 * Helper to get the audio track count
1412 static inline size_t
1413 vlc_player_GetAudioTrackCount(vlc_player_t *player)
1415 return vlc_player_GetTrackCount(player, AUDIO_ES);
1419 * Helper to get an audio track at a specific index
1421 static inline const struct vlc_player_track *
1422 vlc_player_GetAudioTrackAt(vlc_player_t *player, size_t index)
1424 return vlc_player_GetTrackAt(player, AUDIO_ES, index);
1428 * Helper to get the subtitle track count
1430 static inline size_t
1431 vlc_player_GetSubtitleTrackCount(vlc_player_t *player)
1433 return vlc_player_GetTrackCount(player, SPU_ES);
1437 * Helper to get a subtitle track at a specific index
1439 static inline const struct vlc_player_track *
1440 vlc_player_GetSubtitleTrackAt(vlc_player_t *player, size_t index)
1442 return vlc_player_GetTrackAt(player, SPU_ES, index);
1446 * Get a track from an ES identifier
1448 * @warning The returned pointer becomes invalid when the player is unlocked.
1449 * The referenced structure can be safely copied with vlc_player_track_Dup().
1451 * @param player locked player instance
1452 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1453 * vlc_player_GetTrackAt())
1454 * @return a valid player track or NULL (if the track was terminated by the
1455 * playback thread)
1457 VLC_API const struct vlc_player_track *
1458 vlc_player_GetTrack(vlc_player_t *player, vlc_es_id_t *es_id);
1461 * Get and the video output used by a ES identifier
1463 * @warning A same vout can be associated with multiple ES during the lifetime
1464 * of the player. The information returned by this function becomes invalid
1465 * when the player is unlocked. The returned vout doesn't need to be released,
1466 * but must be held with vout_Hold() if it is accessed after the player is
1467 * unlocked.
1469 * @param player locked player instance
1470 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1471 * vlc_player_GetTrackAt())
1472 * @param order if not null, the order of the vout
1473 * @return a valid vout or NULL (if the track is disabled, it it's not a video
1474 * or spu track, or if the vout failed to start)
1476 VLC_API vout_thread_t *
1477 vlc_player_GetEsIdVout(vlc_player_t *player, vlc_es_id_t *es_id,
1478 enum vlc_vout_order *order);
1481 * Get the ES identifier of a video output
1483 * @warning A same vout can be associated with multiple ES during the lifetime
1484 * of the player. The information returned by this function becomes invalid
1485 * when the player is unlocked. The returned es_id doesn't need to be released,
1486 * but must be held with vlc_es_id_Hold() if it accessed after the player is
1487 * unlocked.
1489 * @param player locked player instance
1490 * @param vout vout (can't be NULL)
1491 * @return a valid ES identifier or NULL (if the vout is stopped)
1493 VLC_API vlc_es_id_t *
1494 vlc_player_GetEsIdFromVout(vlc_player_t *player, vout_thread_t *vout);
1497 * Helper to get the selected track from an ES category
1499 * @warning The player can have more than one selected track for a same ES
1500 * category. This function will only return the first selected one. Use
1501 * vlc_player_GetTrackAt() and vlc_player_GetTrackCount() to iterate through
1502 * several selected tracks.
1504 static inline const struct vlc_player_track *
1505 vlc_player_GetSelectedTrack(vlc_player_t *player, enum es_format_category_e cat)
1507 size_t count = vlc_player_GetTrackCount(player, cat);
1508 for (size_t i = 0; i < count; ++i)
1510 const struct vlc_player_track *track =
1511 vlc_player_GetTrackAt(player, cat, i);
1512 assert(track);
1513 if (track->selected)
1514 return track;
1516 return NULL;
1520 * Select tracks by their string identifier
1522 * This function can be used pre-select a list of tracks before starting the
1523 * player. It has only effect for the current media. It can also be used when
1524 * the player is already started.
1526 * 'str_ids' can contain more than one track id, delimited with ','. "" or any
1527 * invalid track id will cause the player to unselect all tracks of that
1528 * category. NULL will disable the preference for newer tracks without
1529 * unselecting any current tracks.
1531 * Example:
1532 * - (VIDEO_ES, "video/1,video/2") will select these 2 video tracks. If there
1533 * is only one video track with the id "video/0", no tracks will be selected.
1534 * - (SPU_ES, "${slave_url_md5sum}/spu/0) will select one spu added by an input
1535 * slave with the corresponding url.
1537 * @note The string identifier of a track can be found via vlc_es_id_GetStrId().
1539 * @param player locked player instance
1540 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1541 * @param str_ids list of string identifier or NULL
1543 VLC_API void
1544 vlc_player_SelectTracksByStringIds(vlc_player_t *player,
1545 enum es_format_category_e cat,
1546 const char *str_ids);
1549 * Select a track from an ES identifier
1551 * @note A successful call will trigger the
1552 * vlc_player_cbs.on_track_selection_changed event.
1554 * @param player locked player instance
1555 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1556 * vlc_player_GetTrackAt())
1557 * @param policy exclusive or simultaneous
1558 * @return the number of track selected for es_id category
1560 VLC_API unsigned
1561 vlc_player_SelectEsId(vlc_player_t *player, vlc_es_id_t *es_id,
1562 enum vlc_player_select_policy policy);
1566 * Helper to select a track
1568 static inline unsigned
1569 vlc_player_SelectTrack(vlc_player_t *player,
1570 const struct vlc_player_track *track,
1571 enum vlc_player_select_policy policy)
1573 return vlc_player_SelectEsId(player, track->es_id, policy);
1577 * Select multiple tracks from a list of ES identifiers.
1579 * Any tracks of the category, not referenced in the list will be unselected.
1581 * @warning there is no guarantee all requested tracks will be selected. The
1582 * behaviour is undefined if the list is not null-terminated.
1584 * @note A successful call will trigger the
1585 * vlc_player_cbs.on_track_selection_changed event for each track that has
1586 * its selection state changed.
1588 * @see VLC_PLAYER_SELECT_SIMULTANEOUS
1590 * @param player locked player instance
1591 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1592 * @param es_id_list a null-terminated list of ES identifiers. es_ids not
1593 * corresponding to the category will be ignored.
1594 * (ES IDs can be retrieved from vlc_player_cbs.on_track_list_changed or
1595 * vlc_player_GetTrackAt())
1596 * @return the number of track selected for that category
1598 VLC_API unsigned
1599 vlc_player_SelectEsIdList(vlc_player_t *player,
1600 enum es_format_category_e cat,
1601 vlc_es_id_t *const es_id_list[]);
1604 * Select the next track
1606 * If the last track is already selected, a call to this function will disable
1607 * this last track. And a second call will select the first track.
1609 * @warning This function has no effects if there are several tracks selected
1610 * for a same category. Therefore the default policy is
1611 * VLC_PLAYER_SELECT_EXCLUSIVE.
1613 * @param player locked player instance
1614 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1616 VLC_API void
1617 vlc_player_SelectNextTrack(vlc_player_t *player,
1618 enum es_format_category_e cat);
1621 * Select the Previous track
1623 * If the first track is already selected, a call to this function will disable
1624 * this first track. And a second call will select the last track.
1626 * @warning This function has no effects if there are several tracks selected
1627 * for a same category. Therefore the default policy is
1628 * VLC_PLAYER_SELECT_EXCLUSIVE.
1630 * @param player locked player instance
1631 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1633 VLC_API void
1634 vlc_player_SelectPrevTrack(vlc_player_t *player,
1635 enum es_format_category_e cat);
1638 * Unselect a track from an ES identifier
1640 * @warning Other tracks of the same category won't be touched.
1642 * @note A successful call will trigger the
1643 * vlc_player_cbs.on_track_selection_changed event.
1645 * @param player locked player instance
1646 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1647 * vlc_player_GetTrackAt())
1649 VLC_API void
1650 vlc_player_UnselectEsId(vlc_player_t *player, vlc_es_id_t *es_id);
1653 * Helper to unselect a track
1655 static inline void
1656 vlc_player_UnselectTrack(vlc_player_t *player,
1657 const struct vlc_player_track *track)
1659 vlc_player_UnselectEsId(player, track->es_id);
1663 * Helper to unselect all tracks from an ES category
1665 static inline void
1666 vlc_player_UnselectTrackCategory(vlc_player_t *player,
1667 enum es_format_category_e cat)
1669 size_t count = vlc_player_GetTrackCount(player, cat);
1670 for (size_t i = 0; i < count; ++i)
1672 const struct vlc_player_track *track =
1673 vlc_player_GetTrackAt(player, cat, i);
1674 assert(track);
1675 if (track->selected)
1676 vlc_player_UnselectTrack(player, track);
1681 * Restart a track from an ES identifier
1683 * @note A successful call will trigger the
1684 * vlc_player_cbs.on_track_selection_changed event.
1686 * @param player locked player instance
1687 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1688 * vlc_player_GetTrackAt())
1690 VLC_API void
1691 vlc_player_RestartEsId(vlc_player_t *player, vlc_es_id_t *es_id);
1694 * Helper to restart a track
1696 static inline void
1697 vlc_player_RestartTrack(vlc_player_t *player,
1698 const struct vlc_player_track *track)
1700 vlc_player_RestartEsId(player, track->es_id);
1704 * Helper to restart all selected tracks from an ES category
1706 static inline void
1707 vlc_player_RestartTrackCategory(vlc_player_t *player,
1708 enum es_format_category_e cat)
1710 size_t count = vlc_player_GetTrackCount(player, cat);
1711 for (size_t i = 0; i < count; ++i)
1713 const struct vlc_player_track *track =
1714 vlc_player_GetTrackAt(player, cat, i);
1715 assert(track);
1716 if (track->selected)
1717 vlc_player_RestartTrack(player, track);
1722 * Select the language for an ES category
1724 * @warning The language will only be set for all future played media.
1726 * @param player locked player instance
1727 * @param cat AUDIO_ES or SPU_ES
1728 * @param lang comma separated, two or three letters country code, 'any' as a
1729 * fallback or NULL to reset the default state
1731 VLC_API void
1732 vlc_player_SelectCategoryLanguage(vlc_player_t *player,
1733 enum es_format_category_e cat,
1734 const char *lang);
1737 * Get the language of an ES category
1739 * @warning This only reflects the change made by
1740 * vlc_player_SelectCategoryLanguage(). The current playing track doesn't
1741 * necessarily correspond to the returned language.
1743 * @see vlc_player_SelectCategoryLanguage
1745 * @param player locked player instance
1746 * @param cat AUDIO_ES or SPU_ES
1747 * @return valid language or NULL, need to be freed
1749 VLC_API char *
1750 vlc_player_GetCategoryLanguage(vlc_player_t *player,
1751 enum es_format_category_e cat);
1754 * Helper to select the audio language
1756 static inline void
1757 vlc_player_SelectAudioLanguage(vlc_player_t *player, const char *lang)
1759 vlc_player_SelectCategoryLanguage(player, AUDIO_ES, lang);
1763 * Helper to select the subtitle language
1765 static inline void
1766 vlc_player_SelectSubtitleLanguage(vlc_player_t *player, const char *lang)
1768 vlc_player_SelectCategoryLanguage(player, SPU_ES, lang);
1772 * Enable or disable a track category
1774 * If a track category is disabled, the player won't select any tracks of this
1775 * category automatically or via an user action (vlc_player_SelectTrack()).
1777 * @param player locked player instance
1778 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1779 * @param enabled true to enable
1781 VLC_API void
1782 vlc_player_SetTrackCategoryEnabled(vlc_player_t *player,
1783 enum es_format_category_e cat, bool enabled);
1786 * Check if a track category is enabled
1788 * @param player locked player instance
1789 * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
1791 VLC_API bool
1792 vlc_player_IsTrackCategoryEnabled(vlc_player_t *player,
1793 enum es_format_category_e cat);
1796 * Helper to enable or disable video tracks
1798 static inline void
1799 vlc_player_SetVideoEnabled(vlc_player_t *player, bool enabled)
1801 vlc_player_SetTrackCategoryEnabled(player, VIDEO_ES, enabled);
1805 * Helper to check if video tracks are enabled
1807 static inline bool
1808 vlc_player_IsVideoEnabled(vlc_player_t *player)
1810 return vlc_player_IsTrackCategoryEnabled(player, VIDEO_ES);
1814 * Helper to enable or disable audio tracks
1816 static inline void
1817 vlc_player_SetAudioEnabled(vlc_player_t *player, bool enabled)
1819 vlc_player_SetTrackCategoryEnabled(player, AUDIO_ES, enabled);
1823 * Helper to check if audio tracks are enabled
1825 static inline bool
1826 vlc_player_IsAudioEnabled(vlc_player_t *player)
1828 return vlc_player_IsTrackCategoryEnabled(player, AUDIO_ES);
1832 * Helper to enable or disable subtitle tracks
1834 static inline void
1835 vlc_player_SetSubtitleEnabled(vlc_player_t *player, bool enabled)
1837 vlc_player_SetTrackCategoryEnabled(player, SPU_ES, enabled);
1841 * Helper to check if subtitle tracks are enabled
1843 static inline bool
1844 vlc_player_IsSubtitleEnabled(vlc_player_t *player)
1846 return vlc_player_IsTrackCategoryEnabled(player, SPU_ES);
1850 * Helper to toggle subtitles
1852 static inline void
1853 vlc_player_ToggleSubtitle(vlc_player_t *player)
1855 bool enabled = !vlc_player_IsSubtitleEnabled(player);
1856 vlc_player_SetSubtitleEnabled(player, enabled);
1860 * Set the subtitle text scaling factor
1862 * @note This function have an effect only if the subtitle track is a text type.
1864 * @param player locked player instance
1865 * @param scale factor in the range [10;500] (default: 100)
1867 VLC_API void
1868 vlc_player_SetSubtitleTextScale(vlc_player_t *player, unsigned scale);
1871 * Get the subtitle text scaling factor
1873 * @param player locked player instance
1874 * @return scale factor
1876 VLC_API unsigned
1877 vlc_player_GetSubtitleTextScale(vlc_player_t *player);
1879 /** @} vlc_player__tracks */
1882 * @defgroup vlc_player__tracks_sync Tracks synchronisation (delay)
1883 * @{
1887 * Get the delay of an ES category for the current media
1889 * @see vlc_player_cbs.on_category_delay_changed
1891 * @param player locked player instance
1892 * @param cat AUDIO_ES or SPU_ES (VIDEO_ES not supported yet)
1893 * @return a valid delay or 0
1895 VLC_API vlc_tick_t
1896 vlc_player_GetCategoryDelay(vlc_player_t *player, enum es_format_category_e cat);
1899 * Set the delay of one category for the current media
1901 * @note A successful call will trigger the
1902 * vlc_player_cbs.on_category_delay_changed event.
1904 * @warning This has no effect on tracks where the delay was set by
1905 * vlc_player_SetEsIdDelay()
1907 * @param player locked player instance
1908 * @param cat AUDIO_ES or SPU_ES (VIDEO_ES not supported yet)
1909 * @param delay a valid time
1910 * @param whence absolute or relative
1911 * @return VLC_SUCCESS or VLC_EGENERIC if the category is not handled
1913 VLC_API int
1914 vlc_player_SetCategoryDelay(vlc_player_t *player, enum es_format_category_e cat,
1915 vlc_tick_t delay, enum vlc_player_whence whence);
1918 * Get the delay of a track
1920 * @see vlc_player_cbs.on_track_delay_changed
1922 * @param player locked player instance
1923 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1924 * vlc_player_GetTrackAt())
1925 * @return a valid delay or INT64_MAX is no delay is set for this track
1927 VLC_API vlc_tick_t
1928 vlc_player_GetEsIdDelay(vlc_player_t *player, vlc_es_id_t *es_id);
1931 * Set the delay of one track
1933 * @note A successful call will trigger the
1934 * vlc_player_cbs.on_track_delay_changed event.
1936 * @warning Setting the delay of one specific track will override previous and
1937 * future changes of delay made by vlc_player_SetCategoryDelay()
1939 * @param player locked player instance
1940 * @param id an ES ID (retrieved from vlc_player_cbs.on_track_list_changed or
1941 * vlc_player_GetTrackAt())
1942 * @param delay a valid time or INT64_MAX to use default category delay
1943 * @param whence absolute or relative
1944 * @return VLC_SUCCESS or VLC_EGENERIC if the category of the es_id is not
1945 * handled (VIDEO_ES not supported yet)
1947 VLC_API int
1948 vlc_player_SetEsIdDelay(vlc_player_t *player, vlc_es_id_t *es_id,
1949 vlc_tick_t delay, enum vlc_player_whence whence);
1952 * Helper to get the audio delay
1954 static inline vlc_tick_t
1955 vlc_player_GetAudioDelay(vlc_player_t *player)
1957 return vlc_player_GetCategoryDelay(player, AUDIO_ES);
1961 * Helper to set the audio delay
1963 static inline void
1964 vlc_player_SetAudioDelay(vlc_player_t *player, vlc_tick_t delay,
1965 enum vlc_player_whence whence)
1968 vlc_player_SetCategoryDelay(player, AUDIO_ES, delay, whence);
1972 * Helper to get the subtitle delay
1974 static inline vlc_tick_t
1975 vlc_player_GetSubtitleDelay(vlc_player_t *player)
1977 return vlc_player_GetCategoryDelay(player, SPU_ES);
1981 * Helper to set the subtitle delay
1983 static inline void
1984 vlc_player_SetSubtitleDelay(vlc_player_t *player, vlc_tick_t delay,
1985 enum vlc_player_whence whence)
1987 vlc_player_SetCategoryDelay(player, SPU_ES, delay, whence);
1991 * Set the associated subtitle FPS
1993 * In order to correct the rate of the associated media according to this FPS
1994 * and the media video FPS.
1996 * @note A successful call will trigger the
1997 * vlc_player_cbs.on_associated_subs_fps_changed event.
1999 * @warning this function will change the rate of all external subtitle files
2000 * associated with the current media.
2002 * @param player locked player instance
2003 * @param fps FPS of the subtitle file
2005 VLC_API void
2006 vlc_player_SetAssociatedSubsFPS(vlc_player_t *player, float fps);
2009 * Get the associated subtitle FPS
2011 * @param player locked player instance
2012 * @return fps
2014 VLC_API float
2015 vlc_player_GetAssociatedSubsFPS(vlc_player_t *player);
2017 /** @} vlc_player__tracks_sync */
2020 * @defgroup vlc_player__teletext Teletext control
2021 * @{
2025 * Check if the media has a teletext menu
2027 * @see vlc_player_cbs.on_teletext_menu_changed
2029 * @param player locked player instance
2030 * @return true if the media has a teletext menu
2032 VLC_API bool
2033 vlc_player_HasTeletextMenu(vlc_player_t *player);
2036 * Enable or disable teletext
2038 * This function has an effect only if the player has a teletext menu.
2040 * @note A successful call will trigger the
2041 * vlc_player_cbs.on_teletext_enabled_changed event.
2043 * @param player locked player instance
2044 * @param enabled true to enable
2046 VLC_API void
2047 vlc_player_SetTeletextEnabled(vlc_player_t *player, bool enabled);
2050 * Check if teletext is enabled
2052 * @see vlc_player_cbs.on_teletext_enabled_changed
2054 * @param player locked player instance
2056 VLC_API bool
2057 vlc_player_IsTeletextEnabled(vlc_player_t *player);
2060 * Select a teletext page or do an action from a key
2062 * This function has an effect only if the player has a teletext menu.
2064 * @note Page keys can be the following: @ref VLC_PLAYER_TELETEXT_KEY_RED,
2065 * @ref VLC_PLAYER_TELETEXT_KEY_GREEN, @ref VLC_PLAYER_TELETEXT_KEY_YELLOW,
2066 * @ref VLC_PLAYER_TELETEXT_KEY_BLUE or @ref VLC_PLAYER_TELETEXT_KEY_INDEX.
2068 * @note A successful call will trigger the
2069 * vlc_player_cbs.on_teletext_page_changed event.
2071 * @param player locked player instance
2072 * @param page a page in the range ]0;888] or a valid key
2074 VLC_API void
2075 vlc_player_SelectTeletextPage(vlc_player_t *player, unsigned page);
2078 * Get the current teletext page
2080 * @see vlc_player_cbs.on_teletext_page_changed
2082 * @param player locked player instance
2084 VLC_API unsigned
2085 vlc_player_GetTeletextPage(vlc_player_t *player);
2088 * Enable or disable teletext transparency
2090 * This function has an effect only if the player has a teletext menu.
2092 * @note A successful call will trigger the
2093 * vlc_player_cbs.on_teletext_transparency_changed event.
2095 * @param player locked player instance
2096 * @param enabled true to enable
2098 VLC_API void
2099 vlc_player_SetTeletextTransparency(vlc_player_t *player, bool enabled);
2102 * Check if teletext is transparent
2104 * @param player locked player instance
2106 VLC_API bool
2107 vlc_player_IsTeletextTransparent(vlc_player_t *player);
2109 /** @} vlc_player__teletext */
2112 * @defgroup vlc_player__renderer External renderer control
2113 * @{
2117 * Set the renderer
2119 * Valid for the current media and all future ones.
2121 * @note A successful call will trigger the vlc_player_cbs.on_renderer_changed
2122 * event.
2124 * @param player locked player instance
2125 * @param renderer a valid renderer item or NULL (to disable it), the item will
2126 * be held by the player
2128 VLC_API void
2129 vlc_player_SetRenderer(vlc_player_t *player, vlc_renderer_item_t *renderer);
2132 * Get the renderer
2134 * @see vlc_player_cbs.on_renderer_changed
2136 * @param player locked player instance
2137 * @return the renderer item set by vlc_player_SetRenderer()
2139 VLC_API vlc_renderer_item_t *
2140 vlc_player_GetRenderer(vlc_player_t *player);
2142 /** @} vlc_player__renderer */
2145 * @defgroup vlc_player__metadata Metadata callbacks
2146 * @{
2150 * Player metadata listener opaque structure.
2152 * This opaque structure is returned by vlc_player_AddMetadataListener() and
2153 * can be used to remove the listener via
2154 * vlc_player_RemoveMetadataListener().
2156 typedef struct vlc_player_metadata_listener_id vlc_player_metadata_listener_id;
2159 * Player metadata option
2161 enum vlc_player_metadata_option
2164 * Ask for momentary loudness measurement
2166 * Very low CPU usage.
2167 * @see vlc_player_metadata_cbs.on_momentary_loudness_changed
2169 VLC_PLAYER_METADATA_LOUDNESS_MOMENTARY,
2172 * Ask for all loudness measurements
2174 * High CPU usage.
2175 * @see vlc_player_metadata_cbs.on_loudness_changed
2177 VLC_PLAYER_METADATA_LOUDNESS_FULL,
2181 * Player metadata callbacks
2183 * Can be registered with vlc_player_AddMetadataListener().
2185 * @warning To avoid deadlocks, users should never call vlc_player_t functions
2186 * from these callbacks.
2188 union vlc_player_metadata_cbs
2191 * Called when the momentary loudness measurement have changed
2193 * @see VLC_PLAYER_METADATA_LOUDNESS_MOMEMTARY
2195 * Only sent when audio is playing, approximately every 400ms (but can be
2196 * higher, depending on the input sample size).
2198 * @param date Absolute date of the measurement. It is most likely in the
2199 * future (0 to 2seconds) depending on the audio output buffer size.
2200 * @param momentary_loudness Momentary loudness
2201 * @param data opaque pointer set by vlc_player_AddMetadataListener()
2203 void (*on_momentary_loudness_changed)(vlc_tick_t date,
2204 double momentary_loudness,
2205 void *data);
2208 * Called when loudness measurements have changed
2210 * @see VLC_PLAYER_METADATA_LOUDNESS_FULL
2212 * Only sent when audio is playing, approximately every 400ms (but can be
2213 * higher, depending on the input sample size).
2215 * @param date Absolute date of the measurement. It is most likely in the
2216 * future (0 to 2seconds) depending on the audio output buffer size.
2217 * @param loudness loudness measurement
2218 * @param data opaque pointer set by vlc_player_AddMetadataListener()
2220 void (*on_loudness_changed)(vlc_tick_t date,
2221 const struct vlc_audio_loudness *loudness,
2222 void *data);
2226 * Add a metadata listener
2228 * @note Every registered loudness meter need to be removed by the caller with
2229 * vlc_player_RemoveMetadataListener().
2231 * @param player locked player instance
2232 * @param cbs pointer to a vlc_player_metadata_cbs union, the
2233 * structure must be valid during the lifetime of the player
2234 * @param cbs_data opaque pointer used by the callbacks
2235 * @return a valid listener id, or NULL in case of error (plugin missing)
2237 VLC_API vlc_player_metadata_listener_id *
2238 vlc_player_AddMetadataListener(vlc_player_t *player,
2239 enum vlc_player_metadata_option option,
2240 const union vlc_player_metadata_cbs *cbs,
2241 void *cbs_data);
2244 * Remove a metadata listener
2246 * @param player player instance
2247 * @param listener_id listener id returned by vlc_player_AddMetadataListener()
2249 VLC_API void
2250 vlc_player_RemoveMetadataListener(vlc_player_t *player,
2251 vlc_player_metadata_listener_id *listener_id);
2254 /** @} vlc_player__metadata */
2257 * @defgroup vlc_player__aout Audio output control
2258 * @{
2262 * Player aout listener opaque structure.
2264 * This opaque structure is returned by vlc_player_aout_AddListener() and can
2265 * be used to remove the listener via vlc_player_aout_RemoveListener().
2267 typedef struct vlc_player_aout_listener_id vlc_player_aout_listener_id;
2270 * Player aout callbacks
2272 * Can be registered with vlc_player_aout_AddListener().
2274 * @warning To avoid deadlocks, users should never call audio_output_t and
2275 * vlc_player_t functions from these callbacks.
2277 struct vlc_player_aout_cbs
2280 * Called when the volume has changed
2282 * @see vlc_player_aout_SetVolume()
2284 * @param aout the main aout of the player
2285 * @param new_volume volume in the range [0;2.f]
2286 * @param data opaque pointer set by vlc_player_aout_AddListener()
2288 void (*on_volume_changed)(audio_output_t *aout, float new_volume,
2289 void *data);
2292 * Called when the mute state has changed
2294 * @see vlc_player_aout_Mute()
2296 * @param aout the main aout of the player
2297 * @param new_mute true if muted
2298 * @param data opaque pointer set by vlc_player_aout_AddListener()
2300 void (*on_mute_changed)(audio_output_t *aout, bool new_muted,
2301 void *data);
2304 * Called when the audio device has changed
2306 * @param aout the main aout of the player
2307 * @param device the device name
2308 * @param data opaque pointer set by vlc_player_aout_AddListener()
2310 void (*on_device_changed)(audio_output_t *aout, const char *device,
2311 void *data);
2315 * Get the audio output
2317 * @warning The returned pointer must be released with aout_Release().
2319 * @param player player instance
2320 * @return a valid audio_output_t * or NULL (if there is no aouts)
2322 VLC_API audio_output_t *
2323 vlc_player_aout_Hold(vlc_player_t *player);
2326 * Reset the main audio output
2328 * @warning The main aout can only by reset if it is not currently used by any
2329 * decoders (before any play).
2331 * @param player player instance
2333 VLC_API void
2334 vlc_player_aout_Reset(vlc_player_t *player);
2337 * Add a listener callback for audio output events
2339 * @note The player instance doesn't need to be locked for vlc_player_aout_*()
2340 * functions.
2341 * @note Every registered callbacks need to be removed by the caller with
2342 * vlc_player_aout_RemoveListener().
2344 * @param player player instance
2345 * @param cbs pointer to a vlc_player_aout_cbs structure, the structure must be
2346 * valid during the lifetime of the player
2347 * @param cbs_data opaque pointer used by the callbacks
2348 * @return a valid listener id, or NULL in case of allocation error
2350 VLC_API vlc_player_aout_listener_id *
2351 vlc_player_aout_AddListener(vlc_player_t *player,
2352 const struct vlc_player_aout_cbs *cbs,
2353 void *cbs_data);
2356 * Remove a aout listener callback
2358 * @param player player instance
2359 * @param listener_id listener id returned by vlc_player_aout_AddListener()
2361 VLC_API void
2362 vlc_player_aout_RemoveListener(vlc_player_t *player,
2363 vlc_player_aout_listener_id *listener_id);
2366 * Get the audio volume
2368 * @note The player instance doesn't need to be locked for vlc_player_aout_*()
2369 * functions.
2371 * @see vlc_player_aout_cbs.on_volume_changed
2373 * @param player player instance
2374 * @return volume in the range [0;2.f] or -1.f if there is no audio outputs
2375 * (independent of mute)
2377 VLC_API float
2378 vlc_player_aout_GetVolume(vlc_player_t *player);
2381 * Set the audio volume
2383 * @note The player instance doesn't need to be locked for vlc_player_aout_*()
2384 * functions.
2386 * @note A successful call will trigger the
2387 * vlc_player_vout_cbs.on_volume_changed event.
2389 * @param player player instance
2390 * @param volume volume in the range [0;2.f]
2391 * @return VLC_SUCCESS or VLC_EGENERIC if there is no audio outputs
2393 VLC_API int
2394 vlc_player_aout_SetVolume(vlc_player_t *player, float volume);
2397 * Increment the audio volume
2399 * @see vlc_player_aout_SetVolume()
2401 * @param player player instance
2402 * @param steps number of "volume-step"
2403 * @param result pointer to store the resulting volume (can be NULL)
2404 * @return VLC_SUCCESS or VLC_EGENERIC if there is no audio outputs
2406 VLC_API int
2407 vlc_player_aout_IncrementVolume(vlc_player_t *player, int steps, float *result);
2410 * Helper to decrement the audio volume
2412 static inline int
2413 vlc_player_aout_DecrementVolume(vlc_player_t *player, int steps, float *result)
2415 return vlc_player_aout_IncrementVolume(player, -steps, result);
2419 * Check if the audio output is muted
2421 * @note The player instance doesn't need to be locked for vlc_player_aout_*()
2422 * functions.
2424 * @see vlc_player_aout_cbs.on_mute_changed
2426 * @param player player instance
2427 * @return 0 if not muted, 1 if muted, -1 if there is no audio outputs
2429 VLC_API int
2430 vlc_player_aout_IsMuted(vlc_player_t *player);
2433 * Mute or unmute the audio output
2435 * @note The player instance doesn't need to be locked for vlc_player_aout_*()
2436 * functions.
2438 * @note A successful call will trigger the
2439 * vlc_player_aout_cbs.on_mute_changed event.
2441 * @param player player instance
2442 * @param mute true to mute
2443 * @return VLC_SUCCESS or VLC_EGENERIC if there is no audio outputs
2445 VLC_API int
2446 vlc_player_aout_Mute(vlc_player_t *player, bool mute);
2449 * Helper to toggle the mute state
2451 static inline int
2452 vlc_player_aout_ToggleMute(vlc_player_t *player)
2454 return vlc_player_aout_Mute(player,
2455 !vlc_player_aout_IsMuted(player));
2459 * Enable or disable an audio filter
2461 * @see aout_EnableFilter()
2463 * @return VLC_SUCCESS or VLC_EGENERIC if there is no audio outputs
2465 VLC_API int
2466 vlc_player_aout_EnableFilter(vlc_player_t *player, const char *name, bool add);
2468 /** @} vlc_player__aout */
2471 * @defgroup vlc_player__vout Video output control
2472 * @{
2476 * Player vout listener opaque structure.
2478 * This opaque structure is returned by vlc_player_vout_AddListener() and can
2479 * be used to remove the listener via vlc_player_vout_RemoveListener().
2481 typedef struct vlc_player_vout_listener_id vlc_player_vout_listener_id;
2484 * action of vlc_player_cbs.on_vout_changed callback
2486 enum vlc_player_vout_action
2488 VLC_PLAYER_VOUT_STARTED,
2489 VLC_PLAYER_VOUT_STOPPED,
2493 * Player vout callbacks
2495 * Can be registered with vlc_player_vout_AddListener().
2497 * @note The state changed from the callbacks can be either applied on the
2498 * player (and all future video outputs), or on a specified video output. The
2499 * state is applied on the player when the vout argument is NULL.
2501 * @warning To avoid deadlocks, users should never call vout_thread_t and
2502 * vlc_player_t functions from these callbacks.
2504 struct vlc_player_vout_cbs
2507 * Called when the player and/or vout fullscreen state has changed
2509 * @see vlc_player_vout_SetFullscreen()
2511 * @param vout cf. vlc_player_vout_cbs note
2512 * @param enabled true when fullscreen is enabled
2513 * @param data opaque pointer set by vlc_player_vout_AddListener()
2515 void (*on_fullscreen_changed)(vout_thread_t *vout, bool enabled,
2516 void *data);
2519 * Called when the player and/or vout wallpaper mode has changed
2521 * @see vlc_player_vout_SetWallpaperModeEnabled()
2523 * @param vout cf. vlc_player_vout_cbs note
2524 * @param enabled true when wallpaper mode is enabled
2525 * @param data opaque pointer set by vlc_player_vout_AddListener()
2527 void (*on_wallpaper_mode_changed)(vout_thread_t *vout, bool enabled,
2528 void *data);
2533 * Get and hold the main video output
2535 * @warning the returned vout_thread_t * must be released with vout_Release().
2536 * @see vlc_players_cbs.on_vout_changed
2538 * @note The player is guaranteed to always hold one valid vout. Only vout
2539 * variables can be changed from this instance. The vout returned before
2540 * playback is not necessarily the same one that will be used for playback.
2542 * @param player player instance
2543 * @return a valid vout_thread_t * or NULL, cf. warning
2545 VLC_API vout_thread_t *
2546 vlc_player_vout_Hold(vlc_player_t *player);
2549 * Get and hold the list of video output
2551 * @warning All vout_thread_t * element of the array must be released with
2552 * vout_Release(). The returned array must be freed.
2554 * @see vlc_players_cbs.on_vout_changed
2556 * @param player player instance
2557 * @param count valid pointer to store the array count
2558 * @return a array of vout_thread_t * or NULL, cf. warning
2560 VLC_API vout_thread_t **
2561 vlc_player_vout_HoldAll(vlc_player_t *player, size_t *count);
2564 * Add a listener callback for video output events
2566 * @note The player instance doesn't need to be locked for vlc_player_vout_*()
2567 * functions.
2568 * @note Every registered callbacks need to be removed by the caller with
2569 * vlc_player_vout_RemoveListener().
2571 * @param player player instance
2572 * @param cbs pointer to a vlc_player_vout_cbs structure, the structure must be
2573 * valid during the lifetime of the player
2574 * @param cbs_data opaque pointer used by the callbacks
2575 * @return a valid listener id, or NULL in case of allocation error
2577 VLC_API vlc_player_vout_listener_id *
2578 vlc_player_vout_AddListener(vlc_player_t *player,
2579 const struct vlc_player_vout_cbs *cbs,
2580 void *cbs_data);
2583 * Remove a vout listener callback
2585 * @param player player instance
2586 * @param listener_id listener id returned by vlc_player_vout_AddListener()
2588 VLC_API void
2589 vlc_player_vout_RemoveListener(vlc_player_t *player,
2590 vlc_player_vout_listener_id *listener_id);
2593 * Check if the player is fullscreen
2595 * @warning The fullscreen state of the player and all vouts can be different.
2597 * @note The player instance doesn't need to be locked for vlc_player_vout_*()
2598 * functions.
2600 * @see vlc_player_vout_cbs.on_fullscreen_changed
2602 * @param player player instance
2603 * @return true if the player is fullscreen
2605 VLC_API bool
2606 vlc_player_vout_IsFullscreen(vlc_player_t *player);
2609 * Enable or disable the player fullscreen state
2611 * This will have an effect on all current and future vouts.
2613 * @note The player instance doesn't need to be locked for vlc_player_vout_*()
2614 * functions.
2615 * @note A successful call will trigger the
2616 * vlc_player_vout_cbs.on_fullscreen_changed event.
2618 * @param player player instance
2619 * @param enabled true to enable fullscreen
2621 VLC_API void
2622 vlc_player_vout_SetFullscreen(vlc_player_t *player, bool enabled);
2625 * Helper to toggle the player fullscreen state
2627 static inline void
2628 vlc_player_vout_ToggleFullscreen(vlc_player_t *player)
2630 vlc_player_vout_SetFullscreen(player,
2631 !vlc_player_vout_IsFullscreen(player));
2635 * Check if the player has wallpaper-mode enaled
2637 * @warning The wallpaper-mode state of the player and all vouts can be
2638 * different.
2640 * @note The player instance doesn't need to be locked for vlc_player_vout_*()
2641 * functions.
2643 * @see vlc_player_vout_cbs.on_wallpaper_mode_changed
2645 * @param player player instance
2646 * @return true if the player is fullscreen
2648 VLC_API bool
2649 vlc_player_vout_IsWallpaperModeEnabled(vlc_player_t *player);
2652 * Enable or disable the player wallpaper-mode
2654 * This will have an effect on all current and future vouts.
2656 * @note The player instance doesn't need to be locked for vlc_player_vout_*()
2657 * functions.
2658 * @note A successful call will trigger the
2659 * vlc_player_vout_cbs.on_wallpaper_mode_changed event.
2661 * @param player player instance
2662 * @param enabled true to enable wallpaper-mode
2664 VLC_API void
2665 vlc_player_vout_SetWallpaperModeEnabled(vlc_player_t *player, bool enabled);
2668 * Helper to toggle the player wallpaper-mode state
2670 static inline void
2671 vlc_player_vout_ToggleWallpaperMode(vlc_player_t *player)
2673 vlc_player_vout_SetWallpaperModeEnabled(player,
2674 !vlc_player_vout_IsWallpaperModeEnabled(player));
2678 * Take a snapshot on all vouts
2680 * @param player player instance
2682 VLC_API void
2683 vlc_player_vout_Snapshot(vlc_player_t *player);
2686 * Display an OSD message on all vouts
2688 * @param player player instance
2689 * @param fmt format string
2691 VLC_API void
2692 vlc_player_osd_Message(vlc_player_t *player, const char *fmt, ...);
2694 /** @} vlc_player__vout */
2697 * @defgroup vlc_player__events Player events
2698 * @{
2702 * Player listener opaque structure.
2704 * This opaque structure is returned by vlc_player_AddListener() and can be
2705 * used to remove the listener via vlc_player_RemoveListener().
2707 typedef struct vlc_player_listener_id vlc_player_listener_id;
2710 * Action of vlc_player_cbs.on_track_list_changed,
2711 * vlc_player_cbs.on_program_list_changed callbacks
2713 enum vlc_player_list_action
2715 VLC_PLAYER_LIST_ADDED,
2716 VLC_PLAYER_LIST_REMOVED,
2717 VLC_PLAYER_LIST_UPDATED,
2721 * Player callbacks
2723 * Can be registered with vlc_player_AddListener().
2725 * All callbacks are called with the player locked (cf. vlc_player_Lock()) and
2726 * from any threads (and even synchronously from a vlc_player function in some
2727 * cases). It is safe to call any vlc_player functions from these callbacks
2728 * except vlc_player_Delete().
2730 * @warning To avoid deadlocks, users should never call vlc_player functions
2731 * with an external mutex locked and lock this same mutex from a player
2732 * callback.
2734 struct vlc_player_cbs
2737 * Called when the current media has changed
2739 * @note This can be called from the PLAYING state (when the player plays
2740 * the next media internally) or from the STOPPED state (from
2741 * vlc_player_SetCurrentMedia() or from an internal transition).
2743 * @see vlc_player_SetCurrentMedia()
2744 * @see vlc_player_InvalidateNextMedia()
2746 * @param player locked player instance
2747 * @param new_media new media currently played or NULL (when there is no
2748 * more media to play)
2749 * @param data opaque pointer set by vlc_player_AddListener()
2751 void (*on_current_media_changed)(vlc_player_t *player,
2752 input_item_t *new_media, void *data);
2755 * Called when the player state has changed
2757 * @see vlc_player_state
2759 * @param player locked player instance
2760 * @param new_state new player state
2761 * @param data opaque pointer set by vlc_player_AddListener()
2763 void (*on_state_changed)(vlc_player_t *player,
2764 enum vlc_player_state new_state, void *data);
2767 * Called when a media triggered an error
2769 * Can be called from any states. When it happens the player will stop
2770 * itself. It is safe to play an other media or event restart the player
2771 * (This will reset the error state).
2773 * @param player locked player instance
2774 * @param error player error
2775 * @param data opaque pointer set by vlc_player_AddListener()
2777 void (*on_error_changed)(vlc_player_t *player,
2778 enum vlc_player_error error, void *data);
2781 * Called when the player buffering (or cache) has changed
2783 * This event is always called with the 0 and 1 values before a playback
2784 * (in case of success). Values in between depends on the media type.
2786 * @param player locked player instance
2787 * @param new_buffering buffering in the range [0:1]
2788 * @param data opaque pointer set by vlc_player_AddListener()
2790 void (*on_buffering_changed)(vlc_player_t *player,
2791 float new_buffering, void *data);
2794 * Called when the player rate has changed
2796 * Triggered by vlc_player_ChangeRate(), not sent when the media starts
2797 * with the default rate (1.f)
2799 * @param player locked player instance
2800 * @param new_rate player
2801 * @param data opaque pointer set by vlc_player_AddListener()
2803 void (*on_rate_changed)(vlc_player_t *player,
2804 float new_rate, void *data);
2807 * Called when the media capabilities has changed
2809 * Always called when the media is opening. Can be called during playback.
2811 * @param player locked player instance
2812 * @param old_caps old player capabilities
2813 * @param new_caps new player capabilities
2814 * @param data opaque pointer set by vlc_player_AddListener()
2816 void (*on_capabilities_changed)(vlc_player_t *player,
2817 int old_caps, int new_caps, void *data);
2820 * Called when the player position has changed
2822 * @note A started and playing media doesn't have necessarily a valid time.
2824 * @param player locked player instance
2825 * @param new_time a valid time or VLC_TICK_INVALID
2826 * @param new_pos a valid position
2827 * @param data opaque pointer set by vlc_player_AddListener()
2829 void (*on_position_changed)(vlc_player_t *player,
2830 vlc_tick_t new_time, float new_pos, void *data);
2833 * Called when the media length has changed
2835 * May be called when the media is opening or during playback.
2837 * @note A started and playing media doesn't have necessarily a valid length.
2839 * @param player locked player instance
2840 * @param new_length a valid time or VLC_TICK_INVALID
2841 * @param data opaque pointer set by vlc_player_AddListener()
2843 void (*on_length_changed)(vlc_player_t *player,
2844 vlc_tick_t new_length, void *data);
2847 * Called when a track is added, removed, or updated
2849 * @note The track is only valid from this callback context. Users should
2850 * duplicate this track via vlc_player_track_Dup() if they want to use it
2851 * from an other context.
2853 * @param player locked player instance
2854 * @param action added, removed or updated
2855 * @param track valid track
2856 * @param data opaque pointer set by vlc_player_AddListener()
2858 void (*on_track_list_changed)(vlc_player_t *player,
2859 enum vlc_player_list_action action,
2860 const struct vlc_player_track *track, void *data);
2863 * Called when a new track is selected and/or unselected
2865 * @note This event can be called with both unselected_id and selected_id
2866 * valid. This mean that a new track is replacing the old one.
2868 * @param player locked player instance
2869 * @param unselected_id valid track id or NULL (when nothing is unselected)
2870 * @param selected_id valid track id or NULL (when nothing is selected)
2871 * @param data opaque pointer set by vlc_player_AddListener()
2873 void (*on_track_selection_changed)(vlc_player_t *player,
2874 vlc_es_id_t *unselected_id, vlc_es_id_t *selected_id, void *data);
2877 * Called when a track delay has changed
2879 * @param player locked player instance
2880 * @param es_id valid track id
2881 * @param delay a valid delay or INT64_MAX if the delay of this track is
2882 * canceled
2884 void (*on_track_delay_changed)(vlc_player_t *player,
2885 vlc_es_id_t *es_id, vlc_tick_t delay, void *data);
2888 * Called when a new program is added, removed or updated
2890 * @note The program is only valid from this callback context. Users should
2891 * duplicate this program via vlc_player_program_Dup() if they want to use
2892 * it from an other context.
2894 * @param player locked player instance
2895 * @param action added, removed or updated
2896 * @param prgm valid program
2897 * @param data opaque pointer set by vlc_player_AddListener()
2899 void (*on_program_list_changed)(vlc_player_t *player,
2900 enum vlc_player_list_action action,
2901 const struct vlc_player_program *prgm, void *data);
2904 * Called when a new program is selected and/or unselected
2906 * @note This event can be called with both unselected_id and selected_id
2907 * valid. This mean that a new program is replacing the old one.
2909 * @param player locked player instance
2910 * @param unselected_id valid program id or -1 (when nothing is unselected)
2911 * @param selected_id valid program id or -1 (when nothing is selected)
2912 * @param data opaque pointer set by vlc_player_AddListener()
2914 void (*on_program_selection_changed)(vlc_player_t *player,
2915 int unselected_id, int selected_id, void *data);
2918 * Called when the media titles has changed
2920 * This event is not called when the opening media doesn't have any titles.
2921 * This title list and all its elements are constant. If an element is to
2922 * be updated, a new list will be sent from this callback.
2924 * @note Users should hold this list with vlc_player_title_list_Hold() if
2925 * they want to use it from an other context.
2927 * @param player locked player instance
2928 * @param titles valid title list or NULL
2929 * @param data opaque pointer set by vlc_player_AddListener()
2931 void (*on_titles_changed)(vlc_player_t *player,
2932 vlc_player_title_list *titles, void *data);
2935 * Called when a new title is selected
2937 * There are no events when a title is unselected. Titles are automatically
2938 * unselected when the title list changes. Titles and indexes are always
2939 * valid inside the vlc_player_title_list sent by
2940 * vlc_player_cbs.on_titles_changed.
2942 * @param player locked player instance
2943 * @param new_title new selected title
2944 * @param new_idx index of this title
2945 * @param data opaque pointer set by vlc_player_AddListener()
2947 void (*on_title_selection_changed)(vlc_player_t *player,
2948 const struct vlc_player_title *new_title, size_t new_idx, void *data);
2951 * Called when a new chapter is selected
2953 * There are no events when a chapter is unselected. Chapters are
2954 * automatically unselected when the title list changes. Titles, chapters
2955 * and indexes are always valid inside the vlc_player_title_list sent by
2956 * vlc_player_cbs.on_titles_changed.
2958 * @param player locked player instance
2959 * @param title selected title
2960 * @param title_idx selected title index
2961 * @param chapter new selected chapter
2962 * @param chapter_idx new selected chapter index
2963 * @param data opaque pointer set by vlc_player_AddListener()
2965 void (*on_chapter_selection_changed)(vlc_player_t *player,
2966 const struct vlc_player_title *title, size_t title_idx,
2967 const struct vlc_player_chapter *new_chapter, size_t new_chapter_idx,
2968 void *data);
2971 * Called when the media has a teletext menu
2973 * @param player locked player instance
2974 * @param has_teletext_menu true if the media has a teletext menu
2975 * @param data opaque pointer set by vlc_player_AddListener()
2977 void (*on_teletext_menu_changed)(vlc_player_t *player,
2978 bool has_teletext_menu, void *data);
2981 * Called when teletext is enabled or disabled
2983 * @see vlc_player_SetTeletextEnabled()
2985 * @param player locked player instance
2986 * @param enabled true if teletext is enabled
2987 * @param data opaque pointer set by vlc_player_AddListener()
2989 void (*on_teletext_enabled_changed)(vlc_player_t *player,
2990 bool enabled, void *data);
2993 * Called when the teletext page has changed
2995 * @see vlc_player_SelectTeletextPage()
2997 * @param player locked player instance
2998 * @param new_page page in the range ]0;888]
2999 * @param data opaque pointer set by vlc_player_AddListener()
3001 void (*on_teletext_page_changed)(vlc_player_t *player,
3002 unsigned new_page, void *data);
3005 * Called when the teletext transparency has changed
3007 * @see vlc_player_SetTeletextTransparency()
3009 * @param player locked player instance
3010 * @param enabled true is the teletext overlay is transparent
3011 * @param data opaque pointer set by vlc_player_AddListener()
3013 void (*on_teletext_transparency_changed)(vlc_player_t *player,
3014 bool enabled, void *data);
3017 * Called when the player category delay has changed for the current media
3019 * @see vlc_player_SetCategoryDelay()
3021 * @param player locked player instance
3022 * @param cat AUDIO_ES or SPU_ES
3023 * @param new_delay audio delay
3024 * @param data opaque pointer set by vlc_player_AddListener()
3026 void (*on_category_delay_changed)(vlc_player_t *player,
3027 enum es_format_category_e cat, vlc_tick_t new_delay, void *data);
3030 * Called when associated subtitle has changed
3032 * @see vlc_player_SetAssociatedSubsFPS()
3034 * @param player locked player instance
3035 * @param sub_fps subtitle fps
3036 * @param data opaque pointer set by vlc_player_AddListener()
3038 void (*on_associated_subs_fps_changed)(vlc_player_t *player,
3039 float subs_fps, void *data);
3042 * Called when a new renderer item is set
3044 * @see vlc_player_SetRenderer()
3046 * @param player locked player instance
3047 * @param new_item a valid renderer item or NULL (if unset)
3048 * @param data opaque pointer set by vlc_player_AddListener()
3050 void (*on_renderer_changed)(vlc_player_t *player,
3051 vlc_renderer_item_t *new_item, void *data);
3054 * Called when the player recording state has changed
3056 * @see vlc_player_SetRecordingEnabled()
3058 * @param player locked player instance
3059 * @param recording true if recording is enabled
3060 * @param data opaque pointer set by vlc_player_AddListener()
3062 void (*on_recording_changed)(vlc_player_t *player,
3063 bool recording, void *data);
3066 * Called when the media signal has changed
3068 * @param player locked player instance
3069 * @param new_quality signal quality
3070 * @param new_strength signal strength,
3071 * @param data opaque pointer set by vlc_player_AddListener()
3073 void (*on_signal_changed)(vlc_player_t *player,
3074 float quality, float strength, void *data);
3077 * Called when the player has new statisics
3079 * @note The stats structure is only valid from this callback context. It
3080 * can be copied in order to use it from an other context.
3082 * @param player locked player instance
3083 * @param stats valid stats, only valid from this context
3084 * @param data opaque pointer set by vlc_player_AddListener()
3086 void (*on_statistics_changed)(vlc_player_t *player,
3087 const struct input_stats_t *stats, void *data);
3090 * Called when the A to B loop has changed
3092 * @see vlc_player_SetAtoBLoop()
3094 * @param player locked player instance
3095 * @param state A, when only A is set, B when both A and B are set, None by
3096 * default
3097 * @param time valid time or VLC_TICK_INVALID of the current state
3098 * @param pos valid pos of the current state
3099 * @param data opaque pointer set by vlc_player_AddListener()
3101 void (*on_atobloop_changed)(vlc_player_t *player,
3102 enum vlc_player_abloop new_state, vlc_tick_t time, float pos,
3103 void *data);
3106 * Called when media stopped action has changed
3108 * @see vlc_player_SetMediaStoppedAction()
3110 * @param player locked player instance
3111 * @param new_action action to execute when a media is stopped
3112 * @param data opaque pointer set by vlc_player_AddListener()
3114 void (*on_media_stopped_action_changed)(vlc_player_t *player,
3115 enum vlc_player_media_stopped_action new_action, void *data);
3118 * Called when the media meta has changed
3120 * @param player locked player instance
3121 * @param media current media
3122 * @param data opaque pointer set by vlc_player_AddListener()
3124 void (*on_media_meta_changed)(vlc_player_t *player,
3125 input_item_t *media, void *data);
3128 * Called when media epg has changed
3130 * @param player locked player instance
3131 * @param media current media
3132 * @param data opaque pointer set by vlc_player_AddListener()
3134 void (*on_media_epg_changed)(vlc_player_t *player,
3135 input_item_t *media, void *data);
3138 * Called when the media has new subitems
3140 * @param player locked player instance
3141 * @param media current media
3142 * @param new_subitems node representing all media subitems
3143 * @param data opaque pointer set by vlc_player_AddListener()
3145 void (*on_media_subitems_changed)(vlc_player_t *player,
3146 input_item_t *media, input_item_node_t *new_subitems, void *data);
3149 * Called when a vout is started or stopped
3151 * @note In case, several media with only one video track are played
3152 * successively, the same vout instance will be started and stopped several
3153 * time.
3155 * @param player locked player instance
3156 * @param action started or stopped
3157 * @param vout vout (can't be NULL)
3158 * @param order vout order
3159 * @param es_id the ES id associated with this vout
3160 * @param data opaque pointer set by vlc_player_AddListener()
3162 void (*on_vout_changed)(vlc_player_t *player,
3163 enum vlc_player_vout_action action, vout_thread_t *vout,
3164 enum vlc_vout_order order, vlc_es_id_t *es_id, void *data);
3167 * Called when the player is corked
3169 * The player can be corked when the audio output loose focus or when a
3170 * renderer was paused from the outside.
3172 * @note called only if pause on cork was not set to true (by
3173 * vlc_player_SetPauseOnCork())
3174 * @note a cork_count higher than 0 means the player is corked. In that
3175 * case, the user should pause the player and release all external resource
3176 * needed by the player. A value higher than 1 mean that the player was
3177 * corked more than one time (for different reasons). A value of 0 means
3178 * the player is no longer corked. In that case, the user could resume the
3179 * player.
3181 * @param player locked player instance
3182 * @param cork_count 0 for uncorked, > 0 for corked
3183 * @param data opaque pointer set by vlc_player_AddListener()
3185 void (*on_cork_changed)(vlc_player_t *player, unsigned cork_count,
3186 void *data);
3189 * Called to query the user about restoring the previous playback position
3191 * If this callback isn't provided, the user won't be asked to restore
3192 * the previous playback position, effectively causing
3193 * VLC_PLAYER_RESTORE_PLAYBACK_POS_ASK to be handled as
3194 * VLC_PLAYER_RESTORE_PLAYBACK_POS_NEVER
3196 * The implementation can react to this callback by calling
3197 * vlc_player_RestorePlaybackPos(), or by discarding the event.
3199 * @param player locked player instance
3200 * @param data opaque pointer set by vlc_player_AddListener()
3202 void (*on_playback_restore_queried)(vlc_player_t *player, void *data);
3206 * Add a listener callback
3208 * @note Every registered callbacks need to be removed by the caller with
3209 * vlc_player_RemoveListener().
3211 * @param player locked player instance
3212 * @param cbs pointer to a vlc_player_cbs structure, the structure must be
3213 * valid during the lifetime of the player
3214 * @param cbs_data opaque pointer used by the callbacks
3215 * @return a valid listener id, or NULL in case of allocation error
3217 VLC_API vlc_player_listener_id *
3218 vlc_player_AddListener(vlc_player_t *player,
3219 const struct vlc_player_cbs *cbs, void *cbs_data);
3222 * Remove a listener callback
3224 * @param player locked player instance
3225 * @param listener_id listener id returned by vlc_player_AddListener()
3227 VLC_API void
3228 vlc_player_RemoveListener(vlc_player_t *player,
3229 vlc_player_listener_id *listener_id);
3231 /** @} vlc_player__events */
3234 * @defgroup vlc_player__timer Player timer
3235 * @{
3239 * Player timer opaque structure.
3241 typedef struct vlc_player_timer_id vlc_player_timer_id;
3244 * Player timer point
3246 * @see vlc_player_timer_cbs.on_update
3248 struct vlc_player_timer_point
3250 /** Position in the range [0.0f;1.0] */
3251 float position;
3252 /** Rate of the player */
3253 double rate;
3254 /** Valid time >= VLC_TICK_0 or VLC_TICK_INVALID, subtract this time with
3255 * VLC_TICK_0 to get the original value. */
3256 vlc_tick_t ts;
3257 /** Valid length >= VLC_TICK_0 or VLC_TICK_INVALID */
3258 vlc_tick_t length;
3259 /** System date of this record (always valid), this date can be in the
3260 * future or in the past. The special value of INT64_MAX mean that the
3261 * clock was paused when this point was updated. In that case,
3262 * vlc_player_timer_point_Interpolate() will return the current ts/pos of
3263 * this point (there is nothing to interpolate). */
3264 vlc_tick_t system_date;
3268 * Player smpte timecode
3270 * @see vlc_player_timer_smpte_cbs
3272 struct vlc_player_timer_smpte_timecode
3274 /** Hours [0;n] */
3275 unsigned hours;
3276 /** Minutes [0;59] */
3277 unsigned minutes;
3278 /** Seconds [0;59] */
3279 unsigned seconds;
3280 /** Frame number [0;n] */
3281 unsigned frames;
3282 /** Maximum number of digits needed to display the frame number */
3283 unsigned frame_resolution;
3284 /** True if the source is NTSC 29.97fps or 59.94fps DF */
3285 bool drop_frame;
3289 * Player timer callbacks
3291 * @see vlc_player_AddTimer
3293 struct vlc_player_timer_cbs
3296 * Called when the state or the time changed.
3298 * Get notified when the time is updated by the input or output source. The
3299 * input source is the 'demux' or the 'access_demux'. The output source are
3300 * audio and video outputs: an update is received each time a video frame
3301 * is displayed or an audio sample is written. The delay between each
3302 * updates may depend on the input and source type (it can be every 5ms,
3303 * 30ms, 1s or 10s...). The user of this timer may need to update the
3304 * position at a higher frequency from its own mainloop via
3305 * vlc_player_timer_point_Interpolate().
3307 * @warning The player is not locked from this callback. It is forbidden
3308 * to call any player functions from here.
3310 * @param value always valid, the time corresponding to the state
3311 * @param data opaque pointer set by vlc_player_AddTimer()
3313 void (*on_update)(const struct vlc_player_timer_point *value, void *data);
3316 * The player is paused or a discontinuity occurred, likely caused by seek
3317 * from the user or because the playback is stopped. The player user should
3318 * stop its "interpolate" timer.
3320 * @param system_date system date of this event, only valid when paused. It
3321 * can be used to interpolate the last updated point to this date in order
3322 * to get the last paused ts/position.
3323 * @param data opaque pointer set by vlc_player_AddTimer()
3325 void (*on_discontinuity)(vlc_tick_t system_date, void *data);
3329 * Player smpte timer callbacks
3331 * @see vlc_player_AddSmpteTimer
3333 struct vlc_player_timer_smpte_cbs
3336 * Called when a new frame is displayed
3338 * @warning The player is not locked from this callback. It is forbidden
3339 * to call any player functions from here.
3341 * @param tc always valid, the timecode corresponding to the frame just
3342 * displayed
3343 * @param data opaque pointer set by vlc_player_AddTimer()
3345 void (*on_update)(const struct vlc_player_timer_smpte_timecode *tc,
3346 void *data);
3350 * Add a timer in order to get times updates
3352 * @param player player instance (locked or not)
3353 * @param min_period corresponds to the minimum period between each updates,
3354 * use it to avoid flood from too many source updates, set it to
3355 * VLC_TICK_INVALID to receive all updates.
3356 * @param cbs pointer to a vlc_player_timer_cbs structure, the structure must
3357 * be valid during the lifetime of the player
3358 * @param cbs_data opaque pointer used by the callbacks
3359 * @return a valid vlc_player_timer_id or NULL in case of memory allocation
3360 * error
3362 VLC_API vlc_player_timer_id *
3363 vlc_player_AddTimer(vlc_player_t *player, vlc_tick_t min_period,
3364 const struct vlc_player_timer_cbs *cbs, void *data);
3367 * Add a smpte timer in order to get accurate video frame updates
3369 * @param player player instance (locked or not)
3370 * @param cbs pointer to a vlc_player_timer_smpte_cbs structure, the structure must
3371 * be valid during the lifetime of the player
3372 * @param cbs_data opaque pointer used by the callbacks
3373 * @return a valid vlc_player_timer_id or NULL in case of memory allocation
3374 * error
3376 VLC_API vlc_player_timer_id *
3377 vlc_player_AddSmpteTimer(vlc_player_t *player,
3378 const struct vlc_player_timer_smpte_cbs *cbs,
3379 void *data);
3382 * Remove a player timer
3384 * @param player player instance (locked or not)
3385 * @param timer timer created by vlc_player_AddTimer()
3387 VLC_API void
3388 vlc_player_RemoveTimer(vlc_player_t *player, vlc_player_timer_id *timer);
3391 * Interpolate the last timer value to now
3393 * @param point time update obtained via the vlc_player_timer_cbs.on_update()
3394 * callback
3395 * @param system_now current system date
3396 * @param player_rate rate of the player
3397 * @param out_ts pointer where to set the interpolated ts, subtract this time
3398 * with VLC_TICK_0 to get the original value.
3399 * @param out_pos pointer where to set the interpolated position
3400 * @return VLC_SUCCESS in case of success, an error in the interpolated ts is
3401 * negative (could happen during the buffering step)
3403 VLC_API int
3404 vlc_player_timer_point_Interpolate(const struct vlc_player_timer_point *point,
3405 vlc_tick_t system_now,
3406 vlc_tick_t *out_ts, float *out_pos);
3409 * Get the date of the next interval
3411 * Can be used to setup an UI timer in order to update some widgets at specific
3412 * interval. A next_interval of VLC_TICK_FROM_SEC(1) can be used to update a
3413 * time widget when the media reaches a new second.
3415 * @note The media time doesn't necessarily correspond to the system time, that
3416 * is why this function is needed and use the rate of the current point.
3418 * @param point time update obtained via the vlc_player_timer_cbs.on_update()
3419 * @param system_now current system date
3420 * @param interpolated_ts ts returned by vlc_player_timer_point_Interpolate()
3421 * with the same system now
3422 * @param next_interval next interval
3423 * @return the absolute system date of the next interval
3425 VLC_API vlc_tick_t
3426 vlc_player_timer_point_GetNextIntervalDate(const struct vlc_player_timer_point *point,
3427 vlc_tick_t system_now,
3428 vlc_tick_t interpolated_ts,
3429 vlc_tick_t next_interval);
3431 /** @} vlc_player__timer */
3433 /** @} vlc_player */
3435 #endif