885319573407c6afa69c7d6c80685fac45d72374
[platform/upstream/gstreamer.git] / gst / gstvalue.h
1 /* GStreamer
2  * Copyright (C) <2003> David A. Schleef <ds@schleef.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GST_VALUE_H__
21 #define __GST_VALUE_H__
22
23 #include <gst/gstconfig.h>
24 #include <gst/gstcaps.h>
25
26 G_BEGIN_DECLS
27
28 #define GST_MAKE_FOURCC(a,b,c,d)        (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
29 #define GST_STR_FOURCC(f)               (guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
30
31 #define GST_FOURCC_FORMAT "%c%c%c%c"
32 #define GST_FOURCC_ARGS(fourcc) \
33         ((gchar) ((fourcc)     &0xff)), \
34         ((gchar) (((fourcc)>>8 )&0xff)), \
35         ((gchar) (((fourcc)>>16)&0xff)), \
36         ((gchar) (((fourcc)>>24)&0xff))
37
38 #define GST_VALUE_HOLDS_FOURCC(x)       (G_VALUE_HOLDS(x, gst_type_fourcc))
39 #define GST_VALUE_HOLDS_INT_RANGE(x)    (G_VALUE_HOLDS(x, gst_type_int_range))
40 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS(x, gst_type_double_range))
41 #define GST_VALUE_HOLDS_LIST(x)         (G_VALUE_HOLDS(x, gst_type_list))
42 #define GST_VALUE_HOLDS_FIXED_LIST(x)   (G_VALUE_HOLDS(x, gst_type_fixed_list))
43 #define GST_VALUE_HOLDS_CAPS(x)         (G_VALUE_HOLDS(x, GST_TYPE_CAPS))
44
45 #define GST_TYPE_FOURCC                  gst_type_fourcc
46 #define GST_TYPE_INT_RANGE               gst_type_int_range
47 #define GST_TYPE_DOUBLE_RANGE            gst_type_double_range
48 #define GST_TYPE_LIST                    gst_type_list
49 #define GST_TYPE_FIXED_LIST              gst_type_fixed_list
50
51 #define GST_VALUE_LESS_THAN              (-1)
52 #define GST_VALUE_EQUAL                   0
53 #define GST_VALUE_GREATER_THAN            1
54 #define GST_VALUE_UNORDERED               2
55
56 typedef int      (* GstValueCompareFunc)     (const GValue *value1,
57                                               const GValue *value2);
58 typedef char *   (* GstValueSerializeFunc)   (const GValue *value1);
59 typedef gboolean (* GstValueDeserializeFunc) (GValue       *dest,
60                                               const char   *s);
61 typedef int      (* GstValueUnionFunc)       (GValue       *dest,
62                                               const GValue *value1,
63                                               const GValue *value2);
64 typedef int      (* GstValueIntersectFunc)   (GValue       *dest,
65                                               const GValue *value1,
66                                               const GValue *value2);
67 typedef int      (* GstValueSubtractFunc)    (GValue       *dest,
68                                               const GValue *minuend,
69                                               const GValue *subtrahend);
70
71 typedef struct _GstValueTable GstValueTable;
72 struct _GstValueTable {
73   GType type;
74   GstValueCompareFunc compare;
75   GstValueSerializeFunc serialize;
76   GstValueDeserializeFunc deserialize;
77
78   void *_gst_reserved [GST_PADDING];
79 };
80
81 extern GType gst_type_fourcc;
82 extern GType gst_type_int_range;
83 extern GType gst_type_double_range;
84 extern GType gst_type_list;
85 extern GType gst_type_fixed_list;
86
87 void                     gst_value_register                (const GstValueTable   *table);
88 void                     gst_value_init_and_copy           (GValue                *dest,
89                                                             const GValue          *src);
90
91 gchar *                  gst_value_serialize               (const GValue          *value);
92 gboolean                 gst_value_deserialize             (GValue                *dest,
93                                                             const gchar           *src);
94
95 /* list */
96 void                     gst_value_list_append_value       (GValue                *value,
97                                                             const GValue          *append_value);
98 void                     gst_value_list_prepend_value      (GValue                *value,
99                                                             const GValue          *prepend_value);
100 void                     gst_value_list_concat             (GValue                *dest,
101                                                             const GValue          *value1,
102                                                             const GValue          *value2);
103 guint                    gst_value_list_get_size           (const GValue          *value);
104 G_CONST_RETURN GValue *  gst_value_list_get_value          (const GValue          *value,
105                                                             guint                  index);
106
107 /* fourcc */
108 void                     gst_value_set_fourcc              (GValue                *value,
109                                                             guint32                fourcc);
110 guint32                  gst_value_get_fourcc              (const GValue          *value);
111
112 /* int range */
113 void                     gst_value_set_int_range           (GValue                *value,
114                                                             int                    start,
115                                                             int                    end);
116 int                      gst_value_get_int_range_min       (const GValue          *value);
117 int                      gst_value_get_int_range_max       (const GValue          *value);
118
119 /* double range */
120 void                     gst_value_set_double_range        (GValue                *value,
121                                                             double                 start,
122                                                             double                 end);
123 double                   gst_value_get_double_range_min    (const GValue          *value);
124 double                   gst_value_get_double_range_max    (const GValue          *value);
125
126 /* caps */
127 G_CONST_RETURN GstCaps * gst_value_get_caps                (const GValue          *value);
128 void                     gst_value_set_caps                (GValue                *value,
129                                                             const GstCaps         *caps);
130
131 /* compare */
132 int                      gst_value_compare                 (const GValue          *value1,
133                                                             const GValue          *value2);
134 gboolean                 gst_value_can_compare             (const GValue          *value1,
135                                                             const GValue          *value2);
136
137 /* union */
138 gboolean                 gst_value_union                   (GValue                *dest,
139                                                             const GValue          *value1,
140                                                             const GValue          *value2);
141 gboolean                 gst_value_can_union               (const GValue          *value1,
142                                                             const GValue          *value2);
143 void                     gst_value_register_union_func     (GType                 type1,
144                                                             GType                 type2,
145                                                             GstValueUnionFunc     func);
146
147 /* intersection */
148 gboolean                 gst_value_intersect               (GValue                *dest,
149                                                             const GValue          *value1,
150                                                             const GValue          *value2);
151 gboolean                 gst_value_can_intersect           (const GValue          *value1,
152                                                             const GValue          *value2);
153 void                     gst_value_register_intersect_func (GType                 type1,
154                                                             GType                 type2,
155                                                             GstValueIntersectFunc func);
156
157 /* subtraction */
158 gboolean                 gst_value_subtract                (GValue                *dest,
159                                                             const GValue          *minuend,
160                                                             const GValue          *subtrahend);
161 gboolean                 gst_value_can_subtract            (const GValue          *minuend,
162                                                             const GValue          *subtrahend);
163 void                     gst_value_register_subtract_func  (GType                 minuend_type,
164                                                             GType                 subtrahend_type,
165                                                             GstValueSubtractFunc  func);
166
167 /* fixation */
168 gboolean                 gst_type_is_fixed                 (GType type);
169
170 /* private */
171 void                     _gst_value_initialize (void);
172
173 G_END_DECLS
174
175 #endif
176
177