inlined and extended docs
[platform/upstream/gstreamer.git] / gst / gstquery.h
1 /* GStreamer
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  *
6  * gstquery.h: GstQuery API declaration
7  *
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
28 #include <glib.h>
29
30 #include <gst/gstiterator.h>
31 #include <gst/gstminiobject.h>
32 #include <gst/gststructure.h>
33 #include <gst/gstformat.h>
34
35 G_BEGIN_DECLS
36
37 /**
38  * GstQueryType:
39  * @GST_QUERY_NONE: invalid query type
40  * @GST_QUERY_POSITION: current/end position in stream
41  * @GST_QUERY_LATENCY: latency of stream
42  * @GST_QUERY_JITTER: current jitter of stream
43  * @GST_QUERY_RATE: current rate of the stream
44  * @GST_QUERY_SEEKING: seeking start/stop positions
45  * @GST_QUERY_CONVERT: convert values
46  * @GST_QUERY_FORMATS: query supported formats for convert
47  *
48  * Standard predefined Query types
49  */
50 typedef enum {
51   GST_QUERY_NONE = 0,
52   GST_QUERY_POSITION,
53   GST_QUERY_LATENCY,
54   GST_QUERY_JITTER,     /* not in draft-query, necessary? */
55   GST_QUERY_RATE,
56   GST_QUERY_SEEKING,
57   GST_QUERY_CONVERT,
58   GST_QUERY_FORMATS
59 } GstQueryType;
60
61 /**
62  * GST_QUERY_TYPE_RATE_DEN:
63  *
64  * Rates are relative to this value
65  */
66 #define GST_QUERY_TYPE_RATE_DEN          G_GINT64_CONSTANT (1000000)
67
68 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
69 typedef struct _GstQuery GstQuery;
70 typedef struct _GstQueryClass GstQueryClass;
71
72 /**
73  * GstQueryTypeDefinition:
74  * @value: the unique id of the Query type
75  * @nick: a short nick
76  * @description: a longer description of the query type
77  *
78  * A Query Type definition
79  */
80 struct _GstQueryTypeDefinition
81 {
82   GstQueryType   value;
83   gchar         *nick;
84   gchar         *description;
85 };
86
87 #define GST_TYPE_QUERY                          (gst_query_get_type())
88 #define GST_IS_QUERY(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
89 #define GST_IS_QUERY_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
90 #define GST_QUERY_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
91 #define GST_QUERY(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
92 #define GST_QUERY_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
93
94 #define GST_QUERY_TYPE(query)  (((GstQuery*)(query))->type)
95
96 struct _GstQuery
97 {
98   GstMiniObject mini_object;
99
100   /*< public > */
101   GstQueryType type;
102
103   GstStructure *structure;
104   
105   /*< private > */
106   gpointer _gst_reserved[GST_PADDING];
107 };
108
109 struct _GstQueryClass {
110   GstMiniObjectClass mini_object_class;
111   
112   /*< private > */
113   gpointer _gst_reserved[GST_PADDING];
114 };
115
116 void            _gst_query_initialize          (void);
117 GType           gst_query_get_type             (void);
118
119 /* register a new query */
120 GstQueryType    gst_query_type_register        (const gchar *nick, 
121                                                 const gchar *description);
122 GstQueryType    gst_query_type_get_by_nick     (const gchar *nick);
123
124 /* check if a query is in an array of querys */
125 gboolean        gst_query_types_contains       (const GstQueryType *types,
126                                                 GstQueryType type);
127
128 /* query for query details */
129
130 G_CONST_RETURN GstQueryTypeDefinition*      
131                 gst_query_type_get_details         (GstQueryType type);
132 GstIterator*    gst_query_type_iterate_definitions (void);
133
134 /* refcounting */
135 #define         gst_query_ref(msg)              GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (msg)))
136 #define         gst_query_unref(msg)            gst_mini_object_unref (GST_MINI_OBJECT (msg))
137 /* copy query */
138 #define         gst_query_copy(msg)             GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (msg)))
139 #define         gst_query_make_writable(msg)    GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (msg)))
140
141 /* position query */
142 GstQuery*       gst_query_new_position          (GstFormat format);
143 void            gst_query_set_position          (GstQuery *query, GstFormat format,
144                                                  gint64 cur, gint64 end);
145 void            gst_query_parse_position        (GstQuery *query, GstFormat *format,
146                                                  gint64 *cur, gint64 *end);
147 /* convert query */
148 GstQuery*       gst_query_new_convert           (GstFormat src_fmt, gint64 value, GstFormat dest_fmt);
149 void            gst_query_set_convert           (GstQuery *query, GstFormat src_format, gint64 src_value,
150                                                  GstFormat dest_format, gint64 dest_value);
151 void            gst_query_parse_convert         (GstQuery *query, GstFormat *src_format, gint64 *src_value,
152                                                  GstFormat *dest_format, gint64 *dest_value);
153
154 /* application specific query */
155 GstQuery *      gst_query_new_application       (GstQueryType type,
156                                                  GstStructure *structure);
157
158
159 GstStructure *  gst_query_get_structure         (GstQuery *query);
160
161 G_END_DECLS
162
163 #endif /* __GST_QUERY_H__ */
164