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>
29 #define GST_TYPE_STRUCTURE (gst_structure_get_type ())
30 #define GST_STRUCTURE(object) ((GstStructure *)(object))
31 #define GST_IS_STRUCTURE(object) ((object) && (GST_STRUCTURE(object)->type == GST_TYPE_STRUCTURE))
33 typedef struct _GstStructure GstStructure;
36 * GstStructureForeachFunc:
37 * @field_id: the #GQuark of the field name
38 * @value: the #GValue of the field
39 * @user_data: user data
41 * A function that will be called in gst_structure_foreach(). The function may
44 * Returns: TRUE if the foreach operation should continue, FALSE if
45 * the foreach operation should stop with FALSE.
47 typedef gboolean (*GstStructureForeachFunc) (GQuark field_id,
52 * GstStructureMapFunc:
53 * @field_id: the #GQuark of the field name
54 * @value: the #GValue of the field
55 * @user_data: user data
57 * A function that will be called in gst_structure_map_in_place(). The function
60 * Returns: TRUE if the map operation should continue, FALSE if
61 * the map operation should stop with FALSE.
63 typedef gboolean (*GstStructureMapFunc) (GQuark field_id,
69 * @type: the GType of a structure
71 * The GstStructure object. Most fields are private.
73 struct _GstStructure {
79 /* owned by parent structure, NULL if no parent */
80 gint *parent_refcount;
84 gpointer _gst_reserved[GST_PADDING];
87 GType gst_structure_get_type (void);
89 GstStructure * gst_structure_empty_new (const gchar * name);
90 GstStructure * gst_structure_id_empty_new (GQuark quark);
91 GstStructure * gst_structure_new (const gchar * name,
92 const gchar * firstfield,
94 GstStructure * gst_structure_new_valist (const gchar * name,
95 const gchar * firstfield,
97 GstStructure * gst_structure_copy (const GstStructure *structure);
98 void gst_structure_set_parent_refcount (GstStructure *structure,
100 void gst_structure_free (GstStructure *structure);
102 G_CONST_RETURN gchar * gst_structure_get_name (const GstStructure *structure);
103 GQuark gst_structure_get_name_id (const GstStructure *structure);
104 gboolean gst_structure_has_name (const GstStructure *structure,
106 void gst_structure_set_name (GstStructure *structure,
109 void gst_structure_id_set_value (GstStructure *structure,
111 const GValue *value);
112 void gst_structure_set_value (GstStructure *structure,
113 const gchar *fieldname,
114 const GValue *value);
115 void gst_structure_set (GstStructure *structure,
116 const gchar *fieldname,
117 ...) G_GNUC_NULL_TERMINATED;
118 void gst_structure_set_valist (GstStructure *structure,
119 const gchar *fieldname,
121 G_CONST_RETURN GValue * gst_structure_id_get_value (const GstStructure *structure,
123 G_CONST_RETURN GValue * gst_structure_get_value (const GstStructure *structure,
124 const gchar *fieldname);
125 void gst_structure_remove_field (GstStructure *structure,
126 const gchar *fieldname);
127 void gst_structure_remove_fields (GstStructure *structure,
128 const gchar *fieldname,
129 ...) G_GNUC_NULL_TERMINATED;
130 void gst_structure_remove_fields_valist (GstStructure *structure,
131 const gchar *fieldname,
133 void gst_structure_remove_all_fields (GstStructure *structure);
135 GType gst_structure_get_field_type (const GstStructure *structure,
136 const gchar *fieldname);
137 gboolean gst_structure_foreach (const GstStructure *structure,
138 GstStructureForeachFunc func,
140 gboolean gst_structure_map_in_place (GstStructure *structure,
141 GstStructureMapFunc func,
143 gint gst_structure_n_fields (const GstStructure *structure);
144 const gchar * gst_structure_nth_field_name (const GstStructure *structure, guint index);
145 gboolean gst_structure_has_field (const GstStructure *structure,
146 const gchar *fieldname);
147 gboolean gst_structure_has_field_typed (const GstStructure *structure,
148 const gchar *fieldname,
151 /* utility functions */
152 gboolean gst_structure_get_boolean (const GstStructure *structure,
153 const gchar *fieldname,
155 gboolean gst_structure_get_int (const GstStructure *structure,
156 const gchar *fieldname,
158 gboolean gst_structure_get_fourcc (const GstStructure *structure,
159 const gchar *fieldname,
161 gboolean gst_structure_get_double (const GstStructure *structure,
162 const gchar *fieldname,
164 gboolean gst_structure_get_date (const GstStructure *structure,
165 const gchar *fieldname,
167 gboolean gst_structure_get_clock_time (const GstStructure *structure,
168 const gchar *fieldname,
169 GstClockTime *value);
170 G_CONST_RETURN gchar * gst_structure_get_string (const GstStructure *structure,
171 const gchar *fieldname);
172 gboolean gst_structure_get_enum (const GstStructure *structure,
173 const gchar *fieldname,
177 gchar * gst_structure_to_string (const GstStructure *structure);
178 GstStructure * gst_structure_from_string (const gchar *string,
181 gboolean gst_structure_fixate_field_nearest_int (GstStructure *structure,
182 const char *field_name,
184 gboolean gst_structure_fixate_field_nearest_double (GstStructure *structure,
185 const char *field_name,
188 gboolean gst_structure_fixate_field_boolean (GstStructure *structure,
189 const char *field_name,