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
58 * @GST_QUERY_ACCEPT_CAPS: the accept caps query
59 * @GST_QUERY_CAPS: the caps query
61 * Standard predefined Query types
63 /* NOTE: don't forget to update the table in gstquery.c when changing
70 GST_QUERY_JITTER, /* not in draft-query, necessary? */
81 GST_QUERY_ACCEPT_CAPS,
85 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
86 typedef struct _GstQuery GstQuery;
89 * GstQueryTypeDefinition:
90 * @value: the unique id of the Query type
92 * @description: a longer description of the query type
93 * @quark: the quark for the nick
95 * A Query Type definition
97 struct _GstQueryTypeDefinition
101 const gchar *description;
105 #define GST_TYPE_QUERY (gst_query_get_type())
106 #define GST_IS_QUERY(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
107 #define GST_QUERY_CAST(obj) ((GstQuery*)(obj))
108 #define GST_QUERY(obj) (GST_QUERY_CAST(obj))
113 * @query: the query to query
115 * Get the #GstQueryType of the query.
117 #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
120 * GST_QUERY_TYPE_NAME:
121 * @query: the query to query
123 * Get a constant string representation of the #GstQueryType of the query.
127 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
132 * @mini_object: The parent #GstMiniObject type
133 * @type: the #GstQueryType
135 * The #GstQuery structure.
139 GstMiniObject mini_object;
141 /*< public > *//* with COW */
145 const gchar* gst_query_type_get_name (GstQueryType query);
146 GQuark gst_query_type_to_quark (GstQueryType query);
148 GType gst_query_get_type (void);
150 /* register a new query */
151 GstQueryType gst_query_type_register (const gchar *nick,
152 const gchar *description);
153 GstQueryType gst_query_type_get_by_nick (const gchar *nick);
155 /* check if a query is in an array of querys */
156 gboolean gst_query_types_contains (const GstQueryType *types,
159 /* query for query details */
161 const GstQueryTypeDefinition*
162 gst_query_type_get_details (GstQueryType type);
163 GstIterator* gst_query_type_iterate_definitions (void) G_GNUC_MALLOC;
168 * @q: a #GstQuery to increase the refcount of.
170 * Increases the refcount of the given query by one.
174 #ifdef _FOOL_GTK_DOC_
175 G_INLINE_FUNC GstQuery * gst_query_ref (GstQuery * q);
178 static inline GstQuery *
179 gst_query_ref (GstQuery * q)
181 return GST_QUERY_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (q)));
186 * @q: a #GstQuery to decrease the refcount of.
188 * Decreases the refcount of the query. If the refcount reaches 0, the query
191 #ifdef _FOOL_GTK_DOC_
192 G_INLINE_FUNC void gst_query_unref (GstQuery * q);
196 gst_query_unref (GstQuery * q)
198 gst_mini_object_unref (GST_MINI_OBJECT_CAST (q));
204 * @q: a #GstQuery to copy.
206 * Copies the given query using the copy function of the parent #GstStructure.
208 * Free-function: gst_query_unref
210 * Returns: (transfer full): a new copy of @q.
212 #ifdef _FOOL_GTK_DOC_
213 G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
216 static inline GstQuery *
217 gst_query_copy (const GstQuery * q)
219 return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (q)));
223 * gst_query_is_writable:
226 * Tests if you can safely write data into a query's structure.
228 #define gst_query_is_writable(q) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (q))
230 * gst_query_make_writable:
231 * @q: (transfer full): a #GstQuery to make writable
233 * Makes a writable query from the given query.
235 * Returns: (transfer full): a new writable query (possibly same as @q)
237 #define gst_query_make_writable(q) GST_QUERY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (q)))
240 * @old_query: (inout) (transfer full): pointer to a pointer to a #GstQuery
242 * @new_query: (allow-none) (transfer none): pointer to a #GstQuery that will
243 * replace the query pointed to by @old_query.
245 * Modifies a pointer to a #GstQuery to point to a different #GstQuery. The
246 * modification is done atomically (so this is useful for ensuring thread safety
247 * in some cases), and the reference counts are updated appropriately (the old
248 * query is unreffed, the new one is reffed).
250 * Either @new_query or the #GstQuery pointed to by @old_query may be NULL.
252 * Returns: TRUE if @new_query was different from @old_query
254 #ifdef _FOOL_GTK_DOC_
255 G_INLINE_FUNC gboolean gst_query_replace (GstQuery **old_query, GstQuery *new_query);
258 static inline gboolean
259 gst_query_replace (GstQuery **old_query, GstQuery *new_query)
261 return gst_mini_object_replace ((GstMiniObject **) old_query, (GstMiniObject *) new_query);
264 /* application specific query */
265 GstQuery * gst_query_new_custom (GstQueryType type, GstStructure *structure) G_GNUC_MALLOC;
267 gst_query_get_structure (GstQuery *query);
268 GstStructure * gst_query_writable_structure (GstQuery *query);
271 GstQuery* gst_query_new_position (GstFormat format) G_GNUC_MALLOC;
272 void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
273 void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
276 GstQuery* gst_query_new_duration (GstFormat format) G_GNUC_MALLOC;
277 void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
278 void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
281 GstQuery* gst_query_new_latency (void) G_GNUC_MALLOC;
282 void gst_query_set_latency (GstQuery *query, gboolean live, GstClockTime min_latency,
283 GstClockTime max_latency);
284 void gst_query_parse_latency (GstQuery *query, gboolean *live, GstClockTime *min_latency,
285 GstClockTime *max_latency);
288 GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format) G_GNUC_MALLOC;
289 void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
290 GstFormat dest_format, gint64 dest_value);
291 void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
292 GstFormat *dest_format, gint64 *dest_value);
294 GstQuery* gst_query_new_segment (GstFormat format) G_GNUC_MALLOC;
295 void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
296 gint64 start_value, gint64 stop_value);
297 void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
298 gint64 *start_value, gint64 *stop_value);
301 GstQuery* gst_query_new_seeking (GstFormat format) G_GNUC_MALLOC;
302 void gst_query_set_seeking (GstQuery *query, GstFormat format,
304 gint64 segment_start,
306 void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
308 gint64 *segment_start,
309 gint64 *segment_end);
311 GstQuery* gst_query_new_formats (void) G_GNUC_MALLOC;
312 void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
313 void gst_query_set_formatsv (GstQuery *query, gint n_formats, const GstFormat *formats);
314 void gst_query_parse_n_formats (GstQuery *query, guint *n_formats);
315 void gst_query_parse_nth_format (GstQuery *query, guint nth, GstFormat *format);
317 /* buffering query */
320 * @GST_BUFFERING_STREAM: a small amount of data is buffered
321 * @GST_BUFFERING_DOWNLOAD: the stream is being downloaded
322 * @GST_BUFFERING_TIMESHIFT: the stream is being downloaded in a ringbuffer
323 * @GST_BUFFERING_LIVE: the stream is a live stream
325 * The different types of buffering methods.
328 GST_BUFFERING_STREAM,
329 GST_BUFFERING_DOWNLOAD,
330 GST_BUFFERING_TIMESHIFT,
334 GstQuery* gst_query_new_buffering (GstFormat format) G_GNUC_MALLOC;
335 void gst_query_set_buffering_percent (GstQuery *query, gboolean busy, gint percent);
336 void gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent);
338 void gst_query_set_buffering_stats (GstQuery *query, GstBufferingMode mode,
339 gint avg_in, gint avg_out,
340 gint64 buffering_left);
341 void gst_query_parse_buffering_stats (GstQuery *query, GstBufferingMode *mode,
342 gint *avg_in, gint *avg_out,
343 gint64 *buffering_left);
345 void gst_query_set_buffering_range (GstQuery *query, GstFormat format,
346 gint64 start, gint64 stop,
347 gint64 estimated_total);
348 void gst_query_parse_buffering_range (GstQuery *query, GstFormat *format,
349 gint64 *start, gint64 *stop,
350 gint64 *estimated_total);
352 gboolean gst_query_add_buffering_range (GstQuery *query,
353 gint64 start, gint64 stop);
354 guint gst_query_get_n_buffering_ranges (GstQuery *query);
355 gboolean gst_query_parse_nth_buffering_range (GstQuery *query,
356 guint index, gint64 *start,
360 GstQuery * gst_query_new_uri (void) G_GNUC_MALLOC;
361 void gst_query_parse_uri (GstQuery *query, gchar **uri);
362 void gst_query_set_uri (GstQuery *query, const gchar *uri);
364 /* allocation query */
365 GstQuery * gst_query_new_allocation (GstCaps *caps, gboolean need_pool) G_GNUC_MALLOC;
366 void gst_query_parse_allocation (GstQuery *query, GstCaps **caps, gboolean *need_pool);
368 void gst_query_set_allocation_params (GstQuery *query, guint size, guint min_buffers,
369 guint max_buffers, guint prefix, guint alignment,
370 GstBufferPool *pool);
371 void gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers,
372 guint *max_buffers, guint *prefix, guint *alignment,
373 GstBufferPool **pool);
375 void gst_query_add_allocation_meta (GstQuery *query, const gchar *api);
376 guint gst_query_get_n_allocation_metas (GstQuery *query);
377 const gchar * gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
378 gboolean gst_query_has_allocation_meta (GstQuery *query, const gchar *api);
380 void gst_query_add_allocation_memory (GstQuery *query, const gchar *alloc);
381 guint gst_query_get_n_allocation_memories (GstQuery *query);
382 const gchar * gst_query_parse_nth_allocation_memory (GstQuery *query, guint index);
384 /* scheduling query */
386 * GstSchedulingFlags:
387 * @GST_SCHEDULING_FLAG_SEEKABLE: if seeking is possible
388 * @GST_SCHEDULING_FLAG_SEQUENTIAL: if sequential access is recommended
390 * The different scheduling flags.
393 GST_SCHEDULING_FLAG_SEEKABLE = (1 << 0),
394 GST_SCHEDULING_FLAG_SEQUENTIAL = (1 << 1)
395 } GstSchedulingFlags;
397 GstQuery * gst_query_new_scheduling (void) G_GNUC_MALLOC;
399 void gst_query_set_scheduling (GstQuery *query, GstSchedulingFlags flags,
400 gint minsize, gint maxsize, gint align);
401 void gst_query_parse_scheduling (GstQuery *query, GstSchedulingFlags *flags,
402 gint *minsize, gint *maxsize, gint *align);
404 void gst_query_add_scheduling_mode (GstQuery *query, GstPadMode mode);
405 guint gst_query_get_n_scheduling_modes (GstQuery *query);
406 GstPadMode gst_query_parse_nth_scheduling_mode (GstQuery *query, guint index);
407 gboolean gst_query_has_scheduling_mode (GstQuery *query, GstPadMode mode);
409 /* accept-caps query */
410 GstQuery * gst_query_new_accept_caps (GstCaps *caps) G_GNUC_MALLOC;
411 void gst_query_parse_accept_caps (GstQuery *query, GstCaps **caps);
412 void gst_query_set_accept_caps_result (GstQuery *query, gboolean result);
413 void gst_query_parse_accept_caps_result (GstQuery *query, gboolean *result);
416 GstQuery * gst_query_new_caps (GstCaps *filter) G_GNUC_MALLOC;
417 void gst_query_parse_caps (GstQuery *query, GstCaps **filter);
419 void gst_query_set_caps_result (GstQuery *query, GstCaps *caps);
420 void gst_query_parse_caps_result (GstQuery *query, GstCaps **caps);
422 void gst_query_intersect_caps_result (GstQuery *query, GstCaps *filter,
423 GstCapsIntersectMode mode);
427 #endif /* __GST_QUERY_H__ */