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
This commit is contained in:
Benjamin Otte 2002-02-24 17:08:07 +00:00
parent 24fb9e8282
commit 1952e9d714
3 changed files with 44 additions and 8 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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