libs/gst/base/gstbasetransform.c (gst_base_transform_prepare_output_buf)

Original commit message from CVS:
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.
This commit is contained in:
Wim Taymans 2005-12-05 13:01:35 +00:00 committed by Andy Wingo
parent 30dab643af
commit 4f28ca8331
10 changed files with 121 additions and 46 deletions

View file

@ -1,3 +1,23 @@
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> 2005-12-05 Thomas Vander Stichele <thomas at apestaart dot org>
patch by: Sebastien Moutte patch by: Sebastien Moutte

View file

@ -82,8 +82,8 @@ The general flow for a source pad starting the negotiation.
done done
endif endif
# if the type is different, this will call the setcaps function of # if the type is different, the buffer will have different caps from
# the pad. # the src pad -- setcaps will get called on the pad_push
buffer = gst_pad_alloc_buffer (srcpad, 0, size, GST_PAD_CAPS (fixedcaps)); buffer = gst_pad_alloc_buffer (srcpad, 0, size, GST_PAD_CAPS (fixedcaps));
if buffer if buffer
[fill buffer and push] [fill buffer and push]

View file

@ -1151,6 +1151,7 @@ gst_pad_new_from_template
gst_pad_new_from_static_template gst_pad_new_from_static_template
gst_pad_alloc_buffer gst_pad_alloc_buffer
gst_pad_alloc_buffer_and_set_caps
gst_pad_set_bufferalloc_function gst_pad_set_bufferalloc_function
GstPadBufferAllocFunction GstPadBufferAllocFunction

View file

@ -27,6 +27,9 @@ network connections also need a protocol to do this.
#GstBuffer, #GstCaps, #GstEvent #GstBuffer, #GstCaps, #GstEvent
</para> </para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstDPHeaderFlag ##### --> <!-- ##### ENUM GstDPHeaderFlag ##### -->
<para> <para>

View file

@ -346,9 +346,9 @@ gst_my_filter_chain (GstPad *pad,
()</function>-function. The idea here is that an element requesting a ()</function>-function. The idea here is that an element requesting a
buffer from downstream, has to specify the type of that buffer. If 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 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, downstream element will set a new caps on the provided buffer. The element
&GStreamer; will trigger renegotiation on the sourcepad of the element should then reconfigure itself to push buffers with the returned caps. The
before the function returns. source pad's setcaps will be called once the buffer is pushed.
</para> </para>
<para> <para>
It is important to note here that different elements actually have It is important to note here that different elements actually have

View file

@ -2215,7 +2215,7 @@ not_accepted:
/* returns TRUE if the src pad could be configured to accept the given caps */ /* returns TRUE if the src pad could be configured to accept the given caps */
static gboolean static gboolean
gst_pad_configure_src (GstPad * pad, GstCaps * caps) gst_pad_configure_src (GstPad * pad, GstCaps * caps, gboolean dosetcaps)
{ {
GstPadAcceptCapsFunction acceptcaps; GstPadAcceptCapsFunction acceptcaps;
GstPadSetCapsFunction setcaps; GstPadSetCapsFunction setcaps;
@ -2230,10 +2230,10 @@ gst_pad_configure_src (GstPad * pad, GstCaps * caps)
if (!acceptcaps (pad, caps)) if (!acceptcaps (pad, caps))
goto not_accepted; goto not_accepted;
} }
/* set caps on pad if call succeeds */ if (dosetcaps)
res = gst_pad_set_caps (pad, caps); res = gst_pad_set_caps (pad, caps);
/* no need to unref the caps here, set_caps takes a ref and else
* our ref goes away when we leave this function. */ res = TRUE;
return res; return res;
@ -2405,33 +2405,9 @@ no_peer:
} }
} }
/** static GstFlowReturn
* gst_pad_alloc_buffer: gst_pad_alloc_buffer_full (GstPad * pad, guint64 offset, gint size,
* @pad: a source #GstPad GstCaps * caps, GstBuffer ** buf, gboolean setcaps)
* @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)
{ {
GstPad *peer; GstPad *peer;
GstFlowReturn ret; GstFlowReturn ret;
@ -2499,7 +2475,7 @@ do_caps:
/* we got a new datatype on the pad, see if it can handle it */ /* we got a new datatype on the pad, see if it can handle it */
if (G_UNLIKELY (caps_changed)) { if (G_UNLIKELY (caps_changed)) {
GST_DEBUG ("caps changed to %" GST_PTR_FORMAT, caps); 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; goto not_negotiated;
} }
return ret; return ret;
@ -2558,6 +2534,64 @@ peer_error:
} }
} }
/**
* 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: * gst_pad_get_internal_links_default:
* @pad: the #GstPad to get the internal links of. * @pad: the #GstPad to get the internal links of.

View file

@ -712,6 +712,8 @@ GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufalloc); void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufalloc);
GstFlowReturn gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size, GstFlowReturn gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size,
GstCaps *caps, GstBuffer **buf); 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 */ /* data passing setup functions */
void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate); void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);

View file

@ -787,7 +787,7 @@ failed_configure:
} }
} }
/* 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 * This function can trigger a renegotiation on the source pad when the
* peer alloc_buffer function sets new caps. Since we currently are * peer alloc_buffer function sets new caps. Since we currently are
@ -848,8 +848,9 @@ gst_base_transform_prepare_output_buf (GstBaseTransform * trans,
if (*out_buf == NULL) { if (*out_buf == NULL) {
/* Sub-class didn't already provide a buffer for us. Make one */ /* Sub-class didn't already provide a buffer for us. Make one */
ret = gst_pad_alloc_buffer (trans->srcpad, GST_BUFFER_OFFSET (in_buf), ret =
out_size, out_caps, out_buf); 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) if (ret != GST_FLOW_OK || *out_buf == NULL)
goto done; goto done;
@ -956,7 +957,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
/* request a buffer with the same caps */ /* request a buffer with the same caps */
GST_DEBUG_OBJECT (trans, "requesting buffer with same caps, size %d", size); 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 { } else {
/* if we are configured, request a buffer with the src caps */ /* if we are configured, request a buffer with the src caps */
GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad); GstCaps *srccaps = gst_pad_get_negotiated_caps (trans->srcpad);
@ -981,7 +984,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
goto unknown_size; 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); gst_caps_unref (srccaps);
} }

View file

@ -469,7 +469,9 @@ gst_queue_bufferalloc (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
queue = GST_QUEUE (GST_PAD_PARENT (pad)); 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; return result;
} }

View file

@ -172,7 +172,11 @@
#define HAVE_WIN32 1 #define HAVE_WIN32 1
/* library dir */ /* library dir */
#define LIBDIR PREFIX "\\lib" #ifdef _DEBUG
# define LIBDIR PREFIX "\\debug\\lib"
#else
# define LIBDIR PREFIX "\\lib"
#endif
/* gettext locale dir */ /* gettext locale dir */
#define LOCALEDIR PREFIX "\\share\\locale" #define LOCALEDIR PREFIX "\\share\\locale"
@ -196,7 +200,11 @@
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
/* Define the plugin directory */ /* 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. */ /* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS #undef STDC_HEADERS