summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-11-14 11:26:17 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2011-11-14 11:26:17 +0100
commitd162d97e1f9927cd71f64e4d80d95bc136bcf71a (patch)
tree1b32bc6cf2b64173835e5d6626d955a6f7fd6102
parent32e7c5d1ef22f55c3da51ed113636205a1056f07 (diff)
query: add caps query
-rw-r--r--gst/gstquark.c2
-rw-r--r--gst/gstquark.h3
-rw-r--r--gst/gstquery.c62
-rw-r--r--gst/gstquery.h9
4 files changed, 73 insertions, 3 deletions
diff --git a/gst/gstquark.c b/gst/gstquark.c
index ffb72dbb3..1b6dd38e5 100644
--- a/gst/gstquark.c
+++ b/gst/gstquark.c
@@ -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];
diff --git a/gst/gstquark.h b/gst/gstquark.h
index 430ba0746..0e3553fdf 100644
--- a/gst/gstquark.h
+++ b/gst/gstquark.h
@@ -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];
diff --git a/gst/gstquery.c b/gst/gstquery.c
index e08e6a51f..d2d66f911 100644
--- a/gst/gstquery.c
+++ b/gst/gstquery.c
@@ -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)));
+}
diff --git a/gst/gstquery.h b/gst/gstquery.h
index 253663759..2fc75ed70 100644
--- a/gst/gstquery.h
+++ b/gst/gstquery.h
@@ -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__ */