<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Initializing GStreamer</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="GStreamer Application Development Manual" HREF="index.html"><LINK REL="UP" TITLE="Basic API" HREF="part-basic-api.html"><LINK REL="PREVIOUS" TITLE="Basic API" HREF="part-basic-api.html"><LINK REL="NEXT" TITLE="Elements" HREF="chapter-elements-api.html"></HEAD ><BODY CLASS="chapter" 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 > Application Development Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="part-basic-api.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="chapter-elements-api.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="chapter-initialisation" ></A >Chapter 11. Initializing <SPAN CLASS="application" >GStreamer</SPAN ></H1 ><P > When writing a <SPAN CLASS="application" >GStreamer</SPAN > application, you can simply include <TT CLASS="filename" >gst/gst.h</TT > to get access to the library functions. </P ><P > Before the <SPAN CLASS="application" >GStreamer</SPAN > libraries can be used, <CODE CLASS="function" >gst_init</CODE > has to be called from the main application. This call will perform the necessary initialization of the library as well as parse the GStreamer-specific command line options. </P ><P > A typical program would start like this: </P ><PRE CLASS="programlisting" > #include <gst/gst.h> ... int main (int argc, char *argv[]) { ... gst_init (&argc, &argv); ... } </PRE ><P > Use the <VAR CLASS="symbol" >GST_VERSION_MAJOR</VAR >, <VAR CLASS="symbol" >GST_VERSION_MINOR</VAR > and <VAR CLASS="symbol" >GST_VERSION_MICRO</VAR > macros to get the <SPAN CLASS="application" >GStreamer</SPAN > version you are building against, or use the function <CODE CLASS="function" >gst_version</CODE > to get the version your application is linked against. </P ><P > It is also possible to call the <CODE CLASS="function" >gst_init</CODE > function with two <VAR CLASS="symbol" >NULL</VAR > arguments, in which case no command line options will parsed by <SPAN CLASS="application" >GStreamer</SPAN >. </P ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="AEN415" >11.1. The popt interface</A ></H1 ><P > You can also use a popt table to initialize your own parameters as shown in the next code fragment: </P ><PRE CLASS="programlisting" > int main(int argc, char *argv[]) { gboolean silent = FALSE; gchar *savefile = NULL; struct poptOption options[] = { {"silent", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &silent, 0, "do not output status information", NULL}, {"output", 'o', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &savefile, 0, "save xml representation of pipeline to FILE and exit", "FILE"}, POPT_TABLEEND }; gst_init_with_popt_table (&argc, &argv, options); ... </PRE ><P > As shown in this fragment, you can use a <A HREF="http://developer.gnome.org/doc/guides/popt/" TARGET="_top" >popt</A > table to define your application-specific command line options, and pass this table to the function <CODE CLASS="function" >gst_init_with_popt_table</CODE >. Your application options will be parsed in addition to the standard <SPAN CLASS="application" >GStreamer</SPAN > options. </P ></DIV ></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="part-basic-api.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="chapter-elements-api.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Basic API</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="part-basic-api.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Elements</TD ></TR ></TABLE ></DIV ></BODY ></HTML >