gstreamer_core/gst/gstquery.c
changeset 0 0e761a78d257
child 7 567bb019e3e3
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
       
     3  *                    2000 Wim Taymans <wim.taymans@chello.be>
       
     4  *                    2005 Wim Taymans <wim@fluendo.com>
       
     5  *
       
     6  * gstquery.c: GstQueryType registration and Query parsing/creation
       
     7  *
       
     8  * This library is free software; you can redistribute it and/or
       
     9  * modify it under the terms of the GNU Library General Public
       
    10  * License as published by the Free Software Foundation; either
       
    11  * version 2 of the License, or (at your option) any later version.
       
    12  *
       
    13  * This library is distributed in the hope that it will be useful,
       
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16  * Library General Public License for more details.
       
    17  *
       
    18  * You should have received a copy of the GNU Library General Public
       
    19  * License along with this library; if not, write to the
       
    20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    21  * Boston, MA 02111-1307, USA.
       
    22  */
       
    23 
       
    24 /**
       
    25  * SECTION:gstquery
       
    26  * @short_description: Dynamically register new query types. Provide functions
       
    27  *                     to create queries, and to set and parse values in them.
       
    28  * @see_also: #GstPad, #GstElement
       
    29  *
       
    30  * GstQuery functions are used to register a new query types to the gstreamer
       
    31  * core.
       
    32  * Query types can be used to perform queries on pads and elements.
       
    33  *
       
    34  * Queries can be created using the gst_query_new_xxx() functions.  
       
    35  * Query values can be set using gst_query_set_xxx(), and parsed using 
       
    36  * gst_query_parse_xxx() helpers.
       
    37  *
       
    38  * The following example shows how to query the duration of a pipeline:
       
    39  * 
       
    40  * <example>
       
    41  *  <title>Query duration on a pipeline</title>
       
    42  *  <programlisting>
       
    43  *  GstQuery *query;
       
    44  *  gboolean res;
       
    45  *  query = gst_query_new_duration (GST_FORMAT_TIME);
       
    46  *  res = gst_element_query (pipeline, query);
       
    47  *  if (res) {
       
    48  *    gint64 duration;
       
    49  *    gst_query_parse_duration (query, NULL, &amp;duration);
       
    50  *    g_print ("duration = %"GST_TIME_FORMAT, GST_TIME_ARGS (duration));
       
    51  *  }
       
    52  *  else {
       
    53  *    g_print ("duration query failed...");
       
    54  *  }
       
    55  *  gst_query_unref (query);
       
    56  *  </programlisting>
       
    57  * </example>
       
    58  *
       
    59  * Last reviewed on 2006-02-14 (0.10.4)
       
    60  */
       
    61 
       
    62 #include "gst_private.h"
       
    63 #include "gstinfo.h"
       
    64 #include "gstquery.h"
       
    65 #include "gstvalue.h"
       
    66 #include "gstenumtypes.h"
       
    67 #include "gstquark.h"
       
    68 
       
    69 #ifdef __SYMBIAN32__
       
    70 #include <glib_global.h>
       
    71 #endif
       
    72 
       
    73 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
       
    74 #define GST_CAT_DEFAULT gst_query_debug
       
    75 
       
    76 static void gst_query_class_init (gpointer g_class, gpointer class_data);
       
    77 static void gst_query_finalize (GstQuery * query);
       
    78 static GstQuery *_gst_query_copy (GstQuery * query);
       
    79 
       
    80 static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
       
    81 static GList *_gst_queries = NULL;
       
    82 static GHashTable *_nick_to_query = NULL;
       
    83 static GHashTable *_query_type_to_nick = NULL;
       
    84 static guint32 _n_values = 1;   /* we start from 1 because 0 reserved for NONE */
       
    85 
       
    86 static GstMiniObjectClass *parent_class = NULL;
       
    87 
       
    88 static GstQueryTypeDefinition standard_definitions[] = {
       
    89   {GST_QUERY_POSITION, "position", "Current position", 0},
       
    90   {GST_QUERY_DURATION, "duration", "Total duration", 0},
       
    91   {GST_QUERY_LATENCY, "latency", "Latency", 0},
       
    92   {GST_QUERY_JITTER, "jitter", "Jitter", 0},
       
    93   {GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1", 0},
       
    94   {GST_QUERY_SEEKING, "seeking", "Seeking capabilities and parameters", 0},
       
    95   {GST_QUERY_SEGMENT, "segment", "currently configured segment", 0},
       
    96   {GST_QUERY_CONVERT, "convert", "Converting between formats", 0},
       
    97   {GST_QUERY_FORMATS, "formats", "Supported formats for conversion", 0},
       
    98   {0, NULL, NULL, 0}
       
    99 };
       
   100 #ifdef __SYMBIAN32__
       
   101 EXPORT_C
       
   102 #endif
       
   103 
       
   104 
       
   105 void
       
   106 _gst_query_initialize (void)
       
   107 {
       
   108   GstQueryTypeDefinition *standards = standard_definitions;
       
   109 
       
   110   GST_CAT_INFO (GST_CAT_GST_INIT, "init queries");
       
   111 
       
   112   GST_DEBUG_CATEGORY_INIT (gst_query_debug, "query", 0, "query system");
       
   113 
       
   114   g_static_mutex_lock (&mutex);
       
   115   if (_nick_to_query == NULL) {
       
   116     _nick_to_query = g_hash_table_new (g_str_hash, g_str_equal);
       
   117     _query_type_to_nick = g_hash_table_new (NULL, NULL);
       
   118   }
       
   119 
       
   120   while (standards->nick) {
       
   121     standards->quark = g_quark_from_static_string (standards->nick);
       
   122     g_hash_table_insert (_nick_to_query, standards->nick, standards);
       
   123     g_hash_table_insert (_query_type_to_nick,
       
   124         GINT_TO_POINTER (standards->value), standards);
       
   125 
       
   126     _gst_queries = g_list_append (_gst_queries, standards);
       
   127     standards++;
       
   128     _n_values++;
       
   129   }
       
   130   g_static_mutex_unlock (&mutex);
       
   131 
       
   132   g_type_class_ref (gst_query_get_type ());
       
   133 }
       
   134 
       
   135 /**
       
   136  * gst_query_type_get_name:
       
   137  * @query: the query type
       
   138  *
       
   139  * Get a printable name for the given query type. Do not modify or free.
       
   140  *
       
   141  * Returns: a reference to the static name of the query.
       
   142  */
       
   143 #ifdef __SYMBIAN32__
       
   144 EXPORT_C
       
   145 #endif
       
   146 
       
   147 const gchar *
       
   148 gst_query_type_get_name (GstQueryType query)
       
   149 {
       
   150   const GstQueryTypeDefinition *def;
       
   151 
       
   152   def = gst_query_type_get_details (query);
       
   153 
       
   154   return def->nick;
       
   155 }
       
   156 
       
   157 /**
       
   158  * gst_query_type_to_quark:
       
   159  * @query: the query type
       
   160  *
       
   161  * Get the unique quark for the given query type.
       
   162  *
       
   163  * Returns: the quark associated with the query type
       
   164  */
       
   165 #ifdef __SYMBIAN32__
       
   166 EXPORT_C
       
   167 #endif
       
   168 
       
   169 GQuark
       
   170 gst_query_type_to_quark (GstQueryType query)
       
   171 {
       
   172   const GstQueryTypeDefinition *def;
       
   173 
       
   174   def = gst_query_type_get_details (query);
       
   175 
       
   176   return def->quark;
       
   177 }
       
   178 #ifdef __SYMBIAN32__
       
   179 EXPORT_C
       
   180 #endif
       
   181 
       
   182 
       
   183 GType
       
   184 gst_query_get_type (void)
       
   185 {
       
   186   static GType _gst_query_type;
       
   187 
       
   188   if (G_UNLIKELY (_gst_query_type == 0)) {
       
   189     static const GTypeInfo query_info = {
       
   190       sizeof (GstQueryClass),
       
   191       NULL,
       
   192       NULL,
       
   193       gst_query_class_init,
       
   194       NULL,
       
   195       NULL,
       
   196       sizeof (GstQuery),
       
   197       0,
       
   198       NULL,
       
   199       NULL
       
   200     };
       
   201 
       
   202     _gst_query_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
       
   203         "GstQuery", &query_info, 0);
       
   204   }
       
   205   return _gst_query_type;
       
   206 }
       
   207 
       
   208 static void
       
   209 gst_query_class_init (gpointer g_class, gpointer class_data)
       
   210 {
       
   211   GstQueryClass *query_class = GST_QUERY_CLASS (g_class);
       
   212 
       
   213   parent_class = g_type_class_peek_parent (g_class);
       
   214 
       
   215   query_class->mini_object_class.copy =
       
   216       (GstMiniObjectCopyFunction) _gst_query_copy;
       
   217   query_class->mini_object_class.finalize =
       
   218       (GstMiniObjectFinalizeFunction) gst_query_finalize;
       
   219 
       
   220 }
       
   221 
       
   222 static void
       
   223 gst_query_finalize (GstQuery * query)
       
   224 {
       
   225   g_return_if_fail (query != NULL);
       
   226 
       
   227   if (query->structure) {
       
   228     gst_structure_set_parent_refcount (query->structure, NULL);
       
   229     gst_structure_free (query->structure);
       
   230   }
       
   231 
       
   232   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (query));
       
   233 }
       
   234 
       
   235 static GstQuery *
       
   236 _gst_query_copy (GstQuery * query)
       
   237 {
       
   238   GstQuery *copy;
       
   239 
       
   240   copy = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);
       
   241 
       
   242   copy->type = query->type;
       
   243 
       
   244   if (query->structure) {
       
   245     copy->structure = gst_structure_copy (query->structure);
       
   246     gst_structure_set_parent_refcount (copy->structure,
       
   247         &query->mini_object.refcount);
       
   248   }
       
   249 
       
   250   return copy;
       
   251 }
       
   252 
       
   253 
       
   254 
       
   255 /**
       
   256  * gst_query_type_register:
       
   257  * @nick: The nick of the new query
       
   258  * @description: The description of the new query
       
   259  *
       
   260  * Create a new GstQueryType based on the nick or return an
       
   261  * already registered query with that nick
       
   262  *
       
   263  * Returns: A new GstQueryType or an already registered query
       
   264  * with the same nick.
       
   265  */
       
   266 #ifdef __SYMBIAN32__
       
   267 EXPORT_C
       
   268 #endif
       
   269 
       
   270 GstQueryType
       
   271 gst_query_type_register (const gchar * nick, const gchar * description)
       
   272 {
       
   273   GstQueryTypeDefinition *query;
       
   274   GstQueryType lookup;
       
   275 
       
   276   g_return_val_if_fail (nick != NULL, 0);
       
   277   g_return_val_if_fail (description != NULL, 0);
       
   278 
       
   279   lookup = gst_query_type_get_by_nick (nick);
       
   280   if (lookup != GST_QUERY_NONE)
       
   281     return lookup;
       
   282 
       
   283   query = g_new0 (GstQueryTypeDefinition, 1);
       
   284   query->value = _n_values;
       
   285   query->nick = g_strdup (nick);
       
   286   query->description = g_strdup (description);
       
   287   query->quark = g_quark_from_static_string (query->nick);
       
   288 
       
   289   g_static_mutex_lock (&mutex);
       
   290   g_hash_table_insert (_nick_to_query, query->nick, query);
       
   291   g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value),
       
   292       query);
       
   293   _gst_queries = g_list_append (_gst_queries, query);
       
   294   _n_values++;
       
   295   g_static_mutex_unlock (&mutex);
       
   296 
       
   297   return query->value;
       
   298 }
       
   299 
       
   300 /**
       
   301  * gst_query_type_get_by_nick:
       
   302  * @nick: The nick of the query
       
   303  *
       
   304  * Get the query type registered with @nick.
       
   305  *
       
   306  * Returns: The query registered with @nick or #GST_QUERY_NONE
       
   307  * if the query was not registered.
       
   308  */
       
   309 #ifdef __SYMBIAN32__
       
   310 EXPORT_C
       
   311 #endif
       
   312 
       
   313 GstQueryType
       
   314 gst_query_type_get_by_nick (const gchar * nick)
       
   315 {
       
   316   GstQueryTypeDefinition *query;
       
   317 
       
   318   g_return_val_if_fail (nick != NULL, 0);
       
   319 
       
   320   g_static_mutex_lock (&mutex);
       
   321   query = g_hash_table_lookup (_nick_to_query, nick);
       
   322   g_static_mutex_unlock (&mutex);
       
   323 
       
   324   if (query != NULL)
       
   325     return query->value;
       
   326   else
       
   327     return GST_QUERY_NONE;
       
   328 }
       
   329 
       
   330 /**
       
   331  * gst_query_types_contains:
       
   332  * @types: The query array to search
       
   333  * @type: the #GstQueryType to find
       
   334  *
       
   335  * See if the given #GstQueryType is inside the @types query types array.
       
   336  *
       
   337  * Returns: TRUE if the type is found inside the array
       
   338  */
       
   339 #ifdef __SYMBIAN32__
       
   340 EXPORT_C
       
   341 #endif
       
   342 
       
   343 gboolean
       
   344 gst_query_types_contains (const GstQueryType * types, GstQueryType type)
       
   345 {
       
   346   if (!types)
       
   347     return FALSE;
       
   348 
       
   349   while (*types) {
       
   350     if (*types == type)
       
   351       return TRUE;
       
   352 
       
   353     types++;
       
   354   }
       
   355   return FALSE;
       
   356 }
       
   357 
       
   358 
       
   359 /**
       
   360  * gst_query_type_get_details:
       
   361  * @type: a #GstQueryType
       
   362  *
       
   363  * Get details about the given #GstQueryType.
       
   364  *
       
   365  * Returns: The #GstQueryTypeDefinition for @type or NULL on failure.
       
   366  */
       
   367 #ifdef __SYMBIAN32__
       
   368 EXPORT_C
       
   369 #endif
       
   370 
       
   371 const GstQueryTypeDefinition *
       
   372 gst_query_type_get_details (GstQueryType type)
       
   373 {
       
   374   const GstQueryTypeDefinition *result;
       
   375 
       
   376   g_static_mutex_lock (&mutex);
       
   377   result = g_hash_table_lookup (_query_type_to_nick, GINT_TO_POINTER (type));
       
   378   g_static_mutex_unlock (&mutex);
       
   379 
       
   380   return result;
       
   381 }
       
   382 
       
   383 /**
       
   384  * gst_query_type_iterate_definitions:
       
   385  *
       
   386  * Get a #GstIterator of all the registered query types. The definitions 
       
   387  * iterated over are read only.
       
   388  *
       
   389  * Returns: A #GstIterator of #GstQueryTypeDefinition.
       
   390  */
       
   391 #ifdef __SYMBIAN32__
       
   392 EXPORT_C
       
   393 #endif
       
   394 
       
   395 GstIterator *
       
   396 gst_query_type_iterate_definitions (void)
       
   397 {
       
   398   GstIterator *result;
       
   399 
       
   400   g_static_mutex_lock (&mutex);
       
   401   /* FIXME: register a boxed type for GstQueryTypeDefinition */
       
   402   result = gst_iterator_new_list (G_TYPE_POINTER,
       
   403       g_static_mutex_get_mutex (&mutex), &_n_values, &_gst_queries,
       
   404       NULL, NULL, NULL);
       
   405   g_static_mutex_unlock (&mutex);
       
   406 
       
   407   return result;
       
   408 }
       
   409 
       
   410 static GstQuery *
       
   411 gst_query_new (GstQueryType type, GstStructure * structure)
       
   412 {
       
   413   GstQuery *query;
       
   414 
       
   415   query = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);
       
   416 
       
   417   GST_DEBUG ("creating new query %p %d", query, type);
       
   418 
       
   419   query->type = type;
       
   420 
       
   421   if (structure) {
       
   422     query->structure = structure;
       
   423     gst_structure_set_parent_refcount (query->structure,
       
   424         &query->mini_object.refcount);
       
   425   } else {
       
   426     query->structure = NULL;
       
   427   }
       
   428 
       
   429   return query;
       
   430 }
       
   431 
       
   432 /**
       
   433  * gst_query_new_position:
       
   434  * @format: the default #GstFormat for the new query
       
   435  *
       
   436  * Constructs a new query stream position query object. Use gst_query_unref()
       
   437  * when done with it. A position query is used to query the current position
       
   438  * of playback in the streams, in some format.
       
   439  *
       
   440  * Returns: A #GstQuery
       
   441  */
       
   442 #ifdef __SYMBIAN32__
       
   443 EXPORT_C
       
   444 #endif
       
   445 
       
   446 GstQuery *
       
   447 gst_query_new_position (GstFormat format)
       
   448 {
       
   449   GstQuery *query;
       
   450   GstStructure *structure;
       
   451 
       
   452   structure = gst_structure_empty_new ("GstQueryPosition");
       
   453   gst_structure_id_set (structure,
       
   454       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   455       GST_QUARK (CURRENT), G_TYPE_INT64, (gint64) - 1, NULL);
       
   456 
       
   457   query = gst_query_new (GST_QUERY_POSITION, structure);
       
   458 
       
   459   return query;
       
   460 }
       
   461 
       
   462 /**
       
   463  * gst_query_set_position:
       
   464  * @query: a #GstQuery with query type GST_QUERY_POSITION
       
   465  * @format: the requested #GstFormat
       
   466  * @cur: the position to set
       
   467  *
       
   468  * Answer a position query by setting the requested value in the given format.
       
   469  */
       
   470 #ifdef __SYMBIAN32__
       
   471 EXPORT_C
       
   472 #endif
       
   473 
       
   474 void
       
   475 gst_query_set_position (GstQuery * query, GstFormat format, gint64 cur)
       
   476 {
       
   477   GstStructure *structure;
       
   478 
       
   479   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
       
   480 
       
   481   structure = gst_query_get_structure (query);
       
   482   gst_structure_id_set (structure,
       
   483       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   484       GST_QUARK (CURRENT), G_TYPE_INT64, cur, NULL);
       
   485 }
       
   486 
       
   487 /**
       
   488  * gst_query_parse_position:
       
   489  * @query: a #GstQuery
       
   490  * @format: the storage for the #GstFormat of the position values (may be NULL)
       
   491  * @cur: the storage for the current position (may be NULL)
       
   492  *
       
   493  * Parse a position query, writing the format into @format, and the position
       
   494  * into @cur, if the respective parameters are non-NULL.
       
   495  */
       
   496 #ifdef __SYMBIAN32__
       
   497 EXPORT_C
       
   498 #endif
       
   499 
       
   500 void
       
   501 gst_query_parse_position (GstQuery * query, GstFormat * format, gint64 * cur)
       
   502 {
       
   503   GstStructure *structure;
       
   504 
       
   505   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
       
   506 
       
   507   structure = gst_query_get_structure (query);
       
   508   if (format)
       
   509     *format = g_value_get_enum (gst_structure_id_get_value (structure,
       
   510             GST_QUARK (FORMAT)));
       
   511   if (cur)
       
   512     *cur = g_value_get_int64 (gst_structure_id_get_value (structure,
       
   513             GST_QUARK (CURRENT)));
       
   514 }
       
   515 
       
   516 
       
   517 /**
       
   518  * gst_query_new_duration:
       
   519  * @format: the #GstFormat for this duration query
       
   520  *
       
   521  * Constructs a new stream duration query object to query in the given format. 
       
   522  * Use gst_query_unref() when done with it. A duration query will give the
       
   523  * total length of the stream.
       
   524  *
       
   525  * Returns: A #GstQuery
       
   526  */
       
   527 #ifdef __SYMBIAN32__
       
   528 EXPORT_C
       
   529 #endif
       
   530 
       
   531 GstQuery *
       
   532 gst_query_new_duration (GstFormat format)
       
   533 {
       
   534   GstQuery *query;
       
   535   GstStructure *structure;
       
   536 
       
   537   structure = gst_structure_empty_new ("GstQueryDuration");
       
   538   gst_structure_id_set (structure,
       
   539       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   540       GST_QUARK (DURATION), G_TYPE_INT64, (gint64) - 1, NULL);
       
   541 
       
   542   query = gst_query_new (GST_QUERY_DURATION, structure);
       
   543 
       
   544   return query;
       
   545 }
       
   546 
       
   547 /**
       
   548  * gst_query_set_duration:
       
   549  * @query: a #GstQuery
       
   550  * @format: the #GstFormat for the duration
       
   551  * @duration: the duration of the stream
       
   552  *
       
   553  * Answer a duration query by setting the requested value in the given format.
       
   554  */
       
   555 #ifdef __SYMBIAN32__
       
   556 EXPORT_C
       
   557 #endif
       
   558 
       
   559 void
       
   560 gst_query_set_duration (GstQuery * query, GstFormat format, gint64 duration)
       
   561 {
       
   562   GstStructure *structure;
       
   563 
       
   564   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);
       
   565 
       
   566   structure = gst_query_get_structure (query);
       
   567   gst_structure_id_set (structure,
       
   568       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   569       GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
       
   570 }
       
   571 
       
   572 /**
       
   573  * gst_query_parse_duration:
       
   574  * @query: a #GstQuery
       
   575  * @format: the storage for the #GstFormat of the duration value, or NULL.
       
   576  * @duration: the storage for the total duration, or NULL.
       
   577  *
       
   578  * Parse a duration query answer. Write the format of the duration into @format,
       
   579  * and the value into @duration, if the respective variables are non-NULL.
       
   580  */
       
   581 #ifdef __SYMBIAN32__
       
   582 EXPORT_C
       
   583 #endif
       
   584 
       
   585 void
       
   586 gst_query_parse_duration (GstQuery * query, GstFormat * format,
       
   587     gint64 * duration)
       
   588 {
       
   589   GstStructure *structure;
       
   590 
       
   591   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);
       
   592 
       
   593   structure = gst_query_get_structure (query);
       
   594   if (format)
       
   595     *format = g_value_get_enum (gst_structure_id_get_value (structure,
       
   596             GST_QUARK (FORMAT)));
       
   597   if (duration)
       
   598     *duration = g_value_get_int64 (gst_structure_id_get_value (structure,
       
   599             GST_QUARK (DURATION)));
       
   600 }
       
   601 
       
   602 /**
       
   603  * gst_query_new_latency:
       
   604  *
       
   605  * Constructs a new latency query object. 
       
   606  * Use gst_query_unref() when done with it. A latency query is usually performed
       
   607  * by sinks to compensate for additional latency introduced by elements in the
       
   608  * pipeline.
       
   609  *
       
   610  * Returns: A #GstQuery
       
   611  *
       
   612  * Since: 0.10.12
       
   613  */
       
   614 #ifdef __SYMBIAN32__
       
   615 EXPORT_C
       
   616 #endif
       
   617 
       
   618 GstQuery *
       
   619 gst_query_new_latency (void)
       
   620 {
       
   621   GstQuery *query;
       
   622   GstStructure *structure;
       
   623 
       
   624   structure = gst_structure_empty_new ("GstQueryLatency");
       
   625   gst_structure_set (structure,
       
   626       "live", G_TYPE_BOOLEAN, FALSE,
       
   627       "min-latency", G_TYPE_UINT64, (gint64) 0,
       
   628       "max-latency", G_TYPE_UINT64, (gint64) - 1, NULL);
       
   629 
       
   630   query = gst_query_new (GST_QUERY_LATENCY, structure);
       
   631 
       
   632   return query;
       
   633 }
       
   634 
       
   635 /**
       
   636  * gst_query_set_latency:
       
   637  * @query: a #GstQuery
       
   638  * @live: if there is a live element upstream
       
   639  * @min_latency: the minimal latency of the live element
       
   640  * @max_latency: the maximal latency of the live element
       
   641  *
       
   642  * Answer a latency query by setting the requested values in the given format.
       
   643  *
       
   644  * Since: 0.10.12
       
   645  */
       
   646 #ifdef __SYMBIAN32__
       
   647 EXPORT_C
       
   648 #endif
       
   649 
       
   650 void
       
   651 gst_query_set_latency (GstQuery * query, gboolean live,
       
   652     GstClockTime min_latency, GstClockTime max_latency)
       
   653 {
       
   654   GstStructure *structure;
       
   655 
       
   656   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
       
   657 
       
   658   structure = gst_query_get_structure (query);
       
   659   gst_structure_set (structure,
       
   660       "live", G_TYPE_BOOLEAN, live,
       
   661       "min-latency", G_TYPE_UINT64, min_latency,
       
   662       "max-latency", G_TYPE_UINT64, max_latency, NULL);
       
   663 }
       
   664 
       
   665 /**
       
   666  * gst_query_parse_latency:
       
   667  * @query: a #GstQuery
       
   668  * @live: storage for live or NULL 
       
   669  * @min_latency: the storage for the min latency or NULL
       
   670  * @max_latency: the storage for the max latency or NULL
       
   671  *
       
   672  * Parse a latency query answer. 
       
   673  *
       
   674  * Since: 0.10.12
       
   675  */
       
   676 #ifdef __SYMBIAN32__
       
   677 EXPORT_C
       
   678 #endif
       
   679 
       
   680 void
       
   681 gst_query_parse_latency (GstQuery * query, gboolean * live,
       
   682     GstClockTime * min_latency, GstClockTime * max_latency)
       
   683 {
       
   684   GstStructure *structure;
       
   685 
       
   686   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
       
   687 
       
   688   structure = gst_query_get_structure (query);
       
   689   if (live)
       
   690     *live = g_value_get_boolean (gst_structure_get_value (structure, "live"));
       
   691   if (min_latency)
       
   692     *min_latency = g_value_get_uint64 (gst_structure_get_value (structure,
       
   693             "min-latency"));
       
   694   if (max_latency)
       
   695     *max_latency = g_value_get_uint64 (gst_structure_get_value (structure,
       
   696             "max-latency"));
       
   697 }
       
   698 
       
   699 /**
       
   700  * gst_query_new_convert:
       
   701  * @src_format: the source #GstFormat for the new query
       
   702  * @value: the value to convert
       
   703  * @dest_format: the target #GstFormat
       
   704  *
       
   705  * Constructs a new convert query object. Use gst_query_unref()
       
   706  * when done with it. A convert query is used to ask for a conversion between
       
   707  * one format and another.
       
   708  *
       
   709  * Returns: A #GstQuery
       
   710  */
       
   711 #ifdef __SYMBIAN32__
       
   712 EXPORT_C
       
   713 #endif
       
   714 
       
   715 GstQuery *
       
   716 gst_query_new_convert (GstFormat src_format, gint64 value,
       
   717     GstFormat dest_format)
       
   718 {
       
   719   GstQuery *query;
       
   720   GstStructure *structure;
       
   721 
       
   722   g_return_val_if_fail (value >= 0, NULL);
       
   723 
       
   724   structure = gst_structure_empty_new ("GstQueryConvert");
       
   725   gst_structure_id_set (structure,
       
   726       GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
       
   727       GST_QUARK (SRC_VALUE), G_TYPE_INT64, value,
       
   728       GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
       
   729       GST_QUARK (DEST_VALUE), G_TYPE_INT64, (gint64) - 1, NULL);
       
   730 
       
   731   query = gst_query_new (GST_QUERY_CONVERT, structure);
       
   732 
       
   733   return query;
       
   734 }
       
   735 
       
   736 /**
       
   737  * gst_query_set_convert:
       
   738  * @query: a #GstQuery
       
   739  * @src_format: the source #GstFormat
       
   740  * @src_value: the source value
       
   741  * @dest_format: the destination #GstFormat
       
   742  * @dest_value: the destination value
       
   743  *
       
   744  * Answer a convert query by setting the requested values.
       
   745  */
       
   746 #ifdef __SYMBIAN32__
       
   747 EXPORT_C
       
   748 #endif
       
   749 
       
   750 void
       
   751 gst_query_set_convert (GstQuery * query, GstFormat src_format, gint64 src_value,
       
   752     GstFormat dest_format, gint64 dest_value)
       
   753 {
       
   754   GstStructure *structure;
       
   755 
       
   756   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
       
   757 
       
   758   structure = gst_query_get_structure (query);
       
   759   gst_structure_id_set (structure,
       
   760       GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
       
   761       GST_QUARK (SRC_VALUE), G_TYPE_INT64, src_value,
       
   762       GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
       
   763       GST_QUARK (DEST_VALUE), G_TYPE_INT64, (gint64) dest_value, NULL);
       
   764 }
       
   765 
       
   766 /**
       
   767  * gst_query_parse_convert:
       
   768  * @query: a #GstQuery
       
   769  * @src_format: the storage for the #GstFormat of the source value, or NULL
       
   770  * @src_value: the storage for the source value, or NULL
       
   771  * @dest_format: the storage for the #GstFormat of the destination value, or NULL
       
   772  * @dest_value: the storage for the destination value, or NULL
       
   773  *
       
   774  * Parse a convert query answer. Any of @src_format, @src_value, @dest_format,
       
   775  * and @dest_value may be NULL, in which case that value is omitted.
       
   776  */
       
   777 #ifdef __SYMBIAN32__
       
   778 EXPORT_C
       
   779 #endif
       
   780 
       
   781 void
       
   782 gst_query_parse_convert (GstQuery * query, GstFormat * src_format,
       
   783     gint64 * src_value, GstFormat * dest_format, gint64 * dest_value)
       
   784 {
       
   785   GstStructure *structure;
       
   786 
       
   787   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
       
   788 
       
   789   structure = gst_query_get_structure (query);
       
   790   if (src_format)
       
   791     *src_format = g_value_get_enum (gst_structure_id_get_value (structure,
       
   792             GST_QUARK (SRC_FORMAT)));
       
   793   if (src_value)
       
   794     *src_value = g_value_get_int64 (gst_structure_id_get_value (structure,
       
   795             GST_QUARK (SRC_VALUE)));
       
   796   if (dest_format)
       
   797     *dest_format = g_value_get_enum (gst_structure_id_get_value (structure,
       
   798             GST_QUARK (DEST_FORMAT)));
       
   799   if (dest_value)
       
   800     *dest_value = g_value_get_int64 (gst_structure_id_get_value (structure,
       
   801             GST_QUARK (DEST_VALUE)));
       
   802 }
       
   803 
       
   804 /**
       
   805  * gst_query_new_segment:
       
   806  * @format: the #GstFormat for the new query
       
   807  *
       
   808  * Constructs a new segment query object. Use gst_query_unref()
       
   809  * when done with it. A segment query is used to discover information about the
       
   810  * currently configured segment for playback.
       
   811  *
       
   812  * Returns: a #GstQuery
       
   813  */
       
   814 #ifdef __SYMBIAN32__
       
   815 EXPORT_C
       
   816 #endif
       
   817 
       
   818 GstQuery *
       
   819 gst_query_new_segment (GstFormat format)
       
   820 {
       
   821   GstQuery *query;
       
   822   GstStructure *structure;
       
   823 
       
   824   structure = gst_structure_empty_new ("GstQuerySegment");
       
   825   gst_structure_id_set (structure,
       
   826       GST_QUARK (RATE), G_TYPE_DOUBLE, (gdouble) 0.0,
       
   827       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   828       GST_QUARK (START_VALUE), G_TYPE_INT64, (gint64) - 1,
       
   829       GST_QUARK (STOP_VALUE), G_TYPE_INT64, (gint64) - 1, NULL);
       
   830 
       
   831   query = gst_query_new (GST_QUERY_SEGMENT, structure);
       
   832 
       
   833   return query;
       
   834 }
       
   835 
       
   836 /**
       
   837  * gst_query_set_segment:
       
   838  * @query: a #GstQuery
       
   839  * @rate: the rate of the segment
       
   840  * @format: the #GstFormat of the segment values (@start_value and @stop_value)
       
   841  * @start_value: the start value
       
   842  * @stop_value: the stop value
       
   843  *
       
   844  * Answer a segment query by setting the requested values. The normal
       
   845  * playback segment of a pipeline is 0 to duration at the default rate of
       
   846  * 1.0. If a seek was performed on the pipeline to play a different
       
   847  * segment, this query will return the range specified in the last seek.
       
   848  *
       
   849  * @start_value and @stop_value will respectively contain the configured 
       
   850  * playback range start and stop values expressed in @format. 
       
   851  * The values are always between 0 and the duration of the media and 
       
   852  * @start_value <= @stop_value. @rate will contain the playback rate. For
       
   853  * negative rates, playback will actually happen from @stop_value to
       
   854  * @start_value.
       
   855  */
       
   856 #ifdef __SYMBIAN32__
       
   857 EXPORT_C
       
   858 #endif
       
   859 
       
   860 void
       
   861 gst_query_set_segment (GstQuery * query, gdouble rate, GstFormat format,
       
   862     gint64 start_value, gint64 stop_value)
       
   863 {
       
   864   GstStructure *structure;
       
   865 
       
   866   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);
       
   867 
       
   868   structure = gst_query_get_structure (query);
       
   869   gst_structure_id_set (structure,
       
   870       GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
       
   871       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   872       GST_QUARK (START_VALUE), G_TYPE_INT64, start_value,
       
   873       GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop_value, NULL);
       
   874 }
       
   875 
       
   876 /**
       
   877  * gst_query_parse_segment:
       
   878  * @query: a #GstQuery
       
   879  * @rate: the storage for the rate of the segment, or NULL
       
   880  * @format: the storage for the #GstFormat of the values, or NULL
       
   881  * @start_value: the storage for the start value, or NULL
       
   882  * @stop_value: the storage for the stop value, or NULL
       
   883  *
       
   884  * Parse a segment query answer. Any of @rate, @format, @start_value, and 
       
   885  * @stop_value may be NULL, which will cause this value to be omitted.
       
   886  *
       
   887  * See gst_query_set_segment() for an explanation of the function arguments.
       
   888  */
       
   889 #ifdef __SYMBIAN32__
       
   890 EXPORT_C
       
   891 #endif
       
   892 
       
   893 void
       
   894 gst_query_parse_segment (GstQuery * query, gdouble * rate, GstFormat * format,
       
   895     gint64 * start_value, gint64 * stop_value)
       
   896 {
       
   897   GstStructure *structure;
       
   898 
       
   899   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);
       
   900 
       
   901   structure = gst_query_get_structure (query);
       
   902   if (rate)
       
   903     *rate = g_value_get_double (gst_structure_id_get_value (structure,
       
   904             GST_QUARK (RATE)));
       
   905   if (format)
       
   906     *format = g_value_get_enum (gst_structure_id_get_value (structure,
       
   907             GST_QUARK (FORMAT)));
       
   908   if (start_value)
       
   909     *start_value = g_value_get_int64 (gst_structure_id_get_value (structure,
       
   910             GST_QUARK (START_VALUE)));
       
   911   if (stop_value)
       
   912     *stop_value = g_value_get_int64 (gst_structure_id_get_value (structure,
       
   913             GST_QUARK (STOP_VALUE)));
       
   914 }
       
   915 
       
   916 /**
       
   917  * gst_query_new_application:
       
   918  * @type: the query type
       
   919  * @structure: a structure for the query
       
   920  *
       
   921  * Constructs a new custom application query object. Use gst_query_unref()
       
   922  * when done with it.
       
   923  *
       
   924  * Returns: a #GstQuery
       
   925  */
       
   926 #ifdef __SYMBIAN32__
       
   927 EXPORT_C
       
   928 #endif
       
   929 
       
   930 GstQuery *
       
   931 gst_query_new_application (GstQueryType type, GstStructure * structure)
       
   932 {
       
   933   g_return_val_if_fail (gst_query_type_get_details (type) != NULL, NULL);
       
   934   g_return_val_if_fail (structure != NULL, NULL);
       
   935 
       
   936   return gst_query_new (type, structure);
       
   937 }
       
   938 
       
   939 /**
       
   940  * gst_query_get_structure:
       
   941  * @query: a #GstQuery
       
   942  *
       
   943  * Get the structure of a query.
       
   944  *
       
   945  * Returns: The #GstStructure of the query. The structure is still owned
       
   946  * by the query and will therefore be freed when the query is unreffed.
       
   947  */
       
   948 #ifdef __SYMBIAN32__
       
   949 EXPORT_C
       
   950 #endif
       
   951 
       
   952 GstStructure *
       
   953 gst_query_get_structure (GstQuery * query)
       
   954 {
       
   955   g_return_val_if_fail (GST_IS_QUERY (query), NULL);
       
   956 
       
   957   return query->structure;
       
   958 }
       
   959 
       
   960 /**
       
   961  * gst_query_new_seeking (GstFormat *format)
       
   962  * @format: the default #GstFormat for the new query
       
   963  *
       
   964  * Constructs a new query object for querying seeking properties of
       
   965  * the stream. 
       
   966  *
       
   967  * Returns: A #GstQuery
       
   968  */
       
   969 #ifdef __SYMBIAN32__
       
   970 EXPORT_C
       
   971 #endif 
       
   972 GstQuery *
       
   973 gst_query_new_seeking (GstFormat format)
       
   974 {
       
   975   GstQuery *query;
       
   976   GstStructure *structure;
       
   977 
       
   978   structure = gst_structure_empty_new ("GstQuerySeeking");
       
   979   gst_structure_id_set (structure,
       
   980       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
   981       GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, FALSE,
       
   982       GST_QUARK (SEGMENT_START), G_TYPE_INT64, (gint64) - 1,
       
   983       GST_QUARK (SEGMENT_END), G_TYPE_INT64, (gint64) - 1, NULL);
       
   984 
       
   985   query = gst_query_new (GST_QUERY_SEEKING, structure);
       
   986 
       
   987   return query;
       
   988 }
       
   989 
       
   990 /**
       
   991  * gst_query_set_seeking:
       
   992  * @query: a #GstQuery
       
   993  * @format: the format to set for the @segment_start and @segment_end values
       
   994  * @seekable: the seekable flag to set
       
   995  * @segment_start: the segment_start to set
       
   996  * @segment_end: the segment_end to set
       
   997  *
       
   998  * Set the seeking query result fields in @query.
       
   999  */
       
  1000 #ifdef __SYMBIAN32__
       
  1001 EXPORT_C
       
  1002 #endif
       
  1003 
       
  1004 void
       
  1005 gst_query_set_seeking (GstQuery * query, GstFormat format,
       
  1006     gboolean seekable, gint64 segment_start, gint64 segment_end)
       
  1007 {
       
  1008   GstStructure *structure;
       
  1009 
       
  1010   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
       
  1011 
       
  1012   structure = gst_query_get_structure (query);
       
  1013   gst_structure_id_set (structure,
       
  1014       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
  1015       GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, seekable,
       
  1016       GST_QUARK (SEGMENT_START), G_TYPE_INT64, segment_start,
       
  1017       GST_QUARK (SEGMENT_END), G_TYPE_INT64, segment_end, NULL);
       
  1018 }
       
  1019 
       
  1020 /**
       
  1021  * gst_query_parse_seeking:
       
  1022  * @query: a GST_QUERY_SEEKING type query #GstQuery
       
  1023  * @format: the format to set for the @segment_start and @segment_end values
       
  1024  * @seekable: the seekable flag to set
       
  1025  * @segment_start: the segment_start to set
       
  1026  * @segment_end: the segment_end to set
       
  1027  *
       
  1028  * Parse a seeking query, writing the format into @format, and 
       
  1029  * other results into the passed parameters, if the respective parameters
       
  1030  * are non-NULL
       
  1031  */
       
  1032 #ifdef __SYMBIAN32__
       
  1033 EXPORT_C
       
  1034 #endif
       
  1035 
       
  1036 void
       
  1037 gst_query_parse_seeking (GstQuery * query, GstFormat * format,
       
  1038     gboolean * seekable, gint64 * segment_start, gint64 * segment_end)
       
  1039 {
       
  1040   GstStructure *structure;
       
  1041 
       
  1042   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
       
  1043 
       
  1044   structure = gst_query_get_structure (query);
       
  1045   if (format)
       
  1046     *format = g_value_get_enum (gst_structure_id_get_value (structure,
       
  1047             GST_QUARK (FORMAT)));
       
  1048   if (seekable)
       
  1049     *seekable = g_value_get_boolean (gst_structure_id_get_value (structure,
       
  1050             GST_QUARK (SEEKABLE)));
       
  1051   if (segment_start)
       
  1052     *segment_start = g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1053             GST_QUARK (SEGMENT_START)));
       
  1054   if (segment_end)
       
  1055     *segment_end = g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1056             GST_QUARK (SEGMENT_END)));
       
  1057 }
       
  1058 
       
  1059 /**
       
  1060  * gst_query_new_formats:
       
  1061  *
       
  1062  * Constructs a new query object for querying formats of
       
  1063  * the stream. 
       
  1064  *
       
  1065  * Returns: A #GstQuery
       
  1066  *
       
  1067  * Since: 0.10.4
       
  1068  */
       
  1069 #ifdef __SYMBIAN32__
       
  1070 EXPORT_C
       
  1071 #endif
       
  1072 
       
  1073 GstQuery *
       
  1074 gst_query_new_formats (void)
       
  1075 {
       
  1076   GstQuery *query;
       
  1077   GstStructure *structure;
       
  1078 
       
  1079   structure = gst_structure_new ("GstQueryFormats", NULL);
       
  1080   query = gst_query_new (GST_QUERY_FORMATS, structure);
       
  1081 
       
  1082   return query;
       
  1083 }
       
  1084 
       
  1085 static void
       
  1086 gst_query_list_add_format (GValue * list, GstFormat format)
       
  1087 {
       
  1088   GValue item = { 0, };
       
  1089 
       
  1090   g_value_init (&item, GST_TYPE_FORMAT);
       
  1091   g_value_set_enum (&item, format);
       
  1092   gst_value_list_append_value (list, &item);
       
  1093   g_value_unset (&item);
       
  1094 }
       
  1095 
       
  1096 /**
       
  1097  * gst_query_set_formats:
       
  1098  * @query: a #GstQuery
       
  1099  * @n_formats: the number of formats to set.
       
  1100  * @...: A number of @GstFormats equal to @n_formats.
       
  1101  *
       
  1102  * Set the formats query result fields in @query. The number of formats passed
       
  1103  * must be equal to @n_formats.
       
  1104  */
       
  1105 #ifdef __SYMBIAN32__
       
  1106 EXPORT_C
       
  1107 #endif
       
  1108 
       
  1109 void
       
  1110 gst_query_set_formats (GstQuery * query, gint n_formats, ...)
       
  1111 {
       
  1112   va_list ap;
       
  1113   GValue list = { 0, };
       
  1114   GstStructure *structure;
       
  1115   gint i;
       
  1116 
       
  1117   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
       
  1118 
       
  1119   g_value_init (&list, GST_TYPE_LIST);
       
  1120 
       
  1121   va_start (ap, n_formats);
       
  1122   for (i = 0; i < n_formats; i++) {
       
  1123     gst_query_list_add_format (&list, va_arg (ap, GstFormat));
       
  1124   }
       
  1125   va_end (ap);
       
  1126 
       
  1127   structure = gst_query_get_structure (query);
       
  1128   gst_structure_set_value (structure, "formats", &list);
       
  1129 
       
  1130   g_value_unset (&list);
       
  1131 
       
  1132 }
       
  1133 
       
  1134 /**
       
  1135  * gst_query_set_formatsv:
       
  1136  * @query: a #GstQuery
       
  1137  * @n_formats: the number of formats to set.
       
  1138  * @formats: An array containing @n_formats @GstFormat values.
       
  1139  *
       
  1140  * Set the formats query result fields in @query. The number of formats passed
       
  1141  * in the @formats array must be equal to @n_formats.
       
  1142  *
       
  1143  * Since: 0.10.4
       
  1144  */
       
  1145 #ifdef __SYMBIAN32__
       
  1146 EXPORT_C
       
  1147 #endif
       
  1148 
       
  1149 void
       
  1150 gst_query_set_formatsv (GstQuery * query, gint n_formats, GstFormat * formats)
       
  1151 {
       
  1152   GValue list = { 0, };
       
  1153   GstStructure *structure;
       
  1154   gint i;
       
  1155 
       
  1156   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
       
  1157 
       
  1158   g_value_init (&list, GST_TYPE_LIST);
       
  1159   for (i = 0; i < n_formats; i++) {
       
  1160     gst_query_list_add_format (&list, formats[i]);
       
  1161   }
       
  1162   structure = gst_query_get_structure (query);
       
  1163   gst_structure_set_value (structure, "formats", &list);
       
  1164 
       
  1165   g_value_unset (&list);
       
  1166 }
       
  1167 
       
  1168 /**
       
  1169  * gst_query_parse_formats_length:
       
  1170  * @query: a #GstQuery
       
  1171  * @n_formats: the number of formats in this query.
       
  1172  *
       
  1173  * Parse the number of formats in the formats @query. 
       
  1174  *
       
  1175  * Since: 0.10.4
       
  1176  */
       
  1177 #ifdef __SYMBIAN32__
       
  1178 EXPORT_C
       
  1179 #endif
       
  1180 
       
  1181 void
       
  1182 gst_query_parse_formats_length (GstQuery * query, guint * n_formats)
       
  1183 {
       
  1184   GstStructure *structure;
       
  1185 
       
  1186   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
       
  1187 
       
  1188   if (n_formats) {
       
  1189     const GValue *list;
       
  1190 
       
  1191     structure = gst_query_get_structure (query);
       
  1192     list = gst_structure_get_value (structure, "formats");
       
  1193     if (list == NULL)
       
  1194       *n_formats = 0;
       
  1195     else
       
  1196       *n_formats = gst_value_list_get_size (list);
       
  1197   }
       
  1198 }
       
  1199 
       
  1200 /**
       
  1201  * gst_query_parse_formats_nth:
       
  1202  * @query: a #GstQuery
       
  1203  * @nth: the nth format to retrieve.
       
  1204  * @format: a pointer to store the nth format
       
  1205  *
       
  1206  * Parse the format query and retrieve the @nth format from it into 
       
  1207  * @format. If the list contains less elements than @nth, @format will be
       
  1208  * set to GST_FORMAT_UNDEFINED.
       
  1209  *
       
  1210  * Since: 0.10.4
       
  1211  */
       
  1212 #ifdef __SYMBIAN32__
       
  1213 EXPORT_C
       
  1214 #endif
       
  1215 
       
  1216 void
       
  1217 gst_query_parse_formats_nth (GstQuery * query, guint nth, GstFormat * format)
       
  1218 {
       
  1219   GstStructure *structure;
       
  1220 
       
  1221   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
       
  1222 
       
  1223   if (format) {
       
  1224     const GValue *list;
       
  1225 
       
  1226     structure = gst_query_get_structure (query);
       
  1227     list = gst_structure_get_value (structure, "formats");
       
  1228     if (list == NULL) {
       
  1229       *format = GST_FORMAT_UNDEFINED;
       
  1230     } else {
       
  1231       if (nth < gst_value_list_get_size (list)) {
       
  1232         *format = g_value_get_enum (gst_value_list_get_value (list, nth));
       
  1233       } else
       
  1234         *format = GST_FORMAT_UNDEFINED;
       
  1235     }
       
  1236   }
       
  1237 }