GStreamer Application Development Manual (0.8.5.2) | ||
---|---|---|
<<< Previous | Next >>> |
When writing a GStreamer application, you can simply include gst/gst.h to get access to the library functions.
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-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 */ |
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.
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.
You can also use a popt table to initialize your own parameters as shown in the next example:
/* 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 */ |
As shown in this fragment, you can use a popt table to define your application-specific command line options, and pass this table to the function gst_init_with_popt_table. Your application options will be parsed in addition to the standard GStreamer options.
[1] | The code for this example is automatically extracted from the documentation and built under examples/manual in the GStreamer tarball. |
<<< Previous | Home | Next >>> |
Basic API | Up | Elements |