Commit 7d78a68c authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

multipartdemux: timestamp output buffers based on first input buffer that provided bytes not last

https://bugzilla.gnome.org/show_bug.cgi?id=637754
parent 54e7e754
......@@ -301,6 +301,7 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
mppad->pad = pad;
mppad->mime = g_strdup (mime);
mppad->last_ret = GST_FLOW_OK;
mppad->last_ts = GST_CLOCK_TIME_NONE;
demux->srcpads = g_slist_prepend (demux->srcpads, mppad);
demux->numpads++;
......@@ -536,7 +537,6 @@ gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstMultipartDemux *multipart;
GstAdapter *adapter;
GstClockTime timestamp;
gint size = 1;
GstFlowReturn res;
......@@ -545,8 +545,6 @@ gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
res = GST_FLOW_OK;
timestamp = GST_BUFFER_TIMESTAMP (buf);
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
gst_adapter_clear (adapter);
}
......@@ -578,9 +576,13 @@ gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
GST_DEBUG_OBJECT (multipart, "skipping empty content.");
gst_adapter_flush (adapter, size - datalen);
} else {
GstClockTime ts;
srcpad =
gst_multipart_find_pad_by_mime (multipart,
multipart->mime_type, &created);
ts = gst_adapter_prev_pts (adapter, NULL);
outbuf = gst_adapter_take_buffer (adapter, datalen);
gst_adapter_flush (adapter, size - datalen);
......@@ -596,11 +598,21 @@ gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
tags = gst_tag_list_new (GST_TAG_CONTAINER_FORMAT, "Multipart", NULL);
gst_tag_list_set_scope (tags, GST_TAG_SCOPE_GLOBAL);
gst_pad_push_event (srcpad->pad, gst_event_new_tag (tags));
}
GST_BUFFER_TIMESTAMP (outbuf) = 0;
outbuf = gst_buffer_make_writable (outbuf);
if (srcpad->last_ts == GST_CLOCK_TIME_NONE || srcpad->last_ts != ts) {
GST_BUFFER_TIMESTAMP (outbuf) = ts;
srcpad->last_ts = ts;
} else {
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
}
if (created)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
else
GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DISCONT);
GST_DEBUG_OBJECT (multipart,
"pushing buffer with timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
......
......@@ -51,6 +51,8 @@ typedef struct
gchar *mime;
GstClockTime last_ts; /* last timestamp to make sure we don't send
* two buffers with the same timestamp */
GstFlowReturn last_ret;
}
GstMultipartPad;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment