annotate src/libid3tag-0.15.1b/id3tag.h @ 3:6c505a35919a

Add some MinGW builds
author Chris Cannam
date Wed, 20 Mar 2013 13:49:36 +0000
parents c7265573341e
children
rev   line source
Chris@0 1 /*
Chris@0 2 * libid3tag - ID3 tag manipulation library
Chris@0 3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
Chris@0 4 *
Chris@0 5 * This program is free software; you can redistribute it and/or modify
Chris@0 6 * it under the terms of the GNU General Public License as published by
Chris@0 7 * the Free Software Foundation; either version 2 of the License, or
Chris@0 8 * (at your option) any later version.
Chris@0 9 *
Chris@0 10 * This program is distributed in the hope that it will be useful,
Chris@0 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 13 * GNU General Public License for more details.
Chris@0 14 *
Chris@0 15 * You should have received a copy of the GNU General Public License
Chris@0 16 * along with this program; if not, write to the Free Software
Chris@0 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Chris@0 18 *
Chris@0 19 * If you would like to negotiate alternate licensing terms, you may do
Chris@0 20 * so by contacting: Underbit Technologies, Inc. <info@underbit.com>
Chris@0 21 *
Chris@0 22 * $Id: id3tag.h,v 1.17 2004/01/23 23:22:46 rob Exp $
Chris@0 23 */
Chris@0 24
Chris@0 25 # ifndef LIBID3TAG_ID3TAG_H
Chris@0 26 # define LIBID3TAG_ID3TAG_H
Chris@0 27
Chris@0 28 # ifdef __cplusplus
Chris@0 29 extern "C" {
Chris@0 30 # endif
Chris@0 31
Chris@0 32 # define ID3_TAG_VERSION 0x0400
Chris@0 33 # define ID3_TAG_VERSION_MAJOR(x) (((x) >> 8) & 0xff)
Chris@0 34 # define ID3_TAG_VERSION_MINOR(x) (((x) >> 0) & 0xff)
Chris@0 35
Chris@0 36 typedef unsigned char id3_byte_t;
Chris@0 37 typedef unsigned long id3_length_t;
Chris@0 38
Chris@0 39 typedef unsigned long id3_ucs4_t;
Chris@0 40
Chris@0 41 typedef unsigned char id3_latin1_t;
Chris@0 42 typedef unsigned short id3_utf16_t;
Chris@0 43 typedef signed char id3_utf8_t;
Chris@0 44
Chris@0 45 struct id3_tag {
Chris@0 46 unsigned int refcount;
Chris@0 47 unsigned int version;
Chris@0 48 int flags;
Chris@0 49 int extendedflags;
Chris@0 50 int restrictions;
Chris@0 51 int options;
Chris@0 52 unsigned int nframes;
Chris@0 53 struct id3_frame **frames;
Chris@0 54 id3_length_t paddedsize;
Chris@0 55 };
Chris@0 56
Chris@0 57 # define ID3_TAG_QUERYSIZE 10
Chris@0 58
Chris@0 59 /* ID3v1 field frames */
Chris@0 60
Chris@0 61 # define ID3_FRAME_TITLE "TIT2"
Chris@0 62 # define ID3_FRAME_ARTIST "TPE1"
Chris@0 63 # define ID3_FRAME_ALBUM "TALB"
Chris@0 64 # define ID3_FRAME_TRACK "TRCK"
Chris@0 65 # define ID3_FRAME_YEAR "TDRC"
Chris@0 66 # define ID3_FRAME_GENRE "TCON"
Chris@0 67 # define ID3_FRAME_COMMENT "COMM"
Chris@0 68
Chris@0 69 /* special frames */
Chris@0 70
Chris@0 71 # define ID3_FRAME_OBSOLETE "ZOBS" /* with apologies to the French */
Chris@0 72
Chris@0 73 /* tag flags */
Chris@0 74
Chris@0 75 enum {
Chris@0 76 ID3_TAG_FLAG_UNSYNCHRONISATION = 0x80,
Chris@0 77 ID3_TAG_FLAG_EXTENDEDHEADER = 0x40,
Chris@0 78 ID3_TAG_FLAG_EXPERIMENTALINDICATOR = 0x20,
Chris@0 79 ID3_TAG_FLAG_FOOTERPRESENT = 0x10,
Chris@0 80
Chris@0 81 ID3_TAG_FLAG_KNOWNFLAGS = 0xf0
Chris@0 82 };
Chris@0 83
Chris@0 84 /* tag extended flags */
Chris@0 85
Chris@0 86 enum {
Chris@0 87 ID3_TAG_EXTENDEDFLAG_TAGISANUPDATE = 0x40,
Chris@0 88 ID3_TAG_EXTENDEDFLAG_CRCDATAPRESENT = 0x20,
Chris@0 89 ID3_TAG_EXTENDEDFLAG_TAGRESTRICTIONS = 0x10,
Chris@0 90
Chris@0 91 ID3_TAG_EXTENDEDFLAG_KNOWNFLAGS = 0x70
Chris@0 92 };
Chris@0 93
Chris@0 94 /* tag restrictions */
Chris@0 95
Chris@0 96 enum {
Chris@0 97 ID3_TAG_RESTRICTION_TAGSIZE_MASK = 0xc0,
Chris@0 98 ID3_TAG_RESTRICTION_TAGSIZE_128_FRAMES_1_MB = 0x00,
Chris@0 99 ID3_TAG_RESTRICTION_TAGSIZE_64_FRAMES_128_KB = 0x40,
Chris@0 100 ID3_TAG_RESTRICTION_TAGSIZE_32_FRAMES_40_KB = 0x80,
Chris@0 101 ID3_TAG_RESTRICTION_TAGSIZE_32_FRAMES_4_KB = 0xc0
Chris@0 102 };
Chris@0 103
Chris@0 104 enum {
Chris@0 105 ID3_TAG_RESTRICTION_TEXTENCODING_MASK = 0x20,
Chris@0 106 ID3_TAG_RESTRICTION_TEXTENCODING_NONE = 0x00,
Chris@0 107 ID3_TAG_RESTRICTION_TEXTENCODING_LATIN1_UTF8 = 0x20
Chris@0 108 };
Chris@0 109
Chris@0 110 enum {
Chris@0 111 ID3_TAG_RESTRICTION_TEXTSIZE_MASK = 0x18,
Chris@0 112 ID3_TAG_RESTRICTION_TEXTSIZE_NONE = 0x00,
Chris@0 113 ID3_TAG_RESTRICTION_TEXTSIZE_1024_CHARS = 0x08,
Chris@0 114 ID3_TAG_RESTRICTION_TEXTSIZE_128_CHARS = 0x10,
Chris@0 115 ID3_TAG_RESTRICTION_TEXTSIZE_30_CHARS = 0x18
Chris@0 116 };
Chris@0 117
Chris@0 118 enum {
Chris@0 119 ID3_TAG_RESTRICTION_IMAGEENCODING_MASK = 0x04,
Chris@0 120 ID3_TAG_RESTRICTION_IMAGEENCODING_NONE = 0x00,
Chris@0 121 ID3_TAG_RESTRICTION_IMAGEENCODING_PNG_JPEG = 0x04
Chris@0 122 };
Chris@0 123
Chris@0 124 enum {
Chris@0 125 ID3_TAG_RESTRICTION_IMAGESIZE_MASK = 0x03,
Chris@0 126 ID3_TAG_RESTRICTION_IMAGESIZE_NONE = 0x00,
Chris@0 127 ID3_TAG_RESTRICTION_IMAGESIZE_256_256 = 0x01,
Chris@0 128 ID3_TAG_RESTRICTION_IMAGESIZE_64_64 = 0x02,
Chris@0 129 ID3_TAG_RESTRICTION_IMAGESIZE_64_64_EXACT = 0x03
Chris@0 130 };
Chris@0 131
Chris@0 132 /* library options */
Chris@0 133
Chris@0 134 enum {
Chris@0 135 ID3_TAG_OPTION_UNSYNCHRONISATION = 0x0001, /* use unsynchronisation */
Chris@0 136 ID3_TAG_OPTION_COMPRESSION = 0x0002, /* use compression */
Chris@0 137 ID3_TAG_OPTION_CRC = 0x0004, /* use CRC */
Chris@0 138
Chris@0 139 ID3_TAG_OPTION_APPENDEDTAG = 0x0010, /* tag will be appended */
Chris@0 140 ID3_TAG_OPTION_FILEALTERED = 0x0020, /* audio data was altered */
Chris@0 141
Chris@0 142 ID3_TAG_OPTION_ID3V1 = 0x0100 /* render ID3v1/ID3v1.1 tag */
Chris@0 143 };
Chris@0 144
Chris@0 145 struct id3_frame {
Chris@0 146 char id[5];
Chris@0 147 char const *description;
Chris@0 148 unsigned int refcount;
Chris@0 149 int flags;
Chris@0 150 int group_id;
Chris@0 151 int encryption_method;
Chris@0 152 id3_byte_t *encoded;
Chris@0 153 id3_length_t encoded_length;
Chris@0 154 id3_length_t decoded_length;
Chris@0 155 unsigned int nfields;
Chris@0 156 union id3_field *fields;
Chris@0 157 };
Chris@0 158
Chris@0 159 enum {
Chris@0 160 /* frame status flags */
Chris@0 161 ID3_FRAME_FLAG_TAGALTERPRESERVATION = 0x4000,
Chris@0 162 ID3_FRAME_FLAG_FILEALTERPRESERVATION = 0x2000,
Chris@0 163 ID3_FRAME_FLAG_READONLY = 0x1000,
Chris@0 164
Chris@0 165 ID3_FRAME_FLAG_STATUSFLAGS = 0xff00,
Chris@0 166
Chris@0 167 /* frame format flags */
Chris@0 168 ID3_FRAME_FLAG_GROUPINGIDENTITY = 0x0040,
Chris@0 169 ID3_FRAME_FLAG_COMPRESSION = 0x0008,
Chris@0 170 ID3_FRAME_FLAG_ENCRYPTION = 0x0004,
Chris@0 171 ID3_FRAME_FLAG_UNSYNCHRONISATION = 0x0002,
Chris@0 172 ID3_FRAME_FLAG_DATALENGTHINDICATOR = 0x0001,
Chris@0 173
Chris@0 174 ID3_FRAME_FLAG_FORMATFLAGS = 0x00ff,
Chris@0 175
Chris@0 176 ID3_FRAME_FLAG_KNOWNFLAGS = 0x704f
Chris@0 177 };
Chris@0 178
Chris@0 179 enum id3_field_type {
Chris@0 180 ID3_FIELD_TYPE_TEXTENCODING,
Chris@0 181 ID3_FIELD_TYPE_LATIN1,
Chris@0 182 ID3_FIELD_TYPE_LATIN1FULL,
Chris@0 183 ID3_FIELD_TYPE_LATIN1LIST,
Chris@0 184 ID3_FIELD_TYPE_STRING,
Chris@0 185 ID3_FIELD_TYPE_STRINGFULL,
Chris@0 186 ID3_FIELD_TYPE_STRINGLIST,
Chris@0 187 ID3_FIELD_TYPE_LANGUAGE,
Chris@0 188 ID3_FIELD_TYPE_FRAMEID,
Chris@0 189 ID3_FIELD_TYPE_DATE,
Chris@0 190 ID3_FIELD_TYPE_INT8,
Chris@0 191 ID3_FIELD_TYPE_INT16,
Chris@0 192 ID3_FIELD_TYPE_INT24,
Chris@0 193 ID3_FIELD_TYPE_INT32,
Chris@0 194 ID3_FIELD_TYPE_INT32PLUS,
Chris@0 195 ID3_FIELD_TYPE_BINARYDATA
Chris@0 196 };
Chris@0 197
Chris@0 198 enum id3_field_textencoding {
Chris@0 199 ID3_FIELD_TEXTENCODING_ISO_8859_1 = 0x00,
Chris@0 200 ID3_FIELD_TEXTENCODING_UTF_16 = 0x01,
Chris@0 201 ID3_FIELD_TEXTENCODING_UTF_16BE = 0x02,
Chris@0 202 ID3_FIELD_TEXTENCODING_UTF_8 = 0x03
Chris@0 203 };
Chris@0 204
Chris@0 205 union id3_field {
Chris@0 206 enum id3_field_type type;
Chris@0 207 struct {
Chris@0 208 enum id3_field_type type;
Chris@0 209 signed long value;
Chris@0 210 } number;
Chris@0 211 struct {
Chris@0 212 enum id3_field_type type;
Chris@0 213 id3_latin1_t *ptr;
Chris@0 214 } latin1;
Chris@0 215 struct {
Chris@0 216 enum id3_field_type type;
Chris@0 217 unsigned int nstrings;
Chris@0 218 id3_latin1_t **strings;
Chris@0 219 } latin1list;
Chris@0 220 struct {
Chris@0 221 enum id3_field_type type;
Chris@0 222 id3_ucs4_t *ptr;
Chris@0 223 } string;
Chris@0 224 struct {
Chris@0 225 enum id3_field_type type;
Chris@0 226 unsigned int nstrings;
Chris@0 227 id3_ucs4_t **strings;
Chris@0 228 } stringlist;
Chris@0 229 struct {
Chris@0 230 enum id3_field_type type;
Chris@0 231 char value[9];
Chris@0 232 } immediate;
Chris@0 233 struct {
Chris@0 234 enum id3_field_type type;
Chris@0 235 id3_byte_t *data;
Chris@0 236 id3_length_t length;
Chris@0 237 } binary;
Chris@0 238 };
Chris@0 239
Chris@0 240 /* file interface */
Chris@0 241
Chris@0 242 enum id3_file_mode {
Chris@0 243 ID3_FILE_MODE_READONLY = 0,
Chris@0 244 ID3_FILE_MODE_READWRITE
Chris@0 245 };
Chris@0 246
Chris@0 247 struct id3_file *id3_file_open(char const *, enum id3_file_mode);
Chris@0 248 struct id3_file *id3_file_fdopen(int, enum id3_file_mode);
Chris@0 249 int id3_file_close(struct id3_file *);
Chris@0 250
Chris@0 251 struct id3_tag *id3_file_tag(struct id3_file const *);
Chris@0 252
Chris@0 253 int id3_file_update(struct id3_file *);
Chris@0 254
Chris@0 255 /* tag interface */
Chris@0 256
Chris@0 257 struct id3_tag *id3_tag_new(void);
Chris@0 258 void id3_tag_delete(struct id3_tag *);
Chris@0 259
Chris@0 260 unsigned int id3_tag_version(struct id3_tag const *);
Chris@0 261
Chris@0 262 int id3_tag_options(struct id3_tag *, int, int);
Chris@0 263 void id3_tag_setlength(struct id3_tag *, id3_length_t);
Chris@0 264
Chris@0 265 void id3_tag_clearframes(struct id3_tag *);
Chris@0 266
Chris@0 267 int id3_tag_attachframe(struct id3_tag *, struct id3_frame *);
Chris@0 268 int id3_tag_detachframe(struct id3_tag *, struct id3_frame *);
Chris@0 269
Chris@0 270 struct id3_frame *id3_tag_findframe(struct id3_tag const *,
Chris@0 271 char const *, unsigned int);
Chris@0 272
Chris@0 273 signed long id3_tag_query(id3_byte_t const *, id3_length_t);
Chris@0 274
Chris@0 275 struct id3_tag *id3_tag_parse(id3_byte_t const *, id3_length_t);
Chris@0 276 id3_length_t id3_tag_render(struct id3_tag const *, id3_byte_t *);
Chris@0 277
Chris@0 278 /* frame interface */
Chris@0 279
Chris@0 280 struct id3_frame *id3_frame_new(char const *);
Chris@0 281 void id3_frame_delete(struct id3_frame *);
Chris@0 282
Chris@0 283 union id3_field *id3_frame_field(struct id3_frame const *, unsigned int);
Chris@0 284
Chris@0 285 /* field interface */
Chris@0 286
Chris@0 287 enum id3_field_type id3_field_type(union id3_field const *);
Chris@0 288
Chris@0 289 int id3_field_setint(union id3_field *, signed long);
Chris@0 290 int id3_field_settextencoding(union id3_field *, enum id3_field_textencoding);
Chris@0 291 int id3_field_setstrings(union id3_field *, unsigned int, id3_ucs4_t **);
Chris@0 292 int id3_field_addstring(union id3_field *, id3_ucs4_t const *);
Chris@0 293 int id3_field_setlanguage(union id3_field *, char const *);
Chris@0 294 int id3_field_setlatin1(union id3_field *, id3_latin1_t const *);
Chris@0 295 int id3_field_setfulllatin1(union id3_field *, id3_latin1_t const *);
Chris@0 296 int id3_field_setstring(union id3_field *, id3_ucs4_t const *);
Chris@0 297 int id3_field_setfullstring(union id3_field *, id3_ucs4_t const *);
Chris@0 298 int id3_field_setframeid(union id3_field *, char const *);
Chris@0 299 int id3_field_setbinarydata(union id3_field *,
Chris@0 300 id3_byte_t const *, id3_length_t);
Chris@0 301
Chris@0 302 signed long id3_field_getint(union id3_field const *);
Chris@0 303 enum id3_field_textencoding id3_field_gettextencoding(union id3_field const *);
Chris@0 304 id3_latin1_t const *id3_field_getlatin1(union id3_field const *);
Chris@0 305 id3_latin1_t const *id3_field_getfulllatin1(union id3_field const *);
Chris@0 306 id3_ucs4_t const *id3_field_getstring(union id3_field const *);
Chris@0 307 id3_ucs4_t const *id3_field_getfullstring(union id3_field const *);
Chris@0 308 unsigned int id3_field_getnstrings(union id3_field const *);
Chris@0 309 id3_ucs4_t const *id3_field_getstrings(union id3_field const *,
Chris@0 310 unsigned int);
Chris@0 311 char const *id3_field_getframeid(union id3_field const *);
Chris@0 312 id3_byte_t const *id3_field_getbinarydata(union id3_field const *,
Chris@0 313 id3_length_t *);
Chris@0 314
Chris@0 315 /* genre interface */
Chris@0 316
Chris@0 317 id3_ucs4_t const *id3_genre_index(unsigned int);
Chris@0 318 id3_ucs4_t const *id3_genre_name(id3_ucs4_t const *);
Chris@0 319 int id3_genre_number(id3_ucs4_t const *);
Chris@0 320
Chris@0 321 /* ucs4 interface */
Chris@0 322
Chris@0 323 id3_latin1_t *id3_ucs4_latin1duplicate(id3_ucs4_t const *);
Chris@0 324 id3_utf16_t *id3_ucs4_utf16duplicate(id3_ucs4_t const *);
Chris@0 325 id3_utf8_t *id3_ucs4_utf8duplicate(id3_ucs4_t const *);
Chris@0 326
Chris@0 327 void id3_ucs4_putnumber(id3_ucs4_t *, unsigned long);
Chris@0 328 unsigned long id3_ucs4_getnumber(id3_ucs4_t const *);
Chris@0 329
Chris@0 330 /* latin1/utf16/utf8 interfaces */
Chris@0 331
Chris@0 332 id3_ucs4_t *id3_latin1_ucs4duplicate(id3_latin1_t const *);
Chris@0 333 id3_ucs4_t *id3_utf16_ucs4duplicate(id3_utf16_t const *);
Chris@0 334 id3_ucs4_t *id3_utf8_ucs4duplicate(id3_utf8_t const *);
Chris@0 335
Chris@0 336 /* version interface */
Chris@0 337
Chris@0 338 # define ID3_VERSION_MAJOR 0
Chris@0 339 # define ID3_VERSION_MINOR 15
Chris@0 340 # define ID3_VERSION_PATCH 1
Chris@0 341 # define ID3_VERSION_EXTRA " (beta)"
Chris@0 342
Chris@0 343 # define ID3_VERSION_STRINGIZE(str) #str
Chris@0 344 # define ID3_VERSION_STRING(num) ID3_VERSION_STRINGIZE(num)
Chris@0 345
Chris@0 346 # define ID3_VERSION ID3_VERSION_STRING(ID3_VERSION_MAJOR) "." \
Chris@0 347 ID3_VERSION_STRING(ID3_VERSION_MINOR) "." \
Chris@0 348 ID3_VERSION_STRING(ID3_VERSION_PATCH) \
Chris@0 349 ID3_VERSION_EXTRA
Chris@0 350
Chris@0 351 # define ID3_PUBLISHYEAR "2000-2004"
Chris@0 352 # define ID3_AUTHOR "Underbit Technologies, Inc."
Chris@0 353 # define ID3_EMAIL "info@underbit.com"
Chris@0 354
Chris@0 355 extern char const id3_version[];
Chris@0 356 extern char const id3_copyright[];
Chris@0 357 extern char const id3_author[];
Chris@0 358 extern char const id3_build[];
Chris@0 359
Chris@0 360 # ifdef __cplusplus
Chris@0 361 }
Chris@0 362 # endif
Chris@0 363
Chris@0 364 # endif