Added CHANGES-0.9 doc, updated status of other docs.
[platform/upstream/gstreamer.git] / gst / gstquery.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *                    2005 Wim Taymans <wim@fluendo.com>
5  *
6  * gstquery.h: GstQuery API declaration
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24
25 #ifndef __GST_QUERY_H__
26 #define __GST_QUERY_H__
27
28 #include <glib.h>
29
30 #include <gst/gstiterator.h>
31 #include <gst/gstminiobject.h>
32 #include <gst/gststructure.h>
33 #include <gst/gstformat.h>
34
35 G_BEGIN_DECLS
36
37 typedef enum {
38   GST_QUERY_NONE = 0,
39   GST_QUERY_TOTAL, /* deprecated, use POSITION */
40   GST_QUERY_POSITION,
41   GST_QUERY_LATENCY,
42   GST_QUERY_JITTER, /* not in draft-query, necessary? */
43   GST_QUERY_START, /* deprecated, use SEEKING */
44   GST_QUERY_SEGMENT_END, /* deprecated, use SEEKING */
45   GST_QUERY_RATE, /* not in draft-query, necessary? */
46   GST_QUERY_SEEKING,
47   GST_QUERY_CONVERT,
48   GST_QUERY_FORMATS
49 } GstQueryType;
50
51 /* rate is relative to 1000000  */
52 #define GST_QUERY_TYPE_RATE_DEN          G_GINT64_CONSTANT (1000000)
53
54 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
55 typedef struct _GstQuery GstQuery;
56 typedef struct _GstQueryClass GstQueryClass;
57
58 struct _GstQueryTypeDefinition
59 {
60   GstQueryType   value;
61   gchar         *nick;
62   gchar         *description;
63 };
64
65 #ifdef G_HAVE_ISO_VARARGS
66 #define GST_QUERY_TYPE_FUNCTION(type, functionname, ...)        \
67 static const GstQueryType*                              \
68 functionname (type object)                              \
69 {                                                       \
70   static const GstQueryType types[] = {                 \
71     __VA_ARGS__,                                        \
72     0                                                   \
73   };                                                    \
74   return types;                                         \
75 }
76 #elif defined(G_HAVE_GNUC_VARARGS)
77 #define GST_QUERY_TYPE_FUNCTION(type, functionname, a...)       \
78 static const GstQueryType*                              \
79 functionname (type object)                              \
80 {                                                       \
81   static const GstQueryType types[] = {                 \
82     a,                                                  \
83     0                                                   \
84   };                                                    \
85   return types;                                         \
86 }
87 #endif
88
89 #define GST_TYPE_QUERY                          (gst_query_get_type())
90 #define GST_IS_QUERY(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
91 #define GST_IS_QUERY_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
92 #define GST_QUERY_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
93 #define GST_QUERY(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
94 #define GST_QUERY_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
95
96 #define GST_QUERY_TYPE(query)  (((GstQuery*)(query))->type)
97
98 struct _GstQuery
99 {
100   GstMiniObject mini_object;
101
102   /*< public > */
103   GstQueryType type;
104
105   GstStructure *structure;
106   
107   /*< private > */
108   gpointer _gst_reserved[GST_PADDING];
109 };
110
111 struct _GstQueryClass {
112   GstMiniObjectClass mini_object_class;
113 };
114
115 void            _gst_query_initialize          (void);
116 GType           gst_query_get_type             (void);
117
118 /* register a new query */
119 GstQueryType    gst_query_type_register        (const gchar *nick, 
120                                                 const gchar *description);
121 GstQueryType    gst_query_type_get_by_nick     (const gchar *nick);
122
123 /* check if a query is in an array of querys */
124 gboolean        gst_query_types_contains       (const GstQueryType *types,
125                                                 GstQueryType type);
126
127 /* query for query details */
128 G_CONST_RETURN GstQueryTypeDefinition*      
129                 gst_query_type_get_details         (GstQueryType type);
130 GstIterator*    gst_query_type_iterate_definitions (void);
131
132 /* refcounting */
133 #define         gst_query_ref(msg)              GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (msg)))
134 #define         gst_query_unref(msg)            gst_mini_object_unref (GST_MINI_OBJECT (msg))
135 /* copy query */
136 #define         gst_query_copy(msg)             GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (msg)))
137 #define         gst_query_make_writable(msg)    GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (msg)))
138
139 /* position query */
140 GstQuery*       gst_query_new_position          (GstFormat format);
141 void            gst_query_set_position          (GstQuery *query, GstFormat format,
142                                                  gint64 cur, gint64 end);
143 void            gst_query_parse_position        (GstQuery *query, GstFormat *format,
144                                                  gint64 *cur, gint64 *end);
145 /* convert query */
146 GstQuery*       gst_query_new_convert           (GstFormat src_fmt, gint64 value, GstFormat dest_fmt);
147 void            gst_query_set_convert           (GstQuery *query, GstFormat src_format, gint64 src_value,
148                                                  GstFormat dest_format, gint64 dest_value);
149 void            gst_query_parse_convert         (GstQuery *query, GstFormat *src_format, gint64 *src_value,
150                                                  GstFormat *dest_format, gint64 *dest_value);
151
152 /* application specific query */
153 GstQuery *      gst_query_new_application       (GstQueryType type,
154                                                  GstStructure *structure);
155
156
157 GstStructure *  gst_query_get_structure         (GstQuery *query);
158
159 G_END_DECLS
160
161 #endif /* __GST_QUERY_H__ */
162