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>
6 * gstquery.h: GstQuery API declaration
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.
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.
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.
25 #ifndef __GST_QUERY_H__
26 #define __GST_QUERY_H__
30 #include <gst/gstiterator.h>
31 #include <gst/gstminiobject.h>
32 #include <gst/gststructure.h>
33 #include <gst/gstformat.h>
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
51 * @GST_QUERY_CUSTOM: a custom application or element defined query. Since
53 * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
55 * Standard predefined Query types
57 /* NOTE: don't forget to update the table in gstquery.c when changing
64 GST_QUERY_JITTER, /* not in draft-query, necessary? */
77 * @GST_BUFFERING_STREAM: a small amount of data is buffered
78 * @GST_BUFFERING_DOWNLOAD: the stream is being downloaded
79 * @GST_BUFFERING_TIMESHIFT: the stream is being downloaded in a ringbuffer
80 * @GST_BUFFERING_LIVE: the stream is a live stream
82 * The different types of buffering methods.
86 GST_BUFFERING_DOWNLOAD,
87 GST_BUFFERING_TIMESHIFT,
91 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
92 typedef struct _GstQuery GstQuery;
95 * GstQueryTypeDefinition:
96 * @value: the unique id of the Query type
98 * @description: a longer description of the query type
99 * @quark: the quark for the nick
101 * A Query Type definition
103 struct _GstQueryTypeDefinition
107 const gchar *description;
111 #define GST_TYPE_QUERY (gst_query_get_type())
112 #define GST_IS_QUERY(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
113 #define GST_QUERY_CAST(obj) ((GstQuery*)(obj))
114 #define GST_QUERY(obj) (GST_QUERY_CAST(obj))
119 * @query: the query to query
121 * Get the #GstQueryType of the query.
123 #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
126 * GST_QUERY_TYPE_NAME:
127 * @query: the query to query
129 * Get a constant string representation of the #GstQueryType of the query.
133 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
138 * @mini_object: The parent #GstMiniObject type
139 * @type: the #GstQueryType
140 * @structure: the #GstStructure containing the query details.
142 * The #GstQuery structure.
146 GstMiniObject mini_object;
148 /*< public > *//* with COW */
151 GstStructure *structure;
154 gpointer _gst_reserved;
157 const gchar* gst_query_type_get_name (GstQueryType query);
158 GQuark gst_query_type_to_quark (GstQueryType query);
160 GType gst_query_get_type (void);
162 /* register a new query */
163 GstQueryType gst_query_type_register (const gchar *nick,
164 const gchar *description);
165 GstQueryType gst_query_type_get_by_nick (const gchar *nick);
167 /* check if a query is in an array of querys */
168 gboolean gst_query_types_contains (const GstQueryType *types,
171 /* query for query details */
173 G_CONST_RETURN GstQueryTypeDefinition*
174 gst_query_type_get_details (GstQueryType type);
175 GstIterator* gst_query_type_iterate_definitions (void);
180 * @q: a #GstQuery to increase the refcount of.
182 * Increases the refcount of the given query by one.
186 #ifdef _FOOL_GTK_DOC_
187 G_INLINE_FUNC GstQuery * gst_query_ref (GstQuery * q);
190 static inline GstQuery *
191 gst_query_ref (GstQuery * q)
193 return GST_QUERY_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (q)));
198 * @q: a #GstQuery to decrease the refcount of.
200 * Decreases the refcount of the query. If the refcount reaches 0, the query
203 #ifdef _FOOL_GTK_DOC_
204 G_INLINE_FUNC void gst_query_unref (GstQuery * q);
208 gst_query_unref (GstQuery * q)
210 gst_mini_object_unref (GST_MINI_OBJECT_CAST (q));
216 * @q: a #GstQuery to copy.
218 * Copies the given query using the copy function of the parent #GstStructure.
220 * Free-function: gst_query_unref
222 * Returns: (transfer full): a new copy of @q.
224 #ifdef _FOOL_GTK_DOC_
225 G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
228 static inline GstQuery *
229 gst_query_copy (const GstQuery * q)
231 return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (q)));
235 * gst_query_make_writable:
236 * @q: (transfer full): a #GstQuery to make writable
238 * Makes a writable query from the given query.
240 * Returns: (transfer full): a new writable query (possibly same as @q)
242 #define gst_query_make_writable(q) GST_QUERY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (q)))
245 GstQuery* gst_query_new_position (GstFormat format);
246 void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
247 void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
250 GstQuery* gst_query_new_duration (GstFormat format);
251 void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
252 void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
255 GstQuery* gst_query_new_latency (void);
256 void gst_query_set_latency (GstQuery *query, gboolean live, GstClockTime min_latency,
257 GstClockTime max_latency);
258 void gst_query_parse_latency (GstQuery *query, gboolean *live, GstClockTime *min_latency,
259 GstClockTime *max_latency);
262 GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format);
263 void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
264 GstFormat dest_format, gint64 dest_value);
265 void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
266 GstFormat *dest_format, gint64 *dest_value);
268 GstQuery* gst_query_new_segment (GstFormat format);
269 void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
270 gint64 start_value, gint64 stop_value);
271 void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
272 gint64 *start_value, gint64 *stop_value);
274 /* application specific query */
275 GstQuery * gst_query_new_application (GstQueryType type,
276 GstStructure *structure);
277 GstStructure * gst_query_get_structure (GstQuery *query);
280 GstQuery* gst_query_new_seeking (GstFormat format);
281 void gst_query_set_seeking (GstQuery *query, GstFormat format,
283 gint64 segment_start,
285 void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
287 gint64 *segment_start,
288 gint64 *segment_end);
290 GstQuery* gst_query_new_formats (void);
291 void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
292 void gst_query_set_formatsv (GstQuery *query, gint n_formats, GstFormat *formats);
293 void gst_query_parse_formats_length (GstQuery *query, guint *n_formats);
294 void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format);
296 /* buffering query */
297 GstQuery* gst_query_new_buffering (GstFormat format);
298 void gst_query_set_buffering_percent (GstQuery *query, gboolean busy, gint percent);
299 void gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent);
301 void gst_query_set_buffering_stats (GstQuery *query, GstBufferingMode mode,
302 gint avg_in, gint avg_out,
303 gint64 buffering_left);
304 void gst_query_parse_buffering_stats (GstQuery *query, GstBufferingMode *mode,
305 gint *avg_in, gint *avg_out,
306 gint64 *buffering_left);
308 void gst_query_set_buffering_range (GstQuery *query, GstFormat format,
309 gint64 start, gint64 stop,
310 gint64 estimated_total);
311 void gst_query_parse_buffering_range (GstQuery *query, GstFormat *format,
312 gint64 *start, gint64 *stop,
313 gint64 *estimated_total);
314 gboolean gst_query_add_buffering_range (GstQuery *query,
315 gint64 start, gint64 stop);
317 guint gst_query_get_n_buffering_ranges (GstQuery *query);
319 gboolean gst_query_parse_nth_buffering_range (GstQuery *query,
320 guint index, gint64 *start,
324 GstQuery * gst_query_new_uri (void);
325 void gst_query_parse_uri (GstQuery *query, gchar **uri);
326 void gst_query_set_uri (GstQuery *query, const gchar *uri);
330 #endif /* __GST_QUERY_H__ */