hlsdemux2/m3u8: use GstClockTimeDiff to do timestamp comparison

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5234>
This commit is contained in:
Hou Qi 2023-08-24 15:18:05 +09:00 committed by Qi Hou
parent 5051a34318
commit aa68b5e02a

View file

@ -1377,7 +1377,7 @@ gst_hls_media_playlist_seek (GstHLSMediaPlaylist * playlist, gboolean forward,
}
}
} else if (part->stream_time <= ts
&& ts < part->stream_time + part->duration) {
&& ts < (GstClockTimeDiff) (part->stream_time + part->duration)) {
res = cand;
if (!want_keyunit || part->independent)
res_part_idx = part_idx;
@ -1413,7 +1413,7 @@ gst_hls_media_playlist_seek (GstHLSMediaPlaylist * playlist, gboolean forward,
goto out;
}
} else if ((cand->stream_time <= ts || idx == 0)
&& ts < cand->stream_time + cand->duration) {
&& ts < (GstClockTimeDiff) (cand->stream_time + cand->duration)) {
res = cand;
goto out;
}
@ -1477,8 +1477,8 @@ gst_hls_media_playlist_find_partial_position (GstHLSMediaPlaylist * playlist,
/* If the target timestamp is before this partial segment, or in the first half, this
* is the partial segment to land in */
if (cand->stream_time + (cand->duration / 2) >= ts &&
cand->stream_time <= ts + (cand->duration / 2)) {
if ((GstClockTimeDiff) (cand->stream_time + (cand->duration / 2)) >= ts &&
cand->stream_time <= (GstClockTimeDiff) (ts + (cand->duration / 2))) {
GST_DEBUG ("choosing partial segment %d", part_idx);
seek_result->segment = gst_m3u8_media_segment_ref (seg);
seek_result->found_partial_segment = TRUE;
@ -1537,7 +1537,7 @@ gst_hls_media_playlist_find_position (GstHLSMediaPlaylist * playlist,
/* If the target stream time is definitely past the end
* of this segment, no earlier segment (with lower stream time)
* could match, so we fail */
if (ts >= cand->stream_time + (3 * cand->duration / 2)) {
if (ts >= (GstClockTimeDiff) (cand->stream_time + (3 * cand->duration / 2))) {
break;
}