From 1952e9d7146c868aa81ed75bbc62c0034c19e312 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 24 Feb 2002 17:08:07 +0000 Subject: [PATCH] updated popt stuff: Original commit message from CVS: updated popt stuff: - added 'gst_init_with_popt_table' to gst.h - added a --silent option to launch to suppress g_object_notify events --- gst/gst.c | 37 +++++++++++++++++++++++++++++++++---- gst/gst.h | 1 + tools/gst-launch.c | 14 ++++++++++---- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gst/gst.c b/gst/gst.c index 5ca75f17ca..1dd3fe0a84 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -79,7 +79,6 @@ enum { /* FIXME: put in the extended mask help */ static const struct poptOption options[] = { {NULL, NUL, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, &init_popt_callback, 0, NULL, NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, {"gst-info-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_INFO_MASK, "info bitmask", "MASK"}, {"gst-debug-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_MASK, "debugging bitmask", "MASK"}, {"gst-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_MASK, "bitmask for both info and debugging", "MASK"}, @@ -115,12 +114,38 @@ gst_init_get_popt_table (void) * registering built-in elements, and loading standard plugins. */ void -gst_init (int *argc, char **argv[]) +gst_init (int *argc, char **argv[]) +{ + gst_init_with_popt_table (argc, argv, NULL); +} +/** + * gst_init_with_popt_table: + * @argc: pointer to application's argc + * @argv: pointer to application's argv + * @popt_options: pointer to a popt table to append + * + * Initializes the GStreamer library, parsing the options, setting up internal path lists, + * registering built-in elements, and loading standard plugins. + */ +void +gst_init_with_popt_table (int *argc, char **argv[], const struct poptOption *popt_options) { poptContext context; gint nextopt, i, j, nstrip; - const struct poptOption *options; gchar **temp; + const struct poptOption *options; + /* this is probably hacky, no? */ + const struct poptOption options_with[] = { + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gst_init_get_popt_table(), 0, "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) popt_options, 0, "Application options:", NULL}, + POPT_TABLEEND + }; + const struct poptOption options_without[] = { + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gst_init_get_popt_table(), 0, "GStreamer options:", NULL}, + POPT_TABLEEND + }; if (!argc || !argv) { if (argc || argv) @@ -131,7 +156,11 @@ gst_init (int *argc, char **argv[]) return; } - options = gst_init_get_popt_table (); + if (popt_options == NULL) { + options = options_without; + } else { + options = options_with; + } context = poptGetContext ("GStreamer", *argc, (const char**)*argv, options, 0); while ((nextopt = poptGetNextOpt (context)) > 0); /* do nothing, it's all callbacks */ diff --git a/gst/gst.h b/gst/gst.h index 8f23c8a408..620bafae2e 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -61,6 +61,7 @@ extern "C" { /* initialize GST */ void gst_init (int *argc, char **argv[]); +void gst_init_with_popt_table (int *argc, char **argv[], const struct poptOption *popt_options); const struct poptOption *gst_init_get_popt_table (void); void gst_main (void); diff --git a/tools/gst-launch.c b/tools/gst-launch.c index c1bf8eadb5..792cfefdf2 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -137,17 +137,22 @@ xmllaunch_parse_cmdline (const gchar **argv) int main(int argc, char *argv[]) { +/* options */ + gboolean silent = FALSE; + struct poptOption options[] = { + {"silent", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &silent, 0, "do not output status information", NULL}, + POPT_TABLEEND + }; + GstElement *pipeline; gchar **argvn; - gchar *cmdline; - int i; gboolean save_pipeline = FALSE; gboolean run_pipeline = TRUE; gchar *savefile = ""; free (malloc (8)); /* -lefence */ - gst_init (&argc, &argv); + gst_init_with_popt_table (&argc, &argv, options); if (argc >= 3 && !strcmp(argv[1], "-o")) { save_pipeline = TRUE; @@ -175,7 +180,8 @@ main(int argc, char *argv[]) exit(1); } - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); + if (!silent) + g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); g_signal_connect (pipeline, "error", G_CALLBACK (error_callback), NULL); #ifndef GST_DISABLE_LOADSAVE