tizen 2.3 release
[framework/multimedia/gst-plugins-base0.10.git] / gst-libs / gst / tag / id3v2.h
1 /* Copyright 2005 Jan Schmidt <thaytan@mad.scientist.com>
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18
19 #ifndef __ID3TAGS_H__
20 #define __ID3TAGS_H__
21
22 #include <gst/gst.h>
23
24 G_BEGIN_DECLS
25
26 #define ID3V2_MARK_SIZE 3
27 #define ID3V2_HDR_SIZE GST_TAG_ID3V2_HEADER_SIZE
28
29 /* From id3v2.c */
30 guint id3v2_read_synch_uint (const guint8 * data, guint size);
31
32 /* Things shared by id3tags.c and id3v2frames.c */
33 #define ID3V2_VERSION 0x0400
34 #define ID3V2_VER_MAJOR(v) ((v) >> 8)
35 #define ID3V2_VER_MINOR(v) ((v) & 0xff)
36    
37 typedef struct {
38   guint16 version;
39   guint8 flags;
40   guint32 size;
41     
42   guint8 *frame_data;
43   guint32 frame_data_size;
44
45   guint32 ext_hdr_size;
46   guint8 ext_flag_bytes;
47   guint8 *ext_flag_data;  
48 } ID3v2Header;
49
50 typedef struct {
51   ID3v2Header hdr;
52   
53   GstBuffer *buffer;
54   GstTagList *tags;
55
56   /* Current frame decoding */
57   guint cur_frame_size;
58   gchar *frame_id;
59   guint16 frame_flags;
60   
61   guint8 *parse_data;
62   guint parse_size;
63   
64   /* To collect day/month from obsolete TDAT frame if it exists */
65   guint pending_month;
66   guint pending_day;
67 } ID3TagsWorking;
68
69 enum {
70   ID3V2_HDR_FLAG_UNSYNC       = 0x80,
71   ID3V2_HDR_FLAG_EXTHDR       = 0x40,
72   ID3V2_HDR_FLAG_EXPERIMENTAL = 0x20,
73   ID3V2_HDR_FLAG_FOOTER       = 0x10
74 };
75
76 enum {
77   ID3V2_EXT_FLAG_UPDATE     = 0x80,
78   ID3V2_EXT_FLAG_CRC        = 0x40,
79   ID3V2_EXT_FLAG_RESTRICTED = 0x20
80 };
81
82 enum {
83   ID3V2_FRAME_STATUS_FRAME_ALTER_PRESERVE  = 0x4000,
84   ID3V2_FRAME_STATUS_FILE_ALTER_PRESERVE   = 0x2000,
85   ID3V2_FRAME_STATUS_READONLY              = 0x1000,
86   ID3V2_FRAME_FORMAT_GROUPING_ID           = 0x0040,
87   ID3V2_FRAME_FORMAT_COMPRESSION           = 0x0008,
88   ID3V2_FRAME_FORMAT_ENCRYPTION            = 0x0004,
89   ID3V2_FRAME_FORMAT_UNSYNCHRONISATION     = 0x0002,
90   ID3V2_FRAME_FORMAT_DATA_LENGTH_INDICATOR = 0x0001
91 };
92
93 #define ID3V2_3_FRAME_FLAGS_MASK              \
94   (ID3V2_FRAME_STATUS_FRAME_ALTER_PRESERVE |  \
95    ID3V2_FRAME_STATUS_FILE_ALTER_PRESERVE  |  \
96    ID3V2_FRAME_STATUS_READONLY |              \
97    ID3V2_FRAME_FORMAT_GROUPING_ID |           \
98    ID3V2_FRAME_FORMAT_COMPRESSION |           \
99    ID3V2_FRAME_FORMAT_ENCRYPTION)
100
101 /* FIXME 0.11: remove 'private' bit from GST_TAG_ID3V2_FRAME */
102 /**
103  * GST_TAG_ID3V2_FRAME:
104  *
105  * Contains a single unprocessed ID3v2 frame. (buffer)
106  *
107  * (Not public API for now)
108  */
109 #define GST_TAG_ID3V2_FRAME                  "private-id3v2-frame"
110
111 /* From id3v2frames.c */
112 gboolean id3v2_parse_frame (ID3TagsWorking *work);
113
114 guint8 * id3v2_ununsync_data (const guint8 * unsync_data, guint32 * size);
115
116 GstDebugCategory * id3v2_ensure_debug_category (void);
117
118 G_END_DECLS
119
120 #endif