matroskademux: track clip duration in segment

This commit is contained in:
Mark Nauwelaerts 2010-03-18 15:29:00 +01:00
parent 6ccffcf5f1
commit 95e38e59a2
2 changed files with 9 additions and 8 deletions

View file

@ -401,7 +401,6 @@ gst_matroska_demux_reset (GstElement * element)
demux->tags_parsed = NULL; demux->tags_parsed = NULL;
gst_segment_init (&demux->segment, GST_FORMAT_TIME); gst_segment_init (&demux->segment, GST_FORMAT_TIME);
demux->duration = -1;
demux->last_stop_end = GST_CLOCK_TIME_NONE; demux->last_stop_end = GST_CLOCK_TIME_NONE;
demux->seek_block = 0; demux->seek_block = 0;
@ -1946,13 +1945,14 @@ gst_matroska_demux_query (GstMatroskaDemux * demux, GstPad * pad,
if (format == GST_FORMAT_TIME) { if (format == GST_FORMAT_TIME) {
GST_OBJECT_LOCK (demux); GST_OBJECT_LOCK (demux);
gst_query_set_duration (query, GST_FORMAT_TIME, demux->duration); gst_query_set_duration (query, GST_FORMAT_TIME,
demux->segment.duration);
GST_OBJECT_UNLOCK (demux); GST_OBJECT_UNLOCK (demux);
} else if (format == GST_FORMAT_DEFAULT && context } else if (format == GST_FORMAT_DEFAULT && context
&& context->default_duration) { && context->default_duration) {
GST_OBJECT_LOCK (demux); GST_OBJECT_LOCK (demux);
gst_query_set_duration (query, GST_FORMAT_DEFAULT, gst_query_set_duration (query, GST_FORMAT_DEFAULT,
demux->duration / context->default_duration); demux->segment.duration / context->default_duration);
GST_OBJECT_UNLOCK (demux); GST_OBJECT_UNLOCK (demux);
} else { } else {
GST_DEBUG_OBJECT (demux, GST_DEBUG_OBJECT (demux,
@ -1973,7 +1973,7 @@ gst_matroska_demux_query (GstMatroskaDemux * demux, GstPad * pad,
gst_query_set_seeking (query, fmt, FALSE, -1, -1); gst_query_set_seeking (query, fmt, FALSE, -1, -1);
} else { } else {
gst_query_set_seeking (query, GST_FORMAT_TIME, TRUE, 0, gst_query_set_seeking (query, GST_FORMAT_TIME, TRUE, 0,
demux->duration); demux->segment.duration);
} }
break; break;
@ -2868,7 +2868,7 @@ gst_matroska_demux_parse_info (GstMatroskaDemux * demux)
dur = gst_gdouble_to_guint64 (num * dur = gst_gdouble_to_guint64 (num *
gst_guint64_to_gdouble (demux->time_scale)); gst_guint64_to_gdouble (demux->time_scale));
if (GST_CLOCK_TIME_IS_VALID (dur) && dur <= G_MAXINT64) if (GST_CLOCK_TIME_IS_VALID (dur) && dur <= G_MAXINT64)
demux->duration = dur; gst_segment_set_duration (&demux->segment, GST_FORMAT_TIME, dur);
break; break;
} }
@ -4470,8 +4470,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
demux->last_stop_end < last_stop_end) demux->last_stop_end < last_stop_end)
demux->last_stop_end = last_stop_end; demux->last_stop_end = last_stop_end;
if (demux->duration == -1 || demux->duration < lace_time) { if (demux->segment.duration == -1 ||
demux->duration = last_stop_end; demux->segment.duration < lace_time) {
gst_segment_set_duration (&demux->segment, GST_FORMAT_TIME,
last_stop_end);
gst_element_post_message (GST_ELEMENT_CAST (demux), gst_element_post_message (GST_ELEMENT_CAST (demux),
gst_message_new_duration (GST_OBJECT_CAST (demux), gst_message_new_duration (GST_OBJECT_CAST (demux),
GST_FORMAT_TIME, GST_CLOCK_TIME_NONE)); GST_FORMAT_TIME, GST_CLOCK_TIME_NONE));

View file

@ -94,7 +94,6 @@ typedef struct _GstMatroskaDemux {
GstSegment segment; GstSegment segment;
gboolean segment_running; gboolean segment_running;
GstClockTime last_stop_end; GstClockTime last_stop_end;
gint64 duration;
GstEvent *close_segment; GstEvent *close_segment;
GstEvent *new_segment; GstEvent *new_segment;