First THREADED backport attempt, focusing on adding locks and making sure the API...
[platform/upstream/gstreamer.git] / gst / gststructure.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_STRUCTURE_H__
21 #define __GST_STRUCTURE_H__
22
23 #include <gst/gstconfig.h>
24 #include <gst/gsttypes.h>
25 #include <glib-object.h>
26
27 G_BEGIN_DECLS
28
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))
32
33 typedef struct _GstStructure GstStructure;
34
35 typedef gboolean (*GstStructureForeachFunc) (GQuark   field_id,
36                                              const GValue * value,
37                                              gpointer user_data);
38
39 typedef gboolean (*GstStructureMapFunc)     (GQuark   field_id,
40                                              GValue * value,
41                                              gpointer user_data);
42
43 struct _GstStructure {
44   GType type;
45
46   /*< private >*/
47   GQuark name;
48
49   /* owned by parent structure, NULL if no parent */
50   GstAtomicInt *parent_refcount;
51
52   GArray *fields;
53
54   gpointer _gst_reserved[GST_PADDING];
55 };
56
57 GType                   gst_structure_get_type             (void) G_GNUC_CONST;
58
59 GstStructure *          gst_structure_empty_new            (const gchar *            name);
60 GstStructure *          gst_structure_id_empty_new         (GQuark                   quark);
61 GstStructure *          gst_structure_new                  (const gchar *            name,
62                                                             const gchar *            firstfield,
63                                                             ...);
64 GstStructure *          gst_structure_new_valist           (const gchar *            name,
65                                                             const gchar *            firstfield,
66                                                             va_list                  varargs);
67 GstStructure *          gst_structure_copy                 (const GstStructure      *structure);
68 void                    gst_structure_set_parent_refcount  (GstStructure            *structure,
69                                                             GstAtomicInt            *refcount);
70 void                    gst_structure_free                 (GstStructure            *structure);
71
72 G_CONST_RETURN gchar *  gst_structure_get_name             (const GstStructure      *structure);
73 GQuark                  gst_structure_get_name_id          (const GstStructure      *structure);
74 void                    gst_structure_set_name             (GstStructure            *structure,
75                                                             const gchar             *name);
76
77 void                    gst_structure_id_set_value         (GstStructure            *structure,
78                                                             GQuark                   field,
79                                                             const GValue            *value);
80 void                    gst_structure_set_value            (GstStructure            *structure,
81                                                             const gchar             *fieldname,
82                                                             const GValue            *value);
83 void                    gst_structure_set                  (GstStructure            *structure,
84                                                             const gchar             *fieldname,
85                                                             ...);
86 void                    gst_structure_set_valist           (GstStructure            *structure,
87                                                             const gchar             *fieldname,
88                                                             va_list varargs);
89 G_CONST_RETURN GValue * gst_structure_id_get_value         (const GstStructure      *structure,
90                                                             GQuark                   field);
91 G_CONST_RETURN GValue * gst_structure_get_value            (const GstStructure      *structure,
92                                                             const gchar             *fieldname);
93 void                    gst_structure_remove_field         (GstStructure            *structure,
94                                                             const gchar             *fieldname);
95 void                    gst_structure_remove_fields        (GstStructure            *structure, 
96                                                              const gchar            *fieldname,
97                                                             ...);
98 void                    gst_structure_remove_fields_valist (GstStructure             *structure, 
99                                                             const gchar             *fieldname,
100                                                             va_list                  varargs);
101 void                    gst_structure_remove_all_fields    (GstStructure            *structure);
102
103 GType                   gst_structure_get_field_type       (const GstStructure      *structure,
104                                                             const gchar             *fieldname);
105 gboolean                gst_structure_foreach              (const GstStructure      *structure,
106                                                             GstStructureForeachFunc  func,
107                                                             gpointer                 user_data);
108 gboolean                gst_structure_map_in_place         (GstStructure            *structure,
109                                                             GstStructureMapFunc      func,
110                                                             gpointer                 user_data);
111 gint                    gst_structure_n_fields             (const GstStructure      *structure);
112 gboolean                gst_structure_has_field            (const GstStructure      *structure,
113                                                             const gchar             *fieldname);
114 gboolean                gst_structure_has_field_typed      (const GstStructure      *structure,
115                                                             const gchar             *fieldname,
116                                                             GType                    type);
117
118 /* utility functions */
119 gboolean                gst_structure_get_boolean          (const GstStructure      *structure,
120                                                             const gchar             *fieldname,
121                                                             gboolean                *value);
122 gboolean                gst_structure_get_int              (const GstStructure      *structure,
123                                                             const gchar             *fieldname,
124                                                             gint                    *value);
125 gboolean                gst_structure_get_fourcc           (const GstStructure      *structure,
126                                                             const gchar             *fieldname,
127                                                             guint32                 *value);
128 gboolean                gst_structure_get_double           (const GstStructure      *structure,
129                                                             const gchar             *fieldname,
130                                                             gdouble                 *value);
131 G_CONST_RETURN gchar *  gst_structure_get_string           (const GstStructure      *structure,
132                                                             const gchar             *fieldname);
133
134 gchar *                 gst_structure_to_string            (const GstStructure      *structure);
135 GstStructure *          gst_structure_from_string          (const gchar             *string,
136                                                             gchar                  **end);
137
138 gboolean                 gst_caps_structure_fixate_field_nearest_int    (GstStructure *structure,
139                                                                          const char   *field_name,
140                                                                          int           target);
141 gboolean                 gst_caps_structure_fixate_field_nearest_double (GstStructure *structure,
142                                                                          const char   *field_name,
143                                                                          double        target);
144
145
146 G_END_DECLS
147
148 #endif
149