mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
dashdemux: reuse seeking function to reduce repeated code
Instead of writing a seek routine, just use the mpdparser function. Also remove function that is not needed anymore
This commit is contained in:
parent
57a2105a31
commit
d617139ee7
3 changed files with 4 additions and 58 deletions
|
@ -591,30 +591,13 @@ gst_dash_demux_setup_streams (GstAdaptiveDemux * demux)
|
||||||
/* If stream is live, try to find the segment that
|
/* If stream is live, try to find the segment that
|
||||||
* is closest to current time */
|
* is closest to current time */
|
||||||
if (gst_mpd_client_is_live (dashdemux->client)) {
|
if (gst_mpd_client_is_live (dashdemux->client)) {
|
||||||
GList *iter;
|
GDateTime *gnow;
|
||||||
gint seg_idx;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (demux, "Seeking to current time of day for live stream ");
|
GST_DEBUG_OBJECT (demux, "Seeking to current time of day for live stream ");
|
||||||
for (iter = demux->next_streams; iter; iter = g_list_next (iter)) {
|
|
||||||
GstDashDemuxStream *stream = iter->data;
|
|
||||||
GstActiveStream *active_stream = stream->active_stream;
|
|
||||||
|
|
||||||
/* Get segment index corresponding to current time. */
|
|
||||||
seg_idx =
|
|
||||||
gst_mpd_client_get_segment_index_at_time (dashdemux->client,
|
|
||||||
active_stream, now);
|
|
||||||
if (seg_idx < 0) {
|
|
||||||
GST_WARNING_OBJECT (demux,
|
|
||||||
"Failed to find a segment that is available "
|
|
||||||
"at this point in time for stream %d.", stream->index);
|
|
||||||
seg_idx = 0;
|
|
||||||
}
|
|
||||||
GST_INFO_OBJECT (demux,
|
|
||||||
"Segment index corresponding to current time for stream "
|
|
||||||
"%d is %d.", stream->index, seg_idx);
|
|
||||||
gst_mpd_client_set_segment_index (active_stream, seg_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
gnow = gst_date_time_to_g_date_time (now);
|
||||||
|
gst_mpd_client_seek_to_time (dashdemux->client, gnow);
|
||||||
|
g_date_time_unref (gnow);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (demux, "Seeking to first segment for on-demand stream ");
|
GST_DEBUG_OBJECT (demux, "Seeking to first segment for on-demand stream ");
|
||||||
|
|
||||||
|
|
|
@ -3527,42 +3527,6 @@ gst_mpd_client_add_time_difference (GstDateTime * t1, gint64 usecs)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
|
||||||
gst_mpd_client_get_segment_index_at_time (GstMpdClient * client,
|
|
||||||
GstActiveStream * stream, const GstDateTime * time)
|
|
||||||
{
|
|
||||||
GstClockTime seg_duration;
|
|
||||||
gint64 diff;
|
|
||||||
GstDateTime *avail_start =
|
|
||||||
gst_mpd_client_get_availability_start_time (client);
|
|
||||||
GstStreamPeriod *stream_period = gst_mpdparser_get_stream_period (client);
|
|
||||||
|
|
||||||
if (avail_start == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (stream_period && stream_period->period) {
|
|
||||||
GstDateTime *t;
|
|
||||||
|
|
||||||
t = gst_mpd_client_add_time_difference (avail_start,
|
|
||||||
stream_period->period->start * 1000);
|
|
||||||
gst_date_time_unref (avail_start);
|
|
||||||
avail_start = t;
|
|
||||||
}
|
|
||||||
diff = gst_mpd_client_calculate_time_difference (avail_start, time);
|
|
||||||
gst_date_time_unref (avail_start);
|
|
||||||
|
|
||||||
if (diff < 0)
|
|
||||||
return -2;
|
|
||||||
if (diff > gst_mpd_client_get_media_presentation_duration (client))
|
|
||||||
return -3;
|
|
||||||
|
|
||||||
/* TODO: Assumes all fragments are roughly the same duration */
|
|
||||||
seg_duration = gst_mpd_client_get_next_fragment_duration (client, stream);
|
|
||||||
if (seg_duration == 0)
|
|
||||||
return -1;
|
|
||||||
return diff / seg_duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstDateTime *
|
static GstDateTime *
|
||||||
gst_mpd_client_get_availability_start_time (GstMpdClient * client)
|
gst_mpd_client_get_availability_start_time (GstMpdClient * client)
|
||||||
{
|
{
|
||||||
|
|
|
@ -505,7 +505,6 @@ gboolean gst_mpd_client_is_live (GstMpdClient * client);
|
||||||
gboolean gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, GstClockTime ts);
|
gboolean gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, GstClockTime ts);
|
||||||
gboolean gst_mpd_client_seek_to_time (GstMpdClient * client, GDateTime * time);
|
gboolean gst_mpd_client_seek_to_time (GstMpdClient * client, GDateTime * time);
|
||||||
GstDateTime *gst_mpd_client_add_time_difference (GstDateTime * t1, gint64 usecs);
|
GstDateTime *gst_mpd_client_add_time_difference (GstDateTime * t1, gint64 usecs);
|
||||||
gint gst_mpd_client_get_segment_index_at_time (GstMpdClient *client, GstActiveStream * stream, const GstDateTime *time);
|
|
||||||
gint gst_mpd_client_check_time_position (GstMpdClient * client, GstActiveStream * stream, GstClockTime ts, gint64 * diff);
|
gint gst_mpd_client_check_time_position (GstMpdClient * client, GstActiveStream * stream, GstClockTime ts, gint64 * diff);
|
||||||
GstClockTime gst_mpd_parser_get_stream_presentation_offset (GstMpdClient *client, guint stream_idx);
|
GstClockTime gst_mpd_parser_get_stream_presentation_offset (GstMpdClient *client, guint stream_idx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue