4.3. Explicit caps

Obviously, many elements will not need this complex mechanism, because they are much simpler than that. They only support one format, or their format is fixed but the contents of the format depend on the stream or something else. In those cases, explicit caps are an easy way of handling caps. Explicit caps are an easy way of specifying one, fixed, supported format on a pad. Pads using explicit caps do not implement their own _getcaps () or _link () functions. When the exact format is known, an elements uses gst_pad_set_explicit_caps () to specify the exact format. This is very useful for demuxers, for example.


static void
gst_my_filter_init (GstMyFilter *filter)
{
  GstElementClass *klass = GST_ELEMENT_GET_CLASS (filter);
[..]
  filter->srcpad = gst_pad_new_from_template (
	gst_element_class_get_pad_template (klass, "src"), "src");
  gst_pad_use_explicit_caps (filter->srcpad);
[..]
}

static void
gst_my_filter_somefunction (GstMyFilter *filter)
{
  GstCaps *caps = ..;
[..]
  gst_pad_set_explicit_caps (filter->srcpad, caps);
[..]
}