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>
34 #include <gst/gstpad.h>
40 * @GST_QUERY_NONE: invalid query type
41 * @GST_QUERY_POSITION: current position in stream
42 * @GST_QUERY_DURATION: total duration of the stream
43 * @GST_QUERY_LATENCY: latency of stream
44 * @GST_QUERY_JITTER: current jitter of stream
45 * @GST_QUERY_RATE: current rate of the stream
46 * @GST_QUERY_SEEKING: seeking capabilities
47 * @GST_QUERY_SEGMENT: segment start/stop positions
48 * @GST_QUERY_CONVERT: convert values between formats
49 * @GST_QUERY_FORMATS: query supported formats for convert
50 * @GST_QUERY_BUFFERING: query available media for efficient seeking. Since
52 * @GST_QUERY_CUSTOM: a custom application or element defined query. Since
54 * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
55 * @GST_QUERY_ALLOCATION: the buffer allocation properties
57 * Standard predefined Query types
59 /* NOTE: don't forget to update the table in gstquery.c when changing
66 GST_QUERY_JITTER, /* not in draft-query, necessary? */
80 * @GST_BUFFERING_STREAM: a small amount of data is buffered
81 * @GST_BUFFERING_DOWNLOAD: the stream is being downloaded
82 * @GST_BUFFERING_TIMESHIFT: the stream is being downloaded in a ringbuffer
83 * @GST_BUFFERING_LIVE: the stream is a live stream
85 * The different types of buffering methods.
89 GST_BUFFERING_DOWNLOAD,
90 GST_BUFFERING_TIMESHIFT,
94 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
95 typedef struct _GstQuery GstQuery;
98 * GstQueryTypeDefinition:
99 * @value: the unique id of the Query type
100 * @nick: a short nick
101 * @description: a longer description of the query type
102 * @quark: the quark for the nick
104 * A Query Type definition
106 struct _GstQueryTypeDefinition
110 const gchar *description;
114 #define GST_TYPE_QUERY (gst_query_get_type())
115 #define GST_IS_QUERY(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
116 #define GST_QUERY_CAST(obj) ((GstQuery*)(obj))
117 #define GST_QUERY(obj) (GST_QUERY_CAST(obj))
122 * @query: the query to query
124 * Get the #GstQueryType of the query.
126 #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
129 * GST_QUERY_TYPE_NAME:
130 * @query: the query to query
132 * Get a constant string representation of the #GstQueryType of the query.
136 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
141 * @mini_object: The parent #GstMiniObject type
142 * @type: the #GstQueryType
143 * @structure: the #GstStructure containing the query details.
145 * The #GstQuery structure.
149 GstMiniObject mini_object;
151 /*< public > *//* with COW */
154 GstStructure *structure;
157 gpointer _gst_reserved;
160 const gchar* gst_query_type_get_name (GstQueryType query);
161 GQuark gst_query_type_to_quark (GstQueryType query);
163 GType gst_query_get_type (void);
165 /* register a new query */
166 GstQueryType gst_query_type_register (const gchar *nick,
167 const gchar *description);
168 GstQueryType gst_query_type_get_by_nick (const gchar *nick);
170 /* check if a query is in an array of querys */
171 gboolean gst_query_types_contains (const GstQueryType *types,
174 /* query for query details */
176 G_CONST_RETURN GstQueryTypeDefinition*
177 gst_query_type_get_details (GstQueryType type);
178 GstIterator* gst_query_type_iterate_definitions (void);
183 * @q: a #GstQuery to increase the refcount of.
185 * Increases the refcount of the given query by one.
189 #ifdef _FOOL_GTK_DOC_
190 G_INLINE_FUNC GstQuery * gst_query_ref (GstQuery * q);
193 static inline GstQuery *
194 gst_query_ref (GstQuery * q)
196 return GST_QUERY_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (q)));
201 * @q: a #GstQuery to decrease the refcount of.
203 * Decreases the refcount of the query. If the refcount reaches 0, the query
206 #ifdef _FOOL_GTK_DOC_
207 G_INLINE_FUNC void gst_query_unref (GstQuery * q);
211 gst_query_unref (GstQuery * q)
213 gst_mini_object_unref (GST_MINI_OBJECT_CAST (q));
219 * @q: a #GstQuery to copy.
221 * Copies the given query using the copy function of the parent #GstStructure.
223 * Free-function: gst_query_unref
225 * Returns: (transfer full): a new copy of @q.
227 #ifdef _FOOL_GTK_DOC_
228 G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
231 static inline GstQuery *
232 gst_query_copy (const GstQuery * q)
234 return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (q)));
238 * gst_query_make_writable:
239 * @q: (transfer full): a #GstQuery to make writable
241 * Makes a writable query from the given query.
243 * Returns: (transfer full): a new writable query (possibly same as @q)
245 #define gst_query_make_writable(q) GST_QUERY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (q)))
248 GstQuery* gst_query_new_position (GstFormat format);
249 void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
250 void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
253 GstQuery* gst_query_new_duration (GstFormat format);
254 void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
255 void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
258 GstQuery* gst_query_new_latency (void);
259 void gst_query_set_latency (GstQuery *query, gboolean live, GstClockTime min_latency,
260 GstClockTime max_latency);
261 void gst_query_parse_latency (GstQuery *query, gboolean *live, GstClockTime *min_latency,
262 GstClockTime *max_latency);
265 GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format);
266 void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
267 GstFormat dest_format, gint64 dest_value);
268 void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
269 GstFormat *dest_format, gint64 *dest_value);
271 GstQuery* gst_query_new_segment (GstFormat format);
272 void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
273 gint64 start_value, gint64 stop_value);
274 void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
275 gint64 *start_value, gint64 *stop_value);
277 /* application specific query */
278 GstQuery * gst_query_new_application (GstQueryType type,
279 GstStructure *structure);
280 GstStructure * gst_query_get_structure (GstQuery *query);
283 GstQuery* gst_query_new_seeking (GstFormat format);
284 void gst_query_set_seeking (GstQuery *query, GstFormat format,
286 gint64 segment_start,
288 void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
290 gint64 *segment_start,
291 gint64 *segment_end);
293 GstQuery* gst_query_new_formats (void);
294 void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
295 void gst_query_set_formatsv (GstQuery *query, gint n_formats, const GstFormat *formats);
296 void gst_query_parse_formats_length (GstQuery *query, guint *n_formats);
297 void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format);
299 /* buffering query */
300 GstQuery* gst_query_new_buffering (GstFormat format);
301 void gst_query_set_buffering_percent (GstQuery *query, gboolean busy, gint percent);
302 void gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent);
304 void gst_query_set_buffering_stats (GstQuery *query, GstBufferingMode mode,
305 gint avg_in, gint avg_out,
306 gint64 buffering_left);
307 void gst_query_parse_buffering_stats (GstQuery *query, GstBufferingMode *mode,
308 gint *avg_in, gint *avg_out,
309 gint64 *buffering_left);
311 void gst_query_set_buffering_range (GstQuery *query, GstFormat format,
312 gint64 start, gint64 stop,
313 gint64 estimated_total);
314 void gst_query_parse_buffering_range (GstQuery *query, GstFormat *format,
315 gint64 *start, gint64 *stop,
316 gint64 *estimated_total);
317 gboolean gst_query_add_buffering_range (GstQuery *query,
318 gint64 start, gint64 stop);
320 guint gst_query_get_n_buffering_ranges (GstQuery *query);
322 gboolean gst_query_parse_nth_buffering_range (GstQuery *query,
323 guint index, gint64 *start,
327 GstQuery * gst_query_new_uri (void);
328 void gst_query_parse_uri (GstQuery *query, gchar **uri);
329 void gst_query_set_uri (GstQuery *query, const gchar *uri);
331 /* allocation query */
332 GstQuery * gst_query_new_allocation (GstCaps *caps, gboolean need_pool);
333 void gst_query_parse_allocation (GstQuery *query, GstCaps **caps, gboolean *need_pool);
335 void gst_query_set_allocation_params (GstQuery *query, guint size, guint min_buffers,
336 guint max_buffers, guint prefix, guint alignment,
337 GstBufferPool *pool);
338 void gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers,
339 guint *max_buffers, guint *prefix, guint *alignment,
340 GstBufferPool **pool);
342 void gst_query_add_allocation_meta (GstQuery *query, const gchar *api);
343 guint gst_query_get_n_allocation_meta (GstQuery *query);
344 const gchar * gst_query_parse_allocation_meta (GstQuery *query, guint index);
349 #endif /* __GST_QUERY_H__ */