query: add caps query

This commit is contained in:
Wim Taymans 2011-11-14 11:26:17 +01:00
parent 32e7c5d1ef
commit d162d97e1f
4 changed files with 73 additions and 3 deletions

View file

@ -55,7 +55,7 @@ static const gchar *_quark_strings[] = {
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
"random-access", "sequential", "allocator", "GstEventFlushStop", "options",
"GstQueryAcceptCaps", "result"
"GstQueryAcceptCaps", "result", "GstQueryCaps"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -157,8 +157,9 @@ typedef enum _GstQuarkId
GST_QUARK_OPTIONS = 128,
GST_QUARK_QUERY_ACCEPT_CAPS = 129,
GST_QUARK_RESULT = 130,
GST_QUARK_QUERY_CAPS = 131,
GST_QUARK_MAX = 131
GST_QUARK_MAX = 132
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -106,6 +106,7 @@ static GstQueryTypeDefinition standard_definitions[] = {
{GST_QUERY_ALLOCATION, "allocation", "Allocation properties", 0},
{GST_QUERY_SCHEDULING, "scheduling", "Scheduling properties", 0},
{GST_QUERY_ACCEPT_CAPS, "accept-caps", "Accept caps", 0},
{GST_QUERY_CAPS, "caps", "Caps", 0},
{GST_QUERY_NONE, NULL, NULL, 0}
};
@ -2072,3 +2073,64 @@ gst_query_parse_accept_caps_result (GstQuery * query, gboolean * result)
gst_structure_id_get (structure,
GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
}
/**
* gst_query_new_caps
*
* Constructs a new query object for querying the caps.
*
* Free-function: gst_query_unref
*
* Returns: (transfer full): a new #GstQuery
*/
GstQuery *
gst_query_new_caps (void)
{
GstQuery *query;
GstStructure *structure;
structure = gst_structure_new_id (GST_QUARK (QUERY_CAPS),
GST_QUARK (CAPS), GST_TYPE_CAPS, NULL, NULL);
query = gst_query_new (GST_QUERY_CAPS, structure);
return query;
}
/**
* gst_query_set_caps:
* @query: The query to use
* @caps: (in): A pointer to the caps
*
* Set the @caps in @query.
*/
void
gst_query_set_caps (GstQuery * query, GstCaps * caps)
{
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
g_return_if_fail (gst_query_is_writable (query));
structure = GST_QUERY_STRUCTURE (query);
gst_structure_id_set (structure, GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL);
}
/**
* gst_query_parse_caps:
* @query: The query to parse
* @caps: (out): A pointer to the caps
*
* Get the caps from @query. The caps remains valid as long as @query remains
* valid.
*/
void
gst_query_parse_caps (GstQuery * query, GstCaps ** caps)
{
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
structure = GST_QUERY_STRUCTURE (query);
*caps = g_value_get_boxed (gst_structure_id_get_value (structure,
GST_QUARK (CAPS)));
}

View file

@ -56,6 +56,7 @@ G_BEGIN_DECLS
* @GST_QUERY_ALLOCATION: the buffer allocation properties
* @GST_QUERY_SCHEDULING: the scheduling properties
* @GST_QUERY_ACCEPT_CAPS: the accept caps query
* @GST_QUERY_CAPS: the caps query
*
* Standard predefined Query types
*/
@ -77,7 +78,8 @@ typedef enum {
GST_QUERY_URI,
GST_QUERY_ALLOCATION,
GST_QUERY_SCHEDULING,
GST_QUERY_ACCEPT_CAPS
GST_QUERY_ACCEPT_CAPS,
GST_QUERY_CAPS
} GstQueryType;
/**
@ -386,6 +388,11 @@ void gst_query_parse_accept_caps (GstQuery *query, GstCaps **c
void gst_query_set_accept_caps_result (GstQuery *query, gboolean result);
void gst_query_parse_accept_caps_result (GstQuery *query, gboolean *result);
/* caps query */
GstQuery * gst_query_new_caps (void);
void gst_query_set_caps (GstQuery *query, GstCaps *caps);
void gst_query_parse_caps (GstQuery *query, GstCaps **caps);
G_END_DECLS
#endif /* __GST_QUERY_H__ */