gst/gstpad.*: add gst_pad_new_from_static_template functions
authorThomas Vander Stichele <thomas@apestaart.org>
Wed, 16 Nov 2005 16:09:49 +0000 (16:09 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Wed, 16 Nov 2005 16:09:49 +0000 (16:09 +0000)
Original commit message from CVS:

* gst/gstpad.c: (gst_pad_new_from_static_template):
* gst/gstpad.h:
add gst_pad_new_from_static_template functions
* gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_setup_sink_pad):
* gst/elements/gsttee.c: (gst_tee_init):
and use them

ChangeLog
gst/check/gstcheck.c
gst/elements/gsttee.c
gst/gstpad.c
gst/gstpad.h
libs/gst/check/gstcheck.c
plugins/elements/gsttee.c

index 2732f9f..87f3113 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,17 @@
+2005-11-16  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * gst/gstpad.c: (gst_pad_new_from_static_template):
+       * gst/gstpad.h:
+         add gst_pad_new_from_static_template functions
+       * gst/check/gstcheck.c: (gst_check_setup_src_pad),
+       (gst_check_setup_sink_pad):
+       * gst/elements/gsttee.c: (gst_tee_init):
+         and use them
+
 2005-11-16  Wim Taymans  <wim@fluendo.com>
 
        * gst/gstpad.c: (gst_pad_pause_task):
-       Removed warning, it's not realy an error either.
+       Removed warning, it's not really an error either.
 
 2005-11-16  Wim Taymans  <wim@fluendo.com>
 
index 54093bf..713e7da 100644 (file)
@@ -152,15 +152,13 @@ gst_check_teardown_element (GstElement * element)
  */
 GstPad *
 gst_check_setup_src_pad (GstElement * element,
-    GstStaticPadTemplate * srctemplate, GstCaps * caps)
+    GstStaticPadTemplate * template, GstCaps * caps)
 {
   GstPad *srcpad, *sinkpad;
 
   GST_DEBUG_OBJECT (element, "setting up sending pad");
   /* sending pad */
-  srcpad =
-      gst_pad_new_from_template (gst_static_pad_template_get (srctemplate),
-      "src");
+  srcpad = gst_pad_new_from_static_template (template, "src");
   fail_if (srcpad == NULL, "Could not create a srcpad");
   ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
 
@@ -211,9 +209,7 @@ gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * template,
 
   GST_DEBUG_OBJECT (element, "setting up receiving pad");
   /* receiving pad */
-  sinkpad =
-      gst_pad_new_from_template (gst_static_pad_template_get (template),
-      "sink");
+  sinkpad = gst_pad_new_from_static_template (template, "sink");
   fail_if (sinkpad == NULL, "Could not create a sinkpad");
 
   srcpad = gst_element_get_pad (element, "src");
index aa78353..6d39b70 100644 (file)
@@ -140,10 +140,7 @@ gst_tee_class_init (GstTeeClass * klass)
 static void
 gst_tee_init (GstTee * tee, GstTeeClass * g_class)
 {
-  GstPadTemplate *templ = gst_static_pad_template_get (&sinktemplate);
-
-  tee->sinkpad = gst_pad_new_from_template (templ, "sink");
-  gst_object_unref (templ);
+  tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
   gst_pad_set_setcaps_function (tee->sinkpad,
       GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
   gst_pad_set_getcaps_function (tee->sinkpad,
index 438a55c..941c106 100644 (file)
@@ -492,6 +492,31 @@ gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name)
 }
 
 /**
+ * gst_pad_new_from_static_template:
+ * @templ: the #GstStaticPadTemplate to use
+ * @name: the name of the element
+ *
+ * Creates a new pad with the given name from the given static template.
+ * If name is NULL, a guaranteed unique name (across all pads)
+ * will be assigned.
+ * This function makes a copy of the name so you can safely free the name.
+ *
+ * Returns: a new #GstPad, or NULL in case of an error.
+ */
+GstPad *
+gst_pad_new_from_static_template (GstStaticPadTemplate * templ,
+    const gchar * name)
+{
+  GstPad *pad;
+  GstPadTemplate *template;
+
+  template = gst_static_pad_template_get (templ);
+  pad = gst_pad_new_from_template (template, name);
+  gst_object_unref (template);
+  return pad;
+}
+
+/**
  * gst_pad_get_direction:
  * @pad: a #GstPad to get the direction of.
  *
index 00d99b3..b1ff345 100644 (file)
@@ -498,6 +498,8 @@ GType                       gst_pad_get_type                        (void);
 /* creating pads */
 GstPad*                        gst_pad_new                             (const gchar *name, GstPadDirection direction);
 GstPad*                        gst_pad_new_from_template               (GstPadTemplate *templ, const gchar *name);
+GstPad*                        gst_pad_new_from_static_template        (GstStaticPadTemplate *templ, const gchar *name);
+
 
 /**
  * gst_pad_get_name:
index 54093bf..713e7da 100644 (file)
@@ -152,15 +152,13 @@ gst_check_teardown_element (GstElement * element)
  */
 GstPad *
 gst_check_setup_src_pad (GstElement * element,
-    GstStaticPadTemplate * srctemplate, GstCaps * caps)
+    GstStaticPadTemplate * template, GstCaps * caps)
 {
   GstPad *srcpad, *sinkpad;
 
   GST_DEBUG_OBJECT (element, "setting up sending pad");
   /* sending pad */
-  srcpad =
-      gst_pad_new_from_template (gst_static_pad_template_get (srctemplate),
-      "src");
+  srcpad = gst_pad_new_from_static_template (template, "src");
   fail_if (srcpad == NULL, "Could not create a srcpad");
   ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
 
@@ -211,9 +209,7 @@ gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * template,
 
   GST_DEBUG_OBJECT (element, "setting up receiving pad");
   /* receiving pad */
-  sinkpad =
-      gst_pad_new_from_template (gst_static_pad_template_get (template),
-      "sink");
+  sinkpad = gst_pad_new_from_static_template (template, "sink");
   fail_if (sinkpad == NULL, "Could not create a sinkpad");
 
   srcpad = gst_element_get_pad (element, "src");
index aa78353..6d39b70 100644 (file)
@@ -140,10 +140,7 @@ gst_tee_class_init (GstTeeClass * klass)
 static void
 gst_tee_init (GstTee * tee, GstTeeClass * g_class)
 {
-  GstPadTemplate *templ = gst_static_pad_template_get (&sinktemplate);
-
-  tee->sinkpad = gst_pad_new_from_template (templ, "sink");
-  gst_object_unref (templ);
+  tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
   gst_pad_set_setcaps_function (tee->sinkpad,
       GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
   gst_pad_set_getcaps_function (tee->sinkpad,