Commit 978b7ace authored by Wonchul Lee's avatar Wonchul Lee Committed by Thiago Sousa Santos

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
parent 7912f37e
......@@ -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,
......
......@@ -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)
......
......@@ -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
......
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