GST_M3U8_CLIENT_LOCK (demux->client);
GST_DEBUG_OBJECT (demux, "seeking to sequence %d", current_sequence);
demux->client->sequence = current_sequence;
- demux->position = start;
+ gst_m3u8_client_get_current_position (demux->client, &demux->position);
+ demux->position_shift = start - demux->position;
demux->need_segment = TRUE;
GST_M3U8_CLIENT_UNLOCK (demux->client);
demux->need_segment = TRUE;
}
if (demux->need_segment) {
+ GstClockTime start = demux->position + demux->position_shift;
/* And send a newsegment */
- GST_DEBUG_OBJECT (demux, "Sending new-segment. Segment start:%"
- GST_TIME_FORMAT, GST_TIME_ARGS (demux->position));
+ GST_DEBUG_OBJECT (demux, "Sending new-segment. segment start:%"
+ GST_TIME_FORMAT, GST_TIME_ARGS (start));
gst_pad_push_event (demux->srcpad,
- gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, demux->position,
- GST_CLOCK_TIME_NONE, demux->position));
+ gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
+ start, GST_CLOCK_TIME_NONE, start));
demux->need_segment = FALSE;
+ demux->position_shift = 0;
}
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buf)))
g_queue_clear (demux->queue);
demux->position = 0;
+ demux->position_shift = 0;
demux->need_segment = TRUE;
}
demux->client->sequence -= demux->fragments_cache;
else
demux->client->sequence = 0;
+ gst_m3u8_client_get_current_position (demux->client, &demux->position);
GST_M3U8_CLIENT_UNLOCK (demux->client);
} else {
GstClockTime duration = gst_m3u8_client_get_duration (demux->client);
return TRUE;
}
+void
+gst_m3u8_client_get_current_position (GstM3U8Client * client,
+ GstClockTime * timestamp)
+{
+ GList *l;
+ GList *walk;
+
+ l = g_list_find_custom (client->current->files, client,
+ (GCompareFunc) _find_next);
+
+ *timestamp = 0;
+ for (walk = client->current->files; walk; walk = walk->next) {
+ if (walk == l)
+ break;
+ *timestamp += GST_M3U8_MEDIA_FILE (walk->data)->duration;
+ }
+ *timestamp *= GST_SECOND;
+}
+
gboolean
gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
gboolean * discontinuity, const gchar ** uri, GstClockTime * duration,
GstClockTime * timestamp)
{
- GList *l;
- GList *walk;
+ GList *l, *walk;
GstM3U8MediaFile *file;
g_return_val_if_fail (client != NULL, FALSE);
return FALSE;
}
+ gst_m3u8_client_get_current_position (client, timestamp);
+
file = GST_M3U8_MEDIA_FILE (l->data);
*discontinuity = client->sequence != file->sequence;
gboolean gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
gboolean * discontinuity, const gchar ** uri, GstClockTime * duration,
GstClockTime * timestamp);
+void gst_m3u8_client_get_current_position (GstM3U8Client * client,
+ GstClockTime * timestamp);
GstClockTime gst_m3u8_client_get_duration (GstM3U8Client * client);
GstClockTime gst_m3u8_client_get_target_duration (GstM3U8Client * client);
const gchar *gst_m3u8_client_get_uri(GstM3U8Client * client);