GNOME Bugzilla – Bug 699754
Don't force elements of type source/sink to add two pads
Last modified: 2014-07-23 08:26:24 UTC
In current implementation of _class_init function, element is forced to add both src and sink pads. It is proper of filter (decoder, encoder etc.) elements. But elements of type source/ sink don't need two pads. If someone wants to add elements of type source/ sink, current implementation of _class_init function would not work. Therefore implementation must be modified to handle these cases.
Which code that could be used for sources/sinks is forcing to add multiple pads?
code in _class_init function in gstomx.c :- /* Add pad templates */ err = NULL; if (!(template_caps = g_key_file_get_string (config, element_name, "sink-template-caps", &err))) { GST_DEBUG ("No sink template caps specified for element '%s', using default '%s'", element_name, class_data->default_sink_template_caps); caps = gst_caps_from_string (class_data->default_sink_template_caps); g_assert (caps != NULL); g_error_free (err); } else { caps = gst_caps_from_string (template_caps); if (!caps) { GST_DEBUG ("Could not parse sink template caps '%s' for element '%s', using default '%s'", template_caps, element_name, class_data->default_sink_template_caps); caps = gst_caps_from_string (class_data->default_sink_template_caps); g_assert (caps != NULL); } } templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps); g_free (template_caps); gst_element_class_add_pad_template (element_class, templ); err = NULL; if (!(template_caps = g_key_file_get_string (config, element_name, "src-template-caps", &err))) { GST_DEBUG ("No src template caps specified for element '%s', using default '%s'", element_name, class_data->default_src_template_caps); caps = gst_caps_from_string (class_data->default_src_template_caps); g_assert (caps != NULL); g_error_free (err); } else { caps = gst_caps_from_string (template_caps); if (!caps) { GST_DEBUG ("Could not parse src template caps '%s' for element '%s', using default '%s'", template_caps, element_name, class_data->default_src_template_caps); caps = gst_caps_from_string (class_data->default_src_template_caps); g_assert (caps != NULL); } } templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps); g_free (template_caps); gst_element_class_add_pad_template (element_class, templ);
Ah, yes. A patch to not require that together with source/sink elements using this would be great :)
We can add one more field in GstOMXClassData structure to identify the type of element and that field can be set by element through its class_init function. Based on type, we can then decide the number of pads to add.
Created attachment 243383 [details] [review] proposed patch
Looks good, what kind of source/sink are you working on and are you planning to submit a patch for that?
commit 715b44ea66be964a216f409bf8a7f11a1a3128b8 Author: jitendra <jvarshney20@gmail.com> Date: Mon May 6 19:03:59 2013 +0530 omx: Add pads based on element type This allows to later add sources and sink that only have a srcpad or sinkpad. https://bugzilla.gnome.org/show_bug.cgi?id=699754