From 917a033d04c47abad2a4efd730df75728c971f27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 15 Apr 2014 12:58:59 +0200 Subject: [PATCH] check: Add new API to set up pads from non-static pad templates --- libs/gst/check/Makefile.am | 4 ++ libs/gst/check/gstcheck.c | 78 +++++++++++++++++++++++++++++++++++++- libs/gst/check/gstcheck.h | 12 +++++- 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/libs/gst/check/Makefile.am b/libs/gst/check/Makefile.am index 120a3b08af..72ddd75ec2 100644 --- a/libs/gst/check/Makefile.am +++ b/libs/gst/check/Makefile.am @@ -82,9 +82,13 @@ LIBGSTCHECK_EXPORTED_FUNCS = \ gst_check_setup_events \ gst_check_setup_events_with_stream_id \ gst_check_setup_sink_pad \ + gst_check_setup_sink_pad_from_template \ gst_check_setup_sink_pad_by_name \ + gst_check_setup_sink_pad_by_name_from_templ \ gst_check_setup_src_pad \ + gst_check_setup_src_pad_from_template \ gst_check_setup_src_pad_by_name \ + gst_check_setup_src_pad_by_name_from_template \ gst_check_teardown_element \ gst_check_teardown_pad_by_name \ gst_check_teardown_sink_pad \ diff --git a/libs/gst/check/gstcheck.c b/libs/gst/check/gstcheck.c index bac4782fdf..454ebb243e 100644 --- a/libs/gst/check/gstcheck.c +++ b/libs/gst/check/gstcheck.c @@ -262,11 +262,48 @@ gst_check_setup_src_pad (GstElement * element, GstStaticPadTemplate * tmpl) GstPad * gst_check_setup_src_pad_by_name (GstElement * element, GstStaticPadTemplate * tmpl, const gchar * name) +{ + GstPadTemplate *ptmpl = gst_static_pad_template_get (tmpl); + GstPad *srcpad; + + srcpad = + gst_check_setup_src_pad_by_name_from_template (element, ptmpl, "sink"); + + gst_object_unref (ptmpl); + + return srcpad; +} + +/** + * gst_check_setup_src_pad_from_template: + * @element: element to setup pad on + * @tmpl: pad template + * + * Returns: (transfer full): a new pad + */ +GstPad * +gst_check_setup_src_pad_from_template (GstElement * element, + GstPadTemplate * tmpl) +{ + return gst_check_setup_src_pad_by_name_from_template (element, tmpl, "sink"); +} + +/** + * gst_check_setup_src_pad_by_name_from_template: + * @element: element to setup pad on + * @tmpl: pad template + * @name: name + * + * Returns: (transfer full): a new pad + */ +GstPad * +gst_check_setup_src_pad_by_name_from_template (GstElement * element, + GstPadTemplate * tmpl, const gchar * name) { GstPad *srcpad, *sinkpad; /* sending pad */ - srcpad = gst_pad_new_from_static_template (tmpl, "src"); + srcpad = gst_pad_new_from_template (tmpl, "src"); GST_DEBUG_OBJECT (element, "setting up sending pad %p", srcpad); fail_if (srcpad == NULL, "Could not create a srcpad"); ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); @@ -348,11 +385,48 @@ gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * tmpl) GstPad * gst_check_setup_sink_pad_by_name (GstElement * element, GstStaticPadTemplate * tmpl, const gchar * name) +{ + GstPadTemplate *ptmpl = gst_static_pad_template_get (tmpl); + GstPad *sinkpad; + + sinkpad = + gst_check_setup_sink_pad_by_name_from_template (element, ptmpl, "src"); + + gst_object_unref (ptmpl); + + return sinkpad; +} + +/** + * gst_check_setup_sink_pad_from_template: + * @element: element to setup pad on + * @tmpl: pad template + * + * Returns: (transfer full): a new pad + */ +GstPad * +gst_check_setup_sink_pad_from_template (GstElement * element, + GstPadTemplate * tmpl) +{ + return gst_check_setup_sink_pad_by_name_from_template (element, tmpl, "src"); +} + +/** + * gst_check_setup_sink_pad_by_name_from_template: + * @element: element to setup pad on + * @tmpl: pad template + * @name: name + * + * Returns: (transfer full): a new pad + */ +GstPad * +gst_check_setup_sink_pad_by_name_from_template (GstElement * element, + GstPadTemplate * tmpl, const gchar * name) { GstPad *srcpad, *sinkpad; /* receiving pad */ - sinkpad = gst_pad_new_from_static_template (tmpl, "sink"); + sinkpad = gst_pad_new_from_template (tmpl, "sink"); GST_DEBUG_OBJECT (element, "setting up receiving pad %p", sinkpad); fail_if (sinkpad == NULL, "Could not create a sinkpad"); diff --git a/libs/gst/check/gstcheck.h b/libs/gst/check/gstcheck.h index c1d7d837be..ee925790dd 100644 --- a/libs/gst/check/gstcheck.h +++ b/libs/gst/check/gstcheck.h @@ -73,10 +73,20 @@ GstElement *gst_check_setup_element (const gchar * factory); void gst_check_teardown_element (GstElement * element); GstPad *gst_check_setup_src_pad (GstElement * element, GstStaticPadTemplate * tmpl); +GstPad *gst_check_setup_src_pad_from_template (GstElement * element, + GstPadTemplate * tmpl); GstPad * gst_check_setup_src_pad_by_name (GstElement * element, GstStaticPadTemplate * tmpl, const gchar *name); +GstPad * gst_check_setup_src_pad_by_name_from_template (GstElement * element, + GstPadTemplate * tmpl, const gchar *name); +GstPad *gst_check_setup_sink_pad (GstElement * element, + GstStaticPadTemplate * tmpl); +GstPad *gst_check_setup_sink_pad_from_template (GstElement * element, + GstPadTemplate * tmpl); GstPad * gst_check_setup_sink_pad_by_name (GstElement * element, GstStaticPadTemplate * tmpl, const gchar *name); +GstPad * gst_check_setup_sink_pad_by_name_from_template (GstElement * element, + GstPadTemplate * tmpl, const gchar *name); void gst_check_teardown_pad_by_name (GstElement * element, const gchar *name); void gst_check_teardown_src_pad (GstElement * element); void gst_check_drop_buffers (void); @@ -88,8 +98,6 @@ void gst_check_element_push_buffer_list (const gchar * element_name, void gst_check_element_push_buffer (const gchar * element_name, GstBuffer * buffer_in, GstCaps * caps_in, GstBuffer * buffer_out, GstCaps *caps_out); -GstPad *gst_check_setup_sink_pad (GstElement * element, - GstStaticPadTemplate * tmpl); void gst_check_teardown_sink_pad (GstElement * element); void gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes); gint gst_check_run_suite (Suite * suite, const gchar * name, -- 2.34.1