gst_pad_set_caps function

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gst_pad_set_caps function

white
Hi All,

I am starting with GStreamer Plugin development. I am going through the pwg guide and have been able to download and set up the build for GStreamer. I could run some sample application (media playback) and also started with template plugin sample code.

I have some doubt regarding gst_pad_set_caps() function. As I understood gst_pad_set_caps() is called during cap negotiation with peer elements.

gst_pad_set_caps (filter->srcpad, myCaps))

Let me put my understanding of above function. I am trying to set "myCaps" on my own filter's source pad "filter->srcpad". Lets assume there are 2 plugins A and B and A is my plugin. Once I call gst_pad_set_caps() it goes and enquires with B's Sink pad caps to see if it matches with "myCaps". If so then Negotiation is successful downstream(A->B).

Please let me know if my understanding is correct.
~White
Reply | Threaded
Open this post in threaded view
|

Re: gst_pad_set_caps function

white
I just got to see the below function in pwg ( advance filter concepts)

static gboolean gst_my_filter_setcaps (GstPad *pad, GstCaps *caps)
{
  GstMyFilter *filter = GST_MY_FILTER (GST_OBJECT_PARENT (pad));
  GstStructure *s;
  /* forward-negotiate */
  if (!gst_pad_set_caps (filter->srcpad, caps))
  return FALSE;
  /* negotiation succeeded, so now configure ourselves */
  s = gst_caps_get_structure (caps, 0);
  gst_structure_get_int (s, "rate", &filter->samplerate);
  gst_structure_get_int (s, "channels", &filter->channels);
  return TRUE;
}
It looks like "caps" is not my filter cap and is coming from other element. who will call gst_my_filter_setcaps() ? is there some baseclass who will do so ?

Why I am saying so is because I see that once the negotiation goes fine we are extracting GstStructure in "s" using "caps" and thereafter fixing our filter parameters(&filter->samplerate etc). Is this "filter" my filter or this is also coming from other element ?

I am really confused now ?
Reply | Threaded
Open this post in threaded view
|

Re: gst_pad_set_caps function

white
Surprisingly, this post has not been accepted till now !!

What is the purpose of having this group then ?

White
Reply | Threaded
Open this post in threaded view
|

Re: gst_pad_set_caps function

white
This post was updated on .
Just thought of replying in case someone like me comes in search of this simple question.

My doubt was regarding gst_pad_set_caps (filter->srcpad, myCaps))

This function is called by GStreamer while it tries to connect adjacent Plugins. The "filter->srcpad" is your plugin's srcpad and "myCaps" is the cap that Gstreamer sent to your plugin to be set on its pad after GStreamer has negociated with adjacent plugins.

In general, whichever "PAD" you want to set is what you supply as first parameter , and whatever "CAP" you want to set is specified as the second parameter.

Hope, it might help someone.