mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst/tcp/gstmultifdsink.c: Small cleanups.
Original commit message from CVS: * gst/tcp/gstmultifdsink.c: (gst_multi_fd_sink_render): Small cleanups. If a buffer is received with no caps, make the buffer metadata writable and set the caps, making sure that we don't screw up the refcounts.
This commit is contained in:
parent
e7b2bf111f
commit
a6a8d58fd2
2 changed files with 34 additions and 19 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2006-08-25 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/tcp/gstmultifdsink.c: (gst_multi_fd_sink_render):
|
||||||
|
Small cleanups.
|
||||||
|
If a buffer is received with no caps, make the buffer metadata
|
||||||
|
writable and set the caps, making sure that we don't screw up the
|
||||||
|
refcounts.
|
||||||
|
|
||||||
2006-08-25 Michael Smith <msmith@fluendo.com>
|
2006-08-25 Michael Smith <msmith@fluendo.com>
|
||||||
|
|
||||||
* gst/gdp/gstgdppay.c: (gst_gdp_pay_reset),
|
* gst/gdp/gstgdppay.c: (gst_gdp_pay_reset),
|
||||||
|
|
|
@ -2207,30 +2207,34 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
||||||
|
|
||||||
sink = GST_MULTI_FD_SINK (bsink);
|
sink = GST_MULTI_FD_SINK (bsink);
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_MULTI_FD_SINK_OPEN),
|
||||||
|
GST_FLOW_WRONG_STATE);
|
||||||
|
|
||||||
/* since we check every buffer for streamheader caps, we need to make
|
/* since we check every buffer for streamheader caps, we need to make
|
||||||
* sure every buffer has caps set */
|
* sure every buffer has caps set */
|
||||||
bufcaps = gst_buffer_get_caps (buf);
|
bufcaps = gst_buffer_get_caps (buf);
|
||||||
padcaps = GST_PAD_CAPS (GST_BASE_SINK_PAD (bsink));
|
padcaps = GST_PAD_CAPS (GST_BASE_SINK_PAD (bsink));
|
||||||
|
|
||||||
/* make sure we have caps on the pad */
|
/* make sure we have caps on the pad */
|
||||||
if (!padcaps) {
|
if (!padcaps && !bufcaps)
|
||||||
if (!bufcaps) {
|
goto no_caps;
|
||||||
GST_ELEMENT_ERROR (sink, CORE, NEGOTIATION, (NULL),
|
|
||||||
("Received first buffer without caps set"));
|
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stamp the buffer with previous caps if no caps set */
|
/* stamp the buffer with previous caps if no caps set */
|
||||||
if (!bufcaps) {
|
if (!bufcaps) {
|
||||||
/* We keep this buffer around, and need to write it, but we can't just use
|
if (!gst_buffer_is_metadata_writable (buf)) {
|
||||||
* gst_buffer_make_writable(), because we're not allowed to unref this buf,
|
/* metadata is not writable, copy will be made and original buffer
|
||||||
* basesink will do that for us */
|
* will be unreffed so we need to ref so that we don't loose the
|
||||||
if (!gst_buffer_is_writable (buf))
|
* buffer in the render method. */
|
||||||
buf = gst_buffer_copy (buf);
|
|
||||||
else
|
|
||||||
gst_buffer_ref (buf);
|
gst_buffer_ref (buf);
|
||||||
|
/* the new buffer is ours only, we keep it out of the scope of this
|
||||||
|
* function */
|
||||||
|
buf = gst_buffer_make_metadata_writable (buf);
|
||||||
|
} else {
|
||||||
|
/* else the metadata is writable, we ref because we keep the buffer
|
||||||
|
* out of the scope of this method */
|
||||||
|
gst_buffer_ref (buf);
|
||||||
|
}
|
||||||
|
/* buffer metadata is writable now, set the caps */
|
||||||
GST_DEBUG_OBJECT (sink, "result is %p", buf);
|
GST_DEBUG_OBJECT (sink, "result is %p", buf);
|
||||||
gst_buffer_set_caps (buf, padcaps);
|
gst_buffer_set_caps (buf, padcaps);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2240,10 +2244,6 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
||||||
gst_buffer_ref (buf);
|
gst_buffer_ref (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_MULTI_FD_SINK_OPEN),
|
|
||||||
GST_FLOW_ERROR);
|
|
||||||
|
|
||||||
in_caps = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
in_caps = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
||||||
|
|
||||||
GST_LOG_OBJECT (sink, "received buffer %p, in_caps: %d", buf, in_caps);
|
GST_LOG_OBJECT (sink, "received buffer %p, in_caps: %d", buf, in_caps);
|
||||||
|
@ -2281,8 +2281,15 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
||||||
|
|
||||||
sink->bytes_to_serve += GST_BUFFER_SIZE (buf);
|
sink->bytes_to_serve += GST_BUFFER_SIZE (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
no_caps:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (sink, CORE, NEGOTIATION, (NULL),
|
||||||
|
("Received first buffer without caps set"));
|
||||||
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue