hlsdemux2: Add gst_hls_media_playlist_get_next_msn_and_part()

Add a function that computes the media sequence number and/or part index that
are immediately after the end of the playlist, for use in blocking playlist
requests

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
Jan Schmidt 2022-11-18 01:23:54 +11:00 committed by GStreamer Marge Bot
parent d41def562c
commit c16366e5f3
2 changed files with 30 additions and 0 deletions

View file

@ -2245,6 +2245,32 @@ gst_hls_media_playlist_get_duration (GstHLSMediaPlaylist * m3u8)
return duration;
}
void
gst_hls_media_playlist_get_next_msn_and_part (GstHLSMediaPlaylist * m3u8,
gboolean low_latency, gint64 * next_msn, gint64 * next_part)
{
/* Return the MSN and part number that are 1 past the end of the current playlist */
if (m3u8->segments->len == 0) {
*next_msn = -1;
*next_part = -1;
return;
}
GstM3U8MediaSegment *last =
g_ptr_array_index (m3u8->segments, m3u8->segments->len - 1);
/* If low_latency mode and the last segment contains partial segments, the next playlist update is
* when one extra partial segment gets added */
if (low_latency && last->partial_segments != NULL) {
*next_msn = last->sequence;
*next_part = last->partial_segments->len;
return;
}
*next_msn = last->sequence + 1;
*next_part = -1;
}
gchar *
gst_hls_media_playlist_get_uri (GstHLSMediaPlaylist * m3u8)
{

View file

@ -315,6 +315,10 @@ gst_hls_media_playlist_get_end_stream_time (GstHLSMediaPlaylist * m3u8);
GstClockTime
gst_hls_media_playlist_get_duration (GstHLSMediaPlaylist * m3u8);
void
gst_hls_media_playlist_get_next_msn_and_part (GstHLSMediaPlaylist * m3u8, gboolean low_latency,
gint64 *next_msn, gint64 *next_part);
gchar *
gst_hls_media_playlist_get_uri (GstHLSMediaPlaylist * m3u8);