mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-29 19:50:40 +00:00
hlsdemux2: Refactor update of GstHLSTimeMap values
This was also missing transferring the PDT if present Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6610>
This commit is contained in:
parent
9a7f455aea
commit
3e810a6721
3 changed files with 35 additions and 25 deletions
|
@ -537,8 +537,8 @@ gst_hlsdemux_stream_handle_internal_time (GstHLSDemuxStream * hls_stream,
|
|||
if (hls_stream->parser_type == GST_HLS_PARSER_ISOBMFF)
|
||||
hls_stream->presentation_offset = internal_time - current_stream_time;
|
||||
|
||||
map->stream_time = current_stream_time;
|
||||
map->internal_time = internal_time;
|
||||
gst_time_map_set_values (map, current_stream_time, internal_time,
|
||||
current_segment->datetime);
|
||||
|
||||
gst_hls_demux_start_rendition_streams (demux);
|
||||
return GST_HLS_PARSER_RESULT_DONE;
|
||||
|
@ -550,8 +550,8 @@ gst_hlsdemux_stream_handle_internal_time (GstHLSDemuxStream * hls_stream,
|
|||
"DISCONT segment, Updating time map to stream_time:%" GST_STIME_FORMAT
|
||||
" internal_time:%" GST_TIME_FORMAT, GST_STIME_ARGS (internal_time),
|
||||
GST_TIME_ARGS (current_stream_time));
|
||||
map->stream_time = current_stream_time;
|
||||
map->internal_time = internal_time;
|
||||
gst_time_map_set_values (map, current_stream_time, internal_time,
|
||||
current_segment->datetime);
|
||||
return GST_HLS_PARSER_RESULT_DONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -916,6 +916,34 @@ gst_hls_time_map_free (GstHLSTimeMap * map)
|
|||
g_free (map);
|
||||
}
|
||||
|
||||
void
|
||||
gst_time_map_set_values (GstHLSTimeMap * map, GstClockTimeDiff stream_time,
|
||||
GstClockTime internal_time, GDateTime * pdt)
|
||||
{
|
||||
GstClockTime offset = 0;
|
||||
|
||||
if (stream_time < 0) {
|
||||
offset = -stream_time;
|
||||
stream_time = 0;
|
||||
/* Handle negative stream times. This can happen for example when the server
|
||||
* returns an older playlist.
|
||||
*
|
||||
* Shift the values accordingly to end up with non-negative reference stream
|
||||
* time */
|
||||
GST_DEBUG ("Shifting values before storage (offset : %" GST_TIME_FORMAT ")",
|
||||
GST_TIME_ARGS (offset));
|
||||
}
|
||||
|
||||
map->stream_time = stream_time;
|
||||
map->internal_time = internal_time;
|
||||
if (pdt) {
|
||||
if (offset)
|
||||
map->pdt = g_date_time_add (pdt, offset / GST_USECOND);
|
||||
else
|
||||
map->pdt = g_date_time_ref (pdt);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gst_hls_demux_add_time_mapping (GstHLSDemux * demux, gint64 dsn,
|
||||
GstClockTimeDiff stream_time, GDateTime * pdt)
|
||||
|
@ -925,7 +953,6 @@ gst_hls_demux_add_time_mapping (GstHLSDemux * demux, gint64 dsn,
|
|||
#endif
|
||||
GstHLSTimeMap *map;
|
||||
GList *tmp;
|
||||
GstClockTime offset = 0;
|
||||
|
||||
/* Check if we don't already have a mapping for the given dsn */
|
||||
for (tmp = demux->mappings; tmp; tmp = tmp->next) {
|
||||
|
@ -955,28 +982,9 @@ gst_hls_demux_add_time_mapping (GstHLSDemux * demux, gint64 dsn,
|
|||
g_free (datestring);
|
||||
#endif
|
||||
|
||||
if (stream_time < 0) {
|
||||
offset = -stream_time;
|
||||
stream_time = 0;
|
||||
/* Handle negative stream times. This can happen for example when the server
|
||||
* returns an older playlist.
|
||||
*
|
||||
* Shift the values accordingly to end up with non-negative reference stream
|
||||
* time */
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"Shifting values before storage (offset : %" GST_TIME_FORMAT ")",
|
||||
GST_TIME_ARGS (offset));
|
||||
}
|
||||
|
||||
map = gst_hls_time_map_new ();
|
||||
map->dsn = dsn;
|
||||
map->stream_time = stream_time;
|
||||
if (pdt) {
|
||||
if (offset)
|
||||
map->pdt = g_date_time_add (pdt, offset / GST_USECOND);
|
||||
else
|
||||
map->pdt = g_date_time_ref (pdt);
|
||||
}
|
||||
gst_time_map_set_values (map, stream_time, GST_CLOCK_TIME_NONE, pdt);
|
||||
|
||||
demux->mappings = g_list_append (demux->mappings, map);
|
||||
}
|
||||
|
|
|
@ -129,6 +129,8 @@ gboolean gst_hls_demux_change_variant_playlist (GstHLSDemux * demux,
|
|||
GstFlowReturn gst_hls_demux_update_variant_playlist (GstHLSDemux * demux,
|
||||
GError ** err);
|
||||
|
||||
void gst_time_map_set_values (GstHLSTimeMap *map, GstClockTimeDiff stream_time,
|
||||
GstClockTime internal_time, GDateTime *pdt);
|
||||
void gst_hls_demux_add_time_mapping (GstHLSDemux * demux, gint64 dsn,
|
||||
GstClockTimeDiff stream_time, GDateTime * pdt);
|
||||
void gst_hls_update_time_mappings (GstHLSDemux * demux,
|
||||
|
|
Loading…
Reference in a new issue