summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/gstcompat.h2
-rw-r--r--gst/gstghostpad.c2
-rw-r--r--gst/gstpad.c94
-rw-r--r--gst/gstpad.h2
-rw-r--r--gst/gstutils.c8
-rw-r--r--libs/gst/base/gstbasesrc.c4
-rw-r--r--libs/gst/base/gstbasetransform.c11
-rw-r--r--tests/check/gst/gstpad.c28
8 files changed, 25 insertions, 126 deletions
diff --git a/gst/gstcompat.h b/gst/gstcompat.h
index d1877d55af..07f5cc23e6 100644
--- a/gst/gstcompat.h
+++ b/gst/gstcompat.h
@@ -44,6 +44,8 @@ G_BEGIN_DECLS
#define gst_element_factory_get_documentation_uri(f) gst_element_factory_get_metadata(f, GST_ELEMENT_METADATA_DOC_URI)
#define gst_element_factory_get_icon_name(f) gst_element_factory_get_metadata(f, GST_ELEMENT_METADATA_ICON_NAME)
+#define gst_pad_get_caps_reffed(p) gst_pad_get_caps(p)
+#define gst_pad_peer_get_caps_reffed(p) gst_pad_peer_get_caps(p)
#ifndef GST_DISABLE_DEPRECATED
diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c
index 83d468cf10..ba3857069a 100644
--- a/gst/gstghostpad.c
+++ b/gst/gstghostpad.c
@@ -200,7 +200,7 @@ gst_proxy_pad_do_getcaps (GstPad * pad)
if (target) {
/* if we have a real target, proxy the call */
- res = gst_pad_get_caps_reffed (target);
+ res = gst_pad_get_caps (target);
GST_DEBUG_OBJECT (pad, "get caps of target %s:%s : %" GST_PTR_FORMAT,
GST_DEBUG_PAD_NAME (target), res);
diff --git a/gst/gstpad.c b/gst/gstpad.c
index 61f4f1d9a2..cbf4e48dc1 100644
--- a/gst/gstpad.c
+++ b/gst/gstpad.c
@@ -2210,38 +2210,6 @@ done:
return result;
}
-/* FIXME-0.11: what about making this the default and using
- * gst_caps_make_writable() explicitely where needed
- */
-/**
- * gst_pad_get_caps_reffed:
- * @pad: a #GstPad to get the capabilities of.
- *
- * Gets the capabilities this pad can produce or consume. Preferred function if
- * one only wants to read or intersect the caps.
- *
- * Returns: the caps of the pad with incremented ref-count.
- *
- * Since: 0.10.26
- */
-GstCaps *
-gst_pad_get_caps_reffed (GstPad * pad)
-{
- GstCaps *result = NULL;
-
- g_return_val_if_fail (GST_IS_PAD (pad), NULL);
-
- GST_OBJECT_LOCK (pad);
-
- GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
-
- result = gst_pad_get_caps_unlocked (pad);
-
- GST_OBJECT_UNLOCK (pad);
-
- return result;
-}
-
/**
* gst_pad_get_caps:
* @pad: a #GstPad to get the capabilities of.
@@ -2253,78 +2221,38 @@ gst_pad_get_caps_reffed (GstPad * pad)
* the pad's get_caps function;
* this returns the pad template caps if not explicitly set.
*
- * Returns: a newly allocated copy of the #GstCaps of this pad.
- *
- * MT safe.
- */
-GstCaps *
-gst_pad_get_caps (GstPad * pad)
-{
- GstCaps *result = gst_pad_get_caps_reffed (pad);
-
- /* be sure that we have a copy */
- if (G_LIKELY (result))
- result = gst_caps_make_writable (result);
-
- return result;
-}
-
-/* FIXME-0.11: what about making this the default and using
- * gst_caps_make_writable() explicitely where needed
- */
-/**
- * gst_pad_peer_get_caps_reffed:
- * @pad: a #GstPad to get the capabilities of.
- *
- * Gets the capabilities of the peer connected to this pad. Preferred function
- * if one only wants to read or intersect the caps.
+ * Note that this function does not return writable #GstCaps, use
+ * gst_caps_make_writable() before modifying the caps.
*
* Returns: the caps of the pad with incremented ref-count.
- *
- * Since: 0.10.26
*/
GstCaps *
-gst_pad_peer_get_caps_reffed (GstPad * pad)
+gst_pad_get_caps (GstPad * pad)
{
- GstPad *peerpad;
GstCaps *result = NULL;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
GST_OBJECT_LOCK (pad);
- GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get peer caps");
+ GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
- peerpad = GST_PAD_PEER (pad);
- if (G_UNLIKELY (peerpad == NULL))
- goto no_peer;
+ result = gst_pad_get_caps_unlocked (pad);
- gst_object_ref (peerpad);
GST_OBJECT_UNLOCK (pad);
- result = gst_pad_get_caps_reffed (peerpad);
-
- gst_object_unref (peerpad);
-
return result;
-
-no_peer:
- {
- GST_OBJECT_UNLOCK (pad);
- return NULL;
- }
}
/**
* gst_pad_peer_get_caps:
- * @pad: a #GstPad to get the peer capabilities of.
+ * @pad: a #GstPad to get the capabilities of.
*
* Gets the capabilities of the peer connected to this pad. Similar to
* gst_pad_get_caps().
*
- * Returns: a newly allocated copy of the #GstCaps of the peer pad. Use
- * gst_caps_unref() to get rid of it. This function returns %NULL if there is
- * no peer pad.
+ * Returns: the caps of the peer pad with incremented ref-count. This function
+ * returns %NULL when there is no peer pad.
*/
GstCaps *
gst_pad_peer_get_caps (GstPad * pad)
@@ -2470,7 +2398,7 @@ gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
GST_DEBUG_OBJECT (pad, "caps %" GST_PTR_FORMAT, caps);
- allowed = gst_pad_get_caps_reffed (pad);
+ allowed = gst_pad_get_caps (pad);
if (!allowed)
goto nothing_allowed;
@@ -2810,9 +2738,9 @@ gst_pad_get_allowed_caps (GstPad * pad)
gst_object_ref (peer);
GST_OBJECT_UNLOCK (pad);
- mycaps = gst_pad_get_caps_reffed (pad);
+ mycaps = gst_pad_get_caps (pad);
- peercaps = gst_pad_get_caps_reffed (peer);
+ peercaps = gst_pad_get_caps (peer);
gst_object_unref (peer);
caps = gst_caps_intersect (mycaps, peercaps);
diff --git a/gst/gstpad.h b/gst/gstpad.h
index 3e6e233953..e9e67b9479 100644
--- a/gst/gstpad.h
+++ b/gst/gstpad.h
@@ -900,13 +900,11 @@ void gst_pad_set_setcaps_function (GstPad *pad, GstPadSetCapsFunction setcaps
G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
/* capsnego function for linked/unlinked pads */
-GstCaps * gst_pad_get_caps_reffed (GstPad * pad);
GstCaps * gst_pad_get_caps (GstPad * pad);
void gst_pad_fixate_caps (GstPad * pad, GstCaps *caps);
gboolean gst_pad_accept_caps (GstPad * pad, GstCaps *caps);
gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps);
-GstCaps * gst_pad_peer_get_caps_reffed (GstPad * pad);
GstCaps * gst_pad_peer_get_caps (GstPad * pad);
gboolean gst_pad_peer_accept_caps (GstPad * pad, GstCaps *caps);
diff --git a/gst/gstutils.c b/gst/gstutils.c
index 7d75e9305c..f8895d2939 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -1148,7 +1148,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
gboolean compatible;
/* Now check if the two pads' caps are compatible */
- temp = gst_pad_get_caps_reffed (pad);
+ temp = gst_pad_get_caps (pad);
if (caps) {
intersection = gst_caps_intersect (temp, caps);
gst_caps_unref (temp);
@@ -1156,7 +1156,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
intersection = temp;
}
- temp = gst_pad_get_caps_reffed (current);
+ temp = gst_pad_get_caps (current);
compatible = gst_caps_can_intersect (temp, intersection);
gst_caps_unref (temp);
gst_caps_unref (intersection);
@@ -1202,7 +1202,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
/* try to create a new one */
/* requesting is a little crazy, we need a template. Let's create one */
/* FIXME: why not gst_pad_get_pad_template (pad); */
- templcaps = gst_pad_get_caps_reffed (pad);
+ templcaps = gst_pad_get_caps (pad);
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
@@ -2680,7 +2680,7 @@ getcaps_fold_func (GstPad * pad, GValue * ret, GstPad * orig)
GstCaps *peercaps, *existing;
existing = g_value_get_pointer (ret);
- peercaps = gst_pad_peer_get_caps_reffed (pad);
+ peercaps = gst_pad_peer_get_caps (pad);
if (G_LIKELY (peercaps)) {
GstCaps *intersection = gst_caps_intersect (existing, peercaps);
diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c
index 649a07c9df..9768f56447 100644
--- a/libs/gst/base/gstbasesrc.c
+++ b/libs/gst/base/gstbasesrc.c
@@ -2589,7 +2589,7 @@ gst_base_src_default_negotiate (GstBaseSrc * basesrc)
gboolean result = FALSE;
/* first see what is possible on our source pad */
- thiscaps = gst_pad_get_caps_reffed (GST_BASE_SRC_PAD (basesrc));
+ thiscaps = gst_pad_get_caps (GST_BASE_SRC_PAD (basesrc));
GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps);
/* nothing or anything is allowed, we're done */
if (thiscaps == NULL || gst_caps_is_any (thiscaps))
@@ -2599,7 +2599,7 @@ gst_base_src_default_negotiate (GstBaseSrc * basesrc)
goto no_caps;
/* get the peer caps */
- peercaps = gst_pad_peer_get_caps_reffed (GST_BASE_SRC_PAD (basesrc));
+ peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
if (peercaps) {
/* get intersection */
diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 62731c5c4c..ba02627669 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -639,7 +639,7 @@ gst_base_transform_getcaps (GstPad * pad)
otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
/* we can do what the peer can */
- caps = gst_pad_peer_get_caps_reffed (otherpad);
+ caps = gst_pad_peer_get_caps (otherpad);
if (caps) {
GstCaps *temp;
const GstCaps *templ;
@@ -888,7 +888,7 @@ gst_base_transform_find_transform (GstBaseTransform * trans, GstPad * pad,
GST_DEBUG_OBJECT (trans, "othercaps now %" GST_PTR_FORMAT, othercaps);
- peercaps = gst_pad_get_caps_reffed (otherpeer);
+ peercaps = gst_pad_get_caps (otherpeer);
intersect = gst_caps_intersect (peercaps, othercaps);
gst_caps_unref (peercaps);
gst_caps_unref (othercaps);
@@ -1029,9 +1029,9 @@ gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
/* get all the formats we can handle on this pad */
if (direction == GST_PAD_SRC)
- allowed = gst_pad_get_caps_reffed (trans->srcpad);
+ allowed = gst_pad_get_caps (trans->srcpad);
else
- allowed = gst_pad_get_caps_reffed (trans->sinkpad);
+ allowed = gst_pad_get_caps (trans->sinkpad);
if (!allowed) {
GST_DEBUG_OBJECT (trans, "gst_pad_get_caps() failed");
@@ -1736,8 +1736,7 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
GST_DEBUG_OBJECT (trans, "Suggested caps is not fixed: %"
GST_PTR_FORMAT, sink_suggest);
- peercaps =
- gst_pad_peer_get_caps_reffed (GST_BASE_TRANSFORM_SINK_PAD (trans));
+ peercaps = gst_pad_peer_get_caps (GST_BASE_TRANSFORM_SINK_PAD (trans));
/* try fixating by intersecting with peer caps */
if (peercaps) {
GstCaps *intersect;
diff --git a/tests/check/gst/gstpad.c b/tests/check/gst/gstpad.c
index 74bfd59751..e07c18e218 100644
--- a/tests/check/gst/gstpad.c
+++ b/tests/check/gst/gstpad.c
@@ -651,33 +651,6 @@ GST_START_TEST (test_sink_unref_unlink)
GST_END_TEST;
-/* gst_pad_get_caps should return a copy of the caps */
-GST_START_TEST (test_get_caps_must_be_copy)
-{
- GstPad *pad;
- GstCaps *caps;
- GstPadTemplate *templ;
-
- caps = gst_caps_new_any ();
- templ =
- gst_pad_template_new ("test_templ", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
-
- pad = gst_pad_new_from_template (templ, NULL);
- fail_unless (GST_PAD_CAPS (pad) == NULL, "caps present on pad");
- /* This is a writable copy ! */
- caps = gst_pad_get_caps (pad);
-
- /* we must own the caps */
- ASSERT_OBJECT_REFCOUNT (caps, "caps", 1);
-
- /* cleanup */
- gst_object_unref (templ);
- gst_caps_unref (caps);
- gst_object_unref (pad);
-}
-
-GST_END_TEST;
-
static void
unblock_async_cb (GstPad * pad, gboolean blocked, gpointer user_data)
{
@@ -989,7 +962,6 @@ gst_pad_suite (void)
tcase_add_test (tc_chain, test_push_negotiation);
tcase_add_test (tc_chain, test_src_unref_unlink);
tcase_add_test (tc_chain, test_sink_unref_unlink);
- tcase_add_test (tc_chain, test_get_caps_must_be_copy);
tcase_add_test (tc_chain, test_block_async);
#if 0
tcase_add_test (tc_chain, test_block_async_replace_callback);