#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
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);
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.
* 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)
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;
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);
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);
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);
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);
/* 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);
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);
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))
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 */
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;
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);
/* 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");
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;
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)
{
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);