- if (GST_CLOCK_TIME_IS_VALID (collect_pad->duration) &&
- duration < collect_pad->duration)
- duration = collect_pad->duration;
- }
- if (duration != 0) {
- GST_DEBUG_OBJECT (mux, "final total duration: %" GST_TIME_FORMAT,
- GST_TIME_ARGS (duration));
- pos = mux->ebml_write->pos;
- gst_ebml_write_seek (ebml, mux->duration_pos);
- gst_ebml_write_float (ebml, GST_MATROSKA_ID_DURATION,
- gst_guint64_to_gdouble (duration) /
- gst_guint64_to_gdouble (mux->time_scale));
- gst_ebml_write_seek (ebml, pos);
- } else {
- /* void'ify */
- guint64 my_pos = ebml->pos;
+ GST_DEBUG_OBJECT (mux,
+ "Pad %" GST_PTR_FORMAT " start ts %" GST_TIME_FORMAT
+ " end ts %" GST_TIME_FORMAT, collect_pad,
+ GST_TIME_ARGS (collect_pad->start_ts),
+ GST_TIME_ARGS (collect_pad->end_ts));
+
+ if (GST_CLOCK_TIME_IS_VALID (collect_pad->start_ts) &&
+ GST_CLOCK_TIME_IS_VALID (collect_pad->end_ts)) {
+ min_duration =
+ GST_CLOCK_DIFF (collect_pad->start_ts, collect_pad->end_ts);
+ if (collect_pad->duration < min_duration)
+ collect_pad->duration = min_duration;
+ GST_DEBUG_OBJECT (collect_pad,
+ "final track duration: %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (collect_pad->duration));
+ }
+
+ if (GST_CLOCK_TIME_IS_VALID (collect_pad->duration) &&
+ duration < collect_pad->duration)
+ duration = collect_pad->duration;
+ }
+ if (duration != 0) {
+ GST_DEBUG_OBJECT (mux, "final total duration: %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (duration));
+ pos = mux->ebml_write->pos;
+ gst_ebml_write_seek (ebml, mux->duration_pos);
+ gst_ebml_write_float (ebml, GST_MATROSKA_ID_DURATION,
+ gst_guint64_to_gdouble (duration) /
+ gst_guint64_to_gdouble (mux->time_scale));
+ gst_ebml_write_seek (ebml, pos);
+ } else {
+ /* void'ify */
+ guint64 my_pos = ebml->pos;