Instead of writing a seek routine, just use the mpdparser function.
Also remove function that is not needed anymore
/* If stream is live, try to find the segment that
* is closest to current time */
if (gst_mpd_client_is_live (dashdemux->client)) {
- GList *iter;
- gint seg_idx;
+ GDateTime *gnow;
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 {
GST_DEBUG_OBJECT (demux, "Seeking to first segment for on-demand stream ");
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 *
gst_mpd_client_get_availability_start_time (GstMpdClient * client)
{
gboolean gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, GstClockTime ts);
gboolean gst_mpd_client_seek_to_time (GstMpdClient * client, GDateTime * time);
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);
GstClockTime gst_mpd_parser_get_stream_presentation_offset (GstMpdClient *client, guint stream_idx);