From b2ce23074e5bd076573ca8c7e254e3080f5b75bc Mon Sep 17 00:00:00 2001 From: Havard Graff Date: Sat, 29 Aug 2015 20:14:44 +0200 Subject: [PATCH] harness: misc bugfixes 1. Get a list of pad templates from the element class, not the factory. This allows us to interact with test-elements that does not have a factory. 2. Use the pad_template_caps in caps-queries when caps is not set explicitly on the pad. Not doing so is simply wrong, and prohibits interactions with special templates used for testing. https://bugzilla.gnome.org/show_bug.cgi?id=754193 --- libs/gst/check/gstharness.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libs/gst/check/gstharness.c b/libs/gst/check/gstharness.c index 7d48526afb..245c5b1d23 100644 --- a/libs/gst/check/gstharness.c +++ b/libs/gst/check/gstharness.c @@ -344,9 +344,11 @@ gst_harness_sink_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstCaps *caps, *filter = NULL; - caps = - priv-> - sink_caps ? gst_caps_ref (priv->sink_caps) : gst_caps_new_any (); + if (priv->sink_caps) { + caps = gst_caps_ref (priv->sink_caps); + } else { + caps = gst_pad_get_pad_template_caps (pad); + } gst_query_parse_caps (query, &filter); if (filter != NULL) { @@ -406,8 +408,11 @@ gst_harness_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstCaps *caps, *filter = NULL; - caps = - priv->src_caps ? gst_caps_ref (priv->src_caps) : gst_caps_new_any (); + if (priv->src_caps) { + caps = gst_caps_ref (priv->src_caps); + } else { + caps = gst_pad_get_pad_template_caps (pad); + } gst_query_parse_caps (query, &filter); if (filter != NULL) { @@ -542,21 +547,20 @@ static void check_element_type (GstElement * element, gboolean * has_sinkpad, gboolean * has_srcpad) { - GstElementFactory *factory; + GstElementClass *element_class = GST_ELEMENT_GET_CLASS (element); const GList *tmpl_list; *has_srcpad = element->numsrcpads > 0; *has_sinkpad = element->numsinkpads > 0; - factory = gst_element_get_factory (element); - tmpl_list = gst_element_factory_get_static_pad_templates (factory); + tmpl_list = gst_element_class_get_pad_template_list (element_class); while (tmpl_list) { - GstStaticPadTemplate *pad_tmpl = (GstStaticPadTemplate *) tmpl_list->data; + GstPadTemplate *pad_tmpl = (GstPadTemplate *) tmpl_list->data; tmpl_list = g_list_next (tmpl_list); - if (pad_tmpl->direction == GST_PAD_SRC) + if (GST_PAD_TEMPLATE_DIRECTION (pad_tmpl) == GST_PAD_SRC) *has_srcpad |= TRUE; - if (pad_tmpl->direction == GST_PAD_SINK) + if (GST_PAD_TEMPLATE_DIRECTION (pad_tmpl) == GST_PAD_SINK) *has_sinkpad |= TRUE; } }