From: Thomas V. S. <tho...@pd...> - 2004-02-05 06:50:35
|
CVS Root: /home/cvs/gstreamer Module: gstreamer Changes by: thomasvs Date: Tue Feb 03 2004 06:59:46 PST Log message: add GstPoptOption to work around evil poptOption struct def make sure popt is i18n'd expand gnome example Modified files: . : ChangeLog docs/manual : gnome.xml gst : gst.c gst.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.192&r2=1.193 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/docs/manual/gnome.xml.diff?r1=1.6&r2=1.7 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gst.c.diff?r1=1.123&r2=1.124 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gst.h.diff?r1=1.61&r2=1.62 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.192 retrieving revision 1.193 diff -u -d -r1.192 -r1.193 --- ChangeLog 3 Feb 2004 11:23:59 -0000 1.192 +++ ChangeLog 3 Feb 2004 14:59:32 -0000 1.193 @@ -1,5 +1,16 @@ 2004-02-03 Thomas Vander Stichele <thomas at apestaart dot org> + * docs/manual/gnome.xml: + expand example a little + * gst/gst.c: (gst_init_with_popt_table), + (gst_init_check_with_popt_table), (init_pre), (init_popt_callback): + make sure popt option displays are done with right textdomain + use GstPoptOption type + * gst/gst.h: + create GstPoptOption type + +2004-02-03 Thomas Vander Stichele <thomas at apestaart dot org> + * gst/gsterror.c: (_gst_stream_errors_init): * gst/gsterror.h: adding error type for no codec Index: gst.c =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/gst.c,v retrieving revision 1.123 retrieving revision 1.124 diff -u -d -r1.123 -r1.124 --- gst.c 2 Feb 2004 22:01:23 -0000 1.123 +++ gst.c 3 Feb 2004 14:59:32 -0000 1.124 @@ -66,7 +66,7 @@ static void load_plugin_func (gpointer data, gpointer user_data); static void init_popt_callback (poptContext context, enum poptCallbackReason reason, - const struct poptOption *option, + const GstPoptOption *option, const char *arg, void *data); static gboolean init_pre (void); static gboolean init_post (void); @@ -113,13 +113,15 @@ /* default scheduler, can be changed in gstscheduler.h with * the GST_SCHEDULER_DEFAULT_NAME define. */ -static const struct poptOption gstreamer_options[] = { +static const GstPoptOption gstreamer_options[] = { {NULL, NUL, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *) &init_popt_callback, 0, NULL, NULL}, + /* make sure we use our GETTEXT_PACKAGE as the domain for popt translations */ + {NULL, NUL, POPT_ARG_INTL_DOMAIN, GETTEXT_PACKAGE, 0, NULL, NULL}, {"gst-version", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, N_("Print the GStreamer version"), NULL}, {"gst-fatal-warnings", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL}, #ifndef GST_DISABLE_GST_DEBUG {"gst-debug-level", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_LEVEL, N_("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"), N_("LEVEL")}, - {"gst-debug", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG, N_("Comma-separated list of category_name:level pairs to set specific levels for the individual categories.\nExample: GST_AUTOPLUG:5,GST_ELEMENT_*:3"), N_("CATEGORIES")}, + {"gst-debug", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG, N_("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"), N_("CATEGORIES")}, {"gst-debug-no-color", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_NO_COLOR, N_("Disable color debugging output"), NULL}, {"gst-disable-debug", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_DISABLE, N_("Disable debugging")}, {"gst-debug-help", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL}, @@ -142,10 +144,13 @@ * actually performed (via poptGetContext), the GStreamer libraries will * be initialized. * + * This function is useful if you want to integrate GStreamer with other + * libraries that use popt. + * * Returns: a pointer to the static GStreamer option table. * No free is necessary. */ -const struct poptOption * +const GstPoptOption * gst_init_get_popt_table (void) { return gstreamer_options; @@ -205,7 +210,7 @@ */ void gst_init_with_popt_table (int *argc, char **argv[], - const struct poptOption *popt_options) + const GstPoptOption *popt_options) { if (!gst_init_check_with_popt_table (argc, argv, popt_options)) { g_print ("Could not initialize GStreamer !\n"); @@ -226,20 +231,20 @@ */ gboolean gst_init_check_with_popt_table (int *argc, char **argv[], - const struct poptOption *popt_options) + const GstPoptOption *popt_options) { poptContext context; gint nextopt; - struct poptOption *options; - struct poptOption options_with[] = { + GstPoptOption *options; + GstPoptOption options_with[] = { {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gstreamer_options, 0, "GStreamer options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) popt_options, 0, "Application options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0, "Application options:", NULL}, POPT_TABLEEND }; - struct poptOption options_without[] = { + GstPoptOption options_without[] = { {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gstreamer_options, 0, "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, "GStreamer options:", NULL}, POPT_TABLEEND }; @@ -385,7 +390,6 @@ static gboolean init_pre (void) { - g_type_init (); if (g_thread_supported ()) { @@ -651,7 +655,7 @@ static void init_popt_callback (poptContext context, enum poptCallbackReason reason, - const struct poptOption *option, const char *arg, void *data) + const GstPoptOption *option, const char *arg, void *data) { GLogLevelFlags fatal_mask; Index: gst.h =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/gst.h,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- gst.h 3 Feb 2004 03:31:25 -0000 1.61 +++ gst.h 3 Feb 2004 14:59:32 -0000 1.62 @@ -70,17 +70,21 @@ G_BEGIN_DECLS +/* make our own type for poptOption because the struct poptOption + * definition is iffy */ +typedef struct poptOption GstPoptOption; + /* initialize GST */ void gst_init (int *argc, char **argv[]); gboolean gst_init_check (int *argc, char **argv[]); void gst_init_with_popt_table (int *argc, char **argv[], - const struct poptOption + const GstPoptOption *popt_options); gboolean gst_init_check_with_popt_table (int *argc, char **argv[], - const struct poptOption + const GstPoptOption *popt_options); -G_CONST_RETURN struct poptOption* - gst_init_get_popt_table (void); + +const GstPoptOption * gst_init_get_popt_table (void); void gst_use_threads (gboolean use_threads); gboolean gst_has_threads (void); Index: gnome.xml =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/docs/manual/gnome.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gnome.xml 28 Jan 2004 15:08:17 -0000 1.6 +++ gnome.xml 3 Feb 2004 14:59:32 -0000 1.7 @@ -30,7 +30,7 @@ int main (int argc, char **argv) { - struct poptOption options[] = { + GstPoptOption options[] = { { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "GStreamer", NULL }, POPT_TABLEEND }; @@ -38,13 +38,20 @@ poptContext context; const gchar **argvn; + GstElement *pipeline; + GstElement *src, *sink; + options[0].arg = (void *) gst_init_get_popt_table (); + g_print ("Calling gnome_program_init with the GStreamer popt table\n"); + /* gnome_program_init will initialize GStreamer now + * as a side effect of having the GStreamer popt table passed. */ if (! (program = gnome_program_init ("my_package", "0.1", LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, options, NULL))) - g_error ("gnome_program_init failed"); + g_error ("gnome_program_init failed"); + g_print ("Getting gnome-program popt context\n"); g_object_get (program, "popt-context", &context, NULL); argvn = poptGetArgs (context); if (!argvn) { @@ -52,11 +59,23 @@ return 0; } + g_print ("Printing rest of arguments\n"); while (*argvn) { g_print ("argument: %s\n", *argvn); ++argvn; } + /* do some GStreamer things to show everything's initialized properly */ + g_print ("Doing some GStreamer stuff to show that everything works\n"); + pipeline = gst_pipeline_new ("pipeline"); + src = gst_element_factory_make ("fakesrc", "src"); + sink = gst_element_factory_make ("fakesink", "sink"); + gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); + gst_element_link (src, sink); + gst_element_set_state (pipeline, GST_STATE_PLAYING); + gst_bin_iterate (GST_BIN (pipeline)); + gst_element_set_state (pipeline, GST_STATE_NULL); + return 0; } /* example-end gnome.c */ |