From 978b7ace5210f2a6a3204fd22c5699a5b487aa07 Mon Sep 17 00:00:00 2001 From: Wonchul Lee Date: Fri, 2 Sep 2016 17:39:17 +0900 Subject: [PATCH] bin: Add setter and getter to suppress element flags Suppress-flags is for preventing propagation of child element's specific flag when it is added to the bin. https://bugzilla.gnome.org/show_bug.cgi?id=770627 --- gst/gstbin.c | 64 ++++++++++++++++++++++++++++++++++++++++--- gst/gstbin.h | 3 ++ win32/common/libgstreamer.def | 2 ++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/gst/gstbin.c b/gst/gstbin.c index e7218f8..b193be1 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -197,6 +197,7 @@ struct _GstBinPrivate gboolean posted_eos; gboolean posted_playing; + GstElementFlags suppressed_flags; }; typedef struct @@ -1206,23 +1207,25 @@ gst_bin_add_func (GstBin * bin, GstElement * element) goto had_parent; /* if we add a sink we become a sink */ - if (is_sink) { + if (is_sink && !(bin->priv->suppressed_flags & GST_ELEMENT_FLAG_SINK)) { GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin, "element \"%s\" was sink", elem_name); GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SINK); } - if (is_source) { + if (is_source && !(bin->priv->suppressed_flags & GST_ELEMENT_FLAG_SOURCE)) { GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin, "element \"%s\" was source", elem_name); GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SOURCE); } - if (provides_clock) { + if (provides_clock + && !(bin->priv->suppressed_flags & GST_ELEMENT_FLAG_PROVIDE_CLOCK)) { GST_DEBUG_OBJECT (bin, "element \"%s\" can provide a clock", elem_name); clock_message = gst_message_new_clock_provide (GST_OBJECT_CAST (element), NULL, TRUE); GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_PROVIDE_CLOCK); } - if (requires_clock) { + if (requires_clock + && !(bin->priv->suppressed_flags & GST_ELEMENT_FLAG_REQUIRE_CLOCK)) { GST_DEBUG_OBJECT (bin, "element \"%s\" requires a clock", elem_name); GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_REQUIRE_CLOCK); } @@ -1407,6 +1410,59 @@ had_parent: } } +/** + * gst_bin_set_suppressed_flags: + * @bin: a #GstBin + * @flags: the #GstElementFlags to suppress + * + * Suppress the given flags on the bin. #GstElementFlags of a + * child element are propagated when it is added to the bin. + * When suppressed flags are set, those specified flags will + * not be propagated to the bin. + * + * MT safe. + * + * Since: 1.10 + */ +void +gst_bin_set_suppressed_flags (GstBin * bin, GstElementFlags flags) +{ + g_return_if_fail (GST_IS_BIN (bin)); + + GST_OBJECT_LOCK (bin); + bin->priv->suppressed_flags = bin->priv->suppressed_flags | flags; + GST_OBJECT_UNLOCK (bin); + + GST_DEBUG_OBJECT (bin, "Set suppressed flags(0x%x) to bin '%s'", flags, + GST_ELEMENT_NAME (bin)); +} + +/** + * gst_bin_get_suppressed_flags: + * @bin: a #GstBin + * + * Return the suppressed flags of the bin. + * + * MT safe. + * + * Returns: the bin's suppressed #GstElementFlags. + * + * Since: 1.10 + */ +GstElementFlags +gst_bin_get_suppressed_flags (GstBin * bin) +{ + GstElementFlags res; + + g_return_val_if_fail (GST_IS_BIN (bin), 0); + + GST_OBJECT_LOCK (bin); + res = bin->priv->suppressed_flags; + GST_OBJECT_UNLOCK (bin); + + return res; +} + /* signal vfunc, will be called when a new element was added */ static void gst_bin_deep_element_added_func (GstBin * bin, GstBin * sub_bin, diff --git a/gst/gstbin.h b/gst/gstbin.h index 809bb79..04afa2d 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -208,6 +208,9 @@ GstIterator* gst_bin_iterate_all_by_interface (GstBin *bin, GType iface); /* latency */ gboolean gst_bin_recalculate_latency (GstBin * bin); +/* set and get suppressed flags */ +void gst_bin_set_suppressed_flags (GstBin * bin, GstElementFlags flags); +GstElementFlags gst_bin_get_suppressed_flags (GstBin * bin); #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBin, gst_object_unref) diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 9313d92..79fe904 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -98,6 +98,7 @@ EXPORTS gst_bin_get_by_interface gst_bin_get_by_name gst_bin_get_by_name_recurse_up + gst_bin_get_suppressed_flags gst_bin_get_type gst_bin_iterate_all_by_interface gst_bin_iterate_elements @@ -109,6 +110,7 @@ EXPORTS gst_bin_recalculate_latency gst_bin_remove gst_bin_remove_many + gst_bin_set_suppressed_flags gst_bin_sync_children_states gst_bitmask_get_type gst_buffer_add_meta -- 2.7.4