diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 403c72f887..dba70f5522 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1712,6 +1712,7 @@ gst_object_unparent gst_object_default_deep_notify gst_object_default_error gst_object_check_uniqueness +gst_object_has_as_ancestor gst_object_has_ancestor gst_object_ref gst_object_unref diff --git a/gst/gstobject.c b/gst/gstobject.c index c24e435924..1f58c8d86f 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -807,7 +807,7 @@ gst_object_has_as_parent (GstObject * object, GstObject * parent) } /** - * gst_object_has_ancestor: + * gst_object_has_as_ancestor: * @object: a #GstObject to check * @ancestor: a #GstObject to check as ancestor * @@ -819,7 +819,7 @@ gst_object_has_as_parent (GstObject * object, GstObject * parent) * MT safe. Grabs and releases @object's locks. */ gboolean -gst_object_has_ancestor (GstObject * object, GstObject * ancestor) +gst_object_has_as_ancestor (GstObject * object, GstObject * ancestor) { GstObject *parent, *tmp; @@ -841,6 +841,32 @@ gst_object_has_ancestor (GstObject * object, GstObject * ancestor) return FALSE; } +/** + * gst_object_has_ancestor: + * @object: a #GstObject to check + * @ancestor: a #GstObject to check as ancestor + * + * Check if @object has an ancestor @ancestor somewhere up in + * the hierarchy. One can e.g. check if a #GstElement is inside a #GstPipeline. + * + * Returns: %TRUE if @ancestor is an ancestor of @object. + * + * Deprecated: Use gst_object_has_as_ancestor() instead. + * + * MT safe. Grabs and releases @object's locks. + */ +/* FIXME 2.0: remove */ +#ifndef GST_REMOVE_DEPRECATED +#ifdef GST_DISABLE_DEPRECATED +gboolean gst_object_has_ancestor (GstObject * object, GstObject * ancestor); +#endif +gboolean +gst_object_has_ancestor (GstObject * object, GstObject * ancestor) +{ + return gst_object_has_as_ancestor (object, ancestor); +} +#endif + /** * gst_object_check_uniqueness: * @list: (transfer none) (element-type Gst.Object): a list of #GstObject to diff --git a/gst/gstobject.h b/gst/gstobject.h index 6c41a69296..b478f3b64d 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -213,7 +213,10 @@ gboolean gst_object_set_parent (GstObject *object, GstObject *parent); GstObject* gst_object_get_parent (GstObject *object); void gst_object_unparent (GstObject *object); gboolean gst_object_has_as_parent (GstObject *object, GstObject *parent); +gboolean gst_object_has_as_ancestor (GstObject *object, GstObject *ancestor); +#ifndef GST_DISABLE_DEPRECATED gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor); +#endif void gst_object_default_deep_notify (GObject *object, GstObject *orig, GParamSpec *pspec, gchar **excluded_props); diff --git a/tests/check/gst/gstobject.c b/tests/check/gst/gstobject.c index e405566422..f88579d561 100644 --- a/tests/check/gst/gstobject.c +++ b/tests/check/gst/gstobject.c @@ -456,7 +456,7 @@ GST_START_TEST (test_fake_object_parentage_dispose) GST_END_TEST; -GST_START_TEST (test_fake_object_has_ancestor) +GST_START_TEST (test_fake_object_has_as_ancestor) { GstObject *object1, *object2, *object3, *object4; gboolean result; @@ -490,40 +490,40 @@ GST_START_TEST (test_fake_object_has_ancestor) /* An object isn't its own parent, but it is its own ancestor */ fail_if (gst_object_has_as_parent (object1, object1)); - fail_unless (gst_object_has_ancestor (object1, object1)); + fail_unless (gst_object_has_as_ancestor (object1, object1)); fail_if (gst_object_has_as_parent (object4, object4)); - fail_unless (gst_object_has_ancestor (object4, object4)); + fail_unless (gst_object_has_as_ancestor (object4, object4)); /* direct parents */ fail_unless (gst_object_has_as_parent (object1, object3)); - fail_unless (gst_object_has_ancestor (object1, object3)); + fail_unless (gst_object_has_as_ancestor (object1, object3)); fail_unless (gst_object_has_as_parent (object2, object3)); - fail_unless (gst_object_has_ancestor (object2, object3)); + fail_unless (gst_object_has_as_ancestor (object2, object3)); fail_unless (gst_object_has_as_parent (object3, object4)); - fail_unless (gst_object_has_ancestor (object3, object4)); + fail_unless (gst_object_has_as_ancestor (object3, object4)); /* grandparents */ fail_if (gst_object_has_as_parent (object1, object4)); - fail_unless (gst_object_has_ancestor (object1, object4)); + fail_unless (gst_object_has_as_ancestor (object1, object4)); fail_if (gst_object_has_as_parent (object2, object4)); - fail_unless (gst_object_has_ancestor (object2, object4)); + fail_unless (gst_object_has_as_ancestor (object2, object4)); /* not ancestors */ fail_if (gst_object_has_as_parent (object1, object2)); - fail_if (gst_object_has_ancestor (object1, object2)); + fail_if (gst_object_has_as_ancestor (object1, object2)); fail_if (gst_object_has_as_parent (object3, object1)); - fail_if (gst_object_has_ancestor (object3, object1)); + fail_if (gst_object_has_as_ancestor (object3, object1)); fail_if (gst_object_has_as_parent (object4, object1)); - fail_if (gst_object_has_ancestor (object4, object1)); + fail_if (gst_object_has_as_ancestor (object4, object1)); fail_if (gst_object_has_as_parent (object4, object3)); - fail_if (gst_object_has_ancestor (object4, object3)); + fail_if (gst_object_has_as_ancestor (object4, object3)); /* unparent everything */ gst_object_unparent (object3); @@ -558,7 +558,7 @@ gst_object_suite (void) tcase_add_test (tc_chain, test_fake_object_parentage); tcase_add_test (tc_chain, test_fake_object_parentage_dispose); - tcase_add_test (tc_chain, test_fake_object_has_ancestor); + tcase_add_test (tc_chain, test_fake_object_has_as_ancestor); //tcase_add_checked_fixture (tc_chain, setup, teardown); return s; diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index fbccec0ad9..04df312a5a 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -781,6 +781,7 @@ EXPORTS gst_object_get_value_array gst_object_has_active_control_bindings gst_object_has_ancestor + gst_object_has_as_ancestor gst_object_has_as_parent gst_object_ref gst_object_ref_sink