Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst / gstquery.h
index f77c0c7..96c5506 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
  *                    2000 Wim Taymans <wim.taymans@chello.be>
  *                    2005 Wim Taymans <wim@fluendo.com>
+ *                    2011 Wim Taymans <wim.taymans@gmail.com>
  *
  * gstquery.h: GstQuery API declaration
  *
@@ -31,6 +32,7 @@
 #include <gst/gstminiobject.h>
 #include <gst/gststructure.h>
 #include <gst/gstformat.h>
+#include <gst/gstpad.h>
 
 G_BEGIN_DECLS
 
@@ -51,6 +53,8 @@ G_BEGIN_DECLS
  * @GST_QUERY_CUSTOM: a custom application or element defined query. Since
  * 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
  */
@@ -69,7 +73,9 @@ typedef enum {
   GST_QUERY_FORMATS,
   GST_QUERY_BUFFERING,
   GST_QUERY_CUSTOM,
-  GST_QUERY_URI
+  GST_QUERY_URI,
+  GST_QUERY_ALLOCATION,
+  GST_QUERY_SCHEDULING
 } GstQueryType;
 
 /**
@@ -90,7 +96,6 @@ typedef enum {
 
 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
 typedef struct _GstQuery GstQuery;
-typedef struct _GstQueryClass GstQueryClass;
 
 /**
  * GstQueryTypeDefinition:
@@ -109,13 +114,10 @@ struct _GstQueryTypeDefinition
   GQuark         quark;
 };
 
-#define GST_TYPE_QUERY                          (gst_query_get_type())
-#define GST_IS_QUERY(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
-#define GST_IS_QUERY_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
-#define GST_QUERY_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
-#define GST_QUERY(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
-#define GST_QUERY_CAST(obj)                    ((GstQuery*)(obj)) /* only since 0.10.23 */
-#define GST_QUERY_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
+#define GST_TYPE_QUERY                         (gst_query_get_type())
+#define GST_IS_QUERY(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
+#define GST_QUERY_CAST(obj)                    ((GstQuery*)(obj))
+#define GST_QUERY(obj)                         (GST_QUERY_CAST(obj))
 
 
 /**
@@ -141,7 +143,6 @@ struct _GstQueryTypeDefinition
  * GstQuery:
  * @mini_object: The parent #GstMiniObject type
  * @type: the #GstQueryType
- * @structure: the #GstStructure containing the query details.
  *
  * The #GstQuery structure.
  */
@@ -151,18 +152,6 @@ struct _GstQuery
 
   /*< public > *//* with COW */
   GstQueryType type;
-
-  GstStructure *structure;
-
-  /*< private >*/
-  gpointer _gst_reserved;
-};
-
-struct _GstQueryClass {
-  GstMiniObjectClass mini_object_class;
-
-  /*< private >*/
-  gpointer _gst_reserved[GST_PADDING];
 };
 
 const gchar*    gst_query_type_get_name        (GstQueryType query);
@@ -243,6 +232,13 @@ gst_query_copy (const GstQuery * q)
 }
 
 /**
+ * gst_query_is_writable:
+ * @q: a #GstQuery
+ *
+ * Tests if you can safely write data into a query's structure.
+ */
+#define         gst_query_is_writable(q)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (q))
+/**
  * gst_query_make_writable:
  * @q: (transfer full): a #GstQuery to make writable
  *
@@ -251,6 +247,29 @@ gst_query_copy (const GstQuery * q)
  * Returns: (transfer full): a new writable query (possibly same as @q)
  */
 #define         gst_query_make_writable(q)      GST_QUERY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (q)))
+/**
+ * gst_query_replace:
+ * @old_query: (inout) (transfer full): pointer to a pointer to a #GstQuery
+ *     to be replaced.
+ * @new_query: (allow-none) (transfer none): pointer to a #GstQuery that will
+ *     replace the query pointed to by @old_query.
+ *
+ * Modifies a pointer to a #GstQuery to point to a different #GstQuery. The
+ * modification is done atomically (so this is useful for ensuring thread safety
+ * in some cases), and the reference counts are updated appropriately (the old
+ * query is unreffed, the new one is reffed).
+ *
+ * Either @new_query or the #GstQuery pointed to by @old_query may be NULL.
+ */
+#define         gst_query_replace(old_query,new_query) \
+    gst_mini_object_replace ((GstMiniObject **)(old_query), GST_MINI_OBJECT_CAST (new_query))
+
+
+/* application specific query */
+GstQuery *      gst_query_new_custom            (GstQueryType type, GstStructure *structure);
+const GstStructure *
+                gst_query_get_structure         (GstQuery *query);
+GstStructure *  gst_query_writable_structure    (GstQuery *query);
 
 /* position query */
 GstQuery*       gst_query_new_position          (GstFormat format);
@@ -282,11 +301,6 @@ void            gst_query_set_segment           (GstQuery *query, gdouble rate,
 void            gst_query_parse_segment         (GstQuery *query, gdouble *rate, GstFormat *format,
                                                  gint64 *start_value, gint64 *stop_value);
 
-/* application specific query */
-GstQuery *      gst_query_new_application       (GstQueryType type,
-                                                 GstStructure *structure);
-GstStructure *  gst_query_get_structure         (GstQuery *query);
-
 /* seeking query */
 GstQuery*       gst_query_new_seeking           (GstFormat format);
 void            gst_query_set_seeking           (GstQuery *query, GstFormat format,
@@ -301,8 +315,8 @@ void            gst_query_parse_seeking         (GstQuery *query, GstFormat *for
 GstQuery*       gst_query_new_formats           (void);
 void            gst_query_set_formats           (GstQuery *query, gint n_formats, ...);
 void            gst_query_set_formatsv          (GstQuery *query, gint n_formats, const GstFormat *formats);
-void            gst_query_parse_formats_length  (GstQuery *query, guint *n_formats);
-void            gst_query_parse_formats_nth     (GstQuery *query, guint nth, GstFormat *format);
+void            gst_query_parse_n_formats       (GstQuery *query, guint *n_formats);
+void            gst_query_parse_nth_format      (GstQuery *query, guint nth, GstFormat *format);
 
 /* buffering query */
 GstQuery*       gst_query_new_buffering           (GstFormat format);
@@ -322,11 +336,10 @@ void            gst_query_set_buffering_range     (GstQuery *query, GstFormat fo
 void            gst_query_parse_buffering_range   (GstQuery *query, GstFormat *format,
                                                    gint64 *start, gint64 *stop,
                                                    gint64 *estimated_total);
-gboolean        gst_query_add_buffering_range     (GstQuery *query,
-                                                   gint64 start, gint64 stop);
-
-guint           gst_query_get_n_buffering_ranges  (GstQuery *query);
 
+gboolean        gst_query_add_buffering_range       (GstQuery *query,
+                                                     gint64 start, gint64 stop);
+guint           gst_query_get_n_buffering_ranges    (GstQuery *query);
 gboolean        gst_query_parse_nth_buffering_range (GstQuery *query,
                                                      guint index, gint64 *start,
                                                      gint64 *stop);
@@ -336,6 +349,35 @@ GstQuery *      gst_query_new_uri                 (void);
 void            gst_query_parse_uri               (GstQuery *query, gchar **uri);
 void            gst_query_set_uri                 (GstQuery *query, const gchar *uri);
 
+/* allocation query */
+GstQuery *      gst_query_new_allocation          (GstCaps *caps, gboolean need_pool);
+void            gst_query_parse_allocation        (GstQuery *query, GstCaps **caps, gboolean *need_pool);
+
+void            gst_query_set_allocation_params   (GstQuery *query, guint size, guint min_buffers,
+                                                   guint max_buffers, guint prefix, guint alignment,
+                                                   GstBufferPool *pool);
+void            gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers,
+                                                   guint *max_buffers, guint *prefix, guint *alignment,
+                                                   GstBufferPool **pool);
+
+void            gst_query_add_allocation_meta       (GstQuery *query, const gchar *api);
+guint           gst_query_get_n_allocation_metas    (GstQuery *query);
+const gchar *   gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
+
+void            gst_query_add_allocation_memory       (GstQuery *query, const gchar *alloc);
+guint           gst_query_get_n_allocation_memories   (GstQuery *query);
+const gchar *   gst_query_parse_nth_allocation_memory (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
 
 #endif /* __GST_QUERY_H__ */