gst/gstquery.h: Fix typo.
[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 /**
38  * GstQueryType:
39  * @GST_QUERY_NONE: invalid query type
40  * @GST_QUERY_POSITION: current position in stream
41  * @GST_QUERY_DURATION: total duration of the stream
42  * @GST_QUERY_LATENCY: latency of stream
43  * @GST_QUERY_JITTER: current jitter of stream
44  * @GST_QUERY_RATE: current rate of the stream
45  * @GST_QUERY_SEEKING: seeking capabilities
46  * @GST_QUERY_SEGMENT: segment start/stop positions
47  * @GST_QUERY_CONVERT: convert values between formats
48  * @GST_QUERY_FORMATS: query supported formats for convert
49  * @GST_QUERY_BUFFERING: query available media for efficient seeking. Since
50  * 0.10.20.
51  *
52  * Standard predefined Query types
53  */
54 /* NOTE: don't forget to update the table in gstquery.c when changing
55  * this enum */
56 typedef enum {
57   GST_QUERY_NONE = 0,
58   GST_QUERY_POSITION,
59   GST_QUERY_DURATION,
60   GST_QUERY_LATENCY,
61   GST_QUERY_JITTER,     /* not in draft-query, necessary? */
62   GST_QUERY_RATE,
63   GST_QUERY_SEEKING,
64   GST_QUERY_SEGMENT,
65   GST_QUERY_CONVERT,
66   GST_QUERY_FORMATS,
67   GST_QUERY_BUFFERING
68 } GstQueryType;
69
70 /**
71  * GstBufferingMode:
72  * @GST_BUFFERING_STREAM: a small amount of data is buffered
73  * @GST_BUFFERING_DOWNLOAD: the stream is being downloaded
74  * @GST_BUFFERING_TIMESHIFT: the stream is being downloaded in a ringbuffer
75  * @GST_BUFFERING_LIVE: the stream is a live stream
76  *
77  * The different types of buffering methods.
78  */
79 typedef enum {
80   GST_BUFFERING_STREAM,
81   GST_BUFFERING_DOWNLOAD,
82   GST_BUFFERING_TIMESHIFT,
83   GST_BUFFERING_LIVE
84 } GstBufferingMode;
85
86 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
87 typedef struct _GstQuery GstQuery;
88 typedef struct _GstQueryClass GstQueryClass;
89
90 /**
91  * GstQueryTypeDefinition:
92  * @value: the unique id of the Query type
93  * @nick: a short nick
94  * @description: a longer description of the query type
95  * @quark: the quark for the nick
96  *
97  * A Query Type definition
98  */
99 struct _GstQueryTypeDefinition
100 {
101   GstQueryType   value;
102   gchar         *nick;
103   gchar         *description;
104   GQuark         quark;
105 };
106
107 #define GST_TYPE_QUERY                          (gst_query_get_type())
108 #define GST_IS_QUERY(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
109 #define GST_IS_QUERY_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
110 #define GST_QUERY_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
111 #define GST_QUERY(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
112 #define GST_QUERY_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
113
114 /**
115  * GST_QUERY_TYPE:
116  * @query: the query to query
117  *
118  * Get the #GstQueryType of the query.
119  */
120 #define GST_QUERY_TYPE(query)  (((GstQuery*)(query))->type)
121
122 /**
123  * GST_QUERY_TYPE_NAME:
124  * @query: the query to query
125  *
126  * Get a constant string representation of the #GstQueryType of the query.
127  *
128  * Since: 0.10.4
129  */
130 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
131
132
133 /**
134  * GstQuery:
135  * @mini_object: The parent #GstMiniObject type
136  * @type: the #GstQueryType
137  * @structure: the #GstStructure containing the query details.
138  *
139  * The #GstQuery structure.
140  */
141 struct _GstQuery
142 {
143   GstMiniObject mini_object;
144
145   /*< public > *//* with COW */
146   GstQueryType type;
147
148   GstStructure *structure;
149
150   /*< private > */
151   gpointer _gst_reserved;
152 };
153
154 struct _GstQueryClass {
155   GstMiniObjectClass mini_object_class;
156
157   /*< private > */
158   gpointer _gst_reserved[GST_PADDING];
159 };
160
161 const gchar*    gst_query_type_get_name        (GstQueryType query);
162 GQuark          gst_query_type_to_quark        (GstQueryType query);
163
164 GType           gst_query_get_type             (void);
165
166 /* register a new query */
167 GstQueryType    gst_query_type_register        (const gchar *nick,
168                                                 const gchar *description);
169 GstQueryType    gst_query_type_get_by_nick     (const gchar *nick);
170
171 /* check if a query is in an array of querys */
172 gboolean        gst_query_types_contains       (const GstQueryType *types,
173                                                 GstQueryType type);
174
175 /* query for query details */
176
177 G_CONST_RETURN GstQueryTypeDefinition*
178                 gst_query_type_get_details         (GstQueryType type);
179 GstIterator*    gst_query_type_iterate_definitions (void);
180
181 /* refcounting */
182 /**
183  * gst_query_ref:
184  * @q: a #GstQuery to increase the refcount of.
185  *
186  * Increases the refcount of the given query by one.
187  */
188 #define         gst_query_ref(q)                GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q)))
189 /**
190  * gst_query_unref:
191  * @q: a #GstQuery to decrease the refcount of.
192  *
193  * Decreases the refcount of the query. If the refcount reaches 0, the query
194  * will be freed.
195  */
196 #define         gst_query_unref(q)              gst_mini_object_unref (GST_MINI_OBJECT (q))
197
198 /* copy query */
199 /**
200  * gst_query_copy:
201  * @q: a #GstQuery to copy.
202  *
203  * Copies the given query using the copy function of the parent #GstData
204  * structure.
205  */
206 #define         gst_query_copy(q)               GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q)))
207 /**
208  * gst_query_make_writable:
209  * @q: a #GstQuery to make writable
210  *
211  * Makes a writable query from the given query.
212  */
213 #define         gst_query_make_writable(q)      GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (q)))
214
215 /* position query */
216 GstQuery*       gst_query_new_position          (GstFormat format);
217 void            gst_query_set_position          (GstQuery *query, GstFormat format, gint64 cur);
218 void            gst_query_parse_position        (GstQuery *query, GstFormat *format, gint64 *cur);
219
220 /* duration query */
221 GstQuery*       gst_query_new_duration          (GstFormat format);
222 void            gst_query_set_duration          (GstQuery *query, GstFormat format, gint64 duration);
223 void            gst_query_parse_duration        (GstQuery *query, GstFormat *format, gint64 *duration);
224
225 /* latency query */
226 GstQuery*       gst_query_new_latency           (void);
227 void            gst_query_set_latency           (GstQuery *query, gboolean live, GstClockTime min_latency,
228                                                  GstClockTime max_latency);
229 void            gst_query_parse_latency         (GstQuery *query, gboolean *live, GstClockTime *min_latency, 
230                                                  GstClockTime *max_latency);
231
232 /* convert query */
233 GstQuery*       gst_query_new_convert           (GstFormat src_format, gint64 value, GstFormat dest_format);
234 void            gst_query_set_convert           (GstQuery *query, GstFormat src_format, gint64 src_value,
235                                                  GstFormat dest_format, gint64 dest_value);
236 void            gst_query_parse_convert         (GstQuery *query, GstFormat *src_format, gint64 *src_value,
237                                                  GstFormat *dest_format, gint64 *dest_value);
238 /* segment query */
239 GstQuery*       gst_query_new_segment           (GstFormat format);
240 void            gst_query_set_segment           (GstQuery *query, gdouble rate, GstFormat format,
241                                                  gint64 start_value, gint64 stop_value);
242 void            gst_query_parse_segment         (GstQuery *query, gdouble *rate, GstFormat *format,
243                                                  gint64 *start_value, gint64 *stop_value);
244
245 /* application specific query */
246 GstQuery *      gst_query_new_application       (GstQueryType type,
247                                                  GstStructure *structure);
248 GstStructure *  gst_query_get_structure         (GstQuery *query);
249
250 /* seeking query */
251 GstQuery*       gst_query_new_seeking           (GstFormat format);
252 void            gst_query_set_seeking           (GstQuery *query, GstFormat format,
253                                                  gboolean seekable,
254                                                  gint64 segment_start,
255                                                  gint64 segment_end);
256 void            gst_query_parse_seeking         (GstQuery *query, GstFormat *format,
257                                                  gboolean *seekable,
258                                                  gint64 *segment_start,
259                                                  gint64 *segment_end);
260 /* formats query */
261 GstQuery*       gst_query_new_formats           (void);
262 void            gst_query_set_formats           (GstQuery *query, gint n_formats, ...);
263 void            gst_query_set_formatsv          (GstQuery *query, gint n_formats, GstFormat *formats);
264 void            gst_query_parse_formats_length  (GstQuery *query, guint *n_formats);
265 void            gst_query_parse_formats_nth     (GstQuery *query, guint nth, GstFormat *format);
266
267 /* buffering query */
268 GstQuery*       gst_query_new_buffering           (GstFormat format);
269 void            gst_query_set_buffering_percent   (GstQuery *query, gboolean busy, gint percent);
270 void            gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent);
271
272 void            gst_query_set_buffering_stats     (GstQuery *query, GstBufferingMode mode,
273                                                    gint avg_in, gint avg_out, 
274                                                    gint64 buffering_left); 
275 void            gst_query_parse_buffering_stats    (GstQuery *query, GstBufferingMode *mode,
276                                                    gint *avg_in, gint *avg_out, 
277                                                    gint64 *buffering_left); 
278
279 void            gst_query_set_buffering_range     (GstQuery *query, GstFormat format,
280                                                    gint64 start, gint64 stop,
281                                                    gint64 estimated_total);
282 void            gst_query_parse_buffering_range   (GstQuery *query, GstFormat *format,
283                                                    gint64 *start, gint64 *stop,
284                                                    gint64 *estimated_total);
285
286 G_END_DECLS
287
288 #endif /* __GST_QUERY_H__ */
289