[gst-devel] patch

Andy Wingo apwingo at eos.ncsu.edu
Wed Jul 11 06:45:14 CEST 2001


This patch adds the function gst_element_add_padtemplate_to_class(). It
also fixes some issues with removal of ghostpads.

Cheers,

Andy
-------------- next part --------------
? gstelement.c-old
? gstelement.h-old
? patch-wingo-10-july-2001
? elements/gsthttpsrc.c-new
? elements/gsthttpsrc.diff
Index: gstelement.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstelement.c,v
retrieving revision 1.67
diff -u -r1.67 gstelement.c
--- gstelement.c	2001/06/25 17:22:58	1.67
+++ gstelement.c	2001/07/11 04:33:11
@@ -148,6 +148,8 @@
 
   klass->change_state =			GST_DEBUG_FUNCPTR(gst_element_change_state);
   klass->elementfactory = NULL;
+  klass->padtemplates = NULL;
+  klass->numpadtemplates = 0;
 }
 
 static void
@@ -412,9 +414,14 @@
   g_return_if_fail (element != NULL);
   g_return_if_fail (GST_IS_ELEMENT (element));
   g_return_if_fail (pad != NULL);
-  g_return_if_fail (GST_IS_PAD (pad));
+  g_return_if_fail (GST_IS_GHOST_PAD (pad));
 
   // FIXME this is redundant?
+  // wingo 10-july-2001: I don't think so, you have to actually remove the pad
+  // from the element. gst_pad_remove_ghost_pad just removes the ghostpad from
+  // the real pad's ghost pad list
+  gst_pad_remove_ghost_pad(GST_PAD_REALIZE(pad), pad);
+  gst_element_remove_pad(element, pad);
 }
 
 
@@ -474,6 +481,27 @@
 }
 
 /**
+ * gst_element_add_padtemplate_to_class:
+ * @klass: element class to add padtemplate to
+ * @templ: padtemplate to add
+ *
+ * Add a padtemplate to an element class. This is useful if you have derived a custom
+ * bin and wish to provide an on-request pad at runtime. Plugin writers should use
+ * gst_elementfactory_add_padtemplate instead.
+ */
+void
+gst_element_add_padtemplate_to_class (GstElementClass *klass, GstPadTemplate *templ)
+{
+  g_return_if_fail (klass != NULL);
+  g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
+  g_return_if_fail (templ != NULL);
+  g_return_if_fail (GST_IS_PADTEMPLATE (templ));
+  
+  klass->padtemplates = g_list_append (klass->padtemplates, templ);
+  klass->numpadtemplates++;
+}
+
+/**
  * gst_element_get_padtemplate_list:
  * @element: element to get padtemplates of
  *
@@ -491,10 +519,7 @@
 
   oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element));
 
-  if (oclass->elementfactory == NULL) return NULL;
-
-  /* return the list of pads */
-  return oclass->elementfactory->padtemplates;
+  return oclass->padtemplates;
 }
 
 /**
Index: gstelement.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstelement.h,v
retrieving revision 1.54
diff -u -r1.54 gstelement.h
--- gstelement.h	2001/06/25 01:20:08	1.54
+++ gstelement.h	2001/07/11 04:33:11
@@ -153,7 +153,10 @@
 
   /* the elementfactory that created us */
   GstElementFactory *elementfactory;
-
+  /* templates for our pads */
+  GList *padtemplates;
+  gint numpadtemplates;
+  
   /* signal callbacks */
   void (*state_change)		(GstElement *element,GstElementState state);
   void (*new_pad)		(GstElement *element,GstPad *pad);
@@ -212,6 +215,7 @@
 void			gst_element_remove_pad		(GstElement *element, GstPad *pad);
 GstPad*			gst_element_get_pad		(GstElement *element, const gchar *name);
 GList*			gst_element_get_pad_list	(GstElement *element);
+void			gst_element_add_padtemplate_to_class	(GstElementClass *element, GstPadTemplate *templ);
 GList*			gst_element_get_padtemplate_list	(GstElement *element);
 GstPadTemplate*		gst_element_get_padtemplate_by_name	(GstElement *element, const guchar *name);
 void			gst_element_add_ghost_pad	(GstElement *element, GstPad *pad, gchar *name);
Index: gstelementfactory.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstelementfactory.c,v
retrieving revision 1.38
diff -u -r1.38 gstelementfactory.c
--- gstelementfactory.c	2001/06/25 06:45:56	1.38
+++ gstelementfactory.c	2001/07/11 04:33:11
@@ -168,7 +168,11 @@
     GST_DEBUG (GST_CAT_ELEMENTFACTORY,"class %s\n", factory->name);
     oclass->elementfactory = factory;
   }
-
+  
+  // copy pad template pointers to the element class
+  oclass->padtemplates = g_list_copy(factory->padtemplates);
+  oclass->numpadtemplates = factory->numpadtemplates;
+  
   gst_object_set_name (GST_OBJECT (element),name);
 
   return element;


More information about the gstreamer-devel mailing list