From: Younghwan Date: Fri, 26 Aug 2016 11:17:19 +0000 (+0900) Subject: add family-id to set unique value from API to plugin X-Git-Tag: accepted/tizen/3.0/ivi/20161011.044154~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b364ef62f77114bf2ab0b41492e6dafdc84bc956;p=platform%2Fupstream%2Fgstreamer.git add family-id to set unique value from API to plugin it will be helpful for debugging when multi-instances are created Change-Id: I7bd65817a2b31146bb3a6c3104b125f7a494a3f6 --- diff --git a/gst/gstbin.c b/gst/gstbin.c index 87eac49..9c9b689 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1297,9 +1297,19 @@ gst_bin_add (GstBin * bin, GstElement * element) if (G_UNLIKELY (bclass->add_element == NULL)) goto no_function; +#ifndef GST_TIZEN_TV GST_CAT_DEBUG (GST_CAT_PARENTAGE, "adding element %s to bin %s", GST_STR_NULL (GST_ELEMENT_NAME (element)), GST_STR_NULL (GST_ELEMENT_NAME (bin))); +#else + gst_set_family_id_to_child (element, (GST_OBJECT_CAST (bin)->family_id)); + + GST_CAT_DEBUG (GST_CAT_PARENTAGE, + "adding element %s (id %d) to bin %s (id %d)", + GST_STR_NULL (GST_ELEMENT_NAME (element)), + GST_OBJECT_CAST (element)->family_id, + GST_STR_NULL (GST_ELEMENT_NAME (bin)), GST_OBJECT_CAST (bin)->family_id); +#endif result = bclass->add_element (bin, element); diff --git a/gst/gstelement.c b/gst/gstelement.c index ccb3734..d731cfc 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -639,6 +639,11 @@ gst_element_add_pad (GstElement * element, GstPad * pad) g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (GST_IS_PAD (pad), FALSE); +#ifdef GST_TIZEN_TV + g_object_set (G_OBJECT (pad), "family-id", + (int) (GST_OBJECT_CAST (element)->family_id), NULL); +#endif + /* locking pad to look at the name */ GST_OBJECT_LOCK (pad); pad_name = g_strdup (GST_PAD_NAME (pad)); diff --git a/gst/gstobject.c b/gst/gstobject.c index 1f58c8d..a1ea06c 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -120,6 +120,9 @@ enum PROP_0, PROP_NAME, PROP_PARENT, +#ifdef GST_TIZEN_TV + PROP_FAMILY_ID, +#endif PROP_LAST }; @@ -182,7 +185,12 @@ gst_object_class_init (GstObjectClass * klass) properties[PROP_PARENT] = g_param_spec_object ("parent", "Parent", "The parent of the object", GST_TYPE_OBJECT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - +#ifdef GST_TIZEN_TV + properties[PROP_FAMILY_ID] = + g_param_spec_int ("family-id", "Family Id", + "The family id of this object group, usually inherit from parent.", + -G_MAXINT, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); +#endif g_object_class_install_properties (gobject_class, PROP_LAST, properties); /** @@ -225,7 +233,9 @@ gst_object_init (GstObject * object) #endif object->flags = 0; - +#ifdef GST_TIZEN_TV + object->family_id = 0; +#endif object->control_rate = 100 * GST_MSECOND; object->last_sync = GST_CLOCK_TIME_NONE; } @@ -925,6 +935,11 @@ gst_object_set_property (GObject * object, guint prop_id, case PROP_PARENT: gst_object_set_parent (gstobject, g_value_get_object (value)); break; +#ifdef GST_TIZEN_TV + case PROP_FAMILY_ID: + g_atomic_int_set (&gstobject->family_id, g_value_get_int (value)); + break; +#endif default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -946,6 +961,11 @@ gst_object_get_property (GObject * object, guint prop_id, case PROP_PARENT: g_value_take_object (value, gst_object_get_parent (gstobject)); break; +#ifdef GST_TIZEN_TV + case PROP_FAMILY_ID: + g_value_set_int (value, g_atomic_int_get (&gstobject->family_id)); + break; +#endif default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gst/gstobject.h b/gst/gstobject.h index b478f3b..0b91ae5 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -169,6 +169,9 @@ struct _GstObject { gchar *name; /* object name */ GstObject *parent; /* this object's parent, weak ref */ guint32 flags; +#ifdef GST_TIZEN_TV + gint family_id; /* inherit the parent's id */ +#endif /*< private >*/ GList *control_bindings; /* List of GstControlBinding */ diff --git a/gst/gstutils.c b/gst/gstutils.c index f01c044..e8695a7 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -4019,4 +4019,41 @@ gst_element_query_resource (GstElement * element, GList ** resource_list) gst_query_unref (query); return TRUE; } + +static void +set_family_id (const GValue * item, gpointer user_data) +{ + gpointer object = g_value_get_object (item); + if (GST_IS_PAD (object)) { + GstPad *pad = GST_PAD_CAST (object); + g_object_set (G_OBJECT (pad), "family-id", (int) user_data, NULL); + } else if (GST_IS_ELEMENT (object)) { + gst_set_family_id_to_child (GST_ELEMENT_CAST (object), (int) user_data); + } + return; +} + +void +gst_set_family_id_to_child (GstElement * child, int id) +{ + GstIterator *it; + if (!GST_IS_ELEMENT (child)) + return; + g_object_set (G_OBJECT (child), "family-id", id, NULL); + it = gst_element_iterate_pads (child); + gst_iterator_foreach (it, (GstIteratorForeachFunction) set_family_id, + (gpointer) id); + gst_iterator_free (it); + it = NULL; + + if (!GST_IS_BIN (child)) + return; + it = gst_bin_iterate_recurse (GST_BIN (child)); + gst_iterator_foreach (it, (GstIteratorForeachFunction) set_family_id, + (gpointer) id); + gst_iterator_free (it); + it = NULL; + return; +} + #endif diff --git a/gst/gstutils.h b/gst/gstutils.h index 7d0bbd7..1af6e68 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -1034,7 +1034,9 @@ gboolean gst_util_fraction_add (gint a_n, gint a_d, gint b_n, g gint *res_n, gint *res_d); gint gst_util_fraction_compare (gint a_n, gint a_d, gint b_n, gint b_d); - +#ifdef GST_TIZEN_TV +void gst_set_family_id_to_child (GstElement* child, int id); +#endif G_END_DECLS #endif /* __GST_UTILS_H__ */