Add new TOC query

This commit is contained in:
Alexander Saprykin 2012-03-14 20:42:56 +04:00 committed by Stefan Sauer
parent af85bd8dbf
commit 105330784c
2 changed files with 101 additions and 1 deletions

View file

@ -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);
}

View file

@ -51,6 +51,8 @@ G_BEGIN_DECLS
* @GST_QUERY_CUSTOM: a custom application or element defined query. Since
* 0.10.22.
* @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
* @GST_QUERY_TOC: query the full table of contents (TOC) with the marker
* for an entry which can be used to extend received TOC. Since 0.10.37.
*
* Standard predefined Query types
*/
@ -69,7 +71,8 @@ typedef enum {
GST_QUERY_FORMATS,
GST_QUERY_BUFFERING,
GST_QUERY_CUSTOM,
GST_QUERY_URI
GST_QUERY_URI,
GST_QUERY_TOC
} GstQueryType;
/**
@ -336,6 +339,11 @@ GstQuery * gst_query_new_uri (void) G_GNUC_MALLOC;
void gst_query_parse_uri (GstQuery *query, gchar **uri);
void gst_query_set_uri (GstQuery *query, const gchar *uri);
/* TOC query */
GstQuery * gst_query_new_toc (void);
void gst_query_set_toc (GstQuery *query, GstToc *toc, const gchar *extend_uid);
void gst_query_parse_toc (GstQuery *query, GstToc **toc, gchar **extend_uid);
G_END_DECLS
#endif /* __GST_QUERY_H__ */