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 | #define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS(x, gst_type_fraction)) |
---|
45 | |
---|
46 | #define GST_TYPE_FOURCC gst_type_fourcc |
---|
47 | #define GST_TYPE_INT_RANGE gst_type_int_range |
---|
48 | #define GST_TYPE_DOUBLE_RANGE gst_type_double_range |
---|
49 | #define GST_TYPE_LIST gst_type_list |
---|
50 | #define GST_TYPE_FIXED_LIST gst_type_fixed_list |
---|
51 | #define GST_TYPE_FRACTION gst_type_fraction |
---|
52 | |
---|
53 | #define GST_VALUE_LESS_THAN (-1) |
---|
54 | #define GST_VALUE_EQUAL 0 |
---|
55 | #define GST_VALUE_GREATER_THAN 1 |
---|
56 | #define GST_VALUE_UNORDERED 2 |
---|
57 | |
---|
58 | typedef int (* GstValueCompareFunc) (const GValue *value1, |
---|
59 | const GValue *value2); |
---|
60 | typedef char * (* GstValueSerializeFunc) (const GValue *value1); |
---|
61 | typedef gboolean (* GstValueDeserializeFunc) (GValue *dest, |
---|
62 | const char *s); |
---|
63 | typedef int (* GstValueUnionFunc) (GValue *dest, |
---|
64 | const GValue *value1, |
---|
65 | const GValue *value2); |
---|
66 | typedef int (* GstValueIntersectFunc) (GValue *dest, |
---|
67 | const GValue *value1, |
---|
68 | const GValue *value2); |
---|
69 | typedef int (* GstValueSubtractFunc) (GValue *dest, |
---|
70 | const GValue *minuend, |
---|
71 | const GValue *subtrahend); |
---|
72 | |
---|
73 | typedef struct _GstValueTable GstValueTable; |
---|
74 | struct _GstValueTable { |
---|
75 | GType type; |
---|
76 | GstValueCompareFunc compare; |
---|
77 | GstValueSerializeFunc serialize; |
---|
78 | GstValueDeserializeFunc deserialize; |
---|
79 | |
---|
80 | /*< private >*/ |
---|
81 | void *_gst_reserved [GST_PADDING]; |
---|
82 | }; |
---|
83 | |
---|
84 | GST_EXPORT GType gst_type_fourcc; |
---|
85 | GST_EXPORT GType gst_type_int_range; |
---|
86 | GST_EXPORT GType gst_type_double_range; |
---|
87 | GST_EXPORT GType gst_type_list; |
---|
88 | GST_EXPORT GType gst_type_fixed_list; |
---|
89 | GST_EXPORT GType gst_type_fraction; |
---|
90 | |
---|
91 | void gst_value_register (const GstValueTable *table); |
---|
92 | void gst_value_init_and_copy (GValue *dest, |
---|
93 | const GValue *src); |
---|
94 | |
---|
95 | gchar * gst_value_serialize (const GValue *value); |
---|
96 | gboolean gst_value_deserialize (GValue *dest, |
---|
97 | const gchar *src); |
---|
98 | |
---|
99 | /* list */ |
---|
100 | void gst_value_list_append_value (GValue *value, |
---|
101 | const GValue *append_value); |
---|
102 | void gst_value_list_prepend_value (GValue *value, |
---|
103 | const GValue *prepend_value); |
---|
104 | void gst_value_list_concat (GValue *dest, |
---|
105 | const GValue *value1, |
---|
106 | const GValue *value2); |
---|
107 | guint gst_value_list_get_size (const GValue *value); |
---|
108 | G_CONST_RETURN GValue * |
---|
109 | gst_value_list_get_value (const GValue *value, |
---|
110 | guint index); |
---|
111 | |
---|
112 | /* fourcc */ |
---|
113 | void gst_value_set_fourcc (GValue *value, |
---|
114 | guint32 fourcc); |
---|
115 | guint32 gst_value_get_fourcc (const GValue *value); |
---|
116 | |
---|
117 | /* int range */ |
---|
118 | void gst_value_set_int_range (GValue *value, |
---|
119 | int start, |
---|
120 | int end); |
---|
121 | int gst_value_get_int_range_min (const GValue *value); |
---|
122 | int gst_value_get_int_range_max (const GValue *value); |
---|
123 | |
---|
124 | /* double range */ |
---|
125 | void gst_value_set_double_range (GValue *value, |
---|
126 | double start, |
---|
127 | double end); |
---|
128 | double gst_value_get_double_range_min (const GValue *value); |
---|
129 | double gst_value_get_double_range_max (const GValue *value); |
---|
130 | |
---|
131 | /* caps */ |
---|
132 | G_CONST_RETURN GstCaps * |
---|
133 | gst_value_get_caps (const GValue *value); |
---|
134 | void gst_value_set_caps (GValue *value, |
---|
135 | const GstCaps *caps); |
---|
136 | |
---|
137 | /* fraction */ |
---|
138 | void gst_value_set_fraction (GValue *value, |
---|
139 | int numerator, |
---|
140 | int denominator); |
---|
141 | int gst_value_get_fraction_numerator (const GValue *value); |
---|
142 | int gst_value_get_fraction_denominator(const GValue *value); |
---|
143 | gboolean gst_value_fraction_multiply (GValue *product, |
---|
144 | const GValue *factor1, |
---|
145 | const GValue *factor2); |
---|
146 | |
---|
147 | /* compare */ |
---|
148 | int gst_value_compare (const GValue *value1, |
---|
149 | const GValue *value2); |
---|
150 | gboolean gst_value_can_compare (const GValue *value1, |
---|
151 | const GValue *value2); |
---|
152 | |
---|
153 | /* union */ |
---|
154 | gboolean gst_value_union (GValue *dest, |
---|
155 | const GValue *value1, |
---|
156 | const GValue *value2); |
---|
157 | gboolean gst_value_can_union (const GValue *value1, |
---|
158 | const GValue *value2); |
---|
159 | void gst_value_register_union_func (GType type1, |
---|
160 | GType type2, |
---|
161 | GstValueUnionFunc func); |
---|
162 | |
---|
163 | /* intersection */ |
---|
164 | gboolean gst_value_intersect (GValue *dest, |
---|
165 | const GValue *value1, |
---|
166 | const GValue *value2); |
---|
167 | gboolean gst_value_can_intersect (const GValue *value1, |
---|
168 | const GValue *value2); |
---|
169 | void gst_value_register_intersect_func (GType type1, |
---|
170 | GType type2, |
---|
171 | GstValueIntersectFunc func); |
---|
172 | |
---|
173 | /* subtraction */ |
---|
174 | gboolean gst_value_subtract (GValue *dest, |
---|
175 | const GValue *minuend, |
---|
176 | const GValue *subtrahend); |
---|
177 | gboolean gst_value_can_subtract (const GValue *minuend, |
---|
178 | const GValue *subtrahend); |
---|
179 | void gst_value_register_subtract_func (GType minuend_type, |
---|
180 | GType subtrahend_type, |
---|
181 | GstValueSubtractFunc func); |
---|
182 | |
---|
183 | /* fixation */ |
---|
184 | gboolean gst_type_is_fixed (GType type); |
---|
185 | gboolean gst_value_is_fixed (const GValue *value); |
---|
186 | |
---|
187 | /* private */ |
---|
188 | void _gst_value_initialize (void); |
---|
189 | |
---|
190 | G_END_DECLS |
---|
191 | |
---|
192 | #endif |
---|
193 | |
---|
194 | |
---|