? gst-wip.patch
Index: gstelement.h
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstelement.h,v
retrieving revision 1.178
diff -u -b -r1.178 gstelement.h
--- gstelement.h	24 Jan 2005 17:04:08 -0000	1.178
+++ gstelement.h	17 Apr 2005 10:28:42 -0000
@@ -126,13 +126,17 @@
   /* element is in error */
   GST_ELEMENT_IN_ERROR,
 
+  /* element doesn't change passed buffer or change it in place */
+  GST_ELEMENT_WORK_IN_PLACE,
+  
   /* use some padding for future expansion */
-  GST_ELEMENT_FLAG_LAST		= GST_OBJECT_FLAG_LAST + 16
+  GST_ELEMENT_FLAG_LAST		= GST_OBJECT_FLAG_LAST + 15
 } GstElementFlags;
 
 #define GST_ELEMENT_IS_THREAD_SUGGESTED(obj)	(GST_FLAG_IS_SET(obj,GST_ELEMENT_THREAD_SUGGESTED))
 #define GST_ELEMENT_IS_EVENT_AWARE(obj)		(GST_FLAG_IS_SET(obj,GST_ELEMENT_EVENT_AWARE))
 #define GST_ELEMENT_IS_DECOUPLED(obj)		(GST_FLAG_IS_SET(obj,GST_ELEMENT_DECOUPLED))
+//#define GST_ELEMENT_WORK_IN_PLACE(obj)          (GST_FLAG_IS_SET(obj,GST_ELEMENT_WORK_IN_PLACE))
 
 #define GST_ELEMENT_NAME(obj)			(GST_OBJECT_NAME(obj))
 #define GST_ELEMENT_PARENT(obj)			(GST_OBJECT_PARENT(obj))
Index: gstpad.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstpad.c,v
retrieving revision 1.357.2.1
diff -u -b -r1.357.2.1 gstpad.c
--- gstpad.c	3 Mar 2005 18:39:49 -0000	1.357.2.1
+++ gstpad.c	17 Apr 2005 10:28:46 -0000
@@ -2972,16 +2972,23 @@
 GstBuffer *
 gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size)
 {
-  GstRealPad *peer;
+  GstRealPad *peer = NULL;
 
   g_return_val_if_fail (GST_IS_PAD (pad), NULL);
   g_return_val_if_fail (GST_PAD_IS_SRC (pad), NULL);
 
+  g_print ("_pad_alloc_buffer\n");
+
   peer = GST_RPAD_PEER (pad);
 
-  if (peer && peer->bufferallocfunc) {
+  do {
+
+    if (peer) {
+      if (peer->bufferallocfunc) {
     GstBuffer *ret;
 
+	g_print ("_pad_alloc_buffer hit on %s\n", GST_ELEMENT_NAME (GST_PAD_PARENT (peer)));
+	    
     GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting buffer",
         GST_DEBUG_PAD_NAME (pad));
     GST_CAT_DEBUG (GST_CAT_PADS,
@@ -2992,7 +2999,32 @@
     ret = (peer->bufferallocfunc) (GST_PAD (peer), offset, size);
     if (ret)
       return ret;
+	else
+	  break;
+      }else {
+	/* 
+	   there is a peer but it doesn't have a bufferallocfunc.
+	   Try to proxy the request if GST_ELEMENT_WORK_IN_PLACE
+	   is setted	   
+	 */
+	GstElement *parent = GST_PAD_PARENT (peer);
+	if (parent == NULL) break;
+	if (GST_FLAG_IS_SET(parent, GST_ELEMENT_WORK_IN_PLACE)) {
+	  /* get the src pad. don't proxy if src pad numbers != 1 */
+	  GstPad *src = gst_element_get_pad (parent, "src");
+	  if (src == NULL) break;
+	  peer = GST_RPAD_PEER (src);
+	  g_print ("try to proxy\n");
+	}else
+	  break;
   }
+	
+    }else
+      break;
+  } while (1);
+
+  g_print ("_pad_alloc_buffer miss on %s\n", GST_ELEMENT_NAME (GST_PAD_PARENT (peer)));  
+  
   return gst_buffer_new_and_alloc (size);
 }
 
Index: elements/gstidentity.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/elements/gstidentity.c,v
retrieving revision 1.70
diff -u -b -r1.70 gstidentity.c
--- elements/gstidentity.c	8 Nov 2004 15:45:31 -0000	1.70
+++ elements/gstidentity.c	17 Apr 2005 10:28:47 -0000
@@ -227,6 +227,8 @@
   identity->srccaps = NULL;
 
   GST_FLAG_SET (identity, GST_ELEMENT_EVENT_AWARE);
+  GST_FLAG_SET (identity, GST_ELEMENT_WORK_IN_PLACE);
+
 }
 
 static void
