Merge branch 'upstream/1.16' into tizen_gst_1.16.2
[platform/upstream/gstreamer.git] / gst / gstquery.c
index 1a82747..6c2147d 100644 (file)
@@ -62,6 +62,9 @@
 #include "gstquark.h"
 #include "gsturi.h"
 #include "gstbufferpool.h"
+#ifdef TIZEN_PROFILE_TV
+#include <stdio.h>
+#endif
 
 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
 #define GST_CAT_DEFAULT gst_query_debug
@@ -106,7 +109,9 @@ static GstQueryQuarks query_quarks[] = {
   {GST_QUERY_DRAIN, "drain", 0},
   {GST_QUERY_CONTEXT, "context", 0},
   {GST_QUERY_BITRATE, "bitrate", 0},
-
+#ifdef TIZEN_PROFILE_TV
+  {GST_QUERY_RESOURCE, "resource", 0},
+#endif
   {0, NULL, 0}
 };
 
@@ -583,6 +588,66 @@ gst_query_new_segment (GstFormat format)
   return query;
 }
 
+#ifdef TIZEN_PROFILE_TV
+/**
+ * gst_query_new_resource:
+ * @resources: pointer to store the resources
+ *
+ * Constructs a new query stream position query object. Use
+ * gst_query_unref()
+ * when done with it. A resource query is used to query the resources used
+ * by the element/bin/pipelein
+ *
+ * Free-function: gst_query_unref
+ *
+ * Returns: (transfer full): a new #GstQuery
+ */
+GstQuery *
+gst_query_new_resource (gchar * resources)
+{
+  GstQuery *query;
+  GstStructure *structure;
+
+  structure = gst_structure_new_id (GST_QUARK (QUERY_RESOURCE),
+      GST_QUARK (QUERY_RESOURCE), G_TYPE_POINTER, resources, NULL);
+
+  query = gst_query_new_custom (GST_QUERY_RESOURCE, structure);
+
+  return query;
+}
+
+/**
+ * gst_query_add_resource:
+ * @query: a #GstQuery
+ * @resource: resource data to add
+ */
+void
+gst_query_add_resource (GstQuery * query, gint resource_id)
+{
+  gchar *resource_info;
+  resource_info = gst_query_parse_resource (query);
+  sprintf (resource_info, "%d", resource_id);
+}
+
+/* gst_query_parse_resources:
+ * @query: a #GstQuery
+ * @resources: (out)  the storage for the resource
+ *   value, or NULL.
+ */
+gchar *
+gst_query_parse_resource (GstQuery * query)
+{
+  GstStructure *structure;
+  void *resources;
+  g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_RESOURCE, NULL);
+
+  structure = GST_QUERY_STRUCTURE (query);
+  resources = g_value_get_pointer (gst_structure_id_get_value (structure,
+          GST_QUARK (QUERY_RESOURCE)));
+  return resources;
+}
+#endif
+
 /**
  * gst_query_set_segment:
  * @query: a #GstQuery