Remove old query functions. Ported old code.
[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/gstdata.h>
32 #include <gst/gststructure.h>
33 #include <gst/gstformat.h>
34
35 G_BEGIN_DECLS
36
37 typedef enum {
38   GST_QUERY_NONE = 0,
39   GST_QUERY_TOTAL, /* deprecated, use POSITION */
40   GST_QUERY_POSITION,
41   GST_QUERY_LATENCY,
42   GST_QUERY_JITTER, /* not in draft-query, necessary? */
43   GST_QUERY_START, /* deprecated, use SEEKING */
44   GST_QUERY_SEGMENT_END, /* deprecated, use SEEKING */
45   GST_QUERY_RATE, /* not in draft-query, necessary? */
46   GST_QUERY_SEEKING,
47   GST_QUERY_CONVERT,
48   GST_QUERY_FORMATS
49 } GstQueryType;
50
51 /* rate is relative to 1000000  */
52 #define GST_QUERY_TYPE_RATE_DEN          G_GINT64_CONSTANT (1000000)
53
54 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
55 typedef struct _GstQuery GstQuery;
56
57 struct _GstQueryTypeDefinition
58 {
59   GstQueryType   value;
60   gchar         *nick;
61   gchar         *description;
62 };
63
64 #ifdef G_HAVE_ISO_VARARGS
65 #define GST_QUERY_TYPE_FUNCTION(type, functionname, ...)        \
66 static const GstQueryType*                              \
67 functionname (type object)                              \
68 {                                                       \
69   static const GstQueryType types[] = {                 \
70     __VA_ARGS__,                                        \
71     0                                                   \
72   };                                                    \
73   return types;                                         \
74 }
75 #elif defined(G_HAVE_GNUC_VARARGS)
76 #define GST_QUERY_TYPE_FUNCTION(type, functionname, a...)       \
77 static const GstQueryType*                              \
78 functionname (type object)                              \
79 {                                                       \
80   static const GstQueryType types[] = {                 \
81     a,                                                  \
82     0                                                   \
83   };                                                    \
84   return types;                                         \
85 }
86 #endif
87
88 GST_EXPORT GType _gst_query_type;
89
90 #define GST_TYPE_QUERY  (_gst_query_type)
91 #define GST_QUERY(query)        ((GstQuery*)(query))
92 #define GST_IS_QUERY(query)     (GST_DATA_TYPE(query) == GST_TYPE_QUERY)
93 #define GST_QUERY_TYPE(query)   (((GstQuery*)(query))->type)
94
95 struct _GstQuery
96 {
97   GstData data;
98
99   /*< public > */
100   GstQueryType type;
101
102   GstStructure *structure;
103   
104   /*< private > */
105   gpointer _gst_reserved[GST_PADDING];
106 };
107
108 void            _gst_query_initialize          (void);
109 GType           gst_query_get_type             (void);
110
111 /* register a new query */
112 GstQueryType    gst_query_type_register        (const gchar *nick, 
113                                                 const gchar *description);
114 GstQueryType    gst_query_type_get_by_nick     (const gchar *nick);
115
116 /* check if a query is in an array of querys */
117 gboolean        gst_query_types_contains       (const GstQueryType *types,
118                                                 GstQueryType type);
119
120 /* query for query details */
121 G_CONST_RETURN GstQueryTypeDefinition*      
122                 gst_query_type_get_details         (GstQueryType type);
123 GstIterator*    gst_query_type_iterate_definitions (void);
124
125 /* refcounting */
126 #define         gst_query_ref(msg)              GST_QUERY (gst_data_ref (GST_DATA (msg)))
127 #define         gst_query_ref_by_count(msg,c)   GST_QUERY (gst_data_ref_by_count (GST_DATA (msg), (c)))
128 #define         gst_query_unref(msg)            gst_data_unref (GST_DATA (msg))
129 /* copy query */
130 #define         gst_query_copy(msg)             GST_QUERY (gst_data_copy (GST_DATA (msg)))
131 #define         gst_query_copy_on_write(msg)    GST_QUERY (gst_data_copy_on_write (GST_DATA (msg)))
132
133 /* position query */
134 GstQuery*       gst_query_new_position          (GstFormat format);
135 void            gst_query_set_position          (GstQuery *query, GstFormat format,
136                                                  gint64 cur, gint64 end);
137 void            gst_query_parse_position        (GstQuery *query, GstFormat *format,
138                                                  gint64 *cur, gint64 *end);
139 /* convert query */
140 GstQuery*       gst_query_new_convert           (GstFormat src_fmt, gint64 value, GstFormat dest_fmt);
141 void            gst_query_set_convert           (GstQuery *query, GstFormat src_format, gint64 src_value,
142                                                  GstFormat dest_format, gint64 dest_value);
143 void            gst_query_parse_convert         (GstQuery *query, GstFormat *src_format, gint64 *src_value,
144                                                  GstFormat *dest_format, gint64 *dest_value);
145
146 /* application specific query */
147 GstQuery *      gst_query_new_application       (GstQueryType type,
148                                                  GstStructure *structure);
149
150
151 GstStructure *  gst_query_get_structure         (GstQuery *query);
152
153 /* hmm */
154 #define GST_QUERY_POSITION_GET_FORMAT(q) \
155     (gst_structure_get_int ((q)->structure, "format"))
156
157 G_END_DECLS
158
159 #endif /* __GST_QUERY_H__ */
160