libs/gst/base/gstbasetransform.c (gst_base_transform_prepare_output_buf)
authorWim Taymans <wim@fluendo.com>
Mon, 5 Dec 2005 13:01:35 +0000 (13:01 +0000)
committerAndy Wingo <wingo@pobox.com>
Mon, 5 Dec 2005 13:01:35 +0000 (13:01 +0000)
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.

ChangeLog
docs/design/part-negotiation.txt
docs/gst/gstreamer-sections.txt
docs/libs/tmpl/gstdataprotocol.sgml
docs/pwg/advanced-negotiation.xml
gst/gstpad.c
gst/gstpad.h
libs/gst/base/gstbasetransform.c
plugins/elements/gstqueue.c
win32/common/config.h

index d3b2435..d080dda 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        patch by: Sebastien Moutte
index dd814c6..270f44f 100644 (file)
@@ -82,8 +82,8 @@ The general flow for a source pad starting the negotiation.
    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]
index 85d2add..1285bbc 100644 (file)
@@ -1151,6 +1151,7 @@ gst_pad_new_from_template
 gst_pad_new_from_static_template
 
 gst_pad_alloc_buffer
+gst_pad_alloc_buffer_and_set_caps
 gst_pad_set_bufferalloc_function
 GstPadBufferAllocFunction
 
index 0277c7c..c5446c9 100644 (file)
@@ -27,6 +27,9 @@ network connections also need a protocol to do this.
 #GstBuffer, #GstCaps, #GstEvent
 </para>
 
+<!-- ##### SECTION Stability_Level ##### -->
+
+
 <!-- ##### ENUM GstDPHeaderFlag ##### -->
 <para>
 
index b5a71e1..76ec222 100644 (file)
@@ -346,9 +346,9 @@ gst_my_filter_chain (GstPad    *pad,
       ()</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
index 77ed21d..566feb4 100644 (file)
@@ -2215,7 +2215,7 @@ not_accepted:
 
 /* 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;
@@ -2230,10 +2230,10 @@ gst_pad_configure_src (GstPad * pad, GstCaps * caps)
     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;
 
@@ -2405,33 +2405,9 @@ no_peer:
   }
 }
 
-/**
- * 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;
@@ -2499,7 +2475,7 @@ do_caps:
   /* 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;
@@ -2559,6 +2535,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:
  * @pad: the #GstPad to get the internal links of.
  *
index 376bb0e..abb8928 100644 (file)
@@ -712,6 +712,8 @@ GstPadTemplate*             gst_pad_get_pad_template                (GstPad *pad);
 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);
index 75c680f..c42bfe1 100644 (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
  * 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) {
     /* 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;
 
@@ -956,7 +957,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
     /* 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);
@@ -981,7 +984,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint 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);
   }
 
index 7061635..2723500 100644 (file)
@@ -469,7 +469,9 @@ gst_queue_bufferalloc (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
 
   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;
 }
index 8d84772..c71d73a 100644 (file)
 #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