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
This commit is contained in:
Havard Graff 2015-08-29 20:14:44 +02:00 committed by Tim-Philipp Müller
parent 8a1f05865f
commit b2ce23074e

View file

@ -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;
}
}