mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 09:04:15 +00:00
pad: move query convenience functions together
Move the caps convenience functions to the other query functions.
This commit is contained in:
parent
e85198bc32
commit
f746174c10
5 changed files with 162 additions and 161 deletions
|
@ -1589,14 +1589,12 @@ gst_pad_unlink
|
||||||
gst_pad_is_linked
|
gst_pad_is_linked
|
||||||
gst_pad_can_link
|
gst_pad_can_link
|
||||||
|
|
||||||
gst_pad_query_caps
|
|
||||||
gst_pad_get_allowed_caps
|
gst_pad_get_allowed_caps
|
||||||
gst_pad_get_current_caps
|
gst_pad_get_current_caps
|
||||||
gst_pad_get_pad_template_caps
|
gst_pad_get_pad_template_caps
|
||||||
gst_pad_set_caps
|
gst_pad_set_caps
|
||||||
|
|
||||||
gst_pad_get_peer
|
gst_pad_get_peer
|
||||||
gst_pad_peer_query_caps
|
|
||||||
gst_pad_use_fixed_caps
|
gst_pad_use_fixed_caps
|
||||||
gst_pad_has_current_caps
|
gst_pad_has_current_caps
|
||||||
|
|
||||||
|
@ -1638,13 +1636,9 @@ GstPadLinkFunction
|
||||||
gst_pad_set_unlink_function
|
gst_pad_set_unlink_function
|
||||||
GstPadUnlinkFunction
|
GstPadUnlinkFunction
|
||||||
|
|
||||||
gst_pad_query_accept_caps
|
|
||||||
|
|
||||||
gst_pad_proxy_query_caps
|
gst_pad_proxy_query_caps
|
||||||
gst_pad_proxy_query_accept_caps
|
gst_pad_proxy_query_accept_caps
|
||||||
|
|
||||||
gst_pad_peer_query_accept_caps
|
|
||||||
|
|
||||||
gst_pad_set_activate_function
|
gst_pad_set_activate_function
|
||||||
GstPadActivateFunction
|
GstPadActivateFunction
|
||||||
|
|
||||||
|
@ -1666,13 +1660,21 @@ gst_pad_event_default
|
||||||
|
|
||||||
gst_pad_query
|
gst_pad_query
|
||||||
gst_pad_peer_query
|
gst_pad_peer_query
|
||||||
|
|
||||||
gst_pad_query_default
|
gst_pad_query_default
|
||||||
|
|
||||||
gst_pad_query_position
|
gst_pad_query_position
|
||||||
gst_pad_query_duration
|
gst_pad_query_duration
|
||||||
gst_pad_query_convert
|
gst_pad_query_convert
|
||||||
|
gst_pad_query_accept_caps
|
||||||
|
gst_pad_query_caps
|
||||||
|
|
||||||
gst_pad_peer_query_position
|
gst_pad_peer_query_position
|
||||||
gst_pad_peer_query_duration
|
gst_pad_peer_query_duration
|
||||||
gst_pad_peer_query_convert
|
gst_pad_peer_query_convert
|
||||||
|
gst_pad_peer_query_accept_caps
|
||||||
|
gst_pad_peer_query_caps
|
||||||
|
|
||||||
gst_pad_set_query_function
|
gst_pad_set_query_function
|
||||||
GstPadQueryFunction
|
GstPadQueryFunction
|
||||||
gst_pad_set_iterate_internal_links_function
|
gst_pad_set_iterate_internal_links_function
|
||||||
|
|
150
gst/gstpad.c
150
gst/gstpad.c
|
@ -2106,156 +2106,6 @@ gst_pad_get_current_caps (GstPad * pad)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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:
|
* gst_pad_set_caps:
|
||||||
* @pad: a #GstPad to set the capabilities of.
|
* @pad: a #GstPad to set the capabilities of.
|
||||||
|
|
|
@ -834,13 +834,8 @@ GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
|
||||||
/* capsnego function for linked/unlinked pads */
|
/* capsnego function for linked/unlinked pads */
|
||||||
GstCaps * gst_pad_get_current_caps (GstPad * pad);
|
GstCaps * gst_pad_get_current_caps (GstPad * pad);
|
||||||
gboolean gst_pad_has_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);
|
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 */
|
/* capsnego for linked pads */
|
||||||
GstCaps * gst_pad_get_allowed_caps (GstPad * pad);
|
GstCaps * gst_pad_get_allowed_caps (GstPad * pad);
|
||||||
|
|
||||||
|
|
149
gst/gstutils.c
149
gst/gstutils.c
|
@ -3038,6 +3038,155 @@ gst_pad_peer_query_convert (GstPad * pad, GstFormat src_format, gint64 src_val,
|
||||||
return ret;
|
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 *
|
static GstPad *
|
||||||
element_find_unlinked_pad (GstElement * element, GstPadDirection direction)
|
element_find_unlinked_pad (GstElement * element, GstPadDirection direction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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_duration (GstPad *pad, GstFormat format, gint64 *duration);
|
||||||
gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
|
gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
|
||||||
GstFormat dest_format, gint64 *dest_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_position (GstPad *pad, GstFormat format, gint64 *cur);
|
||||||
gboolean gst_pad_peer_query_duration (GstPad *pad, GstFormat format, gint64 *duration);
|
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,
|
gboolean gst_pad_peer_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
|
||||||
GstFormat dest_format, gint64 *dest_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 */
|
/* bin functions */
|
||||||
void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
|
void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
Loading…
Reference in a new issue