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 * 2011 Wim Taymans <wim.taymans@gmail.com>
7 * gstquery.h: GstQuery API declaration
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 #ifndef __GST_QUERY_H__
27 #define __GST_QUERY_H__
31 #include <gst/gstiterator.h>
32 #include <gst/gstminiobject.h>
33 #include <gst/gststructure.h>
34 #include <gst/gstformat.h>
35 #include <gst/gstpad.h>
41 * @GST_QUERY_NONE: invalid query type
42 * @GST_QUERY_POSITION: current position in stream
43 * @GST_QUERY_DURATION: total duration of the stream
44 * @GST_QUERY_LATENCY: latency of stream
45 * @GST_QUERY_JITTER: current jitter of stream
46 * @GST_QUERY_RATE: current rate of the stream
47 * @GST_QUERY_SEEKING: seeking capabilities
48 * @GST_QUERY_SEGMENT: segment start/stop positions
49 * @GST_QUERY_CONVERT: convert values between formats
50 * @GST_QUERY_FORMATS: query supported formats for convert
51 * @GST_QUERY_BUFFERING: query available media for efficient seeking. Since
53 * @GST_QUERY_CUSTOM: a custom application or element defined query. Since
55 * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
56 * @GST_QUERY_ALLOCATION: the buffer allocation properties
57 * @GST_QUERY_SCHEDULING: the scheduling properties
59 * Standard predefined Query types
61 /* NOTE: don't forget to update the table in gstquery.c when changing
68 GST_QUERY_JITTER, /* not in draft-query, necessary? */
83 * @GST_BUFFERING_STREAM: a small amount of data is buffered
84 * @GST_BUFFERING_DOWNLOAD: the stream is being downloaded
85 * @GST_BUFFERING_TIMESHIFT: the stream is being downloaded in a ringbuffer
86 * @GST_BUFFERING_LIVE: the stream is a live stream
88 * The different types of buffering methods.
92 GST_BUFFERING_DOWNLOAD,
93 GST_BUFFERING_TIMESHIFT,
97 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
98 typedef struct _GstQuery GstQuery;
101 * GstQueryTypeDefinition:
102 * @value: the unique id of the Query type
103 * @nick: a short nick
104 * @description: a longer description of the query type
105 * @quark: the quark for the nick
107 * A Query Type definition
109 struct _GstQueryTypeDefinition
113 const gchar *description;
117 #define GST_TYPE_QUERY (gst_query_get_type())
118 #define GST_IS_QUERY(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
119 #define GST_QUERY_CAST(obj) ((GstQuery*)(obj))
120 #define GST_QUERY(obj) (GST_QUERY_CAST(obj))
125 * @query: the query to query
127 * Get the #GstQueryType of the query.
129 #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
132 * GST_QUERY_TYPE_NAME:
133 * @query: the query to query
135 * Get a constant string representation of the #GstQueryType of the query.
139 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
144 * @mini_object: The parent #GstMiniObject type
145 * @type: the #GstQueryType
146 * @structure: the #GstStructure containing the query details.
148 * The #GstQuery structure.
152 GstMiniObject mini_object;
154 /*< public > *//* with COW */
158 const gchar* gst_query_type_get_name (GstQueryType query);
159 GQuark gst_query_type_to_quark (GstQueryType query);
161 GType gst_query_get_type (void);
163 /* register a new query */
164 GstQueryType gst_query_type_register (const gchar *nick,
165 const gchar *description);
166 GstQueryType gst_query_type_get_by_nick (const gchar *nick);
168 /* check if a query is in an array of querys */
169 gboolean gst_query_types_contains (const GstQueryType *types,
172 /* query for query details */
174 G_CONST_RETURN GstQueryTypeDefinition*
175 gst_query_type_get_details (GstQueryType type);
176 GstIterator* gst_query_type_iterate_definitions (void);
181 * @q: a #GstQuery to increase the refcount of.
183 * Increases the refcount of the given query by one.
187 #ifdef _FOOL_GTK_DOC_
188 G_INLINE_FUNC GstQuery * gst_query_ref (GstQuery * q);
191 static inline GstQuery *
192 gst_query_ref (GstQuery * q)
194 return GST_QUERY_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (q)));
199 * @q: a #GstQuery to decrease the refcount of.
201 * Decreases the refcount of the query. If the refcount reaches 0, the query
204 #ifdef _FOOL_GTK_DOC_
205 G_INLINE_FUNC void gst_query_unref (GstQuery * q);
209 gst_query_unref (GstQuery * q)
211 gst_mini_object_unref (GST_MINI_OBJECT_CAST (q));
217 * @q: a #GstQuery to copy.
219 * Copies the given query using the copy function of the parent #GstStructure.
221 * Free-function: gst_query_unref
223 * Returns: (transfer full): a new copy of @q.
225 #ifdef _FOOL_GTK_DOC_
226 G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
229 static inline GstQuery *
230 gst_query_copy (const GstQuery * q)
232 return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (q)));
236 * gst_query_is_writable:
239 * Tests if you can safely write data into a query's structure.
241 #define gst_query_is_writable(q) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (q))
243 * gst_query_make_writable:
244 * @q: (transfer full): a #GstQuery to make writable
246 * Makes a writable query from the given query.
248 * Returns: (transfer full): a new writable query (possibly same as @q)
250 #define gst_query_make_writable(q) GST_QUERY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (q)))
253 * @old_query: (inout) (transfer full): pointer to a pointer to a #GstQuery
255 * @new_query: (allow-none) (transfer none): pointer to a #GstQuery that will
256 * replace the query pointed to by @old_query.
258 * Modifies a pointer to a #GstQuery to point to a different #GstQuery. The
259 * modification is done atomically (so this is useful for ensuring thread safety
260 * in some cases), and the reference counts are updated appropriately (the old
261 * query is unreffed, the new one is reffed).
263 * Either @new_query or the #GstQuery pointed to by @old_query may be NULL.
265 #define gst_query_replace(old_query,new_query) \
266 gst_mini_object_replace ((GstMiniObject **)(old_query), GST_MINI_OBJECT_CAST (new_query))
269 /* application specific query */
270 GstQuery * gst_query_new_custom (GstQueryType type, GstStructure *structure);
272 gst_query_get_structure (GstQuery *query);
273 GstStructure * gst_query_writable_structure (GstQuery *query);
276 GstQuery* gst_query_new_position (GstFormat format);
277 void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
278 void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
281 GstQuery* gst_query_new_duration (GstFormat format);
282 void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
283 void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
286 GstQuery* gst_query_new_latency (void);
287 void gst_query_set_latency (GstQuery *query, gboolean live, GstClockTime min_latency,
288 GstClockTime max_latency);
289 void gst_query_parse_latency (GstQuery *query, gboolean *live, GstClockTime *min_latency,
290 GstClockTime *max_latency);
293 GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format);
294 void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
295 GstFormat dest_format, gint64 dest_value);
296 void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
297 GstFormat *dest_format, gint64 *dest_value);
299 GstQuery* gst_query_new_segment (GstFormat format);
300 void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
301 gint64 start_value, gint64 stop_value);
302 void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
303 gint64 *start_value, gint64 *stop_value);
306 GstQuery* gst_query_new_seeking (GstFormat format);
307 void gst_query_set_seeking (GstQuery *query, GstFormat format,
309 gint64 segment_start,
311 void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
313 gint64 *segment_start,
314 gint64 *segment_end);
316 GstQuery* gst_query_new_formats (void);
317 void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
318 void gst_query_set_formatsv (GstQuery *query, gint n_formats, const GstFormat *formats);
319 void gst_query_parse_n_formats (GstQuery *query, guint *n_formats);
320 void gst_query_parse_nth_format (GstQuery *query, guint nth, GstFormat *format);
322 /* buffering query */
323 GstQuery* gst_query_new_buffering (GstFormat format);
324 void gst_query_set_buffering_percent (GstQuery *query, gboolean busy, gint percent);
325 void gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent);
327 void gst_query_set_buffering_stats (GstQuery *query, GstBufferingMode mode,
328 gint avg_in, gint avg_out,
329 gint64 buffering_left);
330 void gst_query_parse_buffering_stats (GstQuery *query, GstBufferingMode *mode,
331 gint *avg_in, gint *avg_out,
332 gint64 *buffering_left);
334 void gst_query_set_buffering_range (GstQuery *query, GstFormat format,
335 gint64 start, gint64 stop,
336 gint64 estimated_total);
337 void gst_query_parse_buffering_range (GstQuery *query, GstFormat *format,
338 gint64 *start, gint64 *stop,
339 gint64 *estimated_total);
341 gboolean gst_query_add_buffering_range (GstQuery *query,
342 gint64 start, gint64 stop);
343 guint gst_query_get_n_buffering_ranges (GstQuery *query);
344 gboolean gst_query_parse_nth_buffering_range (GstQuery *query,
345 guint index, gint64 *start,
349 GstQuery * gst_query_new_uri (void);
350 void gst_query_parse_uri (GstQuery *query, gchar **uri);
351 void gst_query_set_uri (GstQuery *query, const gchar *uri);
353 /* allocation query */
354 GstQuery * gst_query_new_allocation (GstCaps *caps, gboolean need_pool);
355 void gst_query_parse_allocation (GstQuery *query, GstCaps **caps, gboolean *need_pool);
357 void gst_query_set_allocation_params (GstQuery *query, guint size, guint min_buffers,
358 guint max_buffers, guint prefix, guint alignment,
359 GstBufferPool *pool);
360 void gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers,
361 guint *max_buffers, guint *prefix, guint *alignment,
362 GstBufferPool **pool);
364 void gst_query_add_allocation_meta (GstQuery *query, const gchar *api);
365 guint gst_query_get_n_allocation_metas (GstQuery *query);
366 const gchar * gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
368 /* scheduling query */
369 GstQuery * gst_query_new_scheduling (void);
371 void gst_query_set_scheduling (GstQuery *query, gboolean pull_mode,
372 gboolean random_access, gboolean sequential,
373 gint minsize, gint maxsize, gint align);
374 void gst_query_parse_scheduling (GstQuery *query, gboolean *pull_mode,
375 gboolean *random_access, gboolean *sequential,
376 gint *minsize, gint *maxsize, gint *align);
380 #endif /* __GST_QUERY_H__ */