mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-13 17:55:30 +00:00
collectpads: handle buffer with dts-only when mapping to running time
Otherwise the buffer was left with the original values and later would be compared with other buffers that were converted to runninn time, leading to bad interleaving of multiple streams. https://bugzilla.gnome.org/show_bug.cgi?id=757961
This commit is contained in:
parent
2c475a0355
commit
288280fb0c
1 changed files with 39 additions and 34 deletions
|
@ -505,47 +505,52 @@ gst_collect_pads_clip_running_time (GstCollectPads * pads,
|
||||||
GstCollectData * cdata, GstBuffer * buf, GstBuffer ** outbuf,
|
GstCollectData * cdata, GstBuffer * buf, GstBuffer ** outbuf,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GstClockTime time;
|
|
||||||
|
|
||||||
*outbuf = buf;
|
*outbuf = buf;
|
||||||
time = GST_BUFFER_PTS (buf);
|
|
||||||
|
|
||||||
/* invalid left alone and passed */
|
/* invalid left alone and passed */
|
||||||
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (time))) {
|
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf))
|
||||||
time = gst_segment_to_running_time (&cdata->segment, GST_FORMAT_TIME, time);
|
|| GST_CLOCK_TIME_IS_VALID (GST_BUFFER_PTS (buf)))) {
|
||||||
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (time))) {
|
GstClockTime time;
|
||||||
GST_DEBUG_OBJECT (cdata->pad, "clipping buffer on pad outside segment %"
|
GstClockTime buf_dts, abs_dts;
|
||||||
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf)));
|
gint dts_sign;
|
||||||
gst_buffer_unref (buf);
|
|
||||||
*outbuf = NULL;
|
|
||||||
} else {
|
|
||||||
GstClockTime buf_dts, abs_dts;
|
|
||||||
gint dts_sign;
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (cdata->pad, "buffer pts %" GST_TIME_FORMAT " -> %"
|
time = GST_BUFFER_PTS (buf);
|
||||||
GST_TIME_FORMAT " running time",
|
|
||||||
GST_TIME_ARGS (GST_BUFFER_PTS (buf)), GST_TIME_ARGS (time));
|
|
||||||
*outbuf = gst_buffer_make_writable (buf);
|
|
||||||
GST_BUFFER_PTS (*outbuf) = time;
|
|
||||||
|
|
||||||
dts_sign = gst_segment_to_running_time_full (&cdata->segment,
|
if (GST_CLOCK_TIME_IS_VALID (time)) {
|
||||||
GST_FORMAT_TIME, GST_BUFFER_DTS (*outbuf), &abs_dts);
|
time =
|
||||||
buf_dts = GST_BUFFER_DTS (*outbuf);
|
gst_segment_to_running_time (&cdata->segment, GST_FORMAT_TIME, time);
|
||||||
if (dts_sign > 0) {
|
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (time))) {
|
||||||
GST_BUFFER_DTS (*outbuf) = abs_dts;
|
GST_DEBUG_OBJECT (cdata->pad, "clipping buffer on pad outside segment %"
|
||||||
GST_COLLECT_PADS_DTS (cdata) = abs_dts;
|
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf)));
|
||||||
} else if (dts_sign < 0) {
|
gst_buffer_unref (buf);
|
||||||
GST_BUFFER_DTS (*outbuf) = GST_CLOCK_TIME_NONE;
|
*outbuf = NULL;
|
||||||
GST_COLLECT_PADS_DTS (cdata) = -((gint64) abs_dts);
|
return GST_FLOW_OK;
|
||||||
} else {
|
|
||||||
GST_BUFFER_DTS (*outbuf) = GST_CLOCK_TIME_NONE;
|
|
||||||
GST_COLLECT_PADS_DTS (cdata) = GST_CLOCK_STIME_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_LOG_OBJECT (cdata->pad, "buffer dts %" GST_TIME_FORMAT " -> %"
|
|
||||||
GST_STIME_FORMAT " running time", GST_TIME_ARGS (buf_dts),
|
|
||||||
GST_STIME_ARGS (GST_COLLECT_PADS_DTS (cdata)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (cdata->pad, "buffer pts %" GST_TIME_FORMAT " -> %"
|
||||||
|
GST_TIME_FORMAT " running time",
|
||||||
|
GST_TIME_ARGS (GST_BUFFER_PTS (buf)), GST_TIME_ARGS (time));
|
||||||
|
*outbuf = gst_buffer_make_writable (buf);
|
||||||
|
GST_BUFFER_PTS (*outbuf) = time;
|
||||||
|
|
||||||
|
dts_sign = gst_segment_to_running_time_full (&cdata->segment,
|
||||||
|
GST_FORMAT_TIME, GST_BUFFER_DTS (*outbuf), &abs_dts);
|
||||||
|
buf_dts = GST_BUFFER_DTS (*outbuf);
|
||||||
|
if (dts_sign > 0) {
|
||||||
|
GST_BUFFER_DTS (*outbuf) = abs_dts;
|
||||||
|
GST_COLLECT_PADS_DTS (cdata) = abs_dts;
|
||||||
|
} else if (dts_sign < 0) {
|
||||||
|
GST_BUFFER_DTS (*outbuf) = GST_CLOCK_TIME_NONE;
|
||||||
|
GST_COLLECT_PADS_DTS (cdata) = -((gint64) abs_dts);
|
||||||
|
} else {
|
||||||
|
GST_BUFFER_DTS (*outbuf) = GST_CLOCK_TIME_NONE;
|
||||||
|
GST_COLLECT_PADS_DTS (cdata) = GST_CLOCK_STIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (cdata->pad, "buffer dts %" GST_TIME_FORMAT " -> %"
|
||||||
|
GST_STIME_FORMAT " running time", GST_TIME_ARGS (buf_dts),
|
||||||
|
GST_STIME_ARGS (GST_COLLECT_PADS_DTS (cdata)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
Loading…
Reference in a new issue