2 * Copyright (C) 2003 David A. Schleef <ds@schleef.org>
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.
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.
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.
20 #ifndef __GST_STRUCTURE_H__
21 #define __GST_STRUCTURE_H__
23 #include <gst/gstconfig.h>
24 #include <glib-object.h>
25 #include <gst/gstclock.h>
26 #include <gst/gstdatetime.h>
27 #include <gst/glib-compat.h>
31 #define GST_TYPE_STRUCTURE (gst_structure_get_type ())
32 #define GST_STRUCTURE(object) ((GstStructure *)(object))
33 #define GST_IS_STRUCTURE(object) ((object) && (GST_STRUCTURE(object)->type == GST_TYPE_STRUCTURE))
35 typedef struct _GstStructure GstStructure;
38 * GstStructureForeachFunc:
39 * @field_id: the #GQuark of the field name
40 * @value: the #GValue of the field
41 * @user_data: user data
43 * A function that will be called in gst_structure_foreach(). The function may
46 * Returns: TRUE if the foreach operation should continue, FALSE if
47 * the foreach operation should stop with FALSE.
49 typedef gboolean (*GstStructureForeachFunc) (GQuark field_id,
54 * GstStructureMapFunc:
55 * @field_id: the #GQuark of the field name
56 * @value: the #GValue of the field
57 * @user_data: user data
59 * A function that will be called in gst_structure_map_in_place(). The function
62 * Returns: TRUE if the map operation should continue, FALSE if
63 * the map operation should stop with FALSE.
65 typedef gboolean (*GstStructureMapFunc) (GQuark field_id,
71 * @type: the GType of a structure
73 * The GstStructure object. Most fields are private.
75 struct _GstStructure {
81 /* owned by parent structure, NULL if no parent */
82 gint *parent_refcount;
86 gpointer _gst_reserved;
89 GType gst_structure_get_type (void);
91 GstStructure * gst_structure_empty_new (const gchar * name);
92 GstStructure * gst_structure_id_empty_new (GQuark quark);
93 GstStructure * gst_structure_new (const gchar * name,
94 const gchar * firstfield,
96 GstStructure * gst_structure_new_valist (const gchar * name,
97 const gchar * firstfield,
99 GstStructure * gst_structure_id_new (GQuark name_quark,
102 GstStructure * gst_structure_copy (const GstStructure *structure);
103 void gst_structure_set_parent_refcount (GstStructure *structure,
105 void gst_structure_free (GstStructure *structure);
107 G_CONST_RETURN gchar * gst_structure_get_name (const GstStructure *structure);
108 GQuark gst_structure_get_name_id (const GstStructure *structure);
109 gboolean gst_structure_has_name (const GstStructure *structure,
111 void gst_structure_set_name (GstStructure *structure,
114 void gst_structure_id_set_value (GstStructure *structure,
116 const GValue *value);
117 void gst_structure_set_value (GstStructure *structure,
118 const gchar *fieldname,
119 const GValue *value);
120 void gst_structure_id_take_value (GstStructure *structure,
123 void gst_structure_take_value (GstStructure *structure,
124 const gchar *fieldname,
126 void gst_structure_set (GstStructure *structure,
127 const gchar *fieldname,
128 ...) G_GNUC_NULL_TERMINATED;
130 void gst_structure_set_valist (GstStructure *structure,
131 const gchar *fieldname,
134 void gst_structure_id_set (GstStructure *structure,
136 ...) G_GNUC_NULL_TERMINATED;
138 void gst_structure_id_set_valist (GstStructure *structure,
142 gboolean gst_structure_get_valist (const GstStructure *structure,
143 const char *first_fieldname,
146 gboolean gst_structure_get (const GstStructure *structure,
147 const char *first_fieldname,
148 ...) G_GNUC_NULL_TERMINATED;
150 gboolean gst_structure_id_get_valist (const GstStructure *structure,
151 GQuark first_field_id,
154 gboolean gst_structure_id_get (const GstStructure *structure,
155 GQuark first_field_id,
156 ...) G_GNUC_NULL_TERMINATED;
158 G_CONST_RETURN GValue * gst_structure_id_get_value (const GstStructure *structure,
160 G_CONST_RETURN GValue * gst_structure_get_value (const GstStructure *structure,
161 const gchar *fieldname);
162 void gst_structure_remove_field (GstStructure *structure,
163 const gchar *fieldname);
164 void gst_structure_remove_fields (GstStructure *structure,
165 const gchar *fieldname,
166 ...) G_GNUC_NULL_TERMINATED;
167 void gst_structure_remove_fields_valist (GstStructure *structure,
168 const gchar *fieldname,
170 void gst_structure_remove_all_fields (GstStructure *structure);
172 GType gst_structure_get_field_type (const GstStructure *structure,
173 const gchar *fieldname);
174 gboolean gst_structure_foreach (const GstStructure *structure,
175 GstStructureForeachFunc func,
177 gboolean gst_structure_map_in_place (GstStructure *structure,
178 GstStructureMapFunc func,
180 gint gst_structure_n_fields (const GstStructure *structure);
181 const gchar * gst_structure_nth_field_name (const GstStructure *structure, guint index);
182 gboolean gst_structure_id_has_field (const GstStructure *structure,
184 gboolean gst_structure_id_has_field_typed (const GstStructure *structure,
187 gboolean gst_structure_has_field (const GstStructure *structure,
188 const gchar *fieldname);
189 gboolean gst_structure_has_field_typed (const GstStructure *structure,
190 const gchar *fieldname,
193 /* utility functions */
194 gboolean gst_structure_get_boolean (const GstStructure *structure,
195 const gchar *fieldname,
197 gboolean gst_structure_get_int (const GstStructure *structure,
198 const gchar *fieldname,
200 gboolean gst_structure_get_uint (const GstStructure *structure,
201 const gchar *fieldname,
203 gboolean gst_structure_get_fourcc (const GstStructure *structure,
204 const gchar *fieldname,
206 gboolean gst_structure_get_double (const GstStructure *structure,
207 const gchar *fieldname,
209 gboolean gst_structure_get_date (const GstStructure *structure,
210 const gchar *fieldname,
212 gboolean gst_structure_get_date_time (const GstStructure *structure,
213 const gchar *fieldname,
214 GstDateTime **value);
215 gboolean gst_structure_get_clock_time (const GstStructure *structure,
216 const gchar *fieldname,
217 GstClockTime *value);
218 G_CONST_RETURN gchar * gst_structure_get_string (const GstStructure *structure,
219 const gchar *fieldname);
220 gboolean gst_structure_get_enum (const GstStructure *structure,
221 const gchar *fieldname,
224 gboolean gst_structure_get_fraction (const GstStructure *structure,
225 const gchar *fieldname,
226 gint *value_numerator,
227 gint *value_denominator);
229 gchar * gst_structure_to_string (const GstStructure *structure);
230 GstStructure * gst_structure_from_string (const gchar *string,
233 gboolean gst_structure_fixate_field_nearest_int (GstStructure *structure,
234 const char *field_name,
236 gboolean gst_structure_fixate_field_nearest_double (GstStructure *structure,
237 const char *field_name,
240 gboolean gst_structure_fixate_field_boolean (GstStructure *structure,
241 const char *field_name,
243 gboolean gst_structure_fixate_field_string (GstStructure *structure,
244 const char *field_name,
245 const gchar *target);
246 gboolean gst_structure_fixate_field_nearest_fraction (GstStructure *structure,
247 const char *field_name,
248 const gint target_numerator,
249 const gint target_denominator);