summaryrefslogtreecommitdiff
path: root/gst/gstquery.c
diff options
context:
space:
mode:
authorAlexander Saprykin <xelfium@gmail.com>2012-03-14 20:42:56 +0400
committerStefan Sauer <ensonic@users.sf.net>2012-04-02 10:49:38 +0200
commit105330784c357df741152b0d10e466216bf359e4 (patch)
treec501f43675dee04f5a364ddd0f377ec48beada76 /gst/gstquery.c
parentaf85bd8dbf8816b1c2be23450bd064e857ad1b0e (diff)
downloadgstreamer-105330784c357df741152b0d10e466216bf359e4.tar.gz
Add new TOC query
Diffstat (limited to 'gst/gstquery.c')
-rw-r--r--gst/gstquery.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/gst/gstquery.c b/gst/gstquery.c
index d9c48f8b91..53b4cf9571 100644
--- a/gst/gstquery.c
+++ b/gst/gstquery.c
@@ -101,6 +101,7 @@ static GstQueryTypeDefinition standard_definitions[] = {
{GST_QUERY_BUFFERING, "buffering", "Buffering status", 0},
{GST_QUERY_CUSTOM, "custom", "Custom query", 0},
{GST_QUERY_URI, "uri", "URI of the source or sink", 0},
+ {GST_QUERY_TOC, "toc", "Full table of contents", 0},
{GST_QUERY_NONE, NULL, NULL, 0}
};
@@ -1495,3 +1496,94 @@ gst_query_parse_uri (GstQuery * query, gchar ** uri)
*uri = g_value_dup_string (gst_structure_id_get_value (query->structure,
GST_QUARK (URI)));
}
+
+/**
+ * gst_query_new_toc:
+ *
+ * Constructs a new query TOC query object. Use gst_query_unref()
+ * when done with it. A TOC query is used to query the full TOC with
+ * the UID marker for TOC extending (to insert some new entries).
+ *
+ * Returns: A #GstQuery.
+ *
+ * Since: 0.10.37
+ */
+GstQuery *
+gst_query_new_toc (void)
+{
+ GstQuery *query;
+
+ query = gst_query_new (GST_QUERY_TOC, NULL);
+
+ return query;
+}
+
+/**
+ * gst_query_set_toc:
+ * @query: a #GstQuery with query type GST_QUERY_TOC.
+ * @toc: the GstToc to set.
+ * @extend_uid: UID which can be used for TOC extending (may be NULL),
+ * 0 means root TOC level.
+ *
+ * Answer a TOC query by setting appropriate #GstToc structure.
+ *
+ * Since: 0.10.37
+ */
+void
+gst_query_set_toc (GstQuery * query, GstToc * toc, const gchar * extend_uid)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (query != NULL);
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC);
+ g_return_if_fail (toc != NULL);
+
+ structure = _gst_toc_to_structure (toc);
+
+ g_return_if_fail (structure != NULL);
+
+ /* that shouldn't be happen in normal usage */
+ if (query->structure != NULL)
+ gst_structure_free (query->structure);
+
+ if (extend_uid != NULL)
+ _gst_toc_structure_set_extend_uid (structure, extend_uid);
+
+ query->structure = structure;
+ gst_structure_set_parent_refcount (query->structure,
+ &(query->mini_object.refcount));
+}
+
+/**
+ * gst_query_parse_toc:
+ * @query: a #GstQuery.
+ * @toc: (out): the storage for the received TOC (may be NULL).
+ * @extend_uid: (out): the storage for the received extend UID marker (may be NULL),
+ * 0 means root TOC level.
+ *
+ * Parse a TOC query, writing the TOC into @toc as a newly
+ * allocated #GstToc and extend UID into @extend_uid, if the respective parameters
+ * are non-NULL. Use @extend_uid value to insert new entries into the TOC (@extend_uid will
+ * act as root entry for newly inserted entries).
+ * Free @toc with gst_toc_free() and @extend_uid with g_free() after usage.
+ *
+ * Since: 0.10.37
+ */
+void
+gst_query_parse_toc (GstQuery * query, GstToc ** toc, gchar ** extend_uid)
+{
+ const GstStructure *structure;
+
+ g_return_if_fail (query != NULL);
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC);
+
+ structure = gst_query_get_structure (query);
+
+ g_return_if_fail (structure != NULL);
+
+ if (toc != NULL)
+ *toc = _gst_toc_from_structure (structure);
+
+ if (extend_uid != NULL)
+ *extend_uid = _gst_toc_structure_get_extend_uid (structure);
+}