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
50 * Standard predefined Query types
52 /* NOTE: don't forget to update the table in gstquery.c when changing
59 GST_QUERY_JITTER, /* not in draft-query, necessary? */
67 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
68 typedef struct _GstQuery GstQuery;
69 typedef struct _GstQueryClass GstQueryClass;
72 * GstQueryTypeDefinition:
73 * @value: the unique id of the Query type
75 * @description: a longer description of the query type
76 * @quark: the quark for the nick
78 * A Query Type definition
80 struct _GstQueryTypeDefinition
88 #define GST_TYPE_QUERY (gst_query_get_type())
89 #define GST_IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
90 #define GST_IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
91 #define GST_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
92 #define GST_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
93 #define GST_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
97 * @query: the query to query
99 * Get the #GstQueryType of the query.
101 #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
104 * GST_QUERY_TYPE_NAME:
105 * @query: the query to query
107 * Get a constant string representation of the #GstQueryType of the query.
111 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
116 * @mini_object: The parent #GstMiniObject type
117 * @type: the #GstQueryType
118 * @structure: the #GstStructure containing the query details.
120 * The #GstQuery structure.
124 GstMiniObject mini_object;
126 /*< public > *//* with COW */
129 GstStructure *structure;
132 gpointer _gst_reserved;
135 struct _GstQueryClass {
136 GstMiniObjectClass mini_object_class;
139 gpointer _gst_reserved[GST_PADDING];
142 void _gst_query_initialize (void);
144 const gchar* gst_query_type_get_name (GstQueryType query);
145 GQuark gst_query_type_to_quark (GstQueryType query);
147 GType gst_query_get_type (void);
149 /* register a new query */
150 GstQueryType gst_query_type_register (const gchar *nick,
151 const gchar *description);
152 GstQueryType gst_query_type_get_by_nick (const gchar *nick);
154 /* check if a query is in an array of querys */
155 gboolean gst_query_types_contains (const GstQueryType *types,
158 /* query for query details */
160 G_CONST_RETURN GstQueryTypeDefinition*
161 gst_query_type_get_details (GstQueryType type);
162 GstIterator* gst_query_type_iterate_definitions (void);
167 * @q: a #GstQuery to increase the refcount of.
169 * Increases the refcount of the given query by one.
171 #define gst_query_ref(q) GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q)))
174 * @q: a #GstQuery to decrease the refcount of.
176 * Decreases the refcount of the query. If the refcount reaches 0, the query
179 #define gst_query_unref(q) gst_mini_object_unref (GST_MINI_OBJECT (q))
184 * @q: a #GstQuery to copy.
186 * Copies the given query using the copy function of the parent #GstData
189 #define gst_query_copy(q) GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q)))
191 * gst_query_make_writable:
192 * @q: a #GstQuery to make writable
194 * Makes a writable query from the given query.
196 #define gst_query_make_writable(q) GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (q)))
199 GstQuery* gst_query_new_position (GstFormat format);
200 void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
201 void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
204 GstQuery* gst_query_new_duration (GstFormat format);
205 void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
206 void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
209 GstQuery* gst_query_new_latency (void);
210 void gst_query_set_latency (GstQuery *query, gboolean live, GstClockTime min_latency,
211 GstClockTime max_latency);
212 void gst_query_parse_latency (GstQuery *query, gboolean *live, GstClockTime *min_latency,
213 GstClockTime *max_latency);
216 GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format);
217 void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
218 GstFormat dest_format, gint64 dest_value);
219 void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
220 GstFormat *dest_format, gint64 *dest_value);
222 GstQuery* gst_query_new_segment (GstFormat format);
223 void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
224 gint64 start_value, gint64 stop_value);
225 void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
226 gint64 *start_value, gint64 *stop_value);
228 /* application specific query */
229 GstQuery * gst_query_new_application (GstQueryType type,
230 GstStructure *structure);
231 GstStructure * gst_query_get_structure (GstQuery *query);
234 GstQuery* gst_query_new_seeking (GstFormat format);
235 void gst_query_set_seeking (GstQuery *query, GstFormat format,
237 gint64 segment_start,
239 void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
241 gint64 *segment_start,
242 gint64 *segment_end);
244 GstQuery* gst_query_new_formats (void);
245 void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
246 void gst_query_set_formatsv (GstQuery *query, gint n_formats, GstFormat *formats);
247 void gst_query_parse_formats_length (GstQuery *query, guint *n_formats);
248 void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format);
252 #endif /* __GST_QUERY_H__ */