query: add SCHEDULING query
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 24 May 2011 10:52:09 +0000 (12:52 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 24 May 2011 15:39:56 +0000 (17:39 +0200)
Add a new query to replace the checkgetrange function.

docs/design/part-scheduling.txt
gst/gstquark.c
gst/gstquark.h
gst/gstquery.c
gst/gstquery.h

index 3e17340..e546130 100644 (file)
@@ -52,6 +52,38 @@ The getrange function
 The getrange function is called when a peer pad performs a _pull_range() on the pad. This
 downstream pad can be a pulling element or another _pull_range() based element.
 
+
+Scheduling Query
+~~~~~~~~~~~~~~~~
+
+A sinkpad can ask the upstream srcpad for its scheduling attributes. It does
+this with the SCHEDULING query.
+
+
+ (out) "pull-mode", G_TYPE_BOOLEAN (default FALSE)
+       - if the pad can operate in pull mode, if this flag is not set the pad
+         will operate in push mode.
+
+ (out) "random-access", G_TYPE_BOOLEAN (default FALSE)
+       - the offset of a pull operation can be specified, if this flag is false,
+         the offset should be -1,
+
+ (out) "sequential", G_TYPE_BOOLEAN (default TRUE)
+       - suggest sequential access to the data. If random-access is specified,
+         seeks are allowed but should be avoided. This is common for network
+         streams. (
+
+ (out) "minsize", G_TYPE_INT (default 1)
+       - the suggested minimum size of pull requests
+
+ (out) "maxsize", G_TYPE_INT (default -1, unlimited)
+       - the suggested maximum size of pull requests
+
+ (out) "align", G_TYPE_INT (default 1)
+       - the suggested alignment for the pull requests.
+
+
+
 Plug-in techniques
 ~~~~~~~~~~~~~~~~~~
 
index 326d43e..360c644 100644 (file)
@@ -53,8 +53,8 @@ static const gchar *_quark_strings[] = {
   "code", "text", "percent", "timeout", "GstBufferPoolConfig", "caps", "size",
   "min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
   "GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
-  "GstEventReconfigure",
-  "segment"
+  "GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
+  "random-access", "sequential"
 };
 
 GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index 137e406..b671922 100644 (file)
@@ -148,8 +148,12 @@ typedef enum _GstQuarkId
   GST_QUARK_EVENT_CAPS = 119,
   GST_QUARK_EVENT_RECONFIGURE = 120,
   GST_QUARK_SEGMENT = 121,
+  GST_QUARK_QUERY_SCHEDULING = 122,
+  GST_QUARK_PULL_MODE = 123,
+  GST_QUARK_RANDOM_ACCESS = 124,
+  GST_QUARK_SEQUENTIAL = 125,
 
-  GST_QUARK_MAX = 122
+  GST_QUARK_MAX = 126
 } GstQuarkId;
 
 extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index 37692c2..ad31fb0 100644 (file)
@@ -1757,3 +1757,93 @@ gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
   }
   return ret;
 }
+
+/**
+ * gst_query_new_scheduling
+ *
+ * Constructs a new query object for querying the scheduling properties.
+ *
+ * Free-function: gst_query_unref
+ *
+ * Returns: (transfer full): a new #GstQuery
+ */
+GstQuery *
+gst_query_new_scheduling (void)
+{
+  GstQuery *query;
+  GstStructure *structure;
+
+  structure = gst_structure_id_new (GST_QUARK (QUERY_SCHEDULING),
+      GST_QUARK (PULL_MODE), G_TYPE_BOOLEAN, FALSE,
+      GST_QUARK (RANDOM_ACCESS), G_TYPE_BOOLEAN, FALSE,
+      GST_QUARK (SEQUENTIAL), G_TYPE_BOOLEAN, TRUE,
+      GST_QUARK (MINSIZE), G_TYPE_INT, 1,
+      GST_QUARK (MAXSIZE), G_TYPE_INT, -1,
+      GST_QUARK (ALIGN), G_TYPE_INT, 1, NULL);
+  query = gst_query_new (GST_QUERY_SCHEDULING, structure);
+
+  return query;
+}
+
+/**
+ * gst_query_set_scheduling
+ * @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
+ * @pull_mode: if pull mode scheduling is supported
+ * @random_access: if random access is possible
+ * @sequential: if sequential access is recommended
+ * @minsize: the suggested minimum size of pull requests
+ * @maxsize the suggested maximum size of pull requests:
+ * @align: the suggested alignment of pull requests
+ *
+ * Set the scheduling properties.
+ */
+void
+gst_query_set_scheduling (GstQuery * query, gboolean pull_mode,
+    gboolean random_access, gboolean sequential,
+    gint minsize, gint maxsize, gint align)
+{
+  GstStructure *structure;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
+  g_return_if_fail (gst_query_is_writable (query));
+
+  structure = GST_QUERY_STRUCTURE (query);
+  gst_structure_id_set (structure,
+      GST_QUARK (PULL_MODE), G_TYPE_BOOLEAN, pull_mode,
+      GST_QUARK (RANDOM_ACCESS), G_TYPE_BOOLEAN, random_access,
+      GST_QUARK (SEQUENTIAL), G_TYPE_BOOLEAN, sequential,
+      GST_QUARK (MINSIZE), G_TYPE_INT, minsize,
+      GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
+      GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
+}
+
+/**
+ * gst_query_parse_scheduling
+ * @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
+ * @pull_mode: if pull mode scheduling is supported
+ * @random_access: if random access is possible
+ * @sequential: if sequential access is recommended
+ * @minsize: the suggested minimum size of pull requests
+ * @maxsize the suggested maximum size of pull requests:
+ * @align: the suggested alignment of pull requests
+ *
+ * Set the scheduling properties.
+ */
+void
+gst_query_parse_scheduling (GstQuery * query, gboolean * pull_mode,
+    gboolean * random_access, gboolean * sequential,
+    gint * minsize, gint * maxsize, gint * align)
+{
+  GstStructure *structure;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
+
+  structure = GST_QUERY_STRUCTURE (query);
+  gst_structure_id_get (structure,
+      GST_QUARK (PULL_MODE), G_TYPE_BOOLEAN, pull_mode,
+      GST_QUARK (RANDOM_ACCESS), G_TYPE_BOOLEAN, random_access,
+      GST_QUARK (SEQUENTIAL), G_TYPE_BOOLEAN, sequential,
+      GST_QUARK (MINSIZE), G_TYPE_INT, minsize,
+      GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
+      GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
+}
index 0837d8a..4b0a2e2 100644 (file)
@@ -54,6 +54,7 @@ G_BEGIN_DECLS
  * 0.10.22.
  * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
  * @GST_QUERY_ALLOCATION: the buffer allocation properties
+ * @GST_QUERY_SCHEDULING: the scheduling properties
  *
  * Standard predefined Query types
  */
@@ -73,7 +74,8 @@ typedef enum {
   GST_QUERY_BUFFERING,
   GST_QUERY_CUSTOM,
   GST_QUERY_URI,
-  GST_QUERY_ALLOCATION
+  GST_QUERY_ALLOCATION,
+  GST_QUERY_SCHEDULING
 } GstQueryType;
 
 /**
@@ -363,6 +365,15 @@ void            gst_query_add_allocation_meta       (GstQuery *query, const gcha
 guint           gst_query_get_n_allocation_metas    (GstQuery *query);
 const gchar *   gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
 
+/* scheduling query */
+GstQuery *      gst_query_new_scheduling          (void);
+
+void            gst_query_set_scheduling          (GstQuery *query, gboolean pull_mode,
+                                                   gboolean random_access, gboolean sequential,
+                                                   gint minsize, gint maxsize, gint align);
+void            gst_query_parse_scheduling        (GstQuery *query, gboolean *pull_mode,
+                                                   gboolean *random_access, gboolean *sequential,
+                                                   gint *minsize, gint *maxsize, gint *align);
 
 G_END_DECLS