Table of Contents
When writing a GStreamer application, you can simply include
gst/gst.h to get access to the library
functions. Besides that, you will also need to initialize the
GStreamer library.
Before the GStreamer libraries can be used,
gst_init 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.
A typical program [1] would have code to initialize GStreamer that looks like this:
Example 4.1. Initializing GStreamer
#include <stdio.h>
#include <gst/gst.h>
int
main (int argc,
char *argv[])
{
const gchar *nano_str;
guint major, minor, micro, nano;
gst_init (&argc, &argv);
gst_version (&major, &minor, µ, &nano);
if (nano == 1)
nano_str = "(CVS)";
else if (nano == 2)
nano_str = "(Prerelease)";
else
nano_str = "";
printf ("This program is linked against GStreamer %d.%d.%d %s\n",
major, minor, micro, nano_str);
return 0;
}
Use the GST_VERSION_MAJOR,
GST_VERSION_MINOR and GST_VERSION_MICRO
macros to get the GStreamer version you are building against, or
use the function gst_version 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.
It is also possible to call the gst_init function
with two NULL arguments, in which case no command line
options will be parsed by GStreamer.
[1]
The code for this example is automatically extracted from
the documentation and built under tests/examples/manual
in the GStreamer tarball.