Index: gst/gstelement.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstelement.c,v
retrieving revision 1.464
diff -u -p -a -u -p -r1.464 gstelement.c
--- gst/gstelement.c	6 Nov 2007 12:28:17 -0000	1.464
+++ gst/gstelement.c	29 Jan 2008 10:43:04 -0000
@@ -238,9 +238,32 @@ static void
 gst_element_base_class_init (gpointer g_class)
 {
   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GList *node, *padtemplates;
 
-  memset (&element_class->details, 0, sizeof (GstElementDetails));
-  element_class->padtemplates = NULL;
+  /* Copy the element details here so elements can inherit the
+   * details from their base class and classes only need to set
+   * the details in class_init instead of base_init */
+  /* FIXME: We probably need something like for copying
+   * the details at a central place */
+  element_class->details.longname = g_strdup (element_class->details.longname);
+  element_class->details.klass = g_strdup (element_class->details.klass);
+  element_class->details.description = g_strdup (element_class->details.description);
+  element_class->details.author = g_strdup (element_class->details.author);
+
+  /* Copy the pad templates so elements inherit them
+   * from their base class but elements can add pad templates in class_init
+   * instead of base_init.
+   */
+  /* FIXME: Do we consider GstPadTemplates as immutable? If so we can
+   * simply ref them instead of copying.
+   */
+  padtemplates = g_list_copy (element_class->padtemplates);
+  for (node = padtemplates; node != NULL; node = node->next) {
+    GstPadTemplate *tmpl = (GstPadTemplate *) node->data;
+    node->data = gst_pad_template_new (tmpl->name_template,
+        tmpl->direction, tmpl->presence, gst_caps_copy (tmpl->caps));
+  }
+  element_class->padtemplates = padtemplates;
 }
 
 static void
@@ -1102,22 +1125,36 @@ gst_element_iterate_sink_pads (GstElemen
  * @klass: the #GstElementClass to add the pad template to.
  * @templ: a #GstPadTemplate to add to the element class.
  *
- * Adds a padtemplate to an element class. This is mainly used in the _base_init
- * functions of classes.
+ * Adds a padtemplate to an element class. This is mainly used in the _class_init
+ * functions of classes. If a pad template with the same name as an already
+ * existing one is added the old one is replaced by the new one.
  */
 void
 gst_element_class_add_pad_template (GstElementClass * klass,
     GstPadTemplate * templ)
 {
+  GList *template_list = klass->padtemplates;
+
   g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
   g_return_if_fail (GST_IS_PAD_TEMPLATE (templ));
 
-  /* avoid registering pad templates with the same name */
-  g_return_if_fail (gst_element_class_get_pad_template (klass,
-          templ->name_template) == NULL);
-
+  /* If we already have a pad template with the same name replace the
+   * old one. */
+  while (template_list) {
+    GstPadTemplate *padtempl = (GstPadTemplate *) template_list->data;
+   
+    /* Found pad with the same name, replace and return */
+    if (strcmp (templ->name_template, padtempl->name_template) == 0) {
+      gst_object_unref (padtempl);
+      template_list->data = templ;
+      return;
+    }
+    template_list = g_list_next (template_list);
+  }
+  
+  /* Not found a pad with the same name so add it to the list */
   klass->padtemplates = g_list_append (klass->padtemplates,
-      gst_object_ref (templ));
+      templ);
   klass->numpadtemplates++;
 }
 
@@ -1127,7 +1164,7 @@ gst_element_class_add_pad_template (GstE
  * @details: details to set
  *
  * Sets the detailed information for a #GstElementClass.
- * <note>This function is for use in _base_init functions only.</note>
+ * <note>This function is for use in _class_init functions only.</note>
  *
  * The @details are copied.
  */
@@ -1155,7 +1192,7 @@ gst_element_class_set_details (GstElemen
  *
  * Sets the detailed information for a #GstElementClass. Simpler version of 
  * gst_element_class_set_details() that generates less linker overhead.
- * <note>This function is for use in _base_init functions only.</note>
+ * <note>This function is for use in _class_init functions only.</note>
  *
  * The detail parameter strings are copied into the #GstElementDetails for
  * the element class.
Index: gst/gstpadtemplate.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstpadtemplate.c,v
retrieving revision 1.11
diff -u -p -a -u -p -r1.11 gstpadtemplate.c
--- gst/gstpadtemplate.c	12 Jun 2006 08:55:21 -0000	1.11
+++ gst/gstpadtemplate.c	29 Jan 2008 10:43:04 -0000
@@ -78,13 +78,13 @@
  * </example>
  *
  * The following example shows you how to add the padtemplate to an
- * element class, this is usually done in the base_init of the class:
+ * element class, this is usually done in the class_init of the class:
  * <informalexample>
  *   <programlisting>
  *   static void
- *   my_element_base_init (gpointer g_class)
+ *   my_element_class_init (GstMyElementClass *klass)
  *   {
- *     GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+ *     GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
  *    
  *     gst_element_class_add_pad_template (gstelement_class,
  *         gst_static_pad_template_get (&amp;my_template));
