mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
multipartdemux: timestamp output buffers based on first input buffer that provided bytes not last
https://bugzilla.gnome.org/show_bug.cgi?id=637754
This commit is contained in:
parent
54e7e7547a
commit
7d78a68c8d
2 changed files with 21 additions and 7 deletions
|
@ -301,6 +301,7 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
|
||||||
mppad->pad = pad;
|
mppad->pad = pad;
|
||||||
mppad->mime = g_strdup (mime);
|
mppad->mime = g_strdup (mime);
|
||||||
mppad->last_ret = GST_FLOW_OK;
|
mppad->last_ret = GST_FLOW_OK;
|
||||||
|
mppad->last_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
demux->srcpads = g_slist_prepend (demux->srcpads, mppad);
|
demux->srcpads = g_slist_prepend (demux->srcpads, mppad);
|
||||||
demux->numpads++;
|
demux->numpads++;
|
||||||
|
@ -536,7 +537,6 @@ gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstMultipartDemux *multipart;
|
GstMultipartDemux *multipart;
|
||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
GstClockTime timestamp;
|
|
||||||
gint size = 1;
|
gint size = 1;
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
|
|
||||||
|
@ -545,8 +545,6 @@ gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
|
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
|
||||||
|
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
|
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
|
||||||
gst_adapter_clear (adapter);
|
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_DEBUG_OBJECT (multipart, "skipping empty content.");
|
||||||
gst_adapter_flush (adapter, size - datalen);
|
gst_adapter_flush (adapter, size - datalen);
|
||||||
} else {
|
} else {
|
||||||
|
GstClockTime ts;
|
||||||
|
|
||||||
srcpad =
|
srcpad =
|
||||||
gst_multipart_find_pad_by_mime (multipart,
|
gst_multipart_find_pad_by_mime (multipart,
|
||||||
multipart->mime_type, &created);
|
multipart->mime_type, &created);
|
||||||
|
|
||||||
|
ts = gst_adapter_prev_pts (adapter, NULL);
|
||||||
outbuf = gst_adapter_take_buffer (adapter, datalen);
|
outbuf = gst_adapter_take_buffer (adapter, datalen);
|
||||||
gst_adapter_flush (adapter, size - 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);
|
tags = gst_tag_list_new (GST_TAG_CONTAINER_FORMAT, "Multipart", NULL);
|
||||||
gst_tag_list_set_scope (tags, GST_TAG_SCOPE_GLOBAL);
|
gst_tag_list_set_scope (tags, GST_TAG_SCOPE_GLOBAL);
|
||||||
gst_pad_push_event (srcpad->pad, gst_event_new_tag (tags));
|
gst_pad_push_event (srcpad->pad, gst_event_new_tag (tags));
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = 0;
|
|
||||||
} else {
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) = 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,
|
GST_DEBUG_OBJECT (multipart,
|
||||||
"pushing buffer with timestamp %" GST_TIME_FORMAT,
|
"pushing buffer with timestamp %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
|
||||||
|
|
|
@ -51,6 +51,8 @@ typedef struct
|
||||||
|
|
||||||
gchar *mime;
|
gchar *mime;
|
||||||
|
|
||||||
|
GstClockTime last_ts; /* last timestamp to make sure we don't send
|
||||||
|
* two buffers with the same timestamp */
|
||||||
GstFlowReturn last_ret;
|
GstFlowReturn last_ret;
|
||||||
}
|
}
|
||||||
GstMultipartPad;
|
GstMultipartPad;
|
||||||
|
|
Loading…
Reference in a new issue