add GST_QUERY_RESOURCE and interface functions 87/85187/6
authorYounghwan <younghwan_.an@samsung.com>
Wed, 24 Aug 2016 06:27:27 +0000 (15:27 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Fri, 2 Sep 2016 01:49:28 +0000 (10:49 +0900)
so, can query an element for using HW resource

Change-Id: I086ce486da448c018b0285f00713a2e0d84b5e78

gst/gstquark.c
gst/gstquark.h
gst/gstquery.c
gst/gstquery.h
gst/gstutils.c
gst/gstutils.h
packaging/gstreamer.spec

index cf5c766..73a4af1 100644 (file)
@@ -71,6 +71,9 @@ static const gchar *_quark_strings[] = {
   "GstMessageStreamStart", "group-id", "uri-redirection",
   "GstMessageDeviceAdded", "GstMessageDeviceRemoved", "device",
   "uri-redirection-permanent"
+#ifdef GST_TIZEN_TV
+  ,"GstQuarkQueryResource"
+#endif
 };
 
 GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index b8daeb0..ba44fd0 100644 (file)
@@ -202,7 +202,12 @@ typedef enum _GstQuarkId
   GST_QUARK_MESSAGE_DEVICE_REMOVED = 171,
   GST_QUARK_DEVICE = 172,
   GST_QUARK_URI_REDIRECTION_PERMANENT = 173,
+#ifndef GST_TIZEN_TV
   GST_QUARK_MAX = 174
+#else
+  GST_QUARK_QUERY_RESOURCE = 174,
+  GST_QUARK_MAX = 175
+#endif
 } GstQuarkId;
 
 extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index 2828bd5..53143ba 100644 (file)
@@ -61,6 +61,9 @@
 #include "gstquark.h"
 #include "gsturi.h"
 #include "gstbufferpool.h"
+#ifdef GST_TIZEN_TV
+#include <stdio.h>
+#endif
 
 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
 #define GST_CAT_DEFAULT gst_query_debug
@@ -104,7 +107,9 @@ static GstQueryQuarks query_quarks[] = {
   {GST_QUERY_CAPS, "caps", 0},
   {GST_QUERY_DRAIN, "drain", 0},
   {GST_QUERY_CONTEXT, "context", 0},
-
+#ifdef GST_TIZEN_TV
+  {GST_QUERY_RESOURCE, "resource", 0},
+#endif
   {0, NULL, 0}
 };
 
@@ -578,6 +583,66 @@ gst_query_new_segment (GstFormat format)
   return query;
 }
 
+#ifdef GST_TIZEN_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_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_RESOURCE);
+
+  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
index 18a075c..3902f71 100644 (file)
@@ -129,6 +129,9 @@ typedef enum {
   GST_QUERY_CAPS         = GST_QUERY_MAKE_TYPE (170, FLAG(BOTH)),
   GST_QUERY_DRAIN        = GST_QUERY_MAKE_TYPE (180, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)),
   GST_QUERY_CONTEXT      = GST_QUERY_MAKE_TYPE (190, FLAG(BOTH))
+#ifdef GST_TIZEN_TV
+  ,GST_QUERY_RESOURCE    = GST_QUERY_MAKE_TYPE (200, FLAG (BOTH))
+#endif
 } GstQueryType;
 #undef FLAG
 
@@ -316,6 +319,13 @@ GstQuery*       gst_query_new_duration          (GstFormat format) G_GNUC_MALLOC
 void            gst_query_set_duration          (GstQuery *query, GstFormat format, gint64 duration);
 void            gst_query_parse_duration        (GstQuery *query, GstFormat *format, gint64 *duration);
 
+#ifdef GST_TIZEN_TV
+/* resrource query */
+GstQuery*      gst_query_new_resource          (gchar * resources) G_GNUC_MALLOC;
+void           gst_query_add_resource          (GstQuery * query, gint resource_id);
+gchar*         gst_query_parse_resource        (GstQuery * query);
+#endif
+
 /* latency query */
 GstQuery*       gst_query_new_latency           (void) G_GNUC_MALLOC;
 void            gst_query_set_latency           (GstQuery *query, gboolean live, GstClockTime min_latency,
index 076de1c..f01c044 100644 (file)
@@ -40,6 +40,9 @@
 #include "gst-i18n-lib.h"
 #include "glib-compat-private.h"
 #include <math.h>
+#ifdef GST_TIZEN_TV
+#include "gstchildproxy.h"
+#endif
 
 /**
  * gst_util_dump_mem:
@@ -3951,3 +3954,69 @@ gst_util_group_id_next (void)
   static gint counter = 0;
   return g_atomic_int_add (&counter, 1);
 }
+
+#ifdef GST_TIZEN_TV
+/**
+ * gst_element_query_resource
+ * @element: (in) a #GstElement to invoke the resource query on.
+ * @resources: (out): a pointer to the list of resources asked for.
+ * Returns: TRUE if the query could be performed.
+ */
+gboolean
+gst_element_query_resource (GstElement * element, GList ** resource_list)
+{
+  GstQuery *query;
+  gboolean ret;
+  char resources[250];
+  char *element_resource;
+  guint count = 0, i = 0;
+  GstObject *object;
+  int resource_num;
+
+  if (resource_list == NULL) {
+    return FALSE;
+  }
+
+  query = gst_query_new_resource (resources);
+  if (GST_IS_BIN (element)) {
+    count = gst_child_proxy_get_children_count ((GstChildProxy *)element);
+    for (i = 0; i < count; i++) {
+      if (!(object = gst_child_proxy_get_child_by_index ((GstChildProxy *)element, i)))
+        continue;
+
+      if (GST_IS_BIN (object)) {
+        ret = gst_element_query_resource ((GstElement *)object, resource_list);
+        gst_object_unref (object);
+        continue;
+      }
+
+      ret = gst_element_query ((GstElement *) object, query);
+      if (ret) {
+        element_resource = gst_query_parse_resource (query);
+        resource_num = (int) atoi (element_resource);
+        GST_DEBUG_OBJECT (element,
+            "\n resource ID received after query is :%d\n", resource_num);
+        if (NULL == (g_list_find (*resource_list, (gconstpointer)resource_num))) {
+          *resource_list =
+              g_list_append (*resource_list, GINT_TO_POINTER (resource_num));
+        }
+      }
+      gst_object_unref (object);
+    }
+  } else {
+    ret = gst_element_query ((GstElement *) element, query);
+    if (ret) {
+      element_resource = gst_query_parse_resource (query);
+      resource_num = (int) atoi (element_resource);
+      GST_DEBUG_OBJECT (element, "\n resource ID received after query is :%d\n",
+          resource_num);
+      if (NULL == (g_list_find (*resource_list, (gconstpointer)resource_num))) {
+        *resource_list =
+            g_list_append (*resource_list, GINT_TO_POINTER (resource_num));
+      }
+    }
+  }
+  gst_query_unref (query);
+  return TRUE;
+}
+#endif
index 186f439..7d0bbd7 100644 (file)
@@ -948,6 +948,10 @@ gboolean                gst_element_query_position      (GstElement *element, Gs
 gboolean                gst_element_query_duration      (GstElement *element, GstFormat format, gint64 *duration);
 gboolean                gst_element_query_convert       (GstElement *element, GstFormat src_format, gint64 src_val,
                                                          GstFormat dest_format, gint64 *dest_val);
+#ifdef GST_TIZEN_TV
+gboolean                gst_element_query_resource     (GstElement *element, GList **resource_list);
+#endif
+
 
 /* pad functions */
 void                    gst_pad_use_fixed_caps          (GstPad *pad);
index ac2b720..cbd3772 100644 (file)
@@ -72,6 +72,9 @@ export CFLAGS="%{optflags} \
        -DGST_BASEPARSE_MODIFICATION\
        -DGST_QUEUE_MODIFICATION\
        -DGST_MQ_MODIFICATION\
+%if "%{?profile}" == "tv"
+       -DGST_TIZEN_TV\
+%endif
        -fno-strict-aliasing"
 
 %configure\