mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
hlsdemux2: Be more tolerant when matching segments with PDT
Some servers might not provide 100% matching PDT when doing updates, or accross variants. This would cause the code matching segments using PDT to fail if the segment PDT was 1 microsecond (or whatever small value) before the candidate segment. And would pick the (wrong) following segment as the matching one. In order to be more tolerant when matching, we instead check whether the candidate segment is within the first segment of the segment we are trying to match. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6961>
This commit is contained in:
parent
e7ab454cf5
commit
421832e506
1 changed files with 16 additions and 7 deletions
|
@ -1876,15 +1876,24 @@ find_segment_in_playlist (GstHLSMediaPlaylist * playlist,
|
|||
}
|
||||
}
|
||||
|
||||
if (cand->datetime
|
||||
&& g_date_time_difference (cand->datetime, segment->datetime) >= 0) {
|
||||
/* The reported PDT might not be 100% identical for matching segments
|
||||
* across playlists, we therefore need to take into account a certain
|
||||
* tolerance otherwise we would fail to match candidates with a PDT which
|
||||
* is slightly before. We therefore check whether the segment starts
|
||||
* within the first third of the candidate segment.
|
||||
*/
|
||||
if (cand->datetime) {
|
||||
GstClockTimeDiff pdtdiff = g_date_time_difference (cand->datetime,
|
||||
segment->datetime) * GST_USECOND + cand->duration / 3;
|
||||
if (pdtdiff >= 0) {
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
gchar *pdtstring = g_date_time_format_iso8601 (cand->datetime);
|
||||
GST_DEBUG ("Picking segment with datetime %s", pdtstring);
|
||||
g_free (pdtstring);
|
||||
gchar *pdtstring = g_date_time_format_iso8601 (cand->datetime);
|
||||
GST_DEBUG ("Picking segment with datetime %s", pdtstring);
|
||||
g_free (pdtstring);
|
||||
#endif
|
||||
*matched_pdt = TRUE;
|
||||
return cand;
|
||||
*matched_pdt = TRUE;
|
||||
return cand;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue