10.2. Fixed caps

The simplest way in which to do caps negotiation is setting a fixed caps on a pad. After a fixed caps has been set, the pad can not be renegotiated from the outside. The only way to reconfigure the pad is for the element owning the pad to set a new fixed caps on the pad. Fixed caps is a setup property for pads, called when creating the pad:


[..]
  pad = gst_pad_new_from_template (..);
  gst_pad_use_fixed_caps (pad);
[..]
    

The fixed caps can then be set on the pad by calling gst_pad_set_caps ().


[..]
  caps = gst_caps_new_simple ("audio/x-raw-float",
      "width", G_TYPE_INT, 32,
      "endianness", G_TYPE_INT, G_BYTE_ORDER,
      "buffer-frames", G_TYPE_INT, <bytes-per-frame>,
      "rate", G_TYPE_INT, <samplerate>,
      "channels", G_TYPE_INT, <num-channels>, NULL);
  if (!gst_pad_set_caps (pad, caps)) {
    GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
        ("Some debug information here"));
    return GST_FLOW_ERROR;
  }
[..]
    

Elements that could implement fixed caps (on their source pads) are, in general, all elements that are not renegotiatable. Examples include:

All other elements that need to be configured for the format should implement full caps negotiation, which will be explained in the next few sections.