gstreamer_core/gst/gstquery.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    63 #include "gstinfo.h"
    63 #include "gstinfo.h"
    64 #include "gstquery.h"
    64 #include "gstquery.h"
    65 #include "gstvalue.h"
    65 #include "gstvalue.h"
    66 #include "gstenumtypes.h"
    66 #include "gstenumtypes.h"
    67 #include "gstquark.h"
    67 #include "gstquark.h"
    68 #include "gsturi.h"
    68 
    69 #ifdef __SYMBIAN32__
    69 #ifdef __SYMBIAN32__
    70 #include <glib_global.h>
    70 #include <glib_global.h>
    71 #endif
    71 #endif
    72 
    72 
    73 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
    73 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
    74 #define GST_CAT_DEFAULT gst_query_debug
    74 #define GST_CAT_DEFAULT gst_query_debug
    75 
    75 
       
    76 static void gst_query_class_init (gpointer g_class, gpointer class_data);
    76 static void gst_query_finalize (GstQuery * query);
    77 static void gst_query_finalize (GstQuery * query);
    77 static GstQuery *_gst_query_copy (GstQuery * query);
    78 static GstQuery *_gst_query_copy (GstQuery * query);
    78 
    79 
    79 static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
    80 static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
    80 static GList *_gst_queries = NULL;
    81 static GList *_gst_queries = NULL;
    92   {GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1", 0},
    93   {GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1", 0},
    93   {GST_QUERY_SEEKING, "seeking", "Seeking capabilities and parameters", 0},
    94   {GST_QUERY_SEEKING, "seeking", "Seeking capabilities and parameters", 0},
    94   {GST_QUERY_SEGMENT, "segment", "currently configured segment", 0},
    95   {GST_QUERY_SEGMENT, "segment", "currently configured segment", 0},
    95   {GST_QUERY_CONVERT, "convert", "Converting between formats", 0},
    96   {GST_QUERY_CONVERT, "convert", "Converting between formats", 0},
    96   {GST_QUERY_FORMATS, "formats", "Supported formats for conversion", 0},
    97   {GST_QUERY_FORMATS, "formats", "Supported formats for conversion", 0},
    97   {GST_QUERY_BUFFERING, "buffering", "Buffering status", 0},
       
    98   {GST_QUERY_CUSTOM, "custom", "Custom query", 0},
       
    99   {GST_QUERY_URI, "uri", "URI of the source or sink", 0},
       
   100   {0, NULL, NULL, 0}
    98   {0, NULL, NULL, 0}
   101 };
    99 };
   102 #ifdef __SYMBIAN32__
   100 #ifdef __SYMBIAN32__
   103 EXPORT_C
   101 EXPORT_C
   104 #endif
   102 #endif
   175 
   173 
   176   def = gst_query_type_get_details (query);
   174   def = gst_query_type_get_details (query);
   177 
   175 
   178   return def->quark;
   176   return def->quark;
   179 }
   177 }
   180 
   178 #ifdef __SYMBIAN32__
   181 G_DEFINE_TYPE (GstQuery, gst_query, GST_TYPE_MINI_OBJECT);
   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 }
   182 
   207 
   183 static void
   208 static void
   184 gst_query_class_init (GstQueryClass * klass)
   209 gst_query_class_init (gpointer g_class, gpointer class_data)
   185 {
   210 {
   186   parent_class = g_type_class_peek_parent (klass);
   211   GstQueryClass *query_class = GST_QUERY_CLASS (g_class);
   187 
   212 
   188   klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
   213   parent_class = g_type_class_peek_parent (g_class);
   189   klass->mini_object_class.finalize =
   214 
       
   215   query_class->mini_object_class.copy =
       
   216       (GstMiniObjectCopyFunction) _gst_query_copy;
       
   217   query_class->mini_object_class.finalize =
   190       (GstMiniObjectFinalizeFunction) gst_query_finalize;
   218       (GstMiniObjectFinalizeFunction) gst_query_finalize;
   191 
   219 
   192 }
       
   193 
       
   194 static void
       
   195 gst_query_init (GstQuery * query)
       
   196 {
       
   197 }
   220 }
   198 
   221 
   199 static void
   222 static void
   200 gst_query_finalize (GstQuery * query)
   223 gst_query_finalize (GstQuery * query)
   201 {
   224 {
   204   if (query->structure) {
   227   if (query->structure) {
   205     gst_structure_set_parent_refcount (query->structure, NULL);
   228     gst_structure_set_parent_refcount (query->structure, NULL);
   206     gst_structure_free (query->structure);
   229     gst_structure_free (query->structure);
   207   }
   230   }
   208 
   231 
   209 /*   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (query)); */
   232   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (query));
   210 }
   233 }
   211 
   234 
   212 static GstQuery *
   235 static GstQuery *
   213 _gst_query_copy (GstQuery * query)
   236 _gst_query_copy (GstQuery * query)
   214 {
   237 {
   424 gst_query_new_position (GstFormat format)
   447 gst_query_new_position (GstFormat format)
   425 {
   448 {
   426   GstQuery *query;
   449   GstQuery *query;
   427   GstStructure *structure;
   450   GstStructure *structure;
   428 
   451 
   429   structure = gst_structure_id_new (GST_QUARK (QUERY_POSITION),
   452   structure = gst_structure_empty_new ("GstQueryPosition");
       
   453   gst_structure_id_set (structure,
   430       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   454       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   431       GST_QUARK (CURRENT), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
   455       GST_QUARK (CURRENT), G_TYPE_INT64, (gint64) - 1, NULL);
   432 
   456 
   433   query = gst_query_new (GST_QUERY_POSITION, structure);
   457   query = gst_query_new (GST_QUERY_POSITION, structure);
   434 
   458 
   435   return query;
   459   return query;
   436 }
   460 }
   508 gst_query_new_duration (GstFormat format)
   532 gst_query_new_duration (GstFormat format)
   509 {
   533 {
   510   GstQuery *query;
   534   GstQuery *query;
   511   GstStructure *structure;
   535   GstStructure *structure;
   512 
   536 
   513   structure = gst_structure_id_new (GST_QUARK (QUERY_DURATION),
   537   structure = gst_structure_empty_new ("GstQueryDuration");
       
   538   gst_structure_id_set (structure,
   514       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   539       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   515       GST_QUARK (DURATION), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
   540       GST_QUARK (DURATION), G_TYPE_INT64, (gint64) - 1, NULL);
   516 
   541 
   517   query = gst_query_new (GST_QUERY_DURATION, structure);
   542   query = gst_query_new (GST_QUERY_DURATION, structure);
   518 
   543 
   519   return query;
   544   return query;
   520 }
   545 }
   594 gst_query_new_latency (void)
   619 gst_query_new_latency (void)
   595 {
   620 {
   596   GstQuery *query;
   621   GstQuery *query;
   597   GstStructure *structure;
   622   GstStructure *structure;
   598 
   623 
   599   structure = gst_structure_id_new (GST_QUARK (QUERY_LATENCY),
   624   structure = gst_structure_empty_new ("GstQueryLatency");
   600       GST_QUARK (LIVE), G_TYPE_BOOLEAN, FALSE,
   625   gst_structure_set (structure,
   601       GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
   626       "live", G_TYPE_BOOLEAN, FALSE,
   602       GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (-1), NULL);
   627       "min-latency", G_TYPE_UINT64, (gint64) 0,
       
   628       "max-latency", G_TYPE_UINT64, (gint64) - 1, NULL);
   603 
   629 
   604   query = gst_query_new (GST_QUERY_LATENCY, structure);
   630   query = gst_query_new (GST_QUERY_LATENCY, structure);
   605 
   631 
   606   return query;
   632   return query;
   607 }
   633 }
   628   GstStructure *structure;
   654   GstStructure *structure;
   629 
   655 
   630   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
   656   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
   631 
   657 
   632   structure = gst_query_get_structure (query);
   658   structure = gst_query_get_structure (query);
   633   gst_structure_id_set (structure,
   659   gst_structure_set (structure,
   634       GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
   660       "live", G_TYPE_BOOLEAN, live,
   635       GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, min_latency,
   661       "min-latency", G_TYPE_UINT64, min_latency,
   636       GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, max_latency, NULL);
   662       "max-latency", G_TYPE_UINT64, max_latency, NULL);
   637 }
   663 }
   638 
   664 
   639 /**
   665 /**
   640  * gst_query_parse_latency:
   666  * gst_query_parse_latency:
   641  * @query: a #GstQuery
   667  * @query: a #GstQuery
   659 
   685 
   660   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
   686   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
   661 
   687 
   662   structure = gst_query_get_structure (query);
   688   structure = gst_query_get_structure (query);
   663   if (live)
   689   if (live)
   664     *live =
   690     *live = g_value_get_boolean (gst_structure_get_value (structure, "live"));
   665         g_value_get_boolean (gst_structure_id_get_value (structure,
       
   666             GST_QUARK (LIVE)));
       
   667   if (min_latency)
   691   if (min_latency)
   668     *min_latency = g_value_get_uint64 (gst_structure_id_get_value (structure,
   692     *min_latency = g_value_get_uint64 (gst_structure_get_value (structure,
   669             GST_QUARK (MIN_LATENCY)));
   693             "min-latency"));
   670   if (max_latency)
   694   if (max_latency)
   671     *max_latency = g_value_get_uint64 (gst_structure_id_get_value (structure,
   695     *max_latency = g_value_get_uint64 (gst_structure_get_value (structure,
   672             GST_QUARK (MAX_LATENCY)));
   696             "max-latency"));
   673 }
   697 }
   674 
   698 
   675 /**
   699 /**
   676  * gst_query_new_convert:
   700  * gst_query_new_convert:
   677  * @src_format: the source #GstFormat for the new query
   701  * @src_format: the source #GstFormat for the new query
   693     GstFormat dest_format)
   717     GstFormat dest_format)
   694 {
   718 {
   695   GstQuery *query;
   719   GstQuery *query;
   696   GstStructure *structure;
   720   GstStructure *structure;
   697 
   721 
   698   structure = gst_structure_id_new (GST_QUARK (QUERY_CONVERT),
   722   g_return_val_if_fail (value >= 0, NULL);
       
   723 
       
   724   structure = gst_structure_empty_new ("GstQueryConvert");
       
   725   gst_structure_id_set (structure,
   699       GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
   726       GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
   700       GST_QUARK (SRC_VALUE), G_TYPE_INT64, value,
   727       GST_QUARK (SRC_VALUE), G_TYPE_INT64, value,
   701       GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
   728       GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
   702       GST_QUARK (DEST_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
   729       GST_QUARK (DEST_VALUE), G_TYPE_INT64, (gint64) - 1, NULL);
   703 
   730 
   704   query = gst_query_new (GST_QUERY_CONVERT, structure);
   731   query = gst_query_new (GST_QUERY_CONVERT, structure);
   705 
   732 
   706   return query;
   733   return query;
   707 }
   734 }
   731   structure = gst_query_get_structure (query);
   758   structure = gst_query_get_structure (query);
   732   gst_structure_id_set (structure,
   759   gst_structure_id_set (structure,
   733       GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
   760       GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
   734       GST_QUARK (SRC_VALUE), G_TYPE_INT64, src_value,
   761       GST_QUARK (SRC_VALUE), G_TYPE_INT64, src_value,
   735       GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
   762       GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
   736       GST_QUARK (DEST_VALUE), G_TYPE_INT64, dest_value, NULL);
   763       GST_QUARK (DEST_VALUE), G_TYPE_INT64, (gint64) dest_value, NULL);
   737 }
   764 }
   738 
   765 
   739 /**
   766 /**
   740  * gst_query_parse_convert:
   767  * gst_query_parse_convert:
   741  * @query: a #GstQuery
   768  * @query: a #GstQuery
   792 gst_query_new_segment (GstFormat format)
   819 gst_query_new_segment (GstFormat format)
   793 {
   820 {
   794   GstQuery *query;
   821   GstQuery *query;
   795   GstStructure *structure;
   822   GstStructure *structure;
   796 
   823 
   797   structure = gst_structure_id_new (GST_QUARK (QUERY_SEGMENT),
   824   structure = gst_structure_empty_new ("GstQuerySegment");
       
   825   gst_structure_id_set (structure,
   798       GST_QUARK (RATE), G_TYPE_DOUBLE, (gdouble) 0.0,
   826       GST_QUARK (RATE), G_TYPE_DOUBLE, (gdouble) 0.0,
   799       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   827       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   800       GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
   828       GST_QUARK (START_VALUE), G_TYPE_INT64, (gint64) - 1,
   801       GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
   829       GST_QUARK (STOP_VALUE), G_TYPE_INT64, (gint64) - 1, NULL);
   802 
   830 
   803   query = gst_query_new (GST_QUERY_SEGMENT, structure);
   831   query = gst_query_new (GST_QUERY_SEGMENT, structure);
   804 
   832 
   805   return query;
   833   return query;
   806 }
   834 }
   928 
   956 
   929   return query->structure;
   957   return query->structure;
   930 }
   958 }
   931 
   959 
   932 /**
   960 /**
   933  * gst_query_new_seeking:
   961  * gst_query_new_seeking (GstFormat *format)
   934  * @format: the default #GstFormat for the new query
   962  * @format: the default #GstFormat for the new query
   935  *
   963  *
   936  * Constructs a new query object for querying seeking properties of
   964  * Constructs a new query object for querying seeking properties of
   937  * the stream. 
   965  * the stream. 
   938  *
   966  *
   939  * Returns: A #GstQuery
   967  * Returns: A #GstQuery
   940  */
   968  */
   941 #ifdef __SYMBIAN32__
   969 #ifdef __SYMBIAN32__
   942 EXPORT_C
   970 EXPORT_C
   943 #endif
   971 #endif 
   944 
       
   945 GstQuery *
   972 GstQuery *
   946 gst_query_new_seeking (GstFormat format)
   973 gst_query_new_seeking (GstFormat format)
   947 {
   974 {
   948   GstQuery *query;
   975   GstQuery *query;
   949   GstStructure *structure;
   976   GstStructure *structure;
   950 
   977 
   951   structure = gst_structure_id_new (GST_QUARK (QUERY_SEEKING),
   978   structure = gst_structure_empty_new ("GstQuerySeeking");
       
   979   gst_structure_id_set (structure,
   952       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   980       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   953       GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, FALSE,
   981       GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, FALSE,
   954       GST_QUARK (SEGMENT_START), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
   982       GST_QUARK (SEGMENT_START), G_TYPE_INT64, (gint64) - 1,
   955       GST_QUARK (SEGMENT_END), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
   983       GST_QUARK (SEGMENT_END), G_TYPE_INT64, (gint64) - 1, NULL);
   956 
   984 
   957   query = gst_query_new (GST_QUERY_SEEKING, structure);
   985   query = gst_query_new (GST_QUERY_SEEKING, structure);
   958 
   986 
   959   return query;
   987   return query;
   960 }
   988 }
  1046 gst_query_new_formats (void)
  1074 gst_query_new_formats (void)
  1047 {
  1075 {
  1048   GstQuery *query;
  1076   GstQuery *query;
  1049   GstStructure *structure;
  1077   GstStructure *structure;
  1050 
  1078 
  1051   structure = gst_structure_id_empty_new (GST_QUARK (QUERY_FORMATS));
  1079   structure = gst_structure_new ("GstQueryFormats", NULL);
  1052   query = gst_query_new (GST_QUERY_FORMATS, structure);
  1080   query = gst_query_new (GST_QUERY_FORMATS, structure);
  1053 
  1081 
  1054   return query;
  1082   return query;
  1055 }
  1083 }
  1056 
  1084 
  1205       } else
  1233       } else
  1206         *format = GST_FORMAT_UNDEFINED;
  1234         *format = GST_FORMAT_UNDEFINED;
  1207     }
  1235     }
  1208   }
  1236   }
  1209 }
  1237 }
  1210 
       
  1211 /**
       
  1212  * gst_query_new_buffering
       
  1213  * @format: the default #GstFormat for the new query
       
  1214  *
       
  1215  * Constructs a new query object for querying the buffering status of
       
  1216  * a stream.
       
  1217  *
       
  1218  * Returns: A #GstQuery
       
  1219  *
       
  1220  * Since: 0.10.20
       
  1221  */
       
  1222 #ifdef __SYMBIAN32__
       
  1223 EXPORT_C
       
  1224 #endif
       
  1225 
       
  1226 GstQuery *
       
  1227 gst_query_new_buffering (GstFormat format)
       
  1228 {
       
  1229   GstQuery *query;
       
  1230   GstStructure *structure;
       
  1231 
       
  1232   /* by default, we configure the answer as no buffering with a 100% buffering
       
  1233    * progress */
       
  1234   structure = gst_structure_id_new (GST_QUARK (QUERY_BUFFERING),
       
  1235       GST_QUARK (BUSY), G_TYPE_BOOLEAN, FALSE,
       
  1236       GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, 100,
       
  1237       GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
       
  1238       GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
       
  1239       GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
       
  1240       GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (0),
       
  1241       GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
       
  1242       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
  1243       GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
       
  1244       GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
       
  1245 
       
  1246   query = gst_query_new (GST_QUERY_BUFFERING, structure);
       
  1247 
       
  1248   return query;
       
  1249 }
       
  1250 
       
  1251 /**
       
  1252  * gst_query_set_buffering_percent
       
  1253  * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
       
  1254  * @busy: if buffering is busy
       
  1255  * @percent: a buffering percent
       
  1256  *
       
  1257  * Set the percentage of buffered data. This is a value between 0 and 100.
       
  1258  * The @busy indicator is %TRUE when the buffering is in progress.
       
  1259  *
       
  1260  * Since: 0.10.20
       
  1261  */
       
  1262 #ifdef __SYMBIAN32__
       
  1263 EXPORT_C
       
  1264 #endif
       
  1265 
       
  1266 void
       
  1267 gst_query_set_buffering_percent (GstQuery * query, gboolean busy, gint percent)
       
  1268 {
       
  1269   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
       
  1270   g_return_if_fail (percent >= 0 && percent <= 100);
       
  1271 
       
  1272   gst_structure_id_set (query->structure,
       
  1273       GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy,
       
  1274       GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent, NULL);
       
  1275 }
       
  1276 
       
  1277 /**
       
  1278  * gst_query_parse_buffering_percent
       
  1279  * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
       
  1280  * @busy: if buffering is busy
       
  1281  * @percent: a buffering percent
       
  1282  *
       
  1283  * Get the percentage of buffered data. This is a value between 0 and 100.
       
  1284  * The @busy indicator is %TRUE when the buffering is in progress.
       
  1285  *
       
  1286  * Since: 0.10.20
       
  1287  */
       
  1288 #ifdef __SYMBIAN32__
       
  1289 EXPORT_C
       
  1290 #endif
       
  1291 
       
  1292 void
       
  1293 gst_query_parse_buffering_percent (GstQuery * query, gboolean * busy,
       
  1294     gint * percent)
       
  1295 {
       
  1296   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
       
  1297 
       
  1298   if (busy)
       
  1299     *busy = g_value_get_boolean (gst_structure_id_get_value (query->structure,
       
  1300             GST_QUARK (BUSY)));
       
  1301   if (percent)
       
  1302     *percent = g_value_get_int (gst_structure_id_get_value (query->structure,
       
  1303             GST_QUARK (BUFFER_PERCENT)));
       
  1304 }
       
  1305 
       
  1306 /**
       
  1307  * gst_query_set_buffering_stats:
       
  1308  * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
       
  1309  * @mode: a buffering mode 
       
  1310  * @avg_in: the average input rate
       
  1311  * @avg_out: the average output rate
       
  1312  * @buffering_left: amount of buffering time left
       
  1313  *
       
  1314  * Configures the buffering stats values in @query.
       
  1315  *
       
  1316  * Since: 0.10.20
       
  1317  */
       
  1318 #ifdef __SYMBIAN32__
       
  1319 EXPORT_C
       
  1320 #endif
       
  1321 
       
  1322 void
       
  1323 gst_query_set_buffering_stats (GstQuery * query, GstBufferingMode mode,
       
  1324     gint avg_in, gint avg_out, gint64 buffering_left)
       
  1325 {
       
  1326   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
       
  1327 
       
  1328   gst_structure_id_set (query->structure,
       
  1329       GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
       
  1330       GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
       
  1331       GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
       
  1332       GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
       
  1333 }
       
  1334 
       
  1335 /**
       
  1336  * gst_query_parse_buffering_stats:
       
  1337  * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
       
  1338  * @mode: a buffering mode 
       
  1339  * @avg_in: the average input rate
       
  1340  * @avg_out: the average output rate
       
  1341  * @buffering_left: amount of buffering time left
       
  1342  *
       
  1343  * Extracts the buffering stats values from @query.
       
  1344  *
       
  1345  * Since: 0.10.20
       
  1346  */
       
  1347 #ifdef __SYMBIAN32__
       
  1348 EXPORT_C
       
  1349 #endif
       
  1350 
       
  1351 void
       
  1352 gst_query_parse_buffering_stats (GstQuery * query,
       
  1353     GstBufferingMode * mode, gint * avg_in, gint * avg_out,
       
  1354     gint64 * buffering_left)
       
  1355 {
       
  1356   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
       
  1357 
       
  1358   if (mode)
       
  1359     *mode = g_value_get_enum (gst_structure_id_get_value (query->structure,
       
  1360             GST_QUARK (BUFFERING_MODE)));
       
  1361   if (avg_in)
       
  1362     *avg_in = g_value_get_int (gst_structure_id_get_value (query->structure,
       
  1363             GST_QUARK (AVG_IN_RATE)));
       
  1364   if (avg_out)
       
  1365     *avg_out = g_value_get_int (gst_structure_id_get_value (query->structure,
       
  1366             GST_QUARK (AVG_OUT_RATE)));
       
  1367   if (buffering_left)
       
  1368     *buffering_left =
       
  1369         g_value_get_int64 (gst_structure_id_get_value (query->structure,
       
  1370             GST_QUARK (BUFFERING_LEFT)));
       
  1371 }
       
  1372 
       
  1373 
       
  1374 /**
       
  1375  * gst_query_set_buffering_range:
       
  1376  * @query: a #GstQuery
       
  1377  * @format: the format to set for the @start and @stop values
       
  1378  * @start: the start to set
       
  1379  * @stop: the stop to set
       
  1380  * @estimated_total: estimated total amount of download time
       
  1381  *
       
  1382  * Set the available query result fields in @query. 
       
  1383  *
       
  1384  * Since: 0.10.20
       
  1385  */
       
  1386 #ifdef __SYMBIAN32__
       
  1387 EXPORT_C
       
  1388 #endif
       
  1389 
       
  1390 void
       
  1391 gst_query_set_buffering_range (GstQuery * query, GstFormat format,
       
  1392     gint64 start, gint64 stop, gint64 estimated_total)
       
  1393 {
       
  1394   GstStructure *structure;
       
  1395 
       
  1396   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
       
  1397 
       
  1398   structure = gst_query_get_structure (query);
       
  1399   gst_structure_id_set (structure,
       
  1400       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
  1401       GST_QUARK (START_VALUE), G_TYPE_INT64, start,
       
  1402       GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop,
       
  1403       GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, estimated_total, NULL);
       
  1404 }
       
  1405 
       
  1406 /**
       
  1407  * gst_query_parse_buffering_range:
       
  1408  * @query: a GST_QUERY_SEEKING type query #GstQuery
       
  1409  * @format: the format to set for the @segment_start and @segment_end values
       
  1410  * @start: the start to set
       
  1411  * @stop: the stop to set
       
  1412  * @estimated_total: estimated total amount of download time
       
  1413  *
       
  1414  * Parse an available query, writing the format into @format, and 
       
  1415  * other results into the passed parameters, if the respective parameters
       
  1416  * are non-NULL
       
  1417  *
       
  1418  * Since: 0.10.20
       
  1419  */
       
  1420 #ifdef __SYMBIAN32__
       
  1421 EXPORT_C
       
  1422 #endif
       
  1423 
       
  1424 void
       
  1425 gst_query_parse_buffering_range (GstQuery * query, GstFormat * format,
       
  1426     gint64 * start, gint64 * stop, gint64 * estimated_total)
       
  1427 {
       
  1428   GstStructure *structure;
       
  1429 
       
  1430   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
       
  1431 
       
  1432   structure = gst_query_get_structure (query);
       
  1433   if (format)
       
  1434     *format = g_value_get_enum (gst_structure_id_get_value (structure,
       
  1435             GST_QUARK (FORMAT)));
       
  1436   if (start)
       
  1437     *start = g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1438             GST_QUARK (START_VALUE)));
       
  1439   if (stop)
       
  1440     *stop = g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1441             GST_QUARK (STOP_VALUE)));
       
  1442   if (estimated_total)
       
  1443     *estimated_total =
       
  1444         g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1445             GST_QUARK (ESTIMATED_TOTAL)));
       
  1446 }
       
  1447 
       
  1448 /**
       
  1449  * gst_query_new_uri:
       
  1450  *
       
  1451  * Constructs a new query URI query object. Use gst_query_unref()
       
  1452  * when done with it. An URI query is used to query the current URI
       
  1453  * that is used by the source or sink.
       
  1454  *
       
  1455  * Returns: A #GstQuery
       
  1456  *
       
  1457  * Since: 0.10.22
       
  1458  */
       
  1459 #ifdef __SYMBIAN32__
       
  1460 EXPORT_C
       
  1461 #endif
       
  1462 
       
  1463 GstQuery *
       
  1464 gst_query_new_uri (void)
       
  1465 {
       
  1466   GstQuery *query;
       
  1467   GstStructure *structure;
       
  1468 
       
  1469   structure = gst_structure_id_new (GST_QUARK (QUERY_URI),
       
  1470       GST_QUARK (URI), G_TYPE_STRING, NULL, NULL);
       
  1471 
       
  1472   query = gst_query_new (GST_QUERY_URI, structure);
       
  1473 
       
  1474   return query;
       
  1475 }
       
  1476 
       
  1477 /**
       
  1478  * gst_query_set_uri:
       
  1479  * @query: a #GstQuery with query type GST_QUERY_URI
       
  1480  * @uri: the URI to set
       
  1481  *
       
  1482  * Answer a URI query by setting the requested URI.
       
  1483  *
       
  1484  * Since: 0.10.22
       
  1485  */
       
  1486 #ifdef __SYMBIAN32__
       
  1487 EXPORT_C
       
  1488 #endif
       
  1489 
       
  1490 void
       
  1491 gst_query_set_uri (GstQuery * query, const gchar * uri)
       
  1492 {
       
  1493   GstStructure *structure;
       
  1494 
       
  1495   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
       
  1496   g_return_if_fail (gst_uri_is_valid (uri));
       
  1497 
       
  1498   structure = gst_query_get_structure (query);
       
  1499   gst_structure_id_set (structure, GST_QUARK (URI), G_TYPE_STRING, uri, NULL);
       
  1500 }
       
  1501 
       
  1502 /**
       
  1503  * gst_query_parse_uri:
       
  1504  * @query: a #GstQuery
       
  1505  * @uri: the storage for the current URI (may be NULL)
       
  1506  *
       
  1507  * Parse an URI query, writing the URI into @uri as a newly
       
  1508  * allocated string, if the respective parameters are non-NULL.
       
  1509  * Free the string with g_free() after usage.
       
  1510  *
       
  1511  * Since: 0.10.22
       
  1512  */
       
  1513 #ifdef __SYMBIAN32__
       
  1514 EXPORT_C
       
  1515 #endif
       
  1516 
       
  1517 void
       
  1518 gst_query_parse_uri (GstQuery * query, gchar ** uri)
       
  1519 {
       
  1520   GstStructure *structure;
       
  1521 
       
  1522   g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
       
  1523 
       
  1524   structure = gst_query_get_structure (query);
       
  1525   if (uri)
       
  1526     *uri = g_value_dup_string (gst_structure_id_get_value (structure,
       
  1527             GST_QUARK (URI)));
       
  1528 }