First THREADED backport attempt, focusing on adding locks and making sure the API...
[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
32 G_BEGIN_DECLS
33
34 typedef enum {
35   GST_QUERY_NONE = 0,
36   GST_QUERY_TOTAL,
37   GST_QUERY_POSITION,
38   GST_QUERY_LATENCY,
39   GST_QUERY_JITTER,
40   GST_QUERY_START,
41   GST_QUERY_SEGMENT_END,
42   GST_QUERY_RATE
43 } GstQueryType;
44
45 /* rate is relative to 1000000  */
46 #define GST_QUERY_TYPE_RATE_DEN          G_GINT64_CONSTANT (1000000)
47
48 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
49
50 struct _GstQueryTypeDefinition
51 {
52   GstQueryType   value;
53   gchar         *nick;
54   gchar         *description;
55 };
56
57 #ifdef G_HAVE_ISO_VARARGS
58 #define GST_QUERY_TYPE_FUNCTION(type, functionname, ...)        \
59 static const GstQueryType*                              \
60 functionname (type object)                              \
61 {                                                       \
62   static const GstQueryType types[] = {                 \
63     __VA_ARGS__,                                        \
64     0                                                   \
65   };                                                    \
66   return types;                                         \
67 }
68 #elif defined(G_HAVE_GNUC_VARARGS)
69 #define GST_QUERY_TYPE_FUNCTION(type, functionname, a...)       \
70 static const GstQueryType*                              \
71 functionname (type object)                              \
72 {                                                       \
73   static const GstQueryType types[] = {                 \
74     a,                                                  \
75     0                                                   \
76   };                                                    \
77   return types;                                         \
78 }
79 #endif
80
81 void                    _gst_query_type_initialize     (void);
82
83 /* register a new query */
84 GstQueryType            gst_query_type_register        (const gchar *nick, 
85                                                         const gchar *description);
86 GstQueryType            gst_query_type_get_by_nick     (const gchar *nick);
87
88 /* check if a query is in an array of querys */
89 gboolean                gst_query_types_contains       (const GstQueryType *types, GstQueryType type);
90
91 /* query for query details */
92 G_CONST_RETURN GstQueryTypeDefinition*      
93                         gst_query_type_get_details         (GstQueryType type);
94 GstIterator*            gst_query_type_iterate_definitions (void);
95
96 G_END_DECLS
97
98 #endif /* __GST_QUERY_H__ */
99