After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699754 - Don't force elements of type source/sink to add two pads
Don't force elements of type source/sink to add two pads
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-omx
1.0.0
Other Linux
: Normal enhancement
: 1.2.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-06 12:40 UTC by jvarshney20
Modified: 2014-07-23 08:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (6.80 KB, patch)
2013-05-06 13:38 UTC, jvarshney20
committed Details | Review

Description jvarshney20 2013-05-06 12:40:35 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.
Comment 1 Sebastian Dröge (slomo) 2013-05-06 12:44:34 UTC
Which code that could be used for sources/sinks is forcing to add multiple pads?
Comment 2 jvarshney20 2013-05-06 12:48:39 UTC
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);
Comment 3 Sebastian Dröge (slomo) 2013-05-06 12:52:02 UTC
Ah, yes. A patch to not require that together with source/sink elements using this would be great :)
Comment 4 jvarshney20 2013-05-06 12:57:46 UTC
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.
Comment 5 jvarshney20 2013-05-06 13:38:38 UTC
Created attachment 243383 [details] [review]
proposed patch
Comment 6 Sebastian Dröge (slomo) 2013-05-06 14:19:30 UTC
Looks good, what kind of source/sink are you working on and are you planning to submit a patch for that?
Comment 7 Sebastian Dröge (slomo) 2013-05-06 14:26:32 UTC
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