Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > f0a9f2b9c81d34eadc43f527947c0b70 > files > 250

libgstreamer0.7-devel-0.7.4-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>The getcaps function</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="GStreamer Plugin Writer's Guide"
HREF="index.html"><LINK
REL="UP"
TITLE="Specifying the pads"
HREF="chapter-building-pads.html"><LINK
REL="PREVIOUS"
TITLE="Specifying the pads"
HREF="chapter-building-pads.html"><LINK
REL="NEXT"
TITLE="Explicit caps"
HREF="section-pads-explicitcaps.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
><SPAN
CLASS="application"
>GStreamer</SPAN
> Plugin Writer's Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="chapter-building-pads.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 4. Specifying the pads</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="section-pads-explicitcaps.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="section-pads-getcapsfn"
>4.2. The getcaps function</A
></H1
><P
>&#13;    The <CODE
CLASS="function"
>_getcaps ()</CODE
> funtion is used to request the list
    of supported formats and properties from the element. In some cases, this
    will be equal to the formats provided by the pad template, in which case
    this function can be omitted. In some cases, too, it will not depend on
    anything inside this element, but it will rather depend on the input from
    another element linked to this element's sink or source pads. In that case,
    you can use <CODE
CLASS="function"
>gst_pad_proxy_getcaps</CODE
> as implementation,
    it provides getcaps forwarding in the core. However, in many cases, the
    format supported by this element cannot be defined externally, but is
    more specific than those provided by the pad template. In this case, you
    should use a <CODE
CLASS="function"
>_getcaps ()</CODE
> function. In the case as
    specified below, we assume that our filter is able to resample sound, so
    it would be able to provide any samplerate (indifferent from the samplerate
    specified on the other pad) on both pads. It explains how a
    <CODE
CLASS="function"
>_getcaps ()</CODE
> can be used to do this.
  </P
><PRE
CLASS="programlisting"
>&#13;static GstCaps *
gst_my_filter_getcaps (GstPad *pad)
{
  GstMyFilter *filter = GST_MY_FILTER (gst_pad_get_parent (pad));
  GstPad *otherpad = (pad == filter-&#62;srcpad) ? filter-&#62;sinkpad :
					       filter-&#62;srcpad;
  GstCaps *othercaps = gst_pad_get_allowed_caps (otherpad), *caps;
  gint n;

  if (gst_caps_is_empty (othercaps))
    return othercaps;

  /* We support *any* samplerate, indifferent from the samplerate
   * supported by the linked elements on both sides. */
  for (i = 0; i &#60; gst_caps_get_size (othercaps); i++) {
    GstStructure *structure = gst_caps_get_structure (othercaps, i);

    gst_structure_remove_field (structure, "rate");
  }
  caps = gst_caps_intersect (othercaps, gst_pad_get_pad_template_caps (pad));
  gst_caps_free (othercaps);

  return caps;
}
  </PRE
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="chapter-building-pads.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="section-pads-explicitcaps.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Specifying the pads</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chapter-building-pads.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Explicit caps</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>