From: Thomas Vander Stichele Date: Mon, 1 Jul 2002 15:39:58 +0000 (+0000) Subject: gconf stuff X-Git-Tag: CAPS~278 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=473fa96cd83e937690078490494ff4d188a865ba;p=platform%2Fupstream%2Fgst-plugins-bad.git gconf stuff Original commit message from CVS: gconf stuff --- diff --git a/gst-libs/gst/Makefile.am b/gst-libs/gst/Makefile.am index b0e84c3..95e0b6d 100644 --- a/gst-libs/gst/Makefile.am +++ b/gst-libs/gst/Makefile.am @@ -1,3 +1,3 @@ -SUBDIRS = audio idct resample riff floatcast +SUBDIRS = audio idct resample riff floatcast gconf -DIST_SUBDIRS = audio idct resample riff floatcast +DIST_SUBDIRS = audio idct resample riff floatcast gconf diff --git a/gst-libs/gst/gconf/Makefile.am b/gst-libs/gst/gconf/Makefile.am new file mode 100644 index 0000000..d1d10e8 --- /dev/null +++ b/gst-libs/gst/gconf/Makefile.am @@ -0,0 +1,17 @@ +librarydir = $(prefix)/lib/gst + +library_LTLIBRARIES = libgstgconf.la + +libgstgconf_la_SOURCES = gconf.c + +libgstgconfincludedir = $(includedir)/@PACKAGE@-@VERSION@/gst/gconf +libgstgconfinclude_HEADERS = gconf.h + +noinst_PROGRAMS = test-gconf + +test_gconf_CFLAGS = $(GST_CFLAGS) $(GCONF_CFLAGS) +test_gconf_LDADD = $(GST_LIBS) $(GCONF_LIBS) -lgstgconf + +libgstgconf_la_LIBADD = $(GCONF_LIBS) +libgstgconf_la_CFLAGS = $(GST_CFLAGS) $(GCONF_CFLAGS) +libgstgconf_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/gst-libs/gst/gconf/gconf.c b/gst-libs/gst/gconf/gconf.c new file mode 100644 index 0000000..6463039 --- /dev/null +++ b/gst-libs/gst/gconf/gconf.c @@ -0,0 +1,93 @@ +/* + * this library handles interaction with GConf + */ + +#include "gconf.h" + +#define GST_GCONF_DIR "/system/gstreamer" + +static GConfClient *_gst_gconf_client = NULL; /* GConf connection */ + + +/* internal functions */ + +GConfClient * +gst_gconf_get_client (void) +{ + if (!_gst_gconf_client) + _gst_gconf_client = gconf_client_get_default (); + + return _gst_gconf_client; +} + +/* external functions */ + +gchar * +gst_gconf_get_string (const gchar *key) +{ + GError *error = NULL; + gchar *value = NULL; + gchar *full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key); + + g_print ("DEBUG: full key: %s\n", full_key); + + value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error); + g_free (full_key); + + if (value) + return value; + else + return NULL; + // this is a good idea: return g_strdup (default_val); +} + +void +gst_gconf_set_string (const gchar *key, const gchar *value) +{ + gconf_client_set_string (gst_gconf_get_client (), key, value, NULL); +} + +gboolean +gst_gconf_render_bin (const gchar *key, GstElement **element) +{ + GstElement *bin; + gchar *pipeline; + GError *error = NULL; + gchar *value = NULL; + + value = gst_gconf_get_string (key); + + pipeline = g_strdup_printf ("bin.( %s )", value); + bin = GST_ELEMENT (gst_parse_launch (pipeline, &error)); + if (error) + { + g_print ("DEBUG: gstgconf: error parsing pipeline %s\n%s\n", + pipeline, error->message); + g_error_free (error); + return FALSE; + } + *element = bin; + return TRUE; +} + +/* +guint gst_gconf_notify_add (const gchar *key, + GConfClientNotifyFunc func, + gpointer user_data); +*/ + +static gboolean +plugin_init (GModule *module, GstPlugin *plugin) +{ + gst_plugin_set_longname (plugin, + "Convenience routines for GConf interaction"); + return TRUE; +} + +GstPluginDesc plugin_desc = { + GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstgconf", + plugin_init +}; + diff --git a/gst-libs/gst/gconf/gconf.h b/gst-libs/gst/gconf/gconf.h new file mode 100644 index 0000000..5367854 --- /dev/null +++ b/gst-libs/gst/gconf/gconf.h @@ -0,0 +1,23 @@ +#ifndef GST_GCONF_H +#define GST_GCONF_H + +/* + * this library handles interaction with GConf + */ + +#include +#include + +gchar * gst_gconf_get_string (const gchar *key); +void gst_gconf_set_string (const gchar *key, + const gchar *value); + +gboolean gst_gconf_render_bin (const gchar *key, + GstElement **element); + +/* +guint gst_gconf_notify_add (const gchar *key, + GConfClientNotifyFunc func, + gpointer user_data); +*/ +#endif /* GST_GCONF_H */ diff --git a/gst-libs/gst/gconf/test-gconf.c b/gst-libs/gst/gconf/test-gconf.c new file mode 100644 index 0000000..8ce459a --- /dev/null +++ b/gst-libs/gst/gconf/test-gconf.c @@ -0,0 +1,10 @@ +#include "gconf.h" + +int +main (int argc, char *argv[]) +{ + printf ("Default video sink : %s\n", + gst_gconf_get_string ("default/videosink")); + printf ("Default audio sink : %s\n", + gst_gconf_get_string ("default/audiosink")); +}