summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2013-12-19 23:00:12 +1100
committerJan Schmidt <jan@centricular.com>2013-12-31 23:23:18 +1100
commit14a56b6964b87e66bc2e242ace03ac385bfe1e12 (patch)
tree2b11234b47601df4ce5e0c9db64ab7aaf718b276 /gst
parent3149dbb44bf6d1324ab7affddcd8d716e33d84e0 (diff)
downloadgstreamer-plugins-bad-14a56b6964b87e66bc2e242ace03ac385bfe1e12.tar.gz
mpegtsmux: Don't disrupt buffer state in the clip function
Collectpads assumes that it can pass any buffer to the clip function for adjustment, some of which are artificially injected - so don't adjust global timestamp tracking there. Instead, only adjust the buffer timestamps and use them directly in the collection function. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=698748
Diffstat (limited to 'gst')
-rw-r--r--gst/mpegtsmux/mpegtsmux.c33
-rw-r--r--gst/mpegtsmux/mpegtsmux.h3
2 files changed, 14 insertions, 22 deletions
diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c
index fa50f56f3..0247fcfc5 100644
--- a/gst/mpegtsmux/mpegtsmux.c
+++ b/gst/mpegtsmux/mpegtsmux.c
@@ -321,8 +321,7 @@ static void
mpegtsmux_pad_reset (MpegTsPadData * pad_data)
{
pad_data->pid = 0;
- pad_data->last_pts = GST_CLOCK_TIME_NONE;
- pad_data->last_dts = GST_CLOCK_TIME_NONE;
+ pad_data->min_dts = GST_CLOCK_TIME_NONE;
pad_data->prog_id = -1;
#if 0
pad_data->prog_id = -1;
@@ -1020,7 +1019,6 @@ mpegtsmux_clip_inc_running_time (GstCollectPads * pads,
GST_LOG_OBJECT (cdata->pad, "buffer pts %" GST_TIME_FORMAT " -> %"
GST_TIME_FORMAT " running time",
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (time));
- pad_data->last_pts = time;
buf = *outbuf = gst_buffer_make_writable (buf);
GST_BUFFER_TIMESTAMP (*outbuf) = time;
}
@@ -1039,14 +1037,11 @@ mpegtsmux_clip_inc_running_time (GstCollectPads * pads,
GST_LOG_OBJECT (cdata->pad, "buffer dts %" GST_TIME_FORMAT " -> %"
GST_TIME_FORMAT " running time",
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (time));
- if (GST_CLOCK_TIME_IS_VALID (pad_data->last_dts) &&
- time < pad_data->last_dts) {
- /* FIXME DTS/PTS mess again;
- * probably needs a whole lot more subtle handling (cf qtmux) */
+ if (GST_CLOCK_TIME_IS_VALID (pad_data->min_dts) &&
+ time < pad_data->min_dts) {
+ /* Ignore DTS going backward */
GST_WARNING_OBJECT (cdata->pad, "ignoring DTS going backward");
- time = pad_data->last_dts;
- } else {
- pad_data->last_dts = time;
+ time = pad_data->min_dts;
}
buf = *outbuf = gst_buffer_make_writable (buf);
GST_BUFFER_DTS (*outbuf) = time;
@@ -1154,18 +1149,16 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
GST_DEBUG_OBJECT (COLLECT_DATA_PAD (best),
"Chose stream for output (PID: 0x%04x)", best->pid);
- if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_PTS (buf)) &&
- GST_CLOCK_TIME_IS_VALID (best->last_pts)) {
- pts = GSTTIME_TO_MPEGTIME (best->last_pts);
+ if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_PTS (buf))) {
+ pts = GSTTIME_TO_MPEGTIME (GST_BUFFER_PTS (buf));
GST_DEBUG_OBJECT (mux, "Buffer has PTS %" GST_TIME_FORMAT " pts %"
- G_GINT64_FORMAT, GST_TIME_ARGS (best->last_pts), pts);
+ G_GINT64_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf)), pts);
}
- if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf)) &&
- GST_CLOCK_TIME_IS_VALID (best->last_dts)) {
- dts = GSTTIME_TO_MPEGTIME (best->last_dts);
+ if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf))) {
+ dts = GSTTIME_TO_MPEGTIME (GST_BUFFER_DTS (buf));
GST_DEBUG_OBJECT (mux, "Buffer has DTS %" GST_TIME_FORMAT " dts %"
- G_GINT64_FORMAT, GST_TIME_ARGS (best->last_dts), dts);
+ G_GINT64_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (buf)), dts);
}
/* should not have a DTS without PTS */
@@ -1197,8 +1190,8 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
if (prog->pcr_stream == best->stream) {
/* prefer DTS if present for PCR as it should be monotone */
mux->last_ts =
- GST_CLOCK_TIME_IS_VALID (best->last_dts) ? best->last_dts : best->
- last_pts;
+ GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf)) ?
+ GST_BUFFER_DTS (buf) : GST_BUFFER_PTS (buf);
}
mux->is_delta = delta;
diff --git a/gst/mpegtsmux/mpegtsmux.h b/gst/mpegtsmux/mpegtsmux.h
index 52b291e7a..c894e5857 100644
--- a/gst/mpegtsmux/mpegtsmux.h
+++ b/gst/mpegtsmux/mpegtsmux.h
@@ -185,8 +185,7 @@ struct MpegTsPadData {
TsMuxStream *stream;
/* most recent valid TS for this stream */
- GstClockTime last_pts;
- GstClockTime last_dts;
+ GstClockTime min_dts;
#if 0
/* (optional) index writing */