Commit 26019f6e authored by Thomas Vander Stichele's avatar Thomas Vander Stichele
Browse files

gconf stuff

Original commit message from CVS:
gconf stuff
parent 7f07809c
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
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)
/*
* 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
};
#ifndef GST_GCONF_H
#define GST_GCONF_H
/*
* this library handles interaction with GConf
*/
#include <gst/gst.h>
#include <gconf/gconf-client.h>
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 */
#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"));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment