Sophie

Sophie

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

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>GstStaticPadTemplate</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="Constructing the Boilerplate"
HREF="chapter-building-boiler.html"><LINK
REL="PREVIOUS"
TITLE="GstElementDetails"
HREF="section-boiler-details.html"><LINK
REL="NEXT"
TITLE="Constructor Functions"
HREF="section-boiler-constructors.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="section-boiler-details.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. Constructing the Boilerplate</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="section-boiler-constructors.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="section-boiler-padtemplates"
>3.5. GstStaticPadTemplate</A
></H1
><P
>&#13;      A GstStaticPadTemplate is a description of a pad that the element will
      (or might) create and use. It contains:
    </P
><P
></P
><UL
><LI
><P
>A short name for the pad.</P
></LI
><LI
><P
>Pad direction.</P
></LI
><LI
><P
>&#13;          Existence property. This indicates whether the pad exists always (an
          <SPAN
CLASS="QUOTE"
>"always"</SPAN
> pad), only in some cases (a
          <SPAN
CLASS="QUOTE"
>"sometimes"</SPAN
> pad) or only if the application requested
          such a pad (a <SPAN
CLASS="QUOTE"
>"request"</SPAN
> pad).
        </P
></LI
><LI
><P
>Supported types by this element (capabilities).</P
></LI
></UL
><P
>&#13;      For example:
    </P
><PRE
CLASS="programlisting"
>&#13;static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
  "sink",
  GST_PAD_SINK,
  GST_PAD_ALWAYS,
  GST_STATIC_CAPS ("ANY")
);
      </PRE
><P
>&#13;      Those pad templates are registered during the
      <CODE
CLASS="function"
>_base_init ()</CODE
> function. Pads are created from these
      templates in the element's <CODE
CLASS="function"
>_init ()</CODE
> function using
      <CODE
CLASS="function"
>gst_pad_new_from_template ()</CODE
>. The template can be
      retrieved from the element class using
      <CODE
CLASS="function"
>gst_element_class_get_pad_template ()</CODE
>. See below
      for more details on this.
    </P
><PRE
CLASS="programlisting"
>&#13;static void
gst_my_filter_base_init (GstMyFilterClass *klass)
{
  static GstStaticPadTemplate sink_factory =
[..]
  , src_factory =
[..]
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);

  gst_element_class_add_pad_template (element_class,
	gst_static_pad_template_get (&#38;src_factory));
  gst_element_class_add_pad_template (element_class,
	gst_static_pad_template_get (&#38;sink_factory));
[..]
}
    </PRE
><P
>&#13;      The last argument in a template is its type
      or list of supported types. In this example, we use 'ANY', which means
      that this element will accept all input. In real-life situations, you
      would set a mimetype and optionally a set of properties to make sure
      that only supported input will come in. This representation should be
      a string that starts with a mimetype, then a set of comma-separates
      properties with their supported values. In case of an audio filter that
      supports raw integer 16-bit audio, mono or stereo at any samplerate, the
      correct template would look like this:
    </P
><PRE
CLASS="programlisting"
>&#13;static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
  "sink",
  GST_PAD_SINK,
  GST_PAD_ALWAYS,
  GST_STATIC_CAPS (
    "audio/x-raw-int, "
      "width = (int) 16, "
      "depth = (int) 16, "
      "endianness = (int) BYTE_ORDER, "
      "channels = (int) { 1, 2 }, "
      "rate = (int) [ 8000, 96000 ]"
  )
);
    </PRE
><P
>&#13;      Values surrounded by {} are lists, values surrounded by [] are ranges.
      Multiple sets of types are supported too, and should be separated by
      a semicolon (<SPAN
CLASS="QUOTE"
>";"</SPAN
>). Later, in the chapter on pads, we will
      see how to use types to know the exact format of a stream:
      <A
HREF="chapter-building-pads.html"
>Chapter 4</A
>.
    </P
></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="section-boiler-details.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-boiler-constructors.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>GstElementDetails</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chapter-building-boiler.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Constructor Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>