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.
54 * @GST_QUERY_TOC: query the full table of contents (TOC) with the marker
55 * for an entry which can be used to extend received TOC. Since 0.10.37.
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;
96 typedef struct _GstQueryClass GstQueryClass;
99 * GstQueryTypeDefinition:
100 * @value: the unique id of the Query type
101 * @nick: a short nick
102 * @description: a longer description of the query type
103 * @quark: the quark for the nick
105 * A Query Type definition
107 struct _GstQueryTypeDefinition
111 const gchar *description;
115 #define GST_TYPE_QUERY (gst_query_get_type())
116 #define GST_IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
117 #define GST_IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
118 #define GST_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
119 #define GST_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
120 #define GST_QUERY_CAST(obj) ((GstQuery*)(obj)) /* only since 0.10.23 */
121 #define GST_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
126 * @query: the query to query
128 * Get the #GstQueryType of the query.
130 #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
133 * GST_QUERY_TYPE_NAME:
134 * @query: the query to query
136 * Get a constant string representation of the #GstQueryType of the query.
140 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
145 * @mini_object: The parent #GstMiniObject type
146 * @type: the #GstQueryType
147 * @structure: the #GstStructure containing the query details.
149 * The #GstQuery structure.
153 GstMiniObject mini_object;
155 /*< public > *//* with COW */
158 GstStructure *structure;
161 gpointer _gst_reserved;
164 struct _GstQueryClass {
165 GstMiniObjectClass mini_object_class;
168 gpointer _gst_reserved[GST_PADDING];
171 const gchar* gst_query_type_get_name (GstQueryType query);
172 GQuark gst_query_type_to_quark (GstQueryType query);
174 GType gst_query_get_type (void);
176 /* register a new query */
177 GstQueryType gst_query_type_register (const gchar *nick,
178 const gchar *description);
179 GstQueryType gst_query_type_get_by_nick (const gchar *nick);
181 /* check if a query is in an array of querys */
182 gboolean gst_query_types_contains (const GstQueryType *types,
185 /* query for query details */
187 const GstQueryTypeDefinition*
188 gst_query_type_get_details (GstQueryType type);
189 GstIterator* gst_query_type_iterate_definitions (void) G_GNUC_MALLOC;
194 * @q: a #GstQuery to increase the refcount of.
196 * Increases the refcount of the given query by one.
200 #ifdef _FOOL_GTK_DOC_
201 G_INLINE_FUNC GstQuery * gst_query_ref (GstQuery * q);
204 static inline GstQuery *
205 gst_query_ref (GstQuery * q)
207 return GST_QUERY_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (q)));
212 * @q: a #GstQuery to decrease the refcount of.
214 * Decreases the refcount of the query. If the refcount reaches 0, the query
217 #ifdef _FOOL_GTK_DOC_
218 G_INLINE_FUNC void gst_query_unref (GstQuery * q);
222 gst_query_unref (GstQuery * q)
224 gst_mini_object_unref (GST_MINI_OBJECT_CAST (q));
230 * @q: a #GstQuery to copy.
232 * Copies the given query using the copy function of the parent #GstStructure.
234 * Free-function: gst_query_unref
236 * Returns: (transfer full): a new copy of @q.
238 #ifdef _FOOL_GTK_DOC_
239 G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
242 static inline GstQuery *
243 gst_query_copy (const GstQuery * q)
245 return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (q)));
249 * gst_query_make_writable:
250 * @q: (transfer full): a #GstQuery to make writable
252 * Makes a writable query from the given query.
254 * Returns: (transfer full): a new writable query (possibly same as @q)
256 #define gst_query_make_writable(q) GST_QUERY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (q)))
259 GstQuery* gst_query_new_position (GstFormat format) G_GNUC_MALLOC;
260 void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
261 void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
264 GstQuery* gst_query_new_duration (GstFormat format) G_GNUC_MALLOC;
265 void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
266 void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
269 GstQuery* gst_query_new_latency (void) G_GNUC_MALLOC;
270 void gst_query_set_latency (GstQuery *query, gboolean live, GstClockTime min_latency,
271 GstClockTime max_latency);
272 void gst_query_parse_latency (GstQuery *query, gboolean *live, GstClockTime *min_latency,
273 GstClockTime *max_latency);
276 GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format) G_GNUC_MALLOC;
277 void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
278 GstFormat dest_format, gint64 dest_value);
279 void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
280 GstFormat *dest_format, gint64 *dest_value);
282 GstQuery* gst_query_new_segment (GstFormat format) G_GNUC_MALLOC;
283 void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
284 gint64 start_value, gint64 stop_value);
285 void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
286 gint64 *start_value, gint64 *stop_value);
288 /* application specific query */
289 GstQuery * gst_query_new_application (GstQueryType type,
290 GstStructure *structure) G_GNUC_MALLOC;
291 GstStructure * gst_query_get_structure (GstQuery *query);
294 GstQuery* gst_query_new_seeking (GstFormat format) G_GNUC_MALLOC;
295 void gst_query_set_seeking (GstQuery *query, GstFormat format,
297 gint64 segment_start,
299 void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
301 gint64 *segment_start,
302 gint64 *segment_end);
304 GstQuery* gst_query_new_formats (void) G_GNUC_MALLOC;
305 void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
306 void gst_query_set_formatsv (GstQuery *query, gint n_formats, const GstFormat *formats);
307 void gst_query_parse_formats_length (GstQuery *query, guint *n_formats);
308 void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format);
310 /* buffering query */
311 GstQuery* gst_query_new_buffering (GstFormat format) G_GNUC_MALLOC;
312 void gst_query_set_buffering_percent (GstQuery *query, gboolean busy, gint percent);
313 void gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent);
315 void gst_query_set_buffering_stats (GstQuery *query, GstBufferingMode mode,
316 gint avg_in, gint avg_out,
317 gint64 buffering_left);
318 void gst_query_parse_buffering_stats (GstQuery *query, GstBufferingMode *mode,
319 gint *avg_in, gint *avg_out,
320 gint64 *buffering_left);
322 void gst_query_set_buffering_range (GstQuery *query, GstFormat format,
323 gint64 start, gint64 stop,
324 gint64 estimated_total);
325 void gst_query_parse_buffering_range (GstQuery *query, GstFormat *format,
326 gint64 *start, gint64 *stop,
327 gint64 *estimated_total);
328 gboolean gst_query_add_buffering_range (GstQuery *query,
329 gint64 start, gint64 stop);
331 guint gst_query_get_n_buffering_ranges (GstQuery *query);
333 gboolean gst_query_parse_nth_buffering_range (GstQuery *query,
334 guint index, gint64 *start,
338 GstQuery * gst_query_new_uri (void) G_GNUC_MALLOC;
339 void gst_query_parse_uri (GstQuery *query, gchar **uri);
340 void gst_query_set_uri (GstQuery *query, const gchar *uri);
343 GstQuery * gst_query_new_toc (void);
344 void gst_query_set_toc (GstQuery *query, GstToc *toc, const gchar *extend_uid);
345 void gst_query_parse_toc (GstQuery *query, GstToc **toc, gchar **extend_uid);
349 #endif /* __GST_QUERY_H__ */