1 <chapter id="cha-initialisation">
2 <title>Initializing <application>GStreamer</application></title>
4 When writing a <application>GStreamer</application> application, you can
5 simply include <filename class='headerfile'>gst/gst.h</filename> to get
6 access to the library functions.
9 Before the <application>GStreamer</application> libraries can be used
10 <function>gst_init</function> has to be called from the main application.
11 This call will perform the necessary initialization of the library as
12 well as parse the GStreamer-specific command line options.
15 A typical program would start like this:
19 #include <gst/gst.h>
24 main (int argc, char *argv[])
27 gst_init (&argc, &argv);
32 Use the <symbol>GST_VERSION_MAJOR</symbol>,
33 <symbol>GST_VERSION_MINOR</symbol> and <symbol>GST_VERSION_MICRO</symbol>
34 macros to get the <application>GStreamer</application> version you are
35 building against, or use the function <function>gst_version</function>
36 to get the version your application is linked against.
37 <!-- FIXME: include an automatically generated list of these options. -->
40 It is also possible to call the <function>gst_init</function> function
41 with two <symbol>NULL</symbol> arguments, in which case no command line
42 options will parsed by <application>GStreamer</application>.
45 Use the GST_VERSION_MAJOR, GST_VERSION_MINOR and GST_VERSION_MICRO macros to
46 get the <application>GStreamer</application> version you are building against or
47 use gst_version() to get the version you are linked against.
50 <title>The popt interface</title>
52 You can also use a popt table to initialize your own parameters as shown in the next code fragment:
56 main(int argc, char *argv[])
58 gboolean silent = FALSE;
59 gchar *savefile = NULL;
60 struct poptOption options[] = {
61 {"silent", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &silent, 0,
62 "do not output status information", NULL},
63 {"output", 'o', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &savefile, 0,
64 "save xml representation of pipeline to FILE and exit", "FILE"},
68 gst_init_with_popt_table (&argc, &argv, options);
73 As shown in this fragment, you can use a <ulink
74 url="http://developer.gnome.org/doc/guides/popt/"
75 type="http">popt</ulink> table to define your application-specific
76 command line options, and pass this table to the
77 function <function>gst_init_with_popt_table</function>. Your
78 application options will be parsed in addition to the standard
79 <application>GStreamer</application> options.