+2005-12-05 Andy Wingo <wingo@pobox.com>
+
+ patch by: Wim Taymans <wim@fluendo.com>
+
+ * libs/gst/base/gstbasetransform.c
+ (gst_base_transform_prepare_output_buf)
+ (gst_base_transform_buffer_alloc):
+ * plugins/elements/gstqueue.c (gst_queue_bufferalloc): Call
+ alloc_buffer_and_set_caps.
+
+ * gst/gstpad.c (gst_pad_alloc_buffer): Changed to not call
+ set_caps on the source pad.
+ (gst_pad_alloc_buffer_and_set_caps): New function, does what
+ alloc_buffer used to do. Fixes #322874.
+
+ * docs/gst/gstreamer-sections.txt:
+ * docs/design/part-negotiation.txt:
+ * docs/pwg/advanced-negotiation.xml: Update for the alloc_buffer
+ changes.
+
2005-12-05 Thomas Vander Stichele <thomas at apestaart dot org>
patch by: Sebastien Moutte
done
endif
- # if the type is different, this will call the setcaps function of
- # the pad.
+ # if the type is different, the buffer will have different caps from
+ # the src pad -- setcaps will get called on the pad_push
buffer = gst_pad_alloc_buffer (srcpad, 0, size, GST_PAD_CAPS (fixedcaps));
if buffer
[fill buffer and push]
gst_pad_new_from_static_template
gst_pad_alloc_buffer
+gst_pad_alloc_buffer_and_set_caps
gst_pad_set_bufferalloc_function
GstPadBufferAllocFunction
#GstBuffer, #GstCaps, #GstEvent
</para>
+<!-- ##### SECTION Stability_Level ##### -->
+
+
<!-- ##### ENUM GstDPHeaderFlag ##### -->
<para>
()</function>-function. The idea here is that an element requesting a
buffer from downstream, has to specify the type of that buffer. If
renegotiation is to take place, this type will no longer apply, and the
- downstream element will set a new caps on the provided buffer. Next,
- &GStreamer; will trigger renegotiation on the sourcepad of the element
- before the function returns.
+ downstream element will set a new caps on the provided buffer. The element
+ should then reconfigure itself to push buffers with the returned caps. The
+ source pad's setcaps will be called once the buffer is pushed.
</para>
<para>
It is important to note here that different elements actually have
/* returns TRUE if the src pad could be configured to accept the given caps */
static gboolean
-gst_pad_configure_src (GstPad * pad, GstCaps * caps)
+gst_pad_configure_src (GstPad * pad, GstCaps * caps, gboolean dosetcaps)
{
GstPadAcceptCapsFunction acceptcaps;
GstPadSetCapsFunction setcaps;
if (!acceptcaps (pad, caps))
goto not_accepted;
}
- /* set caps on pad if call succeeds */
- res = gst_pad_set_caps (pad, caps);
- /* no need to unref the caps here, set_caps takes a ref and
- * our ref goes away when we leave this function. */
+ if (dosetcaps)
+ res = gst_pad_set_caps (pad, caps);
+ else
+ res = TRUE;
return res;
}
}
-/**
- * gst_pad_alloc_buffer:
- * @pad: a source #GstPad
- * @offset: the offset of the new buffer in the stream
- * @size: the size of the new buffer
- * @caps: the caps of the new buffer
- * @buf: a newly allocated buffer
- *
- * Allocates a new, empty buffer optimized to push to pad @pad. This
- * function only works if @pad is a source pad and has a peer.
- *
- * You need to check the caps of the buffer after performing this
- * function and renegotiate to the format if needed.
- *
- * A new, empty #GstBuffer will be put in the @buf argument.
- *
- * Returns: a result code indicating success of the operation. Any
- * result code other than GST_FLOW_OK is an error and @buf should
- * not be used.
- * An error can occur if the pad is not connected or when the downstream
- * peer elements cannot provide an acceptable buffer.
- *
- * MT safe.
- */
-GstFlowReturn
-gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size, GstCaps * caps,
- GstBuffer ** buf)
+static GstFlowReturn
+gst_pad_alloc_buffer_full (GstPad * pad, guint64 offset, gint size,
+ GstCaps * caps, GstBuffer ** buf, gboolean setcaps)
{
GstPad *peer;
GstFlowReturn ret;
/* we got a new datatype on the pad, see if it can handle it */
if (G_UNLIKELY (caps_changed)) {
GST_DEBUG ("caps changed to %" GST_PTR_FORMAT, caps);
- if (G_UNLIKELY (!gst_pad_configure_src (pad, caps)))
+ if (G_UNLIKELY (!gst_pad_configure_src (pad, caps, setcaps)))
goto not_negotiated;
}
return ret;
}
/**
+ * gst_pad_alloc_buffer:
+ * @pad: a source #GstPad
+ * @offset: the offset of the new buffer in the stream
+ * @size: the size of the new buffer
+ * @caps: the caps of the new buffer
+ * @buf: a newly allocated buffer
+ *
+ * Allocates a new, empty buffer optimized to push to pad @pad. This
+ * function only works if @pad is a source pad and has a peer.
+ *
+ * You need to check the caps of the buffer after performing this
+ * function and renegotiate to the format if needed.
+ *
+ * A new, empty #GstBuffer will be put in the @buf argument.
+ *
+ * Returns: a result code indicating success of the operation. Any
+ * result code other than GST_FLOW_OK is an error and @buf should
+ * not be used.
+ * An error can occur if the pad is not connected or when the downstream
+ * peer elements cannot provide an acceptable buffer.
+ *
+ * MT safe.
+ */
+GstFlowReturn
+gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size, GstCaps * caps,
+ GstBuffer ** buf)
+{
+ return gst_pad_alloc_buffer_full (pad, offset, size, caps, buf, FALSE);
+}
+
+/**
+ * gst_pad_alloc_buffer_and_set_caps:
+ * @pad: a source #GstPad
+ * @offset: the offset of the new buffer in the stream
+ * @size: the size of the new buffer
+ * @caps: the caps of the new buffer
+ * @buf: a newly allocated buffer
+ *
+ * In addition to the function gst_pad_alloc_buffer(), this function
+ * automatically calls gst_pad_set_caps() when the caps of the
+ * newly allocated buffer are different from the @pad caps.
+ *
+ * Returns: a result code indicating success of the operation. Any
+ * result code other than GST_FLOW_OK is an error and @buf should
+ * not be used.
+ * An error can occur if the pad is not connected or when the downstream
+ * peer elements cannot provide an acceptable buffer.
+ *
+ * MT safe.
+ */
+GstFlowReturn
+gst_pad_alloc_buffer_and_set_caps (GstPad * pad, guint64 offset, gint size,
+ GstCaps * caps, GstBuffer ** buf)
+{
+ return gst_pad_alloc_buffer_full (pad, offset, size, caps, buf, TRUE);
+}
+
+/**
* gst_pad_get_internal_links_default:
* @pad: the #GstPad to get the internal links of.
*
void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufalloc);
GstFlowReturn gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size,
GstCaps *caps, GstBuffer **buf);
+GstFlowReturn gst_pad_alloc_buffer_and_set_caps (GstPad *pad, guint64 offset, gint size,
+ GstCaps *caps, GstBuffer **buf);
/* data passing setup functions */
void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);
}
}
-/* Allocate a buffer using gst_pad_alloc_buffer.
+/* Allocate a buffer using gst_pad_alloc_buffer_and_set_caps.
*
* This function can trigger a renegotiation on the source pad when the
* peer alloc_buffer function sets new caps. Since we currently are
if (*out_buf == NULL) {
/* Sub-class didn't already provide a buffer for us. Make one */
- ret = gst_pad_alloc_buffer (trans->srcpad, GST_BUFFER_OFFSET (in_buf),
- out_size, out_caps, out_buf);
+ ret =
+ gst_pad_alloc_buffer_and_set_caps (trans->srcpad,
+ GST_BUFFER_OFFSET (in_buf), out_size, out_caps, out_buf);
if (ret != GST_FLOW_OK || *out_buf == NULL)
goto done;
/* request a buffer with the same caps */
GST_DEBUG_OBJECT (trans, "requesting buffer with same caps, size %d", size);
- res = gst_pad_alloc_buffer (trans->srcpad, offset, size, caps, buf);
+ res =
+ gst_pad_alloc_buffer_and_set_caps (trans->srcpad, offset, size, caps,
+ buf);
} else {
/* if we are configured, request a buffer with the src caps */
GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad);
goto unknown_size;
}
- res = gst_pad_alloc_buffer (trans->srcpad, offset, new_size, srccaps, buf);
+ res =
+ gst_pad_alloc_buffer_and_set_caps (trans->srcpad, offset, new_size,
+ srccaps, buf);
gst_caps_unref (srccaps);
}
queue = GST_QUEUE (GST_PAD_PARENT (pad));
- result = gst_pad_alloc_buffer (queue->srcpad, offset, size, caps, buf);
+ result =
+ gst_pad_alloc_buffer_and_set_caps (queue->srcpad, offset, size, caps,
+ buf);
return result;
}
#define HAVE_WIN32 1
/* library dir */
-#define LIBDIR PREFIX "\\lib"
+#ifdef _DEBUG
+# define LIBDIR PREFIX "\\debug\\lib"
+#else
+# define LIBDIR PREFIX "\\lib"
+#endif
/* gettext locale dir */
#define LOCALEDIR PREFIX "\\share\\locale"
#undef PACKAGE_VERSION
/* Define the plugin directory */
-#define PLUGINDIR PREFIX "\\lib\\gstreamer-0.10"
+#ifdef _DEBUG
+# define PLUGINDIR PREFIX "\\debug\\lib\\gstreamer-0.10"
+#else
+# define PLUGINDIR PREFIX "\\lib\\gstreamer-0.10"
+#endif
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS