blob: 6accc2e1b59df54f7908c4735955236bcc5cf6e2 [file] [log] [blame]
Wim Taymans347505b2002-12-30 17:42:11 +00001/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
Wim Taymansc47dc4d2005-03-07 18:27:42 +00004 * 2005 Wim Taymans <wim@fluendo.com>
Wim Taymans347505b2002-12-30 17:42:11 +00005 *
Andy Wingo73f2d452003-07-16 15:49:40 +00006 * gstquery.h: GstQuery API declaration
Wim Taymans347505b2002-12-30 17:42:11 +00007 *
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.
12 *
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.
17 *
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.
22 */
23
24
25#ifndef __GST_QUERY_H__
26#define __GST_QUERY_H__
27
Wim Taymanseb6c33f2003-01-01 03:09:39 +000028#include <glib.h>
Wim Taymans347505b2002-12-30 17:42:11 +000029
Wim Taymansc47dc4d2005-03-07 18:27:42 +000030#include <gst/gstiterator.h>
David Schleefe134f7f2005-05-16 20:21:55 +000031#include <gst/gstminiobject.h>
Andy Wingo8970bda2005-05-06 21:41:22 +000032#include <gst/gststructure.h>
Wim Taymans8df6cd72005-05-09 10:53:13 +000033#include <gst/gstformat.h>
Wim Taymansc47dc4d2005-03-07 18:27:42 +000034
Johan Dahlinecd88e32004-03-15 14:43:35 +000035G_BEGIN_DECLS
36
Stefan Kostba327dc2005-08-29 21:41:02 +000037/**
38 * GstQueryType:
39 * @GST_QUERY_NONE: invalid query type
Wim Taymans7612a382005-10-19 15:50:10 +000040 * @GST_QUERY_POSITION: current position in stream
41 * @GST_QUERY_DURATION: total duration of the stream
Stefan Kostba327dc2005-08-29 21:41:02 +000042 * @GST_QUERY_LATENCY: latency of stream
43 * @GST_QUERY_JITTER: current jitter of stream
44 * @GST_QUERY_RATE: current rate of the stream
Wim Taymans4793bc22005-09-22 16:51:27 +000045 * @GST_QUERY_SEEKING: seeking capabilities
46 * @GST_QUERY_SEGMENT: segment start/stop positions
Michael Smith96936912005-11-10 10:17:01 +000047 * @GST_QUERY_CONVERT: convert values between formats
Stefan Kostba327dc2005-08-29 21:41:02 +000048 * @GST_QUERY_FORMATS: query supported formats for convert
49 *
50 * Standard predefined Query types
51 */
Wim Taymans8d469702005-11-19 18:57:00 +000052/* NOTE: don't forget to update the table in gstquery.c when changing
53 * this enum */
Johan Dahlinecd88e32004-03-15 14:43:35 +000054typedef enum {
Wim Taymans347505b2002-12-30 17:42:11 +000055 GST_QUERY_NONE = 0,
Stefan Kostba327dc2005-08-29 21:41:02 +000056 GST_QUERY_POSITION,
Wim Taymans7612a382005-10-19 15:50:10 +000057 GST_QUERY_DURATION,
Stefan Kostba327dc2005-08-29 21:41:02 +000058 GST_QUERY_LATENCY,
Wim Taymansb9880f82005-07-07 08:43:17 +000059 GST_QUERY_JITTER, /* not in draft-query, necessary? */
Stefan Kostba327dc2005-08-29 21:41:02 +000060 GST_QUERY_RATE,
61 GST_QUERY_SEEKING,
Wim Taymans4793bc22005-09-22 16:51:27 +000062 GST_QUERY_SEGMENT,
Stefan Kostba327dc2005-08-29 21:41:02 +000063 GST_QUERY_CONVERT,
64 GST_QUERY_FORMATS
Johan Dahlinecd88e32004-03-15 14:43:35 +000065} GstQueryType;
Wim Taymans347505b2002-12-30 17:42:11 +000066
Stefan Kostba327dc2005-08-29 21:41:02 +000067/**
68 * GST_QUERY_TYPE_RATE_DEN:
69 *
70 * Rates are relative to this value
71 */
Wim Taymans136e5d22003-02-10 20:16:38 +000072#define GST_QUERY_TYPE_RATE_DEN G_GINT64_CONSTANT (1000000)
Wim Taymanseb6c33f2003-01-01 03:09:39 +000073
74typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
Andy Wingo8970bda2005-05-06 21:41:22 +000075typedef struct _GstQuery GstQuery;
David Schleefe134f7f2005-05-16 20:21:55 +000076typedef struct _GstQueryClass GstQueryClass;
Wim Taymanseb6c33f2003-01-01 03:09:39 +000077
Stefan Kostba327dc2005-08-29 21:41:02 +000078/**
79 * GstQueryTypeDefinition:
80 * @value: the unique id of the Query type
81 * @nick: a short nick
82 * @description: a longer description of the query type
Wim Taymans10a32af2005-11-20 14:50:43 +000083 * @quark: the quark for the nick
Stefan Kostba327dc2005-08-29 21:41:02 +000084 *
85 * A Query Type definition
86 */
Wim Taymanseb6c33f2003-01-01 03:09:39 +000087struct _GstQueryTypeDefinition
88{
Johan Dahlinecd88e32004-03-15 14:43:35 +000089 GstQueryType value;
90 gchar *nick;
91 gchar *description;
Wim Taymans8d469702005-11-19 18:57:00 +000092 GQuark quark;
Wim Taymanseb6c33f2003-01-01 03:09:39 +000093};
94
David Schleefe134f7f2005-05-16 20:21:55 +000095#define GST_TYPE_QUERY (gst_query_get_type())
96#define GST_IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
97#define GST_IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
98#define GST_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
99#define GST_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
100#define GST_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
Andy Wingo8970bda2005-05-06 21:41:22 +0000101
David Schleefe134f7f2005-05-16 20:21:55 +0000102#define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
Andy Wingo8970bda2005-05-06 21:41:22 +0000103
Wim Taymansa9f7f7b2005-11-24 09:44:07 +0000104/**
105 * GstQuery:
106 * @mini_object: The parent #GstMiniObject type
107 * @type: the #GstQueryType
108 * @structure: the #GstStructure containing the query details.
109 *
110 * The #GstQuery structure.
111 */
Andy Wingo8970bda2005-05-06 21:41:22 +0000112struct _GstQuery
113{
David Schleefe134f7f2005-05-16 20:21:55 +0000114 GstMiniObject mini_object;
Andy Wingo8970bda2005-05-06 21:41:22 +0000115
Wim Taymansa9f7f7b2005-11-24 09:44:07 +0000116 /*< public > *//* with COW */
Andy Wingo8970bda2005-05-06 21:41:22 +0000117 GstQueryType type;
118
119 GstStructure *structure;
Thomas Vander Stichele2dd15982005-10-15 15:30:24 +0000120
Andy Wingo8970bda2005-05-06 21:41:22 +0000121 /*< private > */
Andy Wingo65ce5ed2005-11-29 18:57:59 +0000122 gpointer _gst_reserved;
Andy Wingo8970bda2005-05-06 21:41:22 +0000123};
124
David Schleefe134f7f2005-05-16 20:21:55 +0000125struct _GstQueryClass {
126 GstMiniObjectClass mini_object_class;
Thomas Vander Stichele2dd15982005-10-15 15:30:24 +0000127
Wim Taymanse1aeec62005-07-18 12:49:53 +0000128 /*< private > */
129 gpointer _gst_reserved[GST_PADDING];
David Schleefe134f7f2005-05-16 20:21:55 +0000130};
131
Andy Wingo8970bda2005-05-06 21:41:22 +0000132void _gst_query_initialize (void);
Wim Taymans8d469702005-11-19 18:57:00 +0000133
134const gchar* gst_query_type_get_name (GstQueryType query);
135GQuark gst_query_type_to_quark (GstQueryType query);
136
Andy Wingo8970bda2005-05-06 21:41:22 +0000137GType gst_query_get_type (void);
Wim Taymanseb6c33f2003-01-01 03:09:39 +0000138
139/* register a new query */
Thomas Vander Stichele2dd15982005-10-15 15:30:24 +0000140GstQueryType gst_query_type_register (const gchar *nick,
Andy Wingo8970bda2005-05-06 21:41:22 +0000141 const gchar *description);
142GstQueryType gst_query_type_get_by_nick (const gchar *nick);
Wim Taymanseb6c33f2003-01-01 03:09:39 +0000143
144/* check if a query is in an array of querys */
Andy Wingo8970bda2005-05-06 21:41:22 +0000145gboolean gst_query_types_contains (const GstQueryType *types,
146 GstQueryType type);
Wim Taymanseb6c33f2003-01-01 03:09:39 +0000147
148/* query for query details */
Stefan Kostba327dc2005-08-29 21:41:02 +0000149
Thomas Vander Stichele2dd15982005-10-15 15:30:24 +0000150G_CONST_RETURN GstQueryTypeDefinition*
Andy Wingo8970bda2005-05-06 21:41:22 +0000151 gst_query_type_get_details (GstQueryType type);
152GstIterator* gst_query_type_iterate_definitions (void);
153
154/* refcounting */
Wim Taymansc3fecfa2005-10-20 21:08:47 +0000155/**
156 * gst_query_ref:
157 * @q: a #GstQuery to increase the refcount of.
158 *
159 * Increases the refcount of the given query by one.
160 */
161#define gst_query_ref(q) GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q)))
162/**
163 * gst_query_unref:
164 * @q: a #GstQuery to decrease the refcount of.
165 *
166 * Decreases the refcount of the query. If the refcount reaches 0, the query
167 * will be freed.
168 */
169#define gst_query_unref(q) gst_mini_object_unref (GST_MINI_OBJECT (q))
170
Andy Wingo8970bda2005-05-06 21:41:22 +0000171/* copy query */
Wim Taymansc3fecfa2005-10-20 21:08:47 +0000172/**
173 * gst_query_copy:
174 * @q: a #GstQuery to copy.
175 *
176 * Copies the given query using the copy function of the parent #GstData
177 * structure.
178 */
179#define gst_query_copy(q) GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q)))
180/**
181 * gst_query_make_writable:
182 * @q: a #GstQuery to make writable
183 *
184 * Makes a writable query from the given query.
185 */
186#define gst_query_make_writable(q) GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (q)))
Andy Wingo8970bda2005-05-06 21:41:22 +0000187
Wim Taymans8df6cd72005-05-09 10:53:13 +0000188/* position query */
189GstQuery* gst_query_new_position (GstFormat format);
Wim Taymans7612a382005-10-19 15:50:10 +0000190void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
191void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
192
193/* duration query */
194GstQuery* gst_query_new_duration (GstFormat format);
195void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
196void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration);
197
Wim Taymans8df6cd72005-05-09 10:53:13 +0000198/* convert query */
Wim Taymans8c96da02005-10-20 19:47:07 +0000199GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format);
Wim Taymans8df6cd72005-05-09 10:53:13 +0000200void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
201 GstFormat dest_format, gint64 dest_value);
202void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
203 GstFormat *dest_format, gint64 *dest_value);
Wim Taymans1901cd02005-09-22 17:40:42 +0000204/* segment query */
205GstQuery* gst_query_new_segment (GstFormat format);
206void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format,
Wim Taymans7612a382005-10-19 15:50:10 +0000207 gint64 start_value, gint64 stop_value);
Wim Taymans1901cd02005-09-22 17:40:42 +0000208void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format,
Wim Taymans7612a382005-10-19 15:50:10 +0000209 gint64 *start_value, gint64 *stop_value);
Wim Taymans1901cd02005-09-22 17:40:42 +0000210
Wim Taymans8df6cd72005-05-09 10:53:13 +0000211
212/* application specific query */
Andy Wingo8970bda2005-05-06 21:41:22 +0000213GstQuery * gst_query_new_application (GstQueryType type,
214 GstStructure *structure);
215
Wim Taymans8df6cd72005-05-09 10:53:13 +0000216
Andy Wingo8970bda2005-05-06 21:41:22 +0000217GstStructure * gst_query_get_structure (GstQuery *query);
218
Thomas Vander Sticheleb98900a2005-09-26 15:03:43 +0000219/* moved from old gstqueryutils.h */
Jan Schmidt84279842005-11-27 22:50:09 +0000220GstQuery* gst_query_new_seeking (GstFormat format);
Wim Taymanscf925eb2005-11-22 18:28:44 +0000221void gst_query_set_seeking (GstQuery *query, GstFormat format,
222 gboolean seekable,
223 gint64 segment_start,
224 gint64 segment_end);
Jan Schmidt84279842005-11-27 22:50:09 +0000225void gst_query_parse_seeking (GstQuery *query, GstFormat *format,
226 gboolean *seekable,
227 gint64 *segment_start,
228 gint64 *segment_end);
229
Wim Taymanscf925eb2005-11-22 18:28:44 +0000230void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
Thomas Vander Sticheleb98900a2005-09-26 15:03:43 +0000231
Wim Taymans347505b2002-12-30 17:42:11 +0000232G_END_DECLS
Johan Dahlinecd88e32004-03-15 14:43:35 +0000233
Wim Taymans347505b2002-12-30 17:42:11 +0000234#endif /* __GST_QUERY_H__ */
Johan Dahlinecd88e32004-03-15 14:43:35 +0000235