API: add GST_TAG_ARTIST_SORTNAME
[platform/upstream/gstreamer.git] / gst / gsttaglist.h
1 /* GStreamer
2  * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
3  *
4  * gsttaglist.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_TAGLIST_H__
24 #define __GST_TAGLIST_H__
25
26 #include <gst/gststructure.h>
27 #include <gst/glib-compat.h>
28
29 G_BEGIN_DECLS
30
31 /**
32  * GstTagMergeMode:
33  * @GST_TAG_MERGE_UNDEFINED: undefined merge mode
34  * @GST_TAG_MERGE_REPLACE_ALL: replace all tags (clear list and append)
35  * @GST_TAG_MERGE_REPLACE: replace tags
36  * @GST_TAG_MERGE_APPEND: append tags
37  * @GST_TAG_MERGE_PREPEND: prepend tags
38  * @GST_TAG_MERGE_KEEP: keep existing tags
39  * @GST_TAG_MERGE_KEEP_ALL: keep all existing tags
40  * @GST_TAG_MERGE_COUNT: the number of merge modes
41  *
42  * The different tag merging modes are basically replace, overwrite and append,
43  * but they can be seen from two directions.
44  * Given two taglists: A - the one that are supplied to
45  * gst_tag_setter_merge_tags() or gst_tag_setter_add_tags() and B - the tags
46  * already in the element, how are the tags merged? In the table below this is
47  * shown for the cases that a tag exists in the list (A) or does not exists (!A)
48  * and combination thereof.
49  *
50  * <table frame="all" colsep="1" rowsep="1">
51  *   <title>merge mode</title>
52  *   <tgroup cols='5' align='left'>
53  *     <thead>
54  *       <row>
55  *         <entry>merge mode</entry>
56  *         <entry>A + B</entry>
57  *         <entry>A + !B</entry>
58  *         <entry>!A + B</entry>
59  *         <entry>!A + !B</entry>
60  *       </row>
61  *     </thead>
62  *     <tbody>
63  *       <row>
64  *         <entry>REPLACE_ALL</entry>
65  *         <entry>B</entry>
66  *         <entry>-</entry>
67  *         <entry>B</entry>
68  *         <entry>-</entry>
69  *       </row>
70  *       <row>
71  *         <entry>REPLACE</entry>
72  *         <entry>B</entry>
73  *         <entry>A</entry>
74  *         <entry>B</entry>
75  *         <entry>-</entry>
76  *       </row>
77  *       <row>
78  *         <entry>APPEND</entry>
79  *         <entry>A, B</entry>
80  *         <entry>A</entry>
81  *         <entry>B</entry>
82  *         <entry>-</entry>
83  *       </row>
84  *       <row>
85  *         <entry>PREPEND</entry>
86  *         <entry>B, A</entry>
87  *         <entry>A</entry>
88  *         <entry>B</entry>
89  *         <entry>-</entry>
90  *       </row>
91  *       <row>
92  *         <entry>KEEP</entry>
93  *         <entry>A</entry>
94  *         <entry>A</entry>
95  *         <entry>B</entry>
96  *         <entry>-</entry>
97  *       </row>
98  *       <row>
99  *         <entry>KEEP_ALL</entry>
100  *         <entry>A</entry>
101  *         <entry>A</entry>
102  *         <entry>-</entry>
103  *         <entry>-</entry>
104  *       </row>
105  *     </tbody>
106  *   </tgroup>
107  * </table>
108  */
109 typedef enum {
110   GST_TAG_MERGE_UNDEFINED,
111   GST_TAG_MERGE_REPLACE_ALL,
112   GST_TAG_MERGE_REPLACE,
113   GST_TAG_MERGE_APPEND,
114   GST_TAG_MERGE_PREPEND,
115   GST_TAG_MERGE_KEEP,
116   GST_TAG_MERGE_KEEP_ALL,
117   /* add more */
118   GST_TAG_MERGE_COUNT
119 } GstTagMergeMode;
120
121 #define GST_TAG_MODE_IS_VALID(mode)     (((mode) > GST_TAG_MERGE_UNDEFINED) && ((mode) < GST_TAG_MERGE_COUNT))
122
123 /**
124  * GstTagFlag:
125  * @GST_TAG_FLAG_UNDEFINED: undefined flag
126  * @GST_TAG_FLAG_META: tag is meta data
127  * @GST_TAG_FLAG_ENCODED: tag is encoded
128  * @GST_TAG_FLAG_DECODED: tag is decoded
129  * @GST_TAG_FLAG_COUNT: number of tag flags
130  *
131  * Extra tag flags used when registering tags.
132  */
133 typedef enum {
134   GST_TAG_FLAG_UNDEFINED,
135   GST_TAG_FLAG_META,
136   GST_TAG_FLAG_ENCODED,
137   GST_TAG_FLAG_DECODED,
138   GST_TAG_FLAG_COUNT
139 } GstTagFlag;
140
141 #define GST_TAG_FLAG_IS_VALID(flag)     (((flag) > GST_TAG_FLAG_UNDEFINED) && ((flag) < GST_TAG_FLAG_COUNT))
142
143 /**
144  * GstTagList:
145  *
146  * Opaque #GstTagList data structure.
147  */
148 typedef GstStructure GstTagList;
149 #define GST_TAG_LIST(x)       ((GstTagList *) (x))
150 #define GST_IS_TAG_LIST(x)    ((x) != NULL && gst_is_tag_list (GST_TAG_LIST (x)))
151 #define GST_TYPE_TAG_LIST     (gst_tag_list_get_type ())
152
153 /**
154  * GstTagForeachFunc:
155  * @list: the #GstTagList
156  * @tag: a name of a tag in @list
157  * @user_data: user data
158  *
159  * A function that will be called in gst_tag_list_foreach(). The function may
160  * not modify the tag list.
161  */
162 typedef void (*GstTagForeachFunc) (const GstTagList * list,
163                                    const gchar      * tag,
164                                    gpointer           user_data);
165
166 /**
167  * GstTagMergeFunc:
168  * @dest: the destination #GValue
169  * @src: the source #GValue
170  *
171  * A function for merging multiple values of a tag used when registering
172  * tags.
173  */
174 typedef void (* GstTagMergeFunc) (GValue *dest, const GValue *src);
175
176 /* initialize tagging system */
177 void         _gst_tag_initialize   (void);
178 GType        gst_tag_list_get_type (void);
179
180 void         gst_tag_register      (const gchar     * name,
181                                     GstTagFlag        flag,
182                                     GType             type,
183                                     const gchar     * nick,
184                                     const gchar     * blurb,
185                                     GstTagMergeFunc   func);
186
187 /* some default merging functions */
188 void      gst_tag_merge_use_first          (GValue * dest, const GValue * src);
189 void      gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src);
190
191 /* basic tag support */
192 gboolean               gst_tag_exists          (const gchar * tag);
193 GType                  gst_tag_get_type        (const gchar * tag);
194 G_CONST_RETURN gchar * gst_tag_get_nick        (const gchar * tag);
195 G_CONST_RETURN gchar * gst_tag_get_description (const gchar * tag);
196 GstTagFlag             gst_tag_get_flag        (const gchar * tag);
197 gboolean               gst_tag_is_fixed        (const gchar * tag);
198
199 /* tag lists */
200 GstTagList * gst_tag_list_new               (void);
201 gboolean     gst_is_tag_list                (gconstpointer p);
202 GstTagList * gst_tag_list_copy              (const GstTagList * list);
203 gboolean     gst_tag_list_is_empty          (const GstTagList * list);
204 void         gst_tag_list_insert            (GstTagList       * into,
205                                              const GstTagList * from,
206                                              GstTagMergeMode    mode);
207 GstTagList * gst_tag_list_merge             (const GstTagList * list1,
208                                              const GstTagList * list2,
209                                              GstTagMergeMode    mode);
210 void         gst_tag_list_free              (GstTagList       * list);
211 guint        gst_tag_list_get_tag_size      (const GstTagList * list,
212                                              const gchar      * tag);
213 void         gst_tag_list_add               (GstTagList       * list,
214                                              GstTagMergeMode    mode,
215                                              const gchar      * tag,
216                                              ...) G_GNUC_NULL_TERMINATED;
217 void         gst_tag_list_add_values        (GstTagList       * list,
218                                              GstTagMergeMode    mode,
219                                              const gchar      * tag,
220                                              ...) G_GNUC_NULL_TERMINATED;
221 void         gst_tag_list_add_valist        (GstTagList       * list,
222                                              GstTagMergeMode    mode,
223                                              const gchar      * tag,
224                                              va_list        var_args);
225 void         gst_tag_list_add_valist_values (GstTagList       * list,
226                                              GstTagMergeMode    mode,
227                                              const gchar      * tag,
228                                              va_list            var_args);
229 void         gst_tag_list_remove_tag        (GstTagList       * list,
230                                              const gchar      * tag);
231 void         gst_tag_list_foreach           (const GstTagList * list,
232                                              GstTagForeachFunc  func,
233                                              gpointer           user_data);
234
235 G_CONST_RETURN GValue *
236              gst_tag_list_get_value_index   (const GstTagList * list,
237                                              const gchar      * tag,
238                                              guint              index);
239 gboolean     gst_tag_list_copy_value        (GValue           * dest,
240                                              const GstTagList * list,
241                                              const gchar      * tag);
242
243 /* simplifications (FIXME: do we want them?) */
244 gboolean     gst_tag_list_get_char          (const GstTagList * list,
245                                              const gchar      * tag,
246                                              gchar            * value);
247 gboolean     gst_tag_list_get_char_index    (const GstTagList * list,
248                                              const gchar      * tag,
249                                              guint              index,
250                                              gchar            * value);
251 gboolean     gst_tag_list_get_uchar         (const GstTagList * list,
252                                              const gchar      * tag,
253                                              guchar           * value);
254 gboolean     gst_tag_list_get_uchar_index   (const GstTagList * list,
255                                              const gchar      * tag,
256                                              guint              index,
257                                              guchar           * value);
258 gboolean     gst_tag_list_get_boolean       (const GstTagList * list,
259                                              const gchar      * tag,
260                                              gboolean         * value);
261 gboolean     gst_tag_list_get_boolean_index (const GstTagList * list,
262                                              const gchar      * tag,
263                                              guint              index,
264                                              gboolean         * value);
265 gboolean     gst_tag_list_get_int           (const GstTagList * list,
266                                              const gchar      * tag,
267                                              gint             * value);
268 gboolean     gst_tag_list_get_int_index     (const GstTagList * list,
269                                              const gchar      * tag,
270                                              guint              index,
271                                              gint             * value);
272 gboolean     gst_tag_list_get_uint          (const GstTagList * list,
273                                              const gchar      * tag,
274                                              guint            * value);
275 gboolean     gst_tag_list_get_uint_index    (const GstTagList * list,
276                                              const gchar      * tag,
277                                              guint              index,
278                                              guint            * value);
279 gboolean     gst_tag_list_get_long          (const GstTagList * list,
280                                              const gchar      * tag,
281                                              glong            * value);
282 gboolean     gst_tag_list_get_long_index    (const GstTagList * list,
283                                              const gchar      * tag,
284                                              guint              index,
285                                              glong            * value);
286 gboolean     gst_tag_list_get_ulong         (const GstTagList * list,
287                                              const gchar      * tag,
288                                              gulong           * value);
289 gboolean     gst_tag_list_get_ulong_index   (const GstTagList * list,
290                                              const gchar      * tag,
291                                              guint              index,
292                                              gulong           * value);
293 gboolean     gst_tag_list_get_int64         (const GstTagList * list,
294                                              const gchar      * tag,
295                                              gint64           * value);
296 gboolean     gst_tag_list_get_int64_index   (const GstTagList * list,
297                                              const gchar      * tag,
298                                              guint              index,
299                                              gint64           * value);
300 gboolean     gst_tag_list_get_uint64        (const GstTagList * list,
301                                              const gchar      * tag,
302                                              guint64          * value);
303 gboolean     gst_tag_list_get_uint64_index  (const GstTagList * list,
304                                              const gchar      * tag,
305                                              guint              index,
306                                              guint64          * value);
307 gboolean     gst_tag_list_get_float         (const GstTagList * list,
308                                              const gchar      * tag,
309                                              gfloat           * value);
310 gboolean     gst_tag_list_get_float_index   (const GstTagList * list,
311                                              const gchar      * tag,
312                                              guint              index,
313                                              gfloat           * value);
314 gboolean     gst_tag_list_get_double        (const GstTagList * list,
315                                              const gchar      * tag,
316                                              gdouble          * value);
317 gboolean     gst_tag_list_get_double_index  (const GstTagList * list,
318                                              const gchar      * tag,
319                                              guint              index,
320                                              gdouble          * value);
321 gboolean     gst_tag_list_get_string        (const GstTagList * list,
322                                              const gchar      * tag,
323                                              gchar           ** value);
324 gboolean     gst_tag_list_get_string_index  (const GstTagList * list,
325                                              const gchar      * tag,
326                                              guint              index,
327                                              gchar           ** value);
328 gboolean     gst_tag_list_get_pointer       (const GstTagList * list,
329                                              const gchar      * tag,
330                                              gpointer         * value);
331 gboolean     gst_tag_list_get_pointer_index (const GstTagList * list,
332                                              const gchar      * tag,
333                                              guint              index,
334                                              gpointer         * value);
335 gboolean     gst_tag_list_get_date          (const GstTagList * list,
336                                              const gchar      * tag,
337                                              GDate           ** value);
338 gboolean     gst_tag_list_get_date_index    (const GstTagList * list,
339                                              const gchar      * tag,
340                                              guint              index,
341                                              GDate           ** value);
342
343 /* GStreamer core tags */
344 /**
345  * GST_TAG_TITLE:
346  *
347  * commonly used title (string)
348  *
349  * The title as it should be displayed, e.g. 'The Doll House'
350  */
351 #define GST_TAG_TITLE                  "title"
352 /**
353  * GST_TAG_TITLE_SORTNAME:
354  *
355  * commonly used title, as used for sorting (string)
356  *
357  * The title as it should be sorted, e.g. 'Doll House, The'
358  *
359  * Since: 0.10.15
360  */
361 #define GST_TAG_TITLE_SORTNAME         "title-sortname"
362 /**
363  * GST_TAG_ARTIST:
364  *
365  * person(s) responsible for the recording (string)
366  *
367  * The artist name as it should be displayed, e.g. 'Jimi Hendrix' or
368  * 'The Guitar Heroes'
369  */
370 #define GST_TAG_ARTIST                 "artist"
371 /**
372  * GST_TAG_ARTIST_SORTNAME:
373  *
374  * person(s) responsible for the recording, as used for sorting (string)
375  *
376  * The artist name as it should be sorted, e.g. 'Hendrix, Jimi' or
377  * 'Guitar Heroes, The'
378  *
379  * Since: 0.10.15
380  */
381 /* FIXME 0.11: change to "artist-sortname" */
382 #define GST_TAG_ARTIST_SORTNAME        "musicbrainz-sortname"
383 /**
384  * GST_TAG_ALBUM:
385  *
386  * album containing this data (string)
387  *
388  * The album name as it should be displayed, e.g. 'The Jazz Guitar'
389  */
390 #define GST_TAG_ALBUM                  "album"
391 /**
392  * GST_TAG_ALBUM_SORTNAME:
393  *
394  * album containing this data, as used for sorting (string)
395  *
396  * The album name as it should be sorted, e.g. 'Jazz Guitar, The'
397  *
398  * Since: 0.10.15
399  */
400 #define GST_TAG_ALBUM_SORTNAME         "album-sortname"
401 /**
402  * GST_TAG_COMPOSER:
403  *
404  * person(s) who composed the recording (string)
405  *
406  * Since: 0.10.15
407  */
408 #define GST_TAG_COMPOSER               "composer"
409 /**
410  * GST_TAG_DATE:
411  *
412  * date the data was created (#GDate structure)
413  */
414 #define GST_TAG_DATE                   "date"
415 /**
416  * GST_TAG_GENRE:
417  *
418  * genre this data belongs to (string)
419  */
420 #define GST_TAG_GENRE                  "genre"
421 /**
422  * GST_TAG_COMMENT:
423  *
424  * free text commenting the data (string)
425  */
426 #define GST_TAG_COMMENT                "comment"
427 /**
428  * GST_TAG_EXTENDED_COMMENT:
429  *
430  * key/value text commenting the data (string)
431  *
432  * Must be in the form of 'key=comment' or
433  * 'key[lc]=comment' where 'lc' is an ISO-639
434  * language code.
435  *
436  * This tag is used for unknown Vorbis comment tags,
437  * unknown APE tags and certain ID3v2 comment fields.
438  *
439  * Since: 0.10.10
440  */
441 #define GST_TAG_EXTENDED_COMMENT       "extended-comment"
442 /**
443  * GST_TAG_TRACK_NUMBER:
444  *
445  * track number inside a collection (unsigned integer)
446  */
447 #define GST_TAG_TRACK_NUMBER           "track-number"
448 /**
449  * GST_TAG_TRACK_COUNT:
450  *
451  * count of tracks inside collection this track belongs to (unsigned integer)
452  */
453 #define GST_TAG_TRACK_COUNT            "track-count"
454 /**
455  * GST_TAG_ALBUM_VOLUME_NUMBER:
456  *
457  * disc number inside a collection (unsigned integer)
458  */
459 #define GST_TAG_ALBUM_VOLUME_NUMBER    "album-disc-number"
460 /**
461  * GST_TAG_ALBUM_VOLUME_COUNT:
462  *
463  * count of discs inside collection this disc belongs to (unsigned integer)
464  */
465 #define GST_TAG_ALBUM_VOLUME_COUNT    "album-disc-count"
466 /**
467  * GST_TAG_LOCATION:
468  *
469  * original location of file as a URI (string)
470  */
471 #define GST_TAG_LOCATION               "location"
472 /**
473  * GST_TAG_DESCRIPTION:
474  *
475  * short text describing the content of the data (string)
476  */
477 #define GST_TAG_DESCRIPTION            "description"
478 /**
479  * GST_TAG_VERSION:
480  *
481  * version of this data (string)
482  */
483 #define GST_TAG_VERSION                "version"
484 /**
485  * GST_TAG_ISRC:
486  *
487  * International Standard Recording Code - see http://www.ifpi.org/isrc/ (string)
488  */
489 #define GST_TAG_ISRC                   "isrc"
490 /**
491  * GST_TAG_ORGANIZATION:
492  *
493  * organization (string)
494  */
495 #define GST_TAG_ORGANIZATION           "organization"
496 /**
497  * GST_TAG_COPYRIGHT:
498  *
499  * copyright notice of the data (string)
500  */
501 #define GST_TAG_COPYRIGHT              "copyright"
502 /**
503  * GST_TAG_COPYRIGHT_URI:
504  *
505  * URI to location where copyright details can be found (string)
506  *
507  * Since: 0.10.14
508  */
509 #define GST_TAG_COPYRIGHT_URI          "copyright-uri"
510 /**
511  * GST_TAG_CONTACT:
512  *
513  * contact information (string)
514  */
515 #define GST_TAG_CONTACT                "contact"
516 /**
517  * GST_TAG_LICENSE:
518  *
519  * license of data (string)
520  */
521 #define GST_TAG_LICENSE                "license"
522 /**
523  * GST_TAG_LICENSE_URI:
524  *
525  * URI to location where license details can be found (string)
526  *
527  * Since: 0.10.14
528  */
529 #define GST_TAG_LICENSE_URI            "license-uri"
530 /**
531  * GST_TAG_PERFORMER:
532  *
533  * person(s) performing (string)
534  */
535 #define GST_TAG_PERFORMER              "performer"
536 /**
537  * GST_TAG_DURATION:
538  *
539  * length in GStreamer time units (nanoseconds) (unsigned 64-bit integer)
540  */
541 #define GST_TAG_DURATION               "duration"
542 /**
543  * GST_TAG_CODEC:
544  *
545  * codec the data is stored in (string)
546  */
547 #define GST_TAG_CODEC                  "codec"
548 /**
549  * GST_TAG_VIDEO_CODEC:
550  *
551  * codec the video data is stored in (string)
552  */
553 #define GST_TAG_VIDEO_CODEC            "video-codec"
554 /**
555  * GST_TAG_AUDIO_CODEC:
556  *
557  * codec the audio data is stored in (string)
558  */
559 #define GST_TAG_AUDIO_CODEC            "audio-codec"
560 /**
561  * GST_TAG_BITRATE:
562  *
563  * exact or average bitrate in bits/s (unsigned integer)
564  */
565 #define GST_TAG_BITRATE                "bitrate"
566 /**
567  * GST_TAG_NOMINAL_BITRATE:
568  *
569  * nominal bitrate in bits/s (unsigned integer)
570  */
571 #define GST_TAG_NOMINAL_BITRATE        "nominal-bitrate"
572 /**
573  * GST_TAG_MINIMUM_BITRATE:
574  *
575  * minimum bitrate in bits/s (unsigned integer)
576  */
577 #define GST_TAG_MINIMUM_BITRATE        "minimum-bitrate"
578 /**
579  * GST_TAG_MAXIMUM_BITRATE:
580  *
581  * maximum bitrate in bits/s (unsigned integer)
582  */
583 #define GST_TAG_MAXIMUM_BITRATE        "maximum-bitrate"
584 /**
585  * GST_TAG_SERIAL:
586  *
587  * serial number of track (unsigned integer)
588  */
589 #define GST_TAG_SERIAL                 "serial"
590 /**
591  * GST_TAG_ENCODER:
592  *
593  * encoder used to encode this stream (string)
594  */
595 #define GST_TAG_ENCODER                "encoder"
596 /**
597  * GST_TAG_ENCODER_VERSION:
598  *
599  * version of the encoder used to encode this stream (unsigned integer)
600  */
601 #define GST_TAG_ENCODER_VERSION        "encoder-version"
602 /**
603  * GST_TAG_TRACK_GAIN:
604  *
605  * track gain in db (double)
606  */
607 #define GST_TAG_TRACK_GAIN             "replaygain-track-gain"
608 /**
609  * GST_TAG_TRACK_PEAK:
610  *
611  * peak of the track (double)
612  */
613 #define GST_TAG_TRACK_PEAK             "replaygain-track-peak"
614 /**
615  * GST_TAG_ALBUM_GAIN:
616  *
617  * album gain in db (double)
618  */
619 #define GST_TAG_ALBUM_GAIN             "replaygain-album-gain"
620 /**
621  * GST_TAG_ALBUM_PEAK:
622  *
623  * peak of the album (double)
624  */
625 #define GST_TAG_ALBUM_PEAK             "replaygain-album-peak"
626 /**
627  * GST_TAG_REFERENCE_LEVEL:
628  *
629  * reference level of track and album gain values (double)
630  *
631  * Since: 0.10.12
632  */
633 #define GST_TAG_REFERENCE_LEVEL        "replaygain-reference-level"
634 /**
635  * GST_TAG_LANGUAGE_CODE:
636  *
637  * Language code (ISO-639-1) (string)
638  */
639 #define GST_TAG_LANGUAGE_CODE          "language-code"
640 /**
641  * GST_TAG_IMAGE:
642  *
643  * image (buffer) (buffer caps should specify the content type)
644  *
645  * Since: 0.10.6
646  */
647 #define GST_TAG_IMAGE                  "image"
648 /**
649  * GST_TAG_PREVIEW_IMAGE:
650  *
651  * image that is meant for preview purposes (buffer)
652  * (buffer caps should specify the content type)
653  *
654  * Since: 0.10.7
655  */
656 #define GST_TAG_PREVIEW_IMAGE          "preview-image"
657 /**
658  * GST_TAG_BEATS_PER_MINUTE:
659  *
660  * number of beats per minute in audio (double)
661  *
662  * Since: 0.10.12
663  */
664 #define GST_TAG_BEATS_PER_MINUTE       "beats-per-minute"
665
666 G_END_DECLS
667
668 #endif /* __GST_TAGLIST_H__ */