[vlc-commits] [Git][videolan/vlc][master] libvlc: add libvlc_media_player_watch_time_on_seek
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Sep 30 10:57:04 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
1b395032 by Thomas Guillem at 2024-09-30T10:42:31+00:00
libvlc: add libvlc_media_player_watch_time_on_seek
- - - - -
3 changed files:
- include/vlc/libvlc_media_player.h
- lib/media_player.c
- lib/media_player_internal.h
Changes:
=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -2963,6 +2963,19 @@ typedef void (*libvlc_media_player_watch_time_on_update)(
typedef void (*libvlc_media_player_watch_time_on_discontinuity)(
int64_t system_date_us, void *data);
+/**
+ * Callback prototype that notify when the player is seeking or finished
+ * seeking
+ *
+ * \warning It is forbidden to call any Media Player functions from here.
+ *
+ * \param value point of the seek request or NULL when seeking is finished
+ * value.system_date_us = INT64_MAX in that case
+ * \param data opaque pointer set by libvlc_media_player_watch_time()
+ */
+typedef void (*libvlc_media_player_watch_time_on_seek)(
+ const libvlc_media_player_time_point_t *value, void *data);
+
/**
* Watch for times updates
*
@@ -2986,6 +2999,7 @@ 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,
+ libvlc_media_player_watch_time_on_seek on_seek,
void *cbs_data);
/**
=====================================
lib/media_player.c
=====================================
@@ -2278,11 +2278,29 @@ static void player_timer_on_discontinuity(vlc_tick_t system_date, void *data)
p_mi->timer.cbs_data);
}
+static void player_timer_on_seek(const struct vlc_player_timer_point *point,
+ void *data)
+{
+ libvlc_media_player_t *p_mi = data;
+
+ if (p_mi->timer.on_seek == NULL)
+ return;
+
+ if (point != NULL)
+ {
+ const libvlc_media_player_time_point_t libpoint = PLAYER_TIME_CORE_TO_LIB(point);
+ p_mi->timer.on_seek(&libpoint, p_mi->timer.cbs_data);
+ }
+ else
+ p_mi->timer.on_seek(NULL, p_mi->timer.cbs_data);
+}
+
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,
+ libvlc_media_player_watch_time_on_seek on_seek,
void *cbs_data)
{
assert(on_update != NULL);
@@ -2290,6 +2308,7 @@ libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
static const struct vlc_player_timer_cbs player_timer_cbs = {
.on_update = player_timer_on_update,
.on_discontinuity = player_timer_on_discontinuity,
+ .on_seek = player_timer_on_seek,
};
vlc_player_t *player = p_mi->player;
@@ -2305,6 +2324,7 @@ libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
p_mi->timer.on_update = on_update;
p_mi->timer.on_discontinuity = on_discontinuity;
+ p_mi->timer.on_seek = on_seek;
p_mi->timer.cbs_data = cbs_data;
p_mi->timer.id = vlc_player_AddTimer(player, VLC_TICK_FROM_US(min_period_us),
=====================================
lib/media_player_internal.h
=====================================
@@ -51,6 +51,7 @@ struct libvlc_media_player_t
vlc_player_timer_id *id;
libvlc_media_player_watch_time_on_update on_update;
libvlc_media_player_watch_time_on_discontinuity on_discontinuity;
+ libvlc_media_player_watch_time_on_seek on_seek;
void *cbs_data;
} timer;
};
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1b395032226a66e8d54ad1e7507d01503182a9f8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1b395032226a66e8d54ad1e7507d01503182a9f8
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list