VLC 4.0.0-dev
Loading...
Searching...
No Matches
LibVLC media player time watch API
Collaboration diagram for LibVLC media player time watch API:

Data Structures

struct  libvlc_media_player_time_point_t
 Media Player timer point. More...
 

Typedefs

typedef struct libvlc_media_player_time_point_t libvlc_media_player_time_point_t
 Media Player timer point.
 
typedef void(* libvlc_media_player_watch_time_on_update) (const libvlc_media_player_time_point_t *value, void *data)
 Callback prototype that notify when the player state or time changed.
 
typedef void(* libvlc_media_player_watch_time_on_discontinuity) (int64_t system_date_us, void *data)
 Callback prototype that notify when the player is paused or a discontinuity occurred.
 

Functions

LIBVLC_API int libvlc_media_player_watch_time (libvlc_media_player_t *p_mi, int64_t min_period_us, libvlc_media_player_watch_time_on_update on_update, libvlc_media_player_watch_time_on_discontinuity on_discontinuity, void *cbs_data)
 Watch for times updates.
 
LIBVLC_API void libvlc_media_player_unwatch_time (libvlc_media_player_t *p_mi)
 Unwatch time updates.
 
LIBVLC_API int libvlc_media_player_time_point_interpolate (const libvlc_media_player_time_point_t *point, int64_t system_now_us, int64_t *out_ts_us, double *out_pos)
 Interpolate a timer value to now.
 
LIBVLC_API int64_t libvlc_media_player_time_point_get_next_date (const libvlc_media_player_time_point_t *point, int64_t system_now_us, int64_t interpolated_ts_us, int64_t next_interval_us)
 Get the date of the next interval.
 

Detailed Description

Typedef Documentation

◆ libvlc_media_player_time_point_t

Media Player timer point.

Note
ts and system_date values should not be used directly by the user. libvlc_media_player_time_point_interpolate() will read these values and return an interpolated ts.
See also
libvlc_media_player_watch_time_on_update

◆ libvlc_media_player_watch_time_on_discontinuity

typedef void(* libvlc_media_player_watch_time_on_discontinuity) (int64_t system_date_us, void *data)

Callback prototype that notify when the player is paused or a discontinuity occurred.

Likely caused by seek from the user or because the playback is stopped. The player user should stop its "interpolate" timer.

Warning
It is forbidden to call any Media Player functions from here.
Parameters
system_date_ussystem date, in us, of this event, only valid (> 0) when paused. It can be used to interpolate the last updated point to this date in order to get the last paused ts/position.
dataopaque pointer set by libvlc_media_player_watch_time()

◆ libvlc_media_player_watch_time_on_update

typedef void(* libvlc_media_player_watch_time_on_update) (const libvlc_media_player_time_point_t *value, void *data)

Callback prototype that notify when the player state or time changed.

Get notified when the time is updated by the input or output source. The input source is the 'demux' or the 'access_demux'. The output source are audio and video outputs: an update is received each time a video frame is displayed or an audio sample is written. The delay between each updates may depend on the input and source type (it can be every 5ms, 30ms, 1s or 10s...). Users of this timer may need to update the position at a higher frequency from their own mainloop via libvlc_media_player_time_point_interpolate().

Warning
It is forbidden to call any Media Player functions from here.
Parameters
valuealways valid, the time corresponding to the state
dataopaque pointer set by libvlc_media_player_watch_time()

Function Documentation

◆ libvlc_media_player_time_point_get_next_date()

LIBVLC_API int64_t libvlc_media_player_time_point_get_next_date ( const libvlc_media_player_time_point_t point,
int64_t  system_now_us,
int64_t  interpolated_ts_us,
int64_t  next_interval_us 
)

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 uses the rate of the current point.
Parameters
pointtime update obtained via the libvlc_media_player_watch_time_on_update()
system_now_ussame system date used by libvlc_media_player_time_point_interpolate()
interpolated_ts_usts returned by libvlc_media_player_time_point_interpolate()
next_interval_usnext interval, in us
Returns
the absolute system date, in us, of the next interval, use libvlc_delay() to get a relative delay.
Version
LibVLC 4.0.0 or later

◆ libvlc_media_player_time_point_interpolate()

LIBVLC_API int libvlc_media_player_time_point_interpolate ( const libvlc_media_player_time_point_t point,
int64_t  system_now_us,
int64_t *  out_ts_us,
double *  out_pos 
)

Interpolate a timer value to now.

Parameters
pointtime update obtained via the libvlc_media_player_watch_time_on_update() callback
system_now_uscurrent system date, in us, returned by libvlc_clock()
out_ts_uspointer where to set the interpolated ts, in us
out_pospointer where to set the interpolated position
Returns
0 in case of success, -1 if the interpolated ts is negative (could happen during the buffering step)
Version
LibVLC 4.0.0 or later

◆ libvlc_media_player_unwatch_time()

LIBVLC_API void libvlc_media_player_unwatch_time ( libvlc_media_player_t p_mi)

Unwatch time updates.

Parameters
p_mithe media player
Version
LibVLC 4.0.0 or later

◆ libvlc_media_player_watch_time()

LIBVLC_API int libvlc_media_player_watch_time ( libvlc_media_player_t p_mi,
int64_t  min_period_us,
libvlc_media_player_watch_time_on_update  on_update,
libvlc_media_player_watch_time_on_discontinuity  on_discontinuity,
void *  cbs_data 
)

Watch for times updates.

Warning
Only one watcher can be registered at a time. Calling this function a second time (if libvlc_media_player_unwatch_time() was not called in-between) will fail.
Parameters
p_mithe media player
min_period_uscorresponds to the minimum period, in us, between each updates, use it to avoid flood from too many source updates, set it to 0 to receive all updates.
on_updatecallback to listen to update events (must not be NULL)
on_discontinuitycallback to listen to discontinuity events (can be be NULL)
cbs_dataopaque pointer used by the callbacks
Returns
0 on success, -1 on error (allocation error, or if already watching)
Version
LibVLC 4.0.0 or later