mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
d0bcc34dad
Original commit message from CVS: * docs/manual/advanced-autoplugging.xml: * docs/manual/advanced-clocks.xml: * docs/manual/advanced-interfaces.xml: * docs/manual/advanced-metadata.xml: * docs/manual/advanced-position.xml: * docs/manual/advanced-schedulers.xml: * docs/manual/advanced-threads.xml: * docs/manual/appendix-gnome.xml: * docs/manual/appendix-programs.xml: * docs/manual/appendix-quotes.xml: * docs/manual/autoplugging.xml: * docs/manual/basics-bins.xml: * docs/manual/basics-data.xml: * docs/manual/basics-elements.xml: * docs/manual/basics-helloworld.xml: * docs/manual/basics-init.xml: * docs/manual/basics-pads.xml: * docs/manual/basics-plugins.xml: * docs/manual/bins-api.xml: * docs/manual/bins.xml: * docs/manual/buffers-api.xml: * docs/manual/buffers.xml: * docs/manual/clocks.xml: * docs/manual/components.xml: * docs/manual/cothreads.xml: * docs/manual/debugging.xml: * docs/manual/dparams-app.xml: * docs/manual/dynamic.xml: * docs/manual/elements-api.xml: * docs/manual/elements.xml: * docs/manual/factories.xml: * docs/manual/gnome.xml: * docs/manual/goals.xml: * docs/manual/helloworld.xml: * docs/manual/helloworld2.xml: * docs/manual/highlevel-components.xml: * docs/manual/highlevel-xml.xml: * docs/manual/init-api.xml: * docs/manual/intro-basics.xml: * docs/manual/intro-motivation.xml: * docs/manual/intro-preface.xml: * docs/manual/intro.xml: * docs/manual/links-api.xml: * docs/manual/links.xml: * docs/manual/manual.xml: * docs/manual/motivation.xml: * docs/manual/pads-api.xml: * docs/manual/pads.xml: * docs/manual/plugins-api.xml: * docs/manual/plugins.xml: * docs/manual/programs.xml: * docs/manual/queues.xml: * docs/manual/quotes.xml: * docs/manual/schedulers.xml: * docs/manual/states-api.xml: * docs/manual/states.xml: * docs/manual/threads.xml: * docs/manual/typedetection.xml: * docs/manual/win32.xml: * docs/manual/xml.xml: Try 2. This time, include a short preface as a "general introduction", also add code blocks around all code samples so they get compiled. We still need a way to tell readers the filename of the code sample. In some cases, don't show all code in the documentation, but do include it in the generated code. This allows for focussing on specific bits in the docs, while still having a full test application available. * examples/manual/Makefile.am: Fix up examples for new ADM. Add several of the new examples that were either added or were missing from the build system. * examples/manual/extract.pl: Allow nameless blocks.
101 lines
3.2 KiB
XML
101 lines
3.2 KiB
XML
<chapter id="chapter-init">
|
|
<title>Initializing &GStreamer;</title>
|
|
<para>
|
|
When writing a &GStreamer; application, you can simply include
|
|
<filename>gst/gst.h</filename> to get access to the library
|
|
functions. Besides that, you will also need to intialize the
|
|
&GStreamer; library.
|
|
</para>
|
|
|
|
<sect1 id="section-init-c">
|
|
<title>Simple initialization</title>
|
|
<para>
|
|
Before the &GStreamer; libraries can be used,
|
|
<function>gst_init</function> 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.
|
|
</para>
|
|
<para>
|
|
A typical program &EXAFOOT; would have code to initialize
|
|
&GStreamer; that looks like this:
|
|
</para>
|
|
<programlisting>
|
|
<!-- example-begin init.c -->
|
|
#include <gst/gst.h>
|
|
|
|
int
|
|
main (int argc,
|
|
char *argv[])
|
|
{
|
|
guint major, minor, micro;
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
gst_version (&major, &minor, &micro);
|
|
printf ("This program is linked against GStreamer %d.%d.%d\n",
|
|
major, minor, micro);
|
|
|
|
return 0;
|
|
}
|
|
<!-- example-end init.c -->
|
|
</programlisting>
|
|
<para>
|
|
Use the <symbol>GST_VERSION_MAJOR</symbol>,
|
|
<symbol>GST_VERSION_MINOR</symbol> and <symbol>GST_VERSION_MICRO</symbol>
|
|
macros to get the &GStreamer; version you are building against, or
|
|
use the function <function>gst_version</function> to get the version
|
|
your application is linked against. &GStreamer; currently uses a
|
|
scheme where versions with the same major and minor versions are
|
|
API-/ and ABI-compatible.
|
|
</para>
|
|
<para>
|
|
It is also possible to call the <function>gst_init</function> function
|
|
with two <symbol>NULL</symbol> arguments, in which case no command line
|
|
options will be parsed by <application>GStreamer</application>.
|
|
</para>
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>The popt interface</title>
|
|
<para>
|
|
You can also use a popt table to initialize your own parameters as
|
|
shown in the next example:
|
|
</para>
|
|
<programlisting>
|
|
<!-- example-begin popt.c -->
|
|
#include <gst/gst.h>
|
|
|
|
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);
|
|
|
|
printf ("Run me with --help to see the Application options appended.\n");
|
|
|
|
return 0;
|
|
}
|
|
<!-- example-end popt.c -->
|
|
</programlisting>
|
|
<para>
|
|
As shown in this fragment, you can use a <ulink
|
|
url="http://developer.gnome.org/doc/guides/popt/"
|
|
type="http">popt</ulink> table to define your application-specific
|
|
command line options, and pass this table to the
|
|
function <function>gst_init_with_popt_table</function>. Your
|
|
application options will be parsed in addition to the standard
|
|
<application>GStreamer</application> options.
|
|
</para>
|
|
</sect1>
|
|
</chapter>
|