VLC  4.0.0-dev
Data Structures | Typedefs | Functions
Collaboration diagram for Player timer:

Data Structures

struct  vlc_player_timer_point
 Player timer point. More...
 
struct  vlc_player_timer_smpte_timecode
 Player smpte timecode. More...
 
struct  vlc_player_timer_cbs
 Player timer callbacks. More...
 
struct  vlc_player_timer_smpte_cbs
 Player smpte timer callbacks. More...
 

Typedefs

typedef struct vlc_player_timer_id vlc_player_timer_id
 Player timer opaque structure. More...
 

Functions

VLC_EXPORT vlc_player_timer_idvlc_player_AddTimer (vlc_player_t *player, vlc_tick_t min_period, const struct vlc_player_timer_cbs *cbs, void *data)
 Add a timer in order to get times updates. More...
 
VLC_EXPORT vlc_player_timer_idvlc_player_AddSmpteTimer (vlc_player_t *player, const struct vlc_player_timer_smpte_cbs *cbs, void *data)
 Add a smpte timer in order to get accurate video frame updates. More...
 
VLC_EXPORT void vlc_player_RemoveTimer (vlc_player_t *player, vlc_player_timer_id *timer)
 Remove a player timer. More...
 
VLC_EXPORT int vlc_player_timer_point_Interpolate (const struct vlc_player_timer_point *point, vlc_tick_t system_now, vlc_tick_t *out_ts, float *out_pos)
 Interpolate the last timer value to now. More...
 
VLC_EXPORT vlc_tick_t vlc_player_timer_point_GetNextIntervalDate (const struct vlc_player_timer_point *point, vlc_tick_t system_now, vlc_tick_t interpolated_ts, vlc_tick_t next_interval)
 Get the date of the next interval. More...
 

Detailed Description

Typedef Documentation

◆ vlc_player_timer_id

Player timer opaque structure.

Function Documentation

◆ vlc_player_AddSmpteTimer()

VLC_EXPORT vlc_player_timer_id* vlc_player_AddSmpteTimer ( vlc_player_t player,
const struct vlc_player_timer_smpte_cbs cbs,
void *  data 
)

Add a smpte timer in order to get accurate video frame updates.

Parameters
playerplayer instance (locked or not)
cbspointer to a vlc_player_timer_smpte_cbs structure, the structure must be valid during the lifetime of the player
cbs_dataopaque pointer used by the callbacks
Returns
a valid vlc_player_timer_id or NULL in case of memory allocation error

References vlc_player_timer_id::cbs, vlc_player_timer_id::data, vlc_player_timer_id::last_update_date, vlc_player_timer::lock, vlc_player_timer_id::node, vlc_player_timer_cbs::on_update, vlc_player_timer_id::period, vlc_player_timer_id::smpte_cbs, vlc_player_t::timer, vlc_list_append(), vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_TICK_INVALID.

◆ vlc_player_AddTimer()

VLC_EXPORT vlc_player_timer_id* vlc_player_AddTimer ( vlc_player_t player,
vlc_tick_t  min_period,
const struct vlc_player_timer_cbs cbs,
void *  data 
)

Add a timer in order to get times updates.

Parameters
playerplayer instance (locked or not)
min_periodcorresponds to the minimum period between each updates, use it to avoid flood from too many source updates, set it to VLC_TICK_INVALID to receive all updates.
cbspointer to a vlc_player_timer_cbs structure, the structure must be valid during the lifetime of the player
cbs_dataopaque pointer used by the callbacks
Returns
a valid vlc_player_timer_id or NULL in case of memory allocation error

References vlc_player_timer_id::cbs, vlc_player_timer_id::data, vlc_player_timer_id::last_update_date, vlc_player_timer::lock, vlc_player_timer_id::node, vlc_player_timer_cbs::on_update, vlc_player_timer_id::period, vlc_player_t::timer, vlc_list_append(), vlc_mutex_lock(), vlc_mutex_unlock(), VLC_TICK_0, and VLC_TICK_INVALID.

◆ vlc_player_RemoveTimer()

VLC_EXPORT void vlc_player_RemoveTimer ( vlc_player_t player,
vlc_player_timer_id timer 
)

Remove a player timer.

Parameters
playerplayer instance (locked or not)
timertimer created by vlc_player_AddTimer()

References vlc_player_timer::lock, vlc_player_timer_id::node, vlc_player_t::timer, vlc_list_remove(), vlc_mutex_lock(), and vlc_mutex_unlock().

◆ vlc_player_timer_point_GetNextIntervalDate()

VLC_EXPORT vlc_tick_t vlc_player_timer_point_GetNextIntervalDate ( const struct vlc_player_timer_point point,
vlc_tick_t  system_now,
vlc_tick_t  interpolated_ts,
vlc_tick_t  next_interval 
)

Get the date of the next interval.

Can be used to setup an UI timer in order to update some widgets at specific interval. A next_interval of VLC_TICK_FROM_SEC(1) can be used to update a time widget when the media reaches a new second.

Note
The media time doesn't necessarily correspond to the system time, that is why this function is needed and use the rate of the current point.
Parameters
pointtime update obtained via the vlc_player_timer_cbs.on_update()
system_nowcurrent system date
interpolated_tsts returned by vlc_player_timer_point_Interpolate() with the same system now
next_intervalnext interval
Returns
the absolute system date of the next interval

References vlc_player_timer_point::rate, and VLC_TICK_INVALID.

◆ vlc_player_timer_point_Interpolate()

VLC_EXPORT int vlc_player_timer_point_Interpolate ( const struct vlc_player_timer_point point,
vlc_tick_t  system_now,
vlc_tick_t out_ts,
float *  out_pos 
)

Interpolate the last timer value to now.

Parameters
pointtime update obtained via the vlc_player_timer_cbs.on_update() callback
system_nowcurrent system date
player_raterate of the player
out_tspointer where to set the interpolated ts, subtract this time with VLC_TICK_0 to get the original value.
out_pospointer where to set the interpolated position
Returns
VLC_SUCCESS in case of success, an error in the interpolated ts is negative (could happen during the buffering step)

References vlc_player_timer_point::length, vlc_player_timer_point::position, vlc_player_timer_point::rate, vlc_player_timer_point::system_date, vlc_player_timer_point::ts, unlikely, VLC_EGENERIC, VLC_SUCCESS, VLC_TICK_0, and VLC_TICK_INVALID.

Referenced by vlc_player_GetTimerPoint().