#define STREAM_IS_EOS(s) (s->time_position == GST_CLOCK_TIME_NONE)
+#define ABSDIFF(x, y) ( (x) > (y) ? ((x) - (y)) : ((y) - (x)) )
+
GST_DEBUG_CATEGORY (qtdemux_debug);
typedef struct _QtDemuxSegment QtDemuxSegment;
guint32 n_samples_moof; /* sample count in a moof */
guint64 duration_moof; /* duration in timescale of a moof, used for figure out
* the framerate of fragmented format stream */
+ guint64 duration_last_moof;
guint32 offset_in_sample; /* Offset in the current sample, used for
* streams which have got exceedingly big
stream->protection_scheme_info = NULL;
stream->n_samples_moof = 0;
stream->duration_moof = 0;
+ stream->duration_last_moof = 0;
g_queue_init (&stream->protection_scheme_event_queue);
return stream;
}
stream->n_samples_moof = 0;
stream->duration_moof = 0;
+ stream->duration_last_moof = 0;
}
static void
stream->samples[stream->n_samples - 1].timestamp +
stream->samples[stream->n_samples - 1].duration;
+ /* If this is a GST_FORMAT_BYTES stream and there's a significant
+ * difference (1 sec.) between decode_ts and timestamp, prefer the
+ * former */
+ if (!qtdemux->upstream_format_is_time
+ && ABSDIFF (decode_ts, timestamp) >
+ MAX (stream->duration_last_moof / 2,
+ GSTTIME_TO_QTSTREAMTIME (stream, GST_SECOND))) {
+ GST_INFO_OBJECT (qtdemux,
+ "decode_ts (%" GST_TIME_FORMAT ") and timestamp (%" GST_TIME_FORMAT
+ ") are significantly different (more than %" GST_TIME_FORMAT
+ "), using decode_ts",
+ GST_TIME_ARGS (QTSTREAMTIME_TO_GSTTIME (stream, decode_ts)),
+ GST_TIME_ARGS (QTSTREAMTIME_TO_GSTTIME (stream, timestamp)),
+ GST_TIME_ARGS (QTSTREAMTIME_TO_GSTTIME (stream,
+ MAX (stream->duration_last_moof / 2,
+ GSTTIME_TO_QTSTREAMTIME (stream, GST_SECOND)))));
+ timestamp = decode_ts;
+ }
+
gst_ts = QTSTREAMTIME_TO_GSTTIME (stream, timestamp);
GST_INFO_OBJECT (qtdemux, "first sample ts %" GST_TIME_FORMAT
" (extends previous samples)", GST_TIME_ARGS (gst_ts));
/* initialise moof sample data */
stream->n_samples_moof = 0;
+ stream->duration_last_moof = stream->duration_moof;
stream->duration_moof = 0;
/* Track Run node */