00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #if defined HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031
00032
00033 #include <string.h>
00034
00035 #include "field_impl.h"
00036 #include "utils.h"
00037 #include "field_def.h"
00038 #include "frame_def.h"
00039 #include "readers.h"
00040
00041 using namespace dami;
00042
00043
00044
00045 static ID3_FieldDef ID3FD_Unimplemented[] =
00046 {
00047 {
00048 ID3FN_DATA,
00049 ID3FTY_BINARY,
00050 0,
00051 ID3V2_EARLIEST,
00052 ID3V2_LATEST,
00053 ID3FF_NONE,
00054 ID3FN_NOFIELD
00055 },
00056 { ID3FN_NOFIELD }
00057 };
00058
00059 const ID3_FieldDef* ID3_FieldDef::DEFAULT = ID3FD_Unimplemented;
00060
00061 static ID3_FieldDef ID3FD_URL[] =
00062 {
00063 {
00064 ID3FN_URL,
00065 ID3FTY_TEXTSTRING,
00066 0,
00067 ID3V2_EARLIEST,
00068 ID3V2_LATEST,
00069 ID3FF_NONE,
00070 ID3FN_NOFIELD
00071 },
00072 { ID3FN_NOFIELD }
00073 };
00074
00075 static ID3_FieldDef ID3FD_UserURL[] =
00076 {
00077 {
00078 ID3FN_TEXTENC,
00079 ID3FTY_INTEGER,
00080 1,
00081 ID3V2_EARLIEST,
00082 ID3V2_LATEST,
00083 ID3FF_NONE,
00084 ID3FN_NOFIELD
00085 },
00086 {
00087 ID3FN_DESCRIPTION,
00088 ID3FTY_TEXTSTRING,
00089 0,
00090 ID3V2_EARLIEST,
00091 ID3V2_LATEST,
00092 ID3FF_CSTR | ID3FF_ENCODABLE,
00093 ID3FN_NOFIELD
00094 },
00095 {
00096 ID3FN_URL,
00097 ID3FTY_TEXTSTRING,
00098 0,
00099 ID3V2_EARLIEST,
00100 ID3V2_LATEST,
00101 ID3FF_NONE,
00102 ID3FN_NOFIELD
00103 },
00104 { ID3FN_NOFIELD }
00105 };
00106
00107 static ID3_FieldDef ID3FD_Text[] =
00108 {
00109 {
00110 ID3FN_TEXTENC,
00111 ID3FTY_INTEGER,
00112 1,
00113 ID3V2_EARLIEST,
00114 ID3V2_LATEST,
00115 ID3FF_NONE,
00116 ID3FN_NOFIELD
00117 },
00118 {
00119 ID3FN_TEXT,
00120 ID3FTY_TEXTSTRING,
00121 0,
00122 ID3V2_EARLIEST,
00123 ID3V2_LATEST,
00124 ID3FF_ENCODABLE,
00125 ID3FN_NOFIELD
00126 },
00127 { ID3FN_NOFIELD }
00128 };
00129
00130
00131 static ID3_FieldDef ID3FD_UserText[] =
00132 {
00133 {
00134 ID3FN_TEXTENC,
00135 ID3FTY_INTEGER,
00136 1,
00137 ID3V2_EARLIEST,
00138 ID3V2_LATEST,
00139 ID3FF_NONE,
00140 ID3FN_NOFIELD
00141 },
00142 {
00143 ID3FN_DESCRIPTION,
00144 ID3FTY_TEXTSTRING,
00145 0,
00146 ID3V2_EARLIEST,
00147 ID3V2_LATEST,
00148 ID3FF_CSTR | ID3FF_ENCODABLE,
00149 ID3FN_NOFIELD
00150 },
00151 {
00152 ID3FN_TEXT,
00153 ID3FTY_TEXTSTRING,
00154 0,
00155 ID3V2_EARLIEST,
00156 ID3V2_LATEST,
00157 ID3FF_ENCODABLE,
00158 ID3FN_NOFIELD
00159 },
00160 { ID3FN_NOFIELD }
00161 };
00162
00163
00164 static ID3_FieldDef ID3FD_GeneralText[] =
00165 {
00166 {
00167 ID3FN_TEXTENC,
00168 ID3FTY_INTEGER,
00169 1,
00170 ID3V2_EARLIEST,
00171 ID3V2_LATEST,
00172 ID3FF_NONE,
00173 ID3FN_NOFIELD
00174 },
00175 {
00176 ID3FN_LANGUAGE,
00177 ID3FTY_TEXTSTRING,
00178 3,
00179 ID3V2_EARLIEST,
00180 ID3V2_LATEST,
00181 ID3FF_NONE,
00182 ID3FN_NOFIELD
00183 },
00184 {
00185 ID3FN_DESCRIPTION,
00186 ID3FTY_TEXTSTRING,
00187 0,
00188 ID3V2_EARLIEST,
00189 ID3V2_LATEST,
00190 ID3FF_CSTR | ID3FF_ENCODABLE,
00191 ID3FN_NOFIELD
00192 },
00193 {
00194 ID3FN_TEXT,
00195 ID3FTY_TEXTSTRING,
00196 0,
00197 ID3V2_EARLIEST,
00198 ID3V2_LATEST,
00199 ID3FF_ENCODABLE,
00200 ID3FN_NOFIELD
00201 },
00202 { ID3FN_NOFIELD }
00203 };
00204
00205 static ID3_FieldDef ID3FD_TermsOfUse[] =
00206 {
00207 {
00208 ID3FN_TEXTENC,
00209 ID3FTY_INTEGER,
00210 1,
00211 ID3V2_3_0,
00212 ID3V2_LATEST,
00213 ID3FF_NONE,
00214 ID3FN_NOFIELD
00215 },
00216 {
00217 ID3FN_LANGUAGE,
00218 ID3FTY_TEXTSTRING,
00219 3,
00220 ID3V2_3_0,
00221 ID3V2_LATEST,
00222 ID3FF_NONE,
00223 ID3FN_NOFIELD
00224 },
00225 {
00226 ID3FN_TEXT,
00227 ID3FTY_TEXTSTRING,
00228 0,
00229 ID3V2_3_0,
00230 ID3V2_LATEST,
00231 ID3FF_ENCODABLE,
00232 ID3FN_NOFIELD
00233 },
00234 { ID3FN_NOFIELD }
00235 };
00236
00237 static ID3_FieldDef ID3FD_LinkedInfo[] =
00238 {
00239 {
00240 ID3FN_ID,
00241 ID3FTY_TEXTSTRING,
00242 3,
00243 ID3V2_EARLIEST,
00244 ID3V2_2_1,
00245 ID3FF_NONE,
00246 ID3FN_NOFIELD
00247 },
00248 {
00249 ID3FN_ID,
00250 ID3FTY_TEXTSTRING,
00251 4,
00252 ID3V2_3_0,
00253 ID3V2_LATEST,
00254 ID3FF_NONE,
00255 ID3FN_NOFIELD
00256 },
00257 {
00258 ID3FN_URL,
00259 ID3FTY_TEXTSTRING,
00260 0,
00261 ID3V2_EARLIEST,
00262 ID3V2_LATEST,
00263 ID3FF_CSTR,
00264 ID3FN_NOFIELD
00265 },
00266 {
00267 ID3FN_TEXT,
00268 ID3FTY_TEXTSTRING,
00269 0,
00270 ID3V2_EARLIEST,
00271 ID3V2_LATEST,
00272 ID3FF_NONE,
00273 ID3FN_NOFIELD
00274 },
00275 { ID3FN_NOFIELD }
00276 };
00277
00278 static ID3_FieldDef ID3FD_Picture[] =
00279 {
00280 {
00281 ID3FN_TEXTENC,
00282 ID3FTY_INTEGER,
00283 1,
00284 ID3V2_EARLIEST,
00285 ID3V2_LATEST,
00286 ID3FF_NONE,
00287 ID3FN_NOFIELD
00288 },
00289 {
00290 ID3FN_IMAGEFORMAT,
00291 ID3FTY_TEXTSTRING,
00292 3,
00293 ID3V2_EARLIEST,
00294 ID3V2_2_1,
00295 ID3FF_NONE,
00296 ID3FN_NOFIELD
00297 },
00298 {
00299 ID3FN_MIMETYPE,
00300 ID3FTY_TEXTSTRING,
00301 0,
00302 ID3V2_3_0,
00303 ID3V2_LATEST,
00304 ID3FF_CSTR,
00305 ID3FN_NOFIELD
00306 },
00307 {
00308 ID3FN_PICTURETYPE,
00309 ID3FTY_INTEGER,
00310 1,
00311 ID3V2_EARLIEST,
00312 ID3V2_LATEST,
00313 ID3FF_NONE,
00314 ID3FN_NOFIELD
00315 },
00316 {
00317 ID3FN_DESCRIPTION,
00318 ID3FTY_TEXTSTRING,
00319 0,
00320 ID3V2_EARLIEST,
00321 ID3V2_LATEST,
00322 ID3FF_CSTR | ID3FF_ENCODABLE,
00323 ID3FN_NOFIELD
00324 },
00325 {
00326 ID3FN_DATA,
00327 ID3FTY_BINARY,
00328 0,
00329 ID3V2_EARLIEST,
00330 ID3V2_LATEST,
00331 ID3FF_NONE,
00332 ID3FN_NOFIELD
00333 },
00334 { ID3FN_NOFIELD }
00335 };
00336
00337 static ID3_FieldDef ID3FD_GEO[] =
00338 {
00339 {
00340 ID3FN_TEXTENC,
00341 ID3FTY_INTEGER,
00342 1,
00343 ID3V2_EARLIEST,
00344 ID3V2_LATEST,
00345 ID3FF_NONE,
00346 ID3FN_NOFIELD
00347 },
00348 {
00349 ID3FN_MIMETYPE,
00350 ID3FTY_TEXTSTRING,
00351 0,
00352 ID3V2_EARLIEST,
00353 ID3V2_LATEST,
00354 ID3FF_CSTR,
00355 ID3FN_NOFIELD
00356 },
00357 {
00358 ID3FN_FILENAME,
00359 ID3FTY_TEXTSTRING,
00360 0,
00361 ID3V2_EARLIEST,
00362 ID3V2_LATEST,
00363 ID3FF_CSTR | ID3FF_ENCODABLE,
00364 ID3FN_NOFIELD
00365 },
00366 {
00367 ID3FN_DESCRIPTION,
00368 ID3FTY_TEXTSTRING,
00369 0,
00370 ID3V2_EARLIEST,
00371 ID3V2_LATEST,
00372 ID3FF_CSTR | ID3FF_ENCODABLE,
00373 ID3FN_NOFIELD
00374 },
00375 {
00376 ID3FN_DATA,
00377 ID3FTY_BINARY,
00378 0,
00379 ID3V2_EARLIEST,
00380 ID3V2_LATEST,
00381 ID3FF_NONE,
00382 ID3FN_NOFIELD
00383 },
00384 { ID3FN_NOFIELD }
00385 };
00386
00387 static ID3_FieldDef ID3FD_UFI[] =
00388 {
00389 {
00390 ID3FN_OWNER,
00391 ID3FTY_TEXTSTRING,
00392 0,
00393 ID3V2_EARLIEST,
00394 ID3V2_LATEST,
00395 ID3FF_CSTR,
00396 ID3FN_NOFIELD
00397 },
00398 {
00399 ID3FN_DATA,
00400 ID3FTY_BINARY,
00401 0,
00402 ID3V2_EARLIEST,
00403 ID3V2_LATEST,
00404 ID3FF_NONE,
00405 ID3FN_NOFIELD
00406 },
00407 { ID3FN_NOFIELD }
00408 };
00409
00410 static ID3_FieldDef ID3FD_PlayCounter[] =
00411 {
00412 {
00413 ID3FN_COUNTER,
00414 ID3FTY_INTEGER,
00415 4,
00416 ID3V2_EARLIEST,
00417 ID3V2_LATEST,
00418 ID3FF_NONE,
00419 ID3FN_NOFIELD
00420 },
00421 { ID3FN_NOFIELD }
00422 };
00423
00424 static ID3_FieldDef ID3FD_Popularimeter[] =
00425 {
00426 {
00427 ID3FN_EMAIL,
00428 ID3FTY_TEXTSTRING,
00429 0,
00430 ID3V2_EARLIEST,
00431 ID3V2_LATEST,
00432 ID3FF_CSTR,
00433 ID3FN_NOFIELD
00434 },
00435 {
00436 ID3FN_RATING,
00437 ID3FTY_INTEGER,
00438 1,
00439 ID3V2_EARLIEST,
00440 ID3V2_LATEST,
00441 ID3FF_NONE,
00442 ID3FN_NOFIELD
00443 },
00444 {
00445 ID3FN_COUNTER,
00446 ID3FTY_INTEGER,
00447 4,
00448 ID3V2_EARLIEST,
00449 ID3V2_LATEST,
00450 ID3FF_NONE,
00451 ID3FN_NOFIELD
00452 },
00453 { ID3FN_NOFIELD }
00454 };
00455
00456 static ID3_FieldDef ID3FD_Private[] =
00457 {
00458 {
00459 ID3FN_OWNER,
00460 ID3FTY_TEXTSTRING,
00461 0,
00462 ID3V2_3_0,
00463 ID3V2_LATEST,
00464 ID3FF_CSTR,
00465 ID3FN_NOFIELD
00466 },
00467 {
00468 ID3FN_DATA,
00469 ID3FTY_BINARY,
00470 0,
00471 ID3V2_3_0,
00472 ID3V2_LATEST,
00473 ID3FF_NONE,
00474 ID3FN_NOFIELD
00475 },
00476 { ID3FN_NOFIELD }
00477 };
00478
00479
00480 static ID3_FieldDef ID3FD_Registration[] =
00481 {
00482 {
00483 ID3FN_OWNER,
00484 ID3FTY_TEXTSTRING,
00485 0,
00486 ID3V2_3_0,
00487 ID3V2_LATEST,
00488 ID3FF_CSTR,
00489 ID3FN_NOFIELD
00490 },
00491 {
00492 ID3FN_ID,
00493 ID3FTY_INTEGER,
00494 1,
00495 ID3V2_3_0,
00496 ID3V2_LATEST,
00497 ID3FF_NONE,
00498 ID3FN_NOFIELD
00499 },
00500 {
00501 ID3FN_DATA,
00502 ID3FTY_BINARY,
00503 0,
00504 ID3V2_3_0,
00505 ID3V2_LATEST,
00506 ID3FF_NONE,
00507 ID3FN_NOFIELD
00508 },
00509 { ID3FN_NOFIELD }
00510 };
00511
00512 static ID3_FieldDef ID3FD_InvolvedPeople[] =
00513 {
00514 {
00515 ID3FN_TEXTENC,
00516 ID3FTY_INTEGER,
00517 1,
00518 ID3V2_EARLIEST,
00519 ID3V2_LATEST,
00520 ID3FF_NONE,
00521 ID3FN_NOFIELD
00522 },
00523 {
00524 ID3FN_TEXT,
00525 ID3FTY_TEXTSTRING,
00526 0,
00527 ID3V2_EARLIEST,
00528 ID3V2_LATEST,
00529 ID3FF_TEXTLIST,
00530 ID3FN_NOFIELD
00531 },
00532 { ID3FN_NOFIELD }
00533 };
00534
00535 static ID3_FieldDef ID3FD_CDM[] =
00536 {
00537 {
00538 ID3FN_DATA,
00539 ID3FTY_BINARY,
00540 0,
00541 ID3V2_2_1,
00542 ID3V2_2_1,
00543 ID3FF_NONE,
00544 ID3FN_NOFIELD
00545 }
00546 };
00547
00548 static ID3_FieldDef ID3FD_SyncLyrics[] =
00549 {
00550 {
00551 ID3FN_TEXTENC,
00552 ID3FTY_INTEGER,
00553 1,
00554 ID3V2_EARLIEST,
00555 ID3V2_LATEST,
00556 ID3FF_NONE,
00557 ID3FN_NOFIELD
00558 },
00559 {
00560 ID3FN_LANGUAGE,
00561 ID3FTY_TEXTSTRING,
00562 3,
00563 ID3V2_EARLIEST,
00564 ID3V2_LATEST,
00565 ID3FF_NONE,
00566 ID3FN_NOFIELD
00567 },
00568 {
00569 ID3FN_TIMESTAMPFORMAT,
00570 ID3FTY_INTEGER,
00571 1,
00572 ID3V2_EARLIEST,
00573 ID3V2_LATEST,
00574 ID3FF_NONE,
00575 ID3FN_NOFIELD
00576 },
00577 {
00578 ID3FN_CONTENTTYPE,
00579 ID3FTY_INTEGER,
00580 1,
00581 ID3V2_EARLIEST,
00582 ID3V2_LATEST,
00583 ID3FF_NONE,
00584 ID3FN_NOFIELD
00585 },
00586 {
00587 ID3FN_DESCRIPTION,
00588 ID3FTY_TEXTSTRING,
00589 0,
00590 ID3V2_EARLIEST,
00591 ID3V2_LATEST,
00592 ID3FF_CSTR | ID3FF_ENCODABLE,
00593 ID3FN_NOFIELD
00594 },
00595 {
00596 ID3FN_DATA,
00597 ID3FTY_BINARY,
00598 0,
00599 ID3V2_EARLIEST,
00600 ID3V2_LATEST,
00601 ID3FF_NONE,
00602 ID3FN_NOFIELD
00603 },
00604 { ID3FN_NOFIELD }
00605 };
00606
00607
00608
00609
00610
00611 #if defined _UNDEFINED_
00612 static ID3_FieldDef ID3FD_Volume[] =
00613 {
00614 {
00615 ID3FN_VOLUMEADJ,
00616 ID3FTY_INTEGER,
00617 1,
00618 ID3V2_EARLIEST,
00619 ID3V2_LATEST,
00620 ID3FF_NONE,
00621 ID3FN_NOFIELD
00622 },
00623 {
00624 ID3FN_NUMBITS,
00625 ID3FTY_INTEGER,
00626 1,
00627 ID3V2_EARLIEST,
00628 ID3V2_LATEST,
00629 ID3FF_NONE,
00630 ID3FN_NOFIELD
00631 },
00632 {
00633 ID3FN_VOLCHGRIGHT,
00634 ID3FTY_BITFIELD,
00635 0,
00636 ID3V2_EARLIEST,
00637 ID3V2_LATEST,
00638 ID3FF_ADJUSTEDBY,
00639 ID3FN_NUMBITS
00640 },
00641 {
00642 ID3FN_VOLCHGLEFT,
00643 ID3FTY_BITFIELD,
00644 0,
00645 ID3V2_EARLIEST,
00646 ID3V2_LATEST,
00647 ID3FF_ADJUSTEDBY,
00648 ID3FN_NUMBITS
00649 },
00650 {
00651 ID3FN_PEAKVOLRIGHT,
00652 ID3FTY_BITFIELD,
00653 0,
00654 ID3V2_EARLIEST,
00655 ID3V2_LATEST,
00656 ID3FF_ADJUSTEDBY,
00657 ID3FN_NUMBITS
00658 },
00659 {
00660 ID3FN_PEAKVOLLEFT,
00661 ID3FTY_BITFIELD,
00662 0,
00663 ID3V2_EARLIEST,
00664 ID3V2_LATEST,
00665 ID3FF_ADJUSTEDBY,
00666 ID3FN_NUMBITS
00667 },
00668 { ID3FN_NOFIELD }
00669 };
00670 #endif
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751 static ID3_FrameDef ID3_FrameDefs[] =
00752 {
00753
00754
00755 {ID3FID_AUDIOCRYPTO, "CRA", "AENC", false, false, ID3FD_Unimplemented, "Audio encryption"},
00756 {ID3FID_PICTURE, "PIC", "APIC", false, false, ID3FD_Picture, "Attached picture"},
00757 {ID3FID_COMMENT, "COM", "COMM", false, false, ID3FD_GeneralText, "Comments"},
00758 {ID3FID_COMMERCIAL, "" , "COMR", false, false, ID3FD_Unimplemented, "Commercial"},
00759 {ID3FID_CRYPTOREG, "" , "ENCR", false, false, ID3FD_Registration, "Encryption method registration"},
00760 {ID3FID_EQUALIZATION, "EQU", "EQUA", false, true, ID3FD_Unimplemented, "Equalization"},
00761 {ID3FID_EVENTTIMING, "ETC", "ETCO", false, true, ID3FD_Unimplemented, "Event timing codes"},
00762 {ID3FID_GENERALOBJECT, "GEO", "GEOB", false, false, ID3FD_GEO, "General encapsulated object"},
00763 {ID3FID_GROUPINGREG, "" , "GRID", false, false, ID3FD_Registration, "Group identification registration"},
00764 {ID3FID_INVOLVEDPEOPLE, "IPL", "IPLS", false, false, ID3FD_InvolvedPeople,"Involved people list"},
00765 {ID3FID_LINKEDINFO, "LNK", "LINK", false, false, ID3FD_LinkedInfo, "Linked information"},
00766 {ID3FID_CDID, "MCI", "MCDI", false, false, ID3FD_Unimplemented, "Music CD identifier"},
00767 {ID3FID_MPEGLOOKUP, "MLL", "MLLT", false, true, ID3FD_Unimplemented, "MPEG location lookup table"},
00768 {ID3FID_OWNERSHIP, "" , "OWNE", false, false, ID3FD_Unimplemented, "Ownership frame"},
00769 {ID3FID_PRIVATE, "" , "PRIV", false, false, ID3FD_Private, "Private frame"},
00770 {ID3FID_PLAYCOUNTER, "CNT", "PCNT", false, false, ID3FD_PlayCounter, "Play counter"},
00771 {ID3FID_POPULARIMETER, "POP", "POPM", false, false, ID3FD_Popularimeter, "Popularimeter"},
00772 {ID3FID_POSITIONSYNC, "" , "POSS", false, true, ID3FD_Unimplemented, "Position synchronisation frame"},
00773 {ID3FID_BUFFERSIZE, "BUF", "RBUF", false, false, ID3FD_Unimplemented, "Recommended buffer size"},
00774 {ID3FID_VOLUMEADJ, "RVA", "RVAD", false, true, ID3FD_Unimplemented, "Relative volume adjustment"},
00775 {ID3FID_REVERB, "REV", "RVRB", false, false, ID3FD_Unimplemented, "Reverb"},
00776 {ID3FID_SYNCEDLYRICS, "SLT", "SYLT", false, false, ID3FD_SyncLyrics, "Synchronized lyric/text"},
00777 {ID3FID_SYNCEDTEMPO, "STC", "SYTC", false, true, ID3FD_Unimplemented, "Synchronized tempo codes"},
00778 {ID3FID_ALBUM, "TAL", "TALB", false, false, ID3FD_Text, "Album/Movie/Show title"},
00779 {ID3FID_BPM, "TBP", "TBPM", false, false, ID3FD_Text, "BPM (beats per minute)"},
00780 {ID3FID_COMPOSER, "TCM", "TCOM", false, false, ID3FD_Text, "Composer"},
00781 {ID3FID_CONTENTTYPE, "TCO", "TCON", false, false, ID3FD_Text, "Content type"},
00782 {ID3FID_COPYRIGHT, "TCR", "TCOP", false, false, ID3FD_Text, "Copyright message"},
00783 {ID3FID_DATE, "TDA", "TDAT", false, false, ID3FD_Text, "Date"},
00784 {ID3FID_PLAYLISTDELAY, "TDY", "TDLY", false, false, ID3FD_Text, "Playlist delay"},
00785 {ID3FID_ENCODEDBY, "TEN", "TENC", false, true, ID3FD_Text, "Encoded by"},
00786 {ID3FID_LYRICIST, "TXT", "TEXT", false, false, ID3FD_Text, "Lyricist/Text writer"},
00787 {ID3FID_FILETYPE, "TFT", "TFLT", false, false, ID3FD_Text, "File type"},
00788 {ID3FID_TIME, "TIM", "TIME", false, false, ID3FD_Text, "Time"},
00789 {ID3FID_CONTENTGROUP, "TT1", "TIT1", false, false, ID3FD_Text, "Content group description"},
00790 {ID3FID_TITLE, "TT2", "TIT2", false, false, ID3FD_Text, "Title/songname/content description"},
00791 {ID3FID_SUBTITLE, "TT3", "TIT3", false, false, ID3FD_Text, "Subtitle/Description refinement"},
00792 {ID3FID_INITIALKEY, "TKE", "TKEY", false, false, ID3FD_Text, "Initial key"},
00793 {ID3FID_LANGUAGE, "TLA", "TLAN", false, false, ID3FD_Text, "Language(s)"},
00794 {ID3FID_SONGLEN, "TLE", "TLEN", false, true, ID3FD_Text, "Length"},
00795 {ID3FID_MEDIATYPE, "TMT", "TMED", false, false, ID3FD_Text, "Media type"},
00796 {ID3FID_ORIGALBUM, "TOT", "TOAL", false, false, ID3FD_Text, "Original album/movie/show title"},
00797 {ID3FID_ORIGFILENAME, "TOF", "TOFN", false, false, ID3FD_Text, "Original filename"},
00798 {ID3FID_ORIGLYRICIST, "TOL", "TOLY", false, false, ID3FD_Text, "Original lyricist(s)/text writer(s)"},
00799 {ID3FID_ORIGARTIST, "TOA", "TOPE", false, false, ID3FD_Text, "Original artist(s)/performer(s)"},
00800 {ID3FID_ORIGYEAR, "TOR", "TORY", false, false, ID3FD_Text, "Original release year"},
00801 {ID3FID_FILEOWNER, "" , "TOWN", false, false, ID3FD_Text, "File owner/licensee"},
00802 {ID3FID_LEADARTIST, "TP1", "TPE1", false, false, ID3FD_Text, "Lead performer(s)/Soloist(s)"},
00803 {ID3FID_BAND, "TP2", "TPE2", false, false, ID3FD_Text, "Band/orchestra/accompaniment"},
00804 {ID3FID_CONDUCTOR, "TP3", "TPE3", false, false, ID3FD_Text, "Conductor/performer refinement"},
00805 {ID3FID_MIXARTIST, "TP4", "TPE4", false, false, ID3FD_Text, "Interpreted, remixed, or otherwise modified by"},
00806 {ID3FID_PARTINSET, "TPA", "TPOS", false, false, ID3FD_Text, "Part of a set"},
00807 {ID3FID_PUBLISHER, "TPB", "TPUB", false, false, ID3FD_Text, "Publisher"},
00808 {ID3FID_TRACKNUM, "TRK", "TRCK", false, false, ID3FD_Text, "Track number/Position in set"},
00809 {ID3FID_RECORDINGDATES, "TRD", "TRDA", false, false, ID3FD_Text, "Recording dates"},
00810 {ID3FID_NETRADIOSTATION, "TRN", "TRSN", false, false, ID3FD_Text, "Internet radio station name"},
00811 {ID3FID_NETRADIOOWNER, "TRO", "TRSO", false, false, ID3FD_Text, "Internet radio station owner"},
00812 {ID3FID_SIZE, "TSI", "TSIZ", false, true, ID3FD_Text, "Size"},
00813 {ID3FID_ISRC, "TRC", "TSRC", false, false, ID3FD_Text, "ISRC (international standard recording code)"},
00814 {ID3FID_ENCODERSETTINGS, "TSS", "TSSE", false, false, ID3FD_Text, "Software/Hardware and settings used for encoding"},
00815 {ID3FID_USERTEXT, "TXX", "TXXX", false, false, ID3FD_UserText, "User defined text information"},
00816 {ID3FID_YEAR, "TYE", "TYER", false, false, ID3FD_Text, "Year"},
00817 {ID3FID_UNIQUEFILEID, "UFI", "UFID", false, false, ID3FD_UFI, "Unique file identifier"},
00818 {ID3FID_TERMSOFUSE, "" , "USER", false, false, ID3FD_TermsOfUse, "Terms of use"},
00819 {ID3FID_UNSYNCEDLYRICS, "ULT", "USLT", false, false, ID3FD_GeneralText, "Unsynchronized lyric/text transcription"},
00820 {ID3FID_WWWCOMMERCIALINFO, "WCM", "WCOM", false, false, ID3FD_URL, "Commercial information"},
00821 {ID3FID_WWWCOPYRIGHT, "WCP", "WCOP", false, false, ID3FD_URL, "Copyright/Legal infromation"},
00822 {ID3FID_WWWAUDIOFILE, "WAF", "WOAF", false, false, ID3FD_URL, "Official audio file webpage"},
00823 {ID3FID_WWWARTIST, "WAR", "WOAR", false, false, ID3FD_URL, "Official artist/performer webpage"},
00824 {ID3FID_WWWAUDIOSOURCE, "WAS", "WOAS", false, false, ID3FD_URL, "Official audio source webpage"},
00825 {ID3FID_WWWRADIOPAGE, "WRA", "WORS", false, false, ID3FD_URL, "Official internet radio station homepage"},
00826 {ID3FID_WWWPAYMENT, "WPY", "WPAY", false, false, ID3FD_URL, "Payment"},
00827 {ID3FID_WWWPUBLISHER, "WPB", "WPUB", false, false, ID3FD_URL, "Official publisher webpage"},
00828 {ID3FID_WWWUSER, "WXX", "WXXX", false, false, ID3FD_UserURL, "User defined URL link"},
00829 {ID3FID_METACRYPTO, "CRM", "" , false, false, ID3FD_Unimplemented, "Encrypted meta frame"},
00830 {ID3FID_METACOMPRESSION, "CDM", "" , false, false, ID3FD_CDM, "Compressed data meta frame"},
00831 {ID3FID_NOFRAME}
00832 };
00833
00891 ID3_FieldImpl::ID3_FieldImpl()
00892 : _id(ID3FN_NOFIELD),
00893 _type(ID3FTY_INTEGER),
00894 _spec_begin(ID3V2_EARLIEST),
00895 _spec_end(ID3V2_LATEST),
00896 _flags(0),
00897 _changed(false),
00898 _fixed_size(0),
00899 _num_items(0),
00900 _enc(ID3TE_NONE)
00901 {
00902 this->Clear();
00903 }
00904
00905 ID3_FieldImpl::ID3_FieldImpl(const ID3_FieldDef& def)
00906 : _id(def._id),
00907 _type(def._type),
00908 _spec_begin(def._spec_begin),
00909 _spec_end(def._spec_end),
00910 _flags(def._flags),
00911 _changed(false),
00912 _fixed_size(def._fixed_size),
00913 _num_items(0),
00914 _enc((_type == ID3FTY_TEXTSTRING) ? ID3TE_ASCII : ID3TE_NONE)
00915 {
00916 this->Clear();
00917 }
00918
00919 ID3_FieldImpl::~ID3_FieldImpl()
00920 {
00921 }
00922
00928 void ID3_FieldImpl::Clear()
00929 {
00930 switch (_type)
00931 {
00932 case ID3FTY_INTEGER:
00933 {
00934 _integer = 0;
00935 break;
00936 }
00937 case ID3FTY_BINARY:
00938 {
00939 _binary.erase();
00940 if (_fixed_size > 0)
00941 {
00942 _binary.assign(_fixed_size, '\0');
00943 }
00944 break;
00945 }
00946 case ID3FTY_TEXTSTRING:
00947 {
00948 _text.erase();
00949 if (_fixed_size > 0)
00950 {
00951 if (this->GetEncoding() == ID3TE_UNICODE)
00952 {
00953 _text.assign(_fixed_size * 2, '\0');
00954 }
00955 else if (this->GetEncoding() == ID3TE_ASCII)
00956 {
00957 _text.assign(_fixed_size, '\0');
00958 }
00959 }
00960 break;
00961 }
00962 default:
00963 {
00964 break;
00965 }
00966 }
00967 _changed = true;
00968
00969 return ;
00970 }
00971
00972 bool
00973 ID3_FieldImpl::HasChanged() const
00974 {
00975 return _changed;
00976 }
00977
00997 size_t ID3_FieldImpl::BinSize() const
00998 {
00999 if (_fixed_size > 0)
01000 {
01001 return _fixed_size;
01002 }
01003 size_t size = this->Size();
01004 if (_type == ID3FTY_TEXTSTRING)
01005 {
01006 ID3_TextEnc enc = this->GetEncoding();
01007 if (enc == ID3TE_UNICODE && size > 0)
01008 {
01009 size++;
01010 }
01011 if (_flags & ID3FF_CSTR)
01012 {
01013 size++;
01014 }
01015 if (enc == ID3TE_UNICODE)
01016 {
01017 size *= 2;
01018 }
01019 }
01020 return size;
01021 }
01022
01023 size_t ID3_FieldImpl::Size() const
01024 {
01025 size_t size = 0;
01026
01027
01028 if (_fixed_size > 0)
01029 {
01030 size = _fixed_size;
01031 }
01032 else if (_type == ID3FTY_INTEGER)
01033 {
01034 size = sizeof(uint32);
01035 }
01036 else if (_type == ID3FTY_TEXTSTRING)
01037 {
01038 size = _text.size();
01039 }
01040 else
01041 {
01042 size = _binary.size();
01043 }
01044
01045 return size;
01046 }
01047
01048 bool ID3_FieldImpl::Parse(ID3_Reader& reader)
01049 {
01050 bool success = false;
01051 switch (this->GetType())
01052 {
01053 case ID3FTY_INTEGER:
01054 {
01055 success = this->ParseInteger(reader);
01056 break;
01057 }
01058
01059 case ID3FTY_BINARY:
01060 {
01061 success = this->ParseBinary(reader);
01062 break;
01063 }
01064
01065 case ID3FTY_TEXTSTRING:
01066 {
01067 success = this->ParseText(reader);
01068 break;
01069 }
01070
01071 default:
01072 {
01073 ID3D_WARNING( "ID3_FieldImpl::Parse(): unknown field type" );
01074 break;
01075 }
01076 }
01077 return success;
01078 }
01079
01080 ID3_FrameDef* ID3_FindFrameDef(ID3_FrameID id)
01081 {
01082 ID3_FrameDef *info = NULL;
01083
01084 for (index_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; cur++)
01085 {
01086 if (ID3_FrameDefs[cur].eID == id)
01087 {
01088 info = &ID3_FrameDefs[cur];
01089 break;
01090 }
01091 }
01092
01093 return info;
01094 }
01095
01096 ID3_FrameID
01097 ID3_FindFrameID(const char *id)
01098 {
01099 ID3_FrameID fid = ID3FID_NOFRAME;
01100
01101 for (index_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; cur++)
01102 {
01103 if (((strcmp(ID3_FrameDefs[cur].sShortTextID, id) == 0) &&
01104 strlen(id) == 3) ||
01105 ((strcmp(ID3_FrameDefs[cur].sLongTextID, id) == 0) &&
01106 strlen(id) == 4))
01107 {
01108 fid = ID3_FrameDefs[cur].eID;
01109 break;
01110 }
01111 }
01112
01113 return fid;
01114 }
01115
01116 void ID3_FieldImpl::Render(ID3_Writer& writer) const
01117 {
01118 switch (this->GetType())
01119 {
01120 case ID3FTY_INTEGER:
01121 {
01122 RenderInteger(writer);
01123 break;
01124 }
01125
01126 case ID3FTY_BINARY:
01127 {
01128 RenderBinary(writer);
01129 break;
01130 }
01131
01132 case ID3FTY_TEXTSTRING:
01133 {
01134 RenderText(writer);
01135 break;
01136 }
01137
01138 default:
01139 {
01140 ID3D_WARNING ( "ID3D_FieldImpl::Render(): unknown field type" );
01141 break;
01142 }
01143 }
01144 }
01145
01146 ID3_Field &
01147 ID3_FieldImpl::operator=( const ID3_Field &rhs )
01148 {
01149 const ID3_FieldImpl* fld = (const ID3_FieldImpl*) &rhs;
01150 if (this != &rhs && this->GetType() == fld->GetType())
01151 {
01152 switch (fld->GetType())
01153 {
01154 case ID3FTY_INTEGER:
01155 {
01156 this->SetInteger(fld->GetInteger());
01157 break;
01158 }
01159 case ID3FTY_TEXTSTRING:
01160 {
01161 this->SetEncoding(fld->GetEncoding());
01162 this->SetText(fld->GetText());
01163 break;
01164 }
01165 case ID3FTY_BINARY:
01166 {
01167 this->SetBinary(fld->GetBinary());
01168 break;
01169 }
01170 default:
01171 {
01172 break;
01173 }
01174 }
01175 }
01176 return *this;
01177 }
01178
01179 bool ID3_FieldImpl::SetEncoding(ID3_TextEnc enc)
01180 {
01181 bool changed = this->IsEncodable() && (enc != this->GetEncoding()) &&
01182 (ID3TE_NONE < enc && enc < ID3TE_NUMENCODINGS);
01183 if (changed)
01184 {
01185 _text = convert(_text, _enc, enc);
01186 _enc = enc;
01187 _changed = true;
01188 }
01189 return changed;
01190 }
01191
01246 char *ID3_FrameInfo::ShortName(ID3_FrameID frameid) {
01247 if(frameid < ID3FID_LASTFRAMEID) {
01248 return ID3_FrameDefs[frameid-1].sShortTextID;
01249 } else {
01250 return NULL;
01251 }
01252 }
01253
01254 char *ID3_FrameInfo::LongName(ID3_FrameID frameid) {
01255 if(frameid < ID3FID_LASTFRAMEID) {
01256 return ID3_FrameDefs[frameid-1].sLongTextID;
01257 } else {
01258 return NULL;
01259 }
01260 }
01261
01262 const char *ID3_FrameInfo::Description(ID3_FrameID frameid) {
01263 if(frameid < ID3FID_LASTFRAMEID) {
01264 return ID3_FrameDefs[frameid-1].sDescription;
01265 } else {
01266 return NULL;
01267 }
01268 }
01269
01270 int ID3_FrameInfo::MaxFrameID() {
01271 return ID3FID_LASTFRAMEID-1;
01272 }
01273
01274 int ID3_FrameInfo::NumFields(ID3_FrameID frameid) {
01275 int fieldnum=0;
01276
01277 while (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._id !=
01278 ID3FN_NOFIELD) {
01279 fieldnum++;
01280 }
01281 return fieldnum;
01282 }
01283
01284 ID3_FieldType ID3_FrameInfo::FieldType(ID3_FrameID frameid, int fieldnum) {
01285 return (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._type);
01286 }
01287
01288 size_t ID3_FrameInfo::FieldSize(ID3_FrameID frameid, int fieldnum) {
01289 return (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._fixed_size);
01290 }
01291
01292 flags_t ID3_FrameInfo::FieldFlags(ID3_FrameID frameid, int fieldnum) {
01293 return (ID3_FrameDefs[frameid-1].aeFieldDefs[fieldnum]._flags);
01294 }
01295