1 <chapter id="chapter-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.
17 would have code to initialize GStreamer that
23 /* example-begin init.c */
28 main (int argc, char *argv[])
30 guint major, minor, micro;
32 gst_init (&argc, &argv);
34 gst_version (&major, &minor, &micro);
35 printf ("This program is linked against GStreamer %d.%d.%d\n",
40 /* example-end init.c */
44 Use the <symbol>GST_VERSION_MAJOR</symbol>,
45 <symbol>GST_VERSION_MINOR</symbol> and <symbol>GST_VERSION_MICRO</symbol>
46 macros to get the <application>GStreamer</application> version you are
47 building against, or use the function <function>gst_version</function>
48 to get the version your application is linked against.
49 <!-- FIXME: include an automatically generated list of these options. -->
52 It is also possible to call the <function>gst_init</function> function
53 with two <symbol>NULL</symbol> arguments, in which case no command line
54 options will be parsed by <application>GStreamer</application>.
57 <title>The popt interface</title>
59 You can also use a popt table to initialize your own parameters as shown in the
63 /* example-begin popt.c */
65 #include <gst/gst.h>
68 main(int argc, char *argv[])
70 gboolean silent = FALSE;
71 gchar *savefile = NULL;
72 struct poptOption options[] = {
73 {"silent", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &silent, 0,
74 "do not output status information", NULL},
75 {"output", 'o', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &savefile, 0,
76 "save xml representation of pipeline to FILE and exit", "FILE"},
80 gst_init_with_popt_table (&argc, &argv, options);
82 printf ("Run me with --help to see the Application options appended.\n");
86 /* example-end popt.c */
89 As shown in this fragment, you can use a <ulink
90 url="http://developer.gnome.org/doc/guides/popt/"
91 type="http">popt</ulink> table to define your application-specific
92 command line options, and pass this table to the
93 function <function>gst_init_with_popt_table</function>. Your
94 application options will be parsed in addition to the standard
95 <application>GStreamer</application> options.