You can also use a GOption table to initialize your own parameters as shown in the next example:
Example 4-2. Initialisation using the GOption interface
#include <gst/gst.h> int main (int argc, char *argv[]) { gboolean silent = FALSE; gchar *savefile = NULL; GOptionContext *ctx; GError *err = NULL; GOptionEntry entries[] = { { "silent", 's', 0, G_OPTION_ARG_NONE, &silent, "do not output status information", NULL }, { "output", 'o', 0, G_OPTION_ARG_STRING, &savefile, "save xml representation of pipeline to FILE and exit", "FILE" }, { NULL } }; ctx = g_option_context_new ("- Your application"); g_option_context_add_main_entries (ctx, entries, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Failed to initialize: %s\n", err->message); g_error_free (err); return 1; } printf ("Run me with --help to see the Application options appended.\n"); return 0; }
As shown in this fragment, you can use a GOption table to define your application-specific
command line options, and pass this table to the GLib initialization
function along with the option group returned from the
function gst_init_get_option_group
. Your
application options will be parsed in addition to the standard
GStreamer options.