Revert "gst/parse: define pure-parser depending on bison version"
[platform/upstream/gstreamer.git] / gst / gstquery.c
index 30180cf..1a82747 100644 (file)
@@ -105,6 +105,7 @@ static GstQueryQuarks query_quarks[] = {
   {GST_QUERY_CAPS, "caps", 0},
   {GST_QUERY_DRAIN, "drain", 0},
   {GST_QUERY_CONTEXT, "context", 0},
+  {GST_QUERY_BITRATE, "bitrate", 0},
 
   {0, NULL, 0}
 };
@@ -195,6 +196,9 @@ _gst_query_free (GstQuery * query)
     gst_structure_set_parent_refcount (s, NULL);
     gst_structure_free (s);
   }
+#ifdef USE_POISONING
+  memset (query, 0xff, sizeof (GstQueryImpl));
+#endif
 
   g_slice_free1 (sizeof (GstQueryImpl), query);
 }
@@ -663,7 +667,7 @@ gst_query_parse_segment (GstQuery * query, gdouble * rate, GstFormat * format,
  *
  * Free-function: gst_query_unref()
  *
- * Returns: (transfer full): a new #GstQuery
+ * Returns: (transfer full) (nullable): a new #GstQuery
  */
 GstQuery *
 gst_query_new_custom (GstQueryType type, GstStructure * structure)
@@ -993,7 +997,7 @@ gst_query_parse_n_formats (GstQuery * query, guint * n_formats)
 /**
  * gst_query_parse_nth_format:
  * @query: a #GstQuery
- * @nth: (out): the nth format to retrieve.
+ * @nth: the nth format to retrieve.
  * @format: (out) (allow-none): a pointer to store the nth format
  *
  * Parse the format query and retrieve the @nth format from it into
@@ -2389,7 +2393,7 @@ gst_query_set_accept_caps_result (GstQuery * query, gboolean result)
 /**
  * gst_query_parse_accept_caps_result:
  * @query: a GST_QUERY_ACCEPT_CAPS type query #GstQuery
- * @result: location for the result
+ * @result: (out) (allow-none): location for the result
  *
  * Parse the result from @query and store in @result.
  */
@@ -2651,3 +2655,75 @@ gst_query_parse_context_type (GstQuery * query, const gchar ** context_type)
 
   return TRUE;
 }
+
+/**
+ * gst_query_new_bitrate:
+ *
+ * Constructs a new query object for querying the bitrate.
+ *
+ * Free-function: gst_query_unref()
+ *
+ * Returns: (transfer full): a new #GstQuery
+ *
+ * Since: 1.16
+ */
+GstQuery *
+gst_query_new_bitrate (void)
+{
+  GstQuery *query;
+  GstStructure *structure;
+
+  structure = gst_structure_new_id_empty (GST_QUARK (QUERY_BITRATE));
+  query = gst_query_new_custom (GST_QUERY_BITRATE, structure);
+
+  return query;
+}
+
+/**
+ * gst_query_set_bitrate:
+ * @query: a GST_QUERY_BITRATE type #GstQuery
+ * @nominal_bitrate: the nominal bitrate in bits per second
+ *
+ * Set the results of a bitrate query.  The nominal bitrate is the average
+ * bitrate expected over the length of the stream as advertised in file
+ * headers (or similar).
+ *
+ * Since: 1.16
+ */
+void
+gst_query_set_bitrate (GstQuery * query, guint nominal_bitrate)
+{
+  GstStructure *s;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BITRATE);
+
+  s = GST_QUERY_STRUCTURE (query);
+
+  gst_structure_id_set (s,
+      GST_QUARK (NOMINAL_BITRATE), G_TYPE_UINT, nominal_bitrate, NULL);
+}
+
+/**
+ * gst_query_parse_bitrate:
+ * @query: a GST_QUERY_BITRATE type #GstQuery
+ * @nominal_bitrate: (out) (allow-none): The resulting bitrate in bits per second
+ *
+ * Get the results of a bitrate query. See also gst_query_set_bitrate().
+ *
+ * Since: 1.16
+ */
+void
+gst_query_parse_bitrate (GstQuery * query, guint * nominal_bitrate)
+{
+  GstStructure *structure;
+  const GValue *value;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BITRATE);
+
+  structure = GST_QUERY_STRUCTURE (query);
+
+  if (nominal_bitrate) {
+    value = gst_structure_id_get_value (structure, GST_QUARK (NOMINAL_BITRATE));
+    *nominal_bitrate = g_value_get_uint (value);
+  }
+}