upload tizen1.0 source
[framework/multimedia/gst-plugins-good0.10.git] / gst / id3demux / id3tags.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 /* private tag for storing unprocessed ID3v2 frames */
27 #define GST_ID3_DEMUX_TAG_ID3V2_FRAME "private-id3v2-frame"
28
29 #define ID3V1_TAG_SIZE 128
30 #define ID3V2_MARK_SIZE 3
31 #define ID3V2_HDR_SIZE 10
32
33 typedef enum {
34   ID3TAGS_MORE_DATA,
35   ID3TAGS_READ_TAG,
36   ID3TAGS_BROKEN_TAG
37 } ID3TagsResult;
38
39 /* From id3tags.c */
40 guint id3demux_calc_id3v2_tag_size (GstBuffer * buf);
41 ID3TagsResult id3demux_read_id3v2_tag (GstBuffer *buffer, guint *id3v2_size,
42   GstTagList **tags);
43
44 guint read_synch_uint (const guint8 * data, guint size);
45
46 /* Things shared by id3tags.c and id3v2frames.c */
47 #define ID3V2_VERSION 0x0400
48 #define ID3V2_VER_MAJOR(v) ((v) >> 8)
49 #define ID3V2_VER_MINOR(v) ((v) & 0xff)
50    
51 typedef struct {
52   guint16 version;
53   guint8 flags;
54   guint32 size;
55     
56   guint8 *frame_data;
57   guint32 frame_data_size;
58
59   guint32 ext_hdr_size;
60   guint8 ext_flag_bytes;
61   guint8 *ext_flag_data;  
62 } ID3v2Header;
63
64 typedef struct {
65   ID3v2Header hdr;
66   
67   GstBuffer *buffer;
68   GstTagList *tags;
69
70   /* Current frame decoding */
71   guint cur_frame_size;
72   gchar *frame_id;
73   guint16 frame_flags;
74   
75   guint8 *parse_data;
76   guint parse_size;
77   
78   /* To collect day/month from obsolete TDAT frame if it exists */
79   guint pending_month;
80   guint pending_day;
81 } ID3TagsWorking;
82
83 enum {
84   ID3V2_HDR_FLAG_UNSYNC       = 0x80,
85   ID3V2_HDR_FLAG_EXTHDR       = 0x40,
86   ID3V2_HDR_FLAG_EXPERIMENTAL = 0x20,
87   ID3V2_HDR_FLAG_FOOTER       = 0x10
88 };
89
90 enum {
91   ID3V2_EXT_FLAG_UPDATE     = 0x80,
92   ID3V2_EXT_FLAG_CRC        = 0x40,
93   ID3V2_EXT_FLAG_RESTRICTED = 0x20
94 };
95
96 enum {
97   ID3V2_FRAME_STATUS_FRAME_ALTER_PRESERVE  = 0x4000,
98   ID3V2_FRAME_STATUS_FILE_ALTER_PRESERVE   = 0x2000,
99   ID3V2_FRAME_STATUS_READONLY              = 0x1000,
100   ID3V2_FRAME_FORMAT_GROUPING_ID           = 0x0040,
101   ID3V2_FRAME_FORMAT_COMPRESSION           = 0x0008,
102   ID3V2_FRAME_FORMAT_ENCRYPTION            = 0x0004,
103   ID3V2_FRAME_FORMAT_UNSYNCHRONISATION     = 0x0002,
104   ID3V2_FRAME_FORMAT_DATA_LENGTH_INDICATOR = 0x0001
105 };
106
107 #define ID3V2_3_FRAME_FLAGS_MASK              \
108   (ID3V2_FRAME_STATUS_FRAME_ALTER_PRESERVE |  \
109    ID3V2_FRAME_STATUS_FILE_ALTER_PRESERVE  |  \
110    ID3V2_FRAME_STATUS_READONLY |              \
111    ID3V2_FRAME_FORMAT_GROUPING_ID |           \
112    ID3V2_FRAME_FORMAT_COMPRESSION |           \
113    ID3V2_FRAME_FORMAT_ENCRYPTION)
114
115 /* From id3v2frames.c */
116 gboolean id3demux_id3v2_parse_frame (ID3TagsWorking *work);
117
118 guint8 * id3demux_ununsync_data (const guint8 * unsync_data, guint32 * size);
119
120 G_END_DECLS
121
122 #endif