+2008-08-20 Wim Taymans <wim.taymans@collabora.co.uk>
+
+ * docs/libs/gstreamer-libs-sections.txt:
+ * libs/gst/base/gstbasetransform.c:
+ (gst_base_transform_handle_buffer), (gst_base_transform_getrange),
+ (gst_base_transform_chain), (gst_base_transform_suggest),
+ (gst_base_transform_reconfigure):
+ * libs/gst/base/gstbasetransform.h:
+ Implement method for reconfiguring basetransform.
+ API: GstBaseTransform::gst_base_transform_reconfigure()
+
2008-08-20 Stefan Kost <ensonic@users.sf.net>
patch by: Murray Cumming <murrayc@murrayc.com>
GstCaps *sink_suggest;
guint size_suggest;
gint suggest_pending;
+
+ gboolean reconfigure;
};
static GstElementClass *parent_class = NULL;
{
GstBaseTransformClass *bclass;
GstFlowReturn ret = GST_FLOW_OK;
- gboolean want_in_place;
+ gboolean want_in_place, reconfigure;
GstClockTime qostime;
+ GstCaps *incaps;
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
+ if (G_LIKELY ((incaps = GST_BUFFER_CAPS (inbuf)))) {
+ GST_OBJECT_LOCK (trans);
+ reconfigure = trans->priv->reconfigure;
+ trans->priv->reconfigure = FALSE;
+ GST_OBJECT_UNLOCK (trans);
+
+ if (G_UNLIKELY (reconfigure)) {
+ /* if we need to reconfigure we pretend a buffer with new caps arrived. This
+ * will reconfigure the transform with the new output format. We can only
+ * do this if the buffer actually has caps. */
+ if (!gst_base_transform_setcaps (trans->sinkpad, incaps))
+ goto not_negotiated;
+ }
+ }
+
if (GST_BUFFER_OFFSET_IS_VALID (inbuf))
GST_DEBUG_OBJECT (trans, "handling buffer %p of size %d and offset %"
G_GUINT64_FORMAT, inbuf, GST_BUFFER_SIZE (inbuf),
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf);
if (ret == GST_FLOW_OK) {
+ GST_BASE_TRANSFORM_LOCK (trans);
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer);
+ GST_BASE_TRANSFORM_UNLOCK (trans);
}
gst_object_unref (trans);
}
/* protect transform method and concurrent buffer alloc */
+ GST_BASE_TRANSFORM_LOCK (trans);
ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf);
+ GST_BASE_TRANSFORM_UNLOCK (trans);
/* outbuf can be NULL, this means a dropped buffer, if we have a buffer but
* GST_BASE_TRANSFORM_FLOW_DROPPED we will not push either. */
* @caps: caps to suggest
* @size: buffer size to suggest
*
- * Instructs @trans to suggest new @caps upstream.
+ * Instructs @trans to suggest new @caps upstream. A copy of @caps will be
+ * taken.
*
* Since: 0.10.21
*/
GST_OBJECT_LOCK (trans->sinkpad);
if (trans->priv->sink_suggest)
gst_caps_unref (trans->priv->sink_suggest);
- trans->priv->sink_suggest = gst_caps_copy (caps);
+ if (caps)
+ caps = gst_caps_copy (caps);
+ trans->priv->sink_suggest = caps;
trans->priv->size_suggest = size;
g_atomic_int_set (&trans->priv->suggest_pending, 1);
GST_DEBUG_OBJECT (trans, "new suggest %" GST_PTR_FORMAT, caps);
GST_OBJECT_UNLOCK (trans->sinkpad);
}
-#if 0
/**
* gst_base_transform_reconfigure:
* @trans: a #GstBaseTransform
*
* Instructs @trans to renegotiate a new downstream transform on the next
- * buffer.
- *
- * Note: Not yet implemented.
+ * buffer. This function is typically called after properties on the transform
+ * were set that influence the output format.
*
* Since: 0.10.21
*/
void
gst_base_transform_reconfigure (GstBaseTransform * trans)
{
+ g_return_if_fail (GST_IS_BASE_TRANSFORM (trans));
+
+ GST_OBJECT_LOCK (trans);
+ trans->priv->reconfigure = TRUE;
+ GST_OBJECT_UNLOCK (trans);
}
-#endif