From f746174c1063b7200fb71d7e2fd76974897f066b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 15 Nov 2011 18:16:24 +0100 Subject: [PATCH] pad: move query convenience functions together Move the caps convenience functions to the other query functions. --- docs/gst/gstreamer-sections.txt | 14 ++-- gst/gstpad.c | 150 ---------------------------------------- gst/gstpad.h | 5 -- gst/gstutils.c | 149 +++++++++++++++++++++++++++++++++++++++ gst/gstutils.h | 5 ++ 5 files changed, 162 insertions(+), 161 deletions(-) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 8bfb90b..cfbdc65 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1589,14 +1589,12 @@ gst_pad_unlink gst_pad_is_linked gst_pad_can_link -gst_pad_query_caps gst_pad_get_allowed_caps gst_pad_get_current_caps gst_pad_get_pad_template_caps gst_pad_set_caps gst_pad_get_peer -gst_pad_peer_query_caps gst_pad_use_fixed_caps gst_pad_has_current_caps @@ -1638,13 +1636,9 @@ GstPadLinkFunction gst_pad_set_unlink_function GstPadUnlinkFunction -gst_pad_query_accept_caps - gst_pad_proxy_query_caps gst_pad_proxy_query_accept_caps -gst_pad_peer_query_accept_caps - gst_pad_set_activate_function GstPadActivateFunction @@ -1666,13 +1660,21 @@ gst_pad_event_default gst_pad_query gst_pad_peer_query + gst_pad_query_default + gst_pad_query_position gst_pad_query_duration gst_pad_query_convert +gst_pad_query_accept_caps +gst_pad_query_caps + gst_pad_peer_query_position gst_pad_peer_query_duration gst_pad_peer_query_convert +gst_pad_peer_query_accept_caps +gst_pad_peer_query_caps + gst_pad_set_query_function GstPadQueryFunction gst_pad_set_iterate_internal_links_function diff --git a/gst/gstpad.c b/gst/gstpad.c index 2a86ac3..ab187fc 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2107,156 +2107,6 @@ gst_pad_get_current_caps (GstPad * pad) } /** - * gst_pad_query_caps: - * @pad: a #GstPad to get the capabilities of. - * @filter: suggested #GstCaps. - * - * Gets the capabilities this pad can produce or consume. - * Note that this method doesn't necessarily return the caps set by - * gst_pad_set_caps() - use gst_pad_get_current_caps() for that instead. - * gst_pad_query_caps returns all possible caps a pad can operate with, using - * the pad's CAPS query function, If the query fails, this function will return - * @filter, if not #NULL, otherwise ANY. - * - * When called on sinkpads @filter contains the caps that - * upstream could produce in the order preferred by upstream. When - * called on srcpads @filter contains the caps accepted by - * downstream in the preffered order. @filter might be %NULL but - * if it is not %NULL the returned caps will be a subset of @filter. - * - * Note that this function does not return writable #GstCaps, use - * gst_caps_make_writable() before modifying the caps. - * - * Returns: (transfer full): the caps of the pad with incremented ref-count. - */ -GstCaps * -gst_pad_query_caps (GstPad * pad, GstCaps * filter) -{ - GstCaps *result = NULL; - GstQuery *query; - - g_return_val_if_fail (GST_IS_PAD (pad), NULL); - g_return_val_if_fail (filter == NULL || GST_IS_CAPS (filter), NULL); - - GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps"); - - query = gst_query_new_caps (filter); - if (gst_pad_query (pad, query)) { - gst_query_parse_caps_result (query, &result); - gst_caps_ref (result); - GST_DEBUG_OBJECT (pad, "query returned %" GST_PTR_FORMAT, result); - } else if (filter) { - result = gst_caps_ref (filter); - } else { - result = gst_caps_new_any (); - } - gst_query_unref (query); - - return result; -} - - -/** - * gst_pad_peer_query_caps: - * @pad: a #GstPad to get the capabilities of. - * @filter: a #GstCaps filter. - * - * Gets the capabilities of the peer connected to this pad. Similar to - * gst_pad_query_caps(). - * - * When called on srcpads @filter contains the caps that - * upstream could produce in the order preferred by upstream. When - * called on sinkpads @filter contains the caps accepted by - * downstream in the preffered order. @filter might be %NULL but - * if it is not %NULL the returned caps will be a subset of @filter. - * - * 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_query_caps (GstPad * pad, GstCaps * filter) -{ - GstCaps *result = NULL; - GstQuery *query; - - g_return_val_if_fail (GST_IS_PAD (pad), NULL); - g_return_val_if_fail (filter == NULL || GST_IS_CAPS (filter), NULL); - - query = gst_query_new_caps (filter); - if (gst_pad_peer_query (pad, query)) { - gst_query_parse_caps_result (query, &result); - gst_caps_ref (result); - GST_DEBUG_OBJECT (pad, "peer query returned %d", result); - } else if (filter) { - result = gst_caps_ref (filter); - } else { - result = gst_caps_new_any (); - } - gst_query_unref (query); - - return result; -} - -/** - * gst_pad_query_accept_caps: - * @pad: a #GstPad to check - * @caps: a #GstCaps to check on the pad - * - * Check if the given pad accepts the caps. - * - * Returns: TRUE if the pad can accept the caps. - */ -gboolean -gst_pad_query_accept_caps (GstPad * pad, GstCaps * caps) -{ - gboolean res = TRUE; - GstQuery *query; - - g_return_val_if_fail (GST_IS_PAD (pad), FALSE); - g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); - - GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "accept caps of %p", caps); - - query = gst_query_new_accept_caps (caps); - if (gst_pad_query (pad, query)) { - GST_DEBUG_OBJECT (pad, "query returned %d", res); - gst_query_parse_accept_caps_result (query, &res); - } - gst_query_unref (query); - - return res; -} - -/** - * gst_pad_peer_query_accept_caps: - * @pad: a #GstPad to check the peer of - * @caps: a #GstCaps to check on the pad - * - * Check if the peer of @pad accepts @caps. If @pad has no peer, this function - * returns TRUE. - * - * Returns: TRUE if the peer of @pad can accept the caps or @pad has no peer. - */ -gboolean -gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps * caps) -{ - gboolean res = TRUE; - GstQuery *query; - - g_return_val_if_fail (GST_IS_PAD (pad), FALSE); - g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); - - query = gst_query_new_accept_caps (caps); - if (gst_pad_peer_query (pad, query)) { - GST_DEBUG_OBJECT (pad, "query returned %d", res); - gst_query_parse_accept_caps_result (query, &res); - } - gst_query_unref (query); - - return res; -} - -/** * gst_pad_set_caps: * @pad: a #GstPad to set the capabilities of. * @caps: (transfer none): a #GstCaps to set. diff --git a/gst/gstpad.h b/gst/gstpad.h index ab9e5ab..f9bc1e7 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -834,13 +834,8 @@ GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); /* capsnego function for linked/unlinked pads */ GstCaps * gst_pad_get_current_caps (GstPad * pad); gboolean gst_pad_has_current_caps (GstPad * pad); -GstCaps * gst_pad_query_caps (GstPad * pad, GstCaps *filter); -gboolean gst_pad_query_accept_caps (GstPad * pad, GstCaps *caps); gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps); -GstCaps * gst_pad_peer_query_caps (GstPad * pad, GstCaps *filter); -gboolean gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps *caps); - /* capsnego for linked pads */ GstCaps * gst_pad_get_allowed_caps (GstPad * pad); diff --git a/gst/gstutils.c b/gst/gstutils.c index 0040672..1f0a2bb 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -3038,6 +3038,155 @@ gst_pad_peer_query_convert (GstPad * pad, GstFormat src_format, gint64 src_val, return ret; } +/** + * gst_pad_query_caps: + * @pad: a #GstPad to get the capabilities of. + * @filter: suggested #GstCaps. + * + * Gets the capabilities this pad can produce or consume. + * Note that this method doesn't necessarily return the caps set by + * gst_pad_set_caps() - use gst_pad_get_current_caps() for that instead. + * gst_pad_query_caps returns all possible caps a pad can operate with, using + * the pad's CAPS query function, If the query fails, this function will return + * @filter, if not #NULL, otherwise ANY. + * + * When called on sinkpads @filter contains the caps that + * upstream could produce in the order preferred by upstream. When + * called on srcpads @filter contains the caps accepted by + * downstream in the preffered order. @filter might be %NULL but + * if it is not %NULL the returned caps will be a subset of @filter. + * + * Note that this function does not return writable #GstCaps, use + * gst_caps_make_writable() before modifying the caps. + * + * Returns: (transfer full): the caps of the pad with incremented ref-count. + */ +GstCaps * +gst_pad_query_caps (GstPad * pad, GstCaps * filter) +{ + GstCaps *result = NULL; + GstQuery *query; + + g_return_val_if_fail (GST_IS_PAD (pad), NULL); + g_return_val_if_fail (filter == NULL || GST_IS_CAPS (filter), NULL); + + GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps"); + + query = gst_query_new_caps (filter); + if (gst_pad_query (pad, query)) { + gst_query_parse_caps_result (query, &result); + gst_caps_ref (result); + GST_DEBUG_OBJECT (pad, "query returned %" GST_PTR_FORMAT, result); + } else if (filter) { + result = gst_caps_ref (filter); + } else { + result = gst_caps_new_any (); + } + gst_query_unref (query); + + return result; +} + +/** + * gst_pad_peer_query_caps: + * @pad: a #GstPad to get the capabilities of. + * @filter: a #GstCaps filter. + * + * Gets the capabilities of the peer connected to this pad. Similar to + * gst_pad_query_caps(). + * + * When called on srcpads @filter contains the caps that + * upstream could produce in the order preferred by upstream. When + * called on sinkpads @filter contains the caps accepted by + * downstream in the preffered order. @filter might be %NULL but + * if it is not %NULL the returned caps will be a subset of @filter. + * + * 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_query_caps (GstPad * pad, GstCaps * filter) +{ + GstCaps *result = NULL; + GstQuery *query; + + g_return_val_if_fail (GST_IS_PAD (pad), NULL); + g_return_val_if_fail (filter == NULL || GST_IS_CAPS (filter), NULL); + + query = gst_query_new_caps (filter); + if (gst_pad_peer_query (pad, query)) { + gst_query_parse_caps_result (query, &result); + gst_caps_ref (result); + GST_DEBUG_OBJECT (pad, "peer query returned %d", result); + } else if (filter) { + result = gst_caps_ref (filter); + } else { + result = gst_caps_new_any (); + } + gst_query_unref (query); + + return result; +} + +/** + * gst_pad_query_accept_caps: + * @pad: a #GstPad to check + * @caps: a #GstCaps to check on the pad + * + * Check if the given pad accepts the caps. + * + * Returns: TRUE if the pad can accept the caps. + */ +gboolean +gst_pad_query_accept_caps (GstPad * pad, GstCaps * caps) +{ + gboolean res = TRUE; + GstQuery *query; + + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); + g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); + + GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "accept caps of %p", caps); + + query = gst_query_new_accept_caps (caps); + if (gst_pad_query (pad, query)) { + GST_DEBUG_OBJECT (pad, "query returned %d", res); + gst_query_parse_accept_caps_result (query, &res); + } + gst_query_unref (query); + + return res; +} + +/** + * gst_pad_peer_query_accept_caps: + * @pad: a #GstPad to check the peer of + * @caps: a #GstCaps to check on the pad + * + * Check if the peer of @pad accepts @caps. If @pad has no peer, this function + * returns TRUE. + * + * Returns: TRUE if the peer of @pad can accept the caps or @pad has no peer. + */ +gboolean +gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps * caps) +{ + gboolean res = TRUE; + GstQuery *query; + + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); + g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); + + query = gst_query_new_accept_caps (caps); + if (gst_pad_peer_query (pad, query)) { + GST_DEBUG_OBJECT (pad, "query returned %d", res); + gst_query_parse_accept_caps_result (query, &res); + } + gst_query_unref (query); + + return res; +} + static GstPad * element_find_unlinked_pad (GstElement * element, GstPadDirection direction) { diff --git a/gst/gstutils.h b/gst/gstutils.h index a3e0112..7bdc350 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -901,11 +901,16 @@ gboolean gst_pad_query_position (GstPad *pad, GstFormat gboolean gst_pad_query_duration (GstPad *pad, GstFormat format, gint64 *duration); gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val, GstFormat dest_format, gint64 *dest_val); +GstCaps * gst_pad_query_caps (GstPad *pad, GstCaps *filter); +gboolean gst_pad_query_accept_caps (GstPad *pad, GstCaps *caps); + gboolean gst_pad_peer_query_position (GstPad *pad, GstFormat format, gint64 *cur); gboolean gst_pad_peer_query_duration (GstPad *pad, GstFormat format, gint64 *duration); gboolean gst_pad_peer_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val, GstFormat dest_format, gint64 *dest_val); +GstCaps * gst_pad_peer_query_caps (GstPad * pad, GstCaps *filter); +gboolean gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps *caps); /* bin functions */ void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED; -- 2.7.4