diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2002-07-12 09:41:25 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2002-07-12 09:41:25 +0000 |
commit | e7639958768f4ca9c6c8902a3586983e5beb35f0 (patch) | |
tree | 4c34effff09b7364e4351fd9f4562c3cd9d14541 | |
parent | 9b61acff595c6bc688b10c1f49dd69b1ff045cf2 (diff) | |
download | gst-plugins-bad-e7639958768f4ca9c6c8902a3586983e5beb35f0.tar.gz gst-plugins-bad-e7639958768f4ca9c6c8902a3586983e5beb35f0.tar.bz2 gst-plugins-bad-e7639958768f4ca9c6c8902a3586983e5beb35f0.zip |
api changes and render/ghost functions
Original commit message from CVS:
api changes and render/ghost functions
-rw-r--r-- | gst-libs/gst/gconf/Makefile.am | 2 | ||||
-rw-r--r-- | gst-libs/gst/gconf/gconf.c | 84 | ||||
-rw-r--r-- | gst-libs/gst/gconf/gconf.h | 4 |
3 files changed, 74 insertions, 16 deletions
diff --git a/gst-libs/gst/gconf/Makefile.am b/gst-libs/gst/gconf/Makefile.am index 0514c53c..63641bde 100644 --- a/gst-libs/gst/gconf/Makefile.am +++ b/gst-libs/gst/gconf/Makefile.am @@ -1,4 +1,4 @@ -librarydir = $(prefix)/lib/gst +librarydir = $(prefix)/lib library_LTLIBRARIES = libgstgconf.la diff --git a/gst-libs/gst/gconf/gconf.c b/gst-libs/gst/gconf/gconf.c index 64630398..60ad07c7 100644 --- a/gst-libs/gst/gconf/gconf.c +++ b/gst-libs/gst/gconf/gconf.c @@ -19,6 +19,44 @@ gst_gconf_get_client (void) return _gst_gconf_client; } +/* go through a bin, finding the one pad that is unconnected in the given + * * direction, and return that pad */ +GstPad * +gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction) +{ + GstPad *pad = NULL; + GList *elements = NULL; + GList *pads = NULL; + GstElement *element = NULL; + + g_print ("DEBUG: find_unconnected start\n"); + elements = (GList *) gst_bin_get_list (bin); + /* traverse all elements looking for unconnected pads */ + while (elements && pad == NULL) + { + element = GST_ELEMENT (elements->data); + g_print ("DEBUG: looking in element %s\n", gst_element_get_name (element)); + pads = gst_element_get_pad_list (element); + while (pads) + { + /* check if the direction matches */ + if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) + { + if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) + { + /* found it ! */ + g_print ("DEBUG: found an unconnected pad !\n"); + pad = GST_PAD (pads->data); + } + } + if (pad) break; /* found one already */ + pads = g_list_next (pads); + } + elements = g_list_next (elements); + } + g_print ("DEBUG: find_unconnected stop\n"); + return pad; +} /* external functions */ @@ -47,27 +85,47 @@ 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) +/* this function renders the given description to a bin, + * and ghosts at most one unconnected src pad and one unconnected sink pad */ +GstElement * +gst_gconf_render_bin_from_description (const gchar *description) { - GstElement *bin; - gchar *pipeline; + GstElement *bin = NULL; + GstPad *pad = NULL; 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)); + /* parse the pipeline */ + bin = GST_ELEMENT (gst_parse_launch (description, &error)); if (error) { g_print ("DEBUG: gstgconf: error parsing pipeline %s\n%s\n", - pipeline, error->message); + description, error->message); g_error_free (error); - return FALSE; + return NULL; } - *element = bin; - return TRUE; + + /* find pads and ghost them if necessary */ + if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SRC))) + gst_element_add_ghost_pad (bin, pad, "src"); + if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SINK))) + gst_element_add_ghost_pad (bin, pad, "sink"); + return bin; +} + +/* this function reads the gconf key, parses the pipeline bit to a bin, + * and ghosts at most one unconnected src pad and one unconnected sink pad */ +GstElement * +gst_gconf_render_bin_from_key (const gchar *key) +{ + GstElement *bin; + gchar *description; + gchar *value = NULL; + + value = gst_gconf_get_string (key); + description = g_strdup_printf ("bin.( %s )", value); + bin = gst_gconf_render_bin_from_description (description); + g_free (description); + return bin; } /* diff --git a/gst-libs/gst/gconf/gconf.h b/gst-libs/gst/gconf/gconf.h index 53678544..a054dc3e 100644 --- a/gst-libs/gst/gconf/gconf.h +++ b/gst-libs/gst/gconf/gconf.h @@ -12,8 +12,8 @@ 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); +GstElement * gst_gconf_render_bin_from_key (const gchar *key); +GstElement * gst_gconf_render_bin_from_description (const gchar *description); /* guint gst_gconf_notify_add (const gchar *key, |