merge in tagging
[platform/upstream/gstreamer.git] / gst / gsttaglist.h
1 /* GStreamer
2  * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
3  *
4  * gsttag.h: Header for tag support
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22
23 #ifndef __GST_TAG_H__
24 #define __GST_TAG_H__
25
26 #include <gst/gststructure.h>
27 #include <gst/gstevent.h>
28
29 G_BEGIN_DECLS
30
31 typedef enum {
32   GST_TAG_MERGE_UNDEFINED,
33   GST_TAG_MERGE_REPLACE_ALL,
34   GST_TAG_MERGE_REPLACE,
35   GST_TAG_MERGE_APPEND,
36   GST_TAG_MERGE_PREPEND,
37   GST_TAG_MERGE_KEEP,
38   GST_TAG_MERGE_KEEP_ALL,
39   /* add more */
40   GST_TAG_MERGE_COUNT
41 } GstTagMergeMode;
42 #define GST_TAG_MODE_IS_VALID(mode)     (((mode) > GST_TAG_MERGE_UNDEFINED) && ((mode) < GST_TAG_MERGE_COUNT))
43
44 typedef GstStructure GstTagList;
45 #define GST_TAG_LIST(x)         ((GstTagList *) (x))
46 #define GST_IS_TAG_LIST(x)      (gst_is_tag_list (GST_TAG_LIST (x)))
47
48 typedef void            (* GstTagForeachFunc)   (const GstTagList *list, const gchar *tag, gpointer user_data);
49 typedef void            (* GstTagMergeFunc)     (GValue *dest, const GValue *src);
50
51 /* initialize tagging system */
52 void            _gst_tag_initialize             (void);
53
54 void            gst_tag_register                (gchar *                name,
55                                                  GType                  type,
56                                                  gchar *                nick,
57                                                  gchar *                blurb,
58                                                  GstTagMergeFunc        func);
59 /* some default merging functions */
60 void            gst_tag_merge_use_first         (GValue *               dest,
61                                                  const GValue *         values);
62 void            gst_tag_merge_strings_with_comma (GValue *              dest,
63                                                  const GValue *         values);
64
65 /* basic tag support */
66 gboolean        gst_tag_exists                  (const gchar *          tag);
67 GType           gst_tag_get_type                (const gchar *          tag);
68 const gchar *   gst_tag_get_nick                (const gchar *          tag);
69 const gchar *   gst_tag_get_description         (const gchar *          tag);
70 gboolean        gst_tag_is_fixed                (const gchar *          tag);
71
72 /* tag lists */
73 GstTagList *    gst_tag_list_new                (void);
74 gboolean        gst_is_tag_list                 (gconstpointer          p);
75 GstTagList *    gst_tag_list_copy               (const GstTagList *     list);
76 void            gst_tag_list_insert             (GstTagList *           into,
77                                                  const GstTagList *     from,
78                                                  GstTagMergeMode        mode);
79 GstTagList *    gst_tag_list_merge              (const GstTagList *     list1,
80                                                  const GstTagList *     list2,
81                                                  GstTagMergeMode        mode);
82 void            gst_tag_list_free               (GstTagList *           list);
83 guint           gst_tag_list_get_tag_size       (const GstTagList *     list,
84                                                  const gchar *          tag);
85 void            gst_tag_list_add                (GstTagList *           list,
86                                                  GstTagMergeMode        mode,
87                                                  const gchar *          tag,
88                                                  ...);
89 void            gst_tag_list_add_valist         (GstTagList *           list,
90                                                  GstTagMergeMode        mode,
91                                                  const gchar *          tag,
92                                                  va_list                var_args);
93 void            gst_tag_list_remove_tag         (GstTagList *           list,
94                                                  const gchar *          tag);
95 void            gst_tag_list_foreach            (GstTagList *           list,
96                                                  GstTagForeachFunc      func,
97                                                  gpointer               user_data);
98
99 G_CONST_RETURN GValue *
100                 gst_tag_list_get_value_index    (const GstTagList *     list,
101                                                  const gchar *          tag,
102                                                  guint                  index);
103 gboolean        gst_tag_list_copy_value         (GValue *               dest,
104                                                  const GstTagList *     list,
105                                                  const gchar *          tag);
106
107 /* simplifications (FIXME: do we want them?) */
108 gboolean        gst_tag_list_get_char           (const GstTagList *     list,
109                                                  const gchar *          tag,
110                                                  gchar *                value);
111 gboolean        gst_tag_list_get_char_index     (const GstTagList *     list,
112                                                  const gchar *          tag,
113                                                  guint                  index,
114                                                  gchar *                value);
115 gboolean        gst_tag_list_get_uchar          (const GstTagList *     list,
116                                                  const gchar *          tag,
117                                                  guchar *               value);
118 gboolean        gst_tag_list_get_uchar_index    (const GstTagList *     list,
119                                                  const gchar *          tag,
120                                                  guint                  index,
121                                                  guchar *               value);
122 gboolean        gst_tag_list_get_boolean        (const GstTagList *     list,
123                                                  const gchar *          tag,
124                                                  gboolean *             value);
125 gboolean        gst_tag_list_get_boolean_index  (const GstTagList *     list,
126                                                  const gchar *          tag,
127                                                  guint                  index,
128                                                  gboolean *             value);
129 gboolean        gst_tag_list_get_int            (const GstTagList *     list,
130                                                  const gchar *          tag,
131                                                  gint *                 value);
132 gboolean        gst_tag_list_get_int_index      (const GstTagList *     list,
133                                                  const gchar *          tag,
134                                                  guint                  index,
135                                                  gint *                 value);
136 gboolean        gst_tag_list_get_uint           (const GstTagList *     list,
137                                                  const gchar *          tag,
138                                                  guint *                value);
139 gboolean        gst_tag_list_get_uint_index     (const GstTagList *     list,
140                                                  const gchar *          tag,
141                                                  guint                  index,
142                                                  guint *                value);
143 gboolean        gst_tag_list_get_long           (const GstTagList *     list,
144                                                  const gchar *          tag,
145                                                  glong *                value);
146 gboolean        gst_tag_list_get_long_index     (const GstTagList *     list,
147                                                  const gchar *          tag,
148                                                  guint                  index,
149                                                  glong *                value);
150 gboolean        gst_tag_list_get_ulong          (const GstTagList *     list,
151                                                  const gchar *          tag,
152                                                  gulong *               value);
153 gboolean        gst_tag_list_get_ulong_index    (const GstTagList *     list,
154                                                  const gchar *          tag,
155                                                  guint                  index,
156                                                  gulong *               value);
157 gboolean        gst_tag_list_get_int64          (const GstTagList *     list,
158                                                  const gchar *          tag,
159                                                  gint64 *               value);
160 gboolean        gst_tag_list_get_int64_index    (const GstTagList *     list,
161                                                  const gchar *          tag,
162                                                  guint                  index,
163                                                  gint64 *               value);
164 gboolean        gst_tag_list_get_uint64         (const GstTagList *     list,
165                                                  const gchar *          tag,
166                                                  guint64 *              value);
167 gboolean        gst_tag_list_get_uint64_index   (const GstTagList *     list,
168                                                  const gchar *          tag,
169                                                  guint                  index,
170                                                  guint64 *              value);
171 gboolean        gst_tag_list_get_float          (const GstTagList *     list,
172                                                  const gchar *          tag,
173                                                  gfloat *               value);
174 gboolean        gst_tag_list_get_float_index    (const GstTagList *     list,
175                                                  const gchar *          tag,
176                                                  guint                  index,
177                                                  gfloat *               value);
178 gboolean        gst_tag_list_get_double         (const GstTagList *     list,
179                                                  const gchar *          tag,
180                                                  gdouble *              value);
181 gboolean        gst_tag_list_get_double_index   (const GstTagList *     list,
182                                                  const gchar *          tag,
183                                                  guint                  index,
184                                                  gdouble *              value);
185 gboolean        gst_tag_list_get_string         (const GstTagList *     list,
186                                                  const gchar *          tag,
187                                                  gchar **               value);
188 gboolean        gst_tag_list_get_string_index   (const GstTagList *     list,
189                                                  const gchar *          tag,
190                                                  guint                  index,
191                                                  gchar **               value);
192 gboolean        gst_tag_list_get_pointer        (const GstTagList *     list,
193                                                  const gchar *          tag,
194                                                  gpointer *             value);
195 gboolean        gst_tag_list_get_pointer_index  (const GstTagList *     list,
196                                                  const gchar *          tag,
197                                                  guint                  index,
198                                                  gpointer *             value);
199
200 /* tag events */
201 GstEvent *      gst_event_new_tag               (GstTagList *           list);
202 GstTagList *    gst_event_tag_get_list          (GstEvent *             tag_event);
203
204
205 /* GStreamer core tags (need to be discussed) */
206 #define GST_TAG_TITLE                   "title"
207 #define GST_TAG_ARTIST                  "artist"
208 #define GST_TAG_ALBUM                   "album"
209 #define GST_TAG_DATE                    "date"
210 #define GST_TAG_GENRE                   "genre"
211 #define GST_TAG_COMMENT                 "comment"
212 #define GST_TAG_TRACK_NUMBER            "track-number"
213 #define GST_TAG_TRACK_COUNT             "track-count"
214 #define GST_TAG_LOCATION                "location"
215 #define GST_TAG_DESCRIPTION             "description"
216 #define GST_TAG_VERSION                 "version"
217 #define GST_TAG_ISRC                    "isrc"
218 #define GST_TAG_ORGANIZATION            "organization"
219 #define GST_TAG_COPYRIGHT               "copyright"
220 #define GST_TAG_CONTACT                 "contact"
221 #define GST_TAG_LICENSE                 "license"
222 #define GST_TAG_PERFORMER               "performer"
223 #define GST_TAG_DURATION                "duration"
224 #define GST_TAG_CODEC                   "codec"
225 #define GST_TAG_BITRATE                 "bitrate"
226 #define GST_TAG_MINIMUM_BITRATE         "minimum-bitrate"
227 #define GST_TAG_MAXIMUM_BITRATE         "maximum-bitrate"
228
229
230 G_END_DECLS
231
232 #endif /* __GST_EVENT_H__ */