From c8b2ab8dbbf6f6b64a2488e3a3cb02e6cf3106a2 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Mon, 3 Nov 2014 11:14:45 +0100 Subject: [PATCH] ges: Add a method to get GES GOption group This allow us to have global options to be passed as arguments of the program to configure GES behaviour API: ges_init_get_option_group https://bugzilla.gnome.org/show_bug.cgi?id=740715 --- docs/libs/ges-sections.txt | 2 ++ ges/ges.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ ges/ges.h | 9 +++---- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 5fb74f3..9229e69 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -4,7 +4,9 @@ ges-common Initialization ges_init +ges_init_check ges_version +ges_init_get_option_group GES_VERSION_MAJOR GES_VERSION_MICRO GES_VERSION_MINOR diff --git a/ges/ges.c b/ges/ges.c index 0e5f63b..6ad1670 100644 --- a/ges/ges.c +++ b/ges/ges.c @@ -18,6 +18,12 @@ * Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include #include #include "ges/gstframepositionner.h" #include "ges-internal.h" @@ -108,6 +114,60 @@ ges_init (void) return TRUE; } +#ifndef GST_DISABLE_OPTION_PARSING +static gboolean +parse_goption_arg (const gchar * s_opt, + const gchar * arg, gpointer data, GError ** err) +{ + if (g_strcmp0 (s_opt, "--ges-version") == 0) { + g_print ("GStreamer Editing Services version %s\n", PACKAGE_VERSION); + exit (0); + } + + return TRUE; +} +#endif + +/** + * ges_init_get_option_group: (skip) + * + * Returns a #GOptionGroup with GES's argument specifications. The + * group is set up to use standard GOption callbacks, so when using this + * group in combination with GOption parsing methods, all argument parsing + * and initialization is automated. + * + * This function is useful if you want to integrate GES with other + * libraries that use GOption (see g_option_context_add_group() ). + * + * If you use this function, you should make sure you initialise the GStreamer + * as one of the very first things in your program. + * + * Returns: (transfer full): a pointer to GES's option group. + */ +GOptionGroup * +ges_init_get_option_group (void) +{ +#ifndef GST_DISABLE_OPTION_PARSING + + GOptionGroup *group; + static const GOptionEntry ges_args[] = { + {"ges-version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + (gpointer) parse_goption_arg, + "Print the GStreamer Editing Services version", + NULL}, + {NULL} + }; + + group = g_option_group_new ("GES", "GStreamer Editing Services Options", + "Show GStreamer Options", NULL, NULL); + g_option_group_add_entries (group, ges_args); + + return group; + +#else + return NULL; +#endif +} /** * ges_version: diff --git a/ges/ges.h b/ges/ges.h index 45c99b7..918cbf0 100644 --- a/ges/ges.h +++ b/ges/ges.h @@ -84,10 +84,11 @@ G_BEGIN_DECLS -gboolean ges_init (void); - -void ges_version (guint * major, guint * minor, guint * micro, - guint * nano); +gboolean ges_init (void); +void ges_version (guint * major, guint * minor, guint * micro, + guint * nano); +GOptionGroup * +ges_init_get_option_group (void); G_END_DECLS -- 2.7.4