hlsdemux2: Print playlist age in debug output

Store the timestamp when playlists are updated, and add some debug output to the
update_fragment_info that estimates how far from the live edge the fragment
currently is

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
Jan Schmidt 2022-08-16 22:05:03 +10:00 committed by GStreamer Marge Bot
parent 43e042c4b7
commit 401ca3ef44
4 changed files with 33 additions and 4 deletions

View file

@ -2308,6 +2308,8 @@ gst_hls_demux_stream_update_media_playlist (GstHLSDemux * demux,
GST_WARNING_OBJECT (stream, "Could not get playlist '%s'", *uri);
return GST_FLOW_ERROR;
}
stream->playlist_last_update_time =
gst_adaptive_demux2_get_monotonic_time (GST_ADAPTIVE_DEMUX (demux));
/* Check if a redirect happened */
if (g_strcmp0 (*uri, new_playlist->uri)) {
@ -2363,7 +2365,8 @@ gst_hls_demux_stream_update_media_playlist (GstHLSDemux * demux,
gst_hls_media_playlist_sync_to_segment (new_playlist,
stream->current_segment);
/* FIXME: Handle LL-HLS partial segment sync */
/* Handle LL-HLS partial segment sync by checking our partial segment
* still makes sense */
if (stream->in_partial_segments && new_segment) {
/* We must be either playing the trailing open-ended partial segment,
* or if we're playing partials from a complete segment, check that we
@ -2529,10 +2532,20 @@ gst_hls_demux_stream_update_fragment_info (GstAdaptiveDemux2Stream * stream)
if (ret != GST_FLOW_OK)
return ret;
}
#ifndef GST_DISABLE_GST_DEBUG
GstClockTimeDiff live_edge_dist =
GST_CLOCK_TIME_IS_VALID (stream->current_position) ?
gst_hls_media_playlist_get_end_stream_time (hlsdemux_stream->playlist) -
stream->current_position : GST_CLOCK_TIME_NONE;
GstClockTime playlist_age =
gst_adaptive_demux2_get_monotonic_time (GST_ADAPTIVE_DEMUX (demux)) -
hlsdemux_stream->playlist_last_update_time;
GST_DEBUG_OBJECT (stream,
"Updating fragment information, current_position:%" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->current_position));
"Updating fragment information, current_position:%" GST_TIME_FORMAT
" which is %" GST_STIME_FORMAT " from live edge. Playlist age %"
GST_TIME_FORMAT, GST_TIME_ARGS (stream->current_position),
GST_STIME_ARGS (live_edge_dist), GST_TIME_ARGS (playlist_age));
#endif
/* Find the current segment if we don't already have it */
if (hlsdemux_stream->current_segment == NULL) {

View file

@ -111,6 +111,7 @@ struct _GstHLSDemuxStream
/* Whether the underlying playlist was fetched on creation */
gboolean playlist_fetched;
GstClockTime playlist_last_update_time;
/* The media playlist currently used */
GstHLSMediaPlaylist *playlist;

View file

@ -2146,6 +2146,18 @@ out:
return file;
}
GstClockTime
gst_hls_media_playlist_get_end_stream_time (GstHLSMediaPlaylist * m3u8)
{
if (m3u8->segments->len == 0)
return GST_CLOCK_TIME_NONE;
GstM3U8MediaSegment *last =
g_ptr_array_index (m3u8->segments, m3u8->segments->len - 1);
return last->stream_time + last->duration;
}
GstClockTime
gst_hls_media_playlist_get_duration (GstHLSMediaPlaylist * m3u8)
{

View file

@ -294,6 +294,9 @@ gboolean
gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist *self, gboolean low_latency,
GstM3U8SeekResult *seek_result);
GstClockTime
gst_hls_media_playlist_get_end_stream_time (GstHLSMediaPlaylist * m3u8);
GstClockTime
gst_hls_media_playlist_get_duration (GstHLSMediaPlaylist * m3u8);