123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- // The authors have released ID3Lib as Public Domain (PD) and claim no copyright,
- // patent or other intellectual property protection in this work. This means that
- // it may be modified, redistributed and used in commercial and non-commercial
- // software and hardware without restrictions. ID3Lib is distributed on an "AS IS"
- // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
- //
- // The ID3Lib authors encourage improvements and optimisations to be sent to the
- // ID3Lib coordinator, currently Dirk Mahoney ([email protected]). Approved
- // submissions may be altered, and will be included and released under these terms.
- //
- // Mon Nov 23 18:34:01 1998
- // improved/optimized/whatever 10/30/00 JF
- #include <windows.h>
- #include <string.h>
- #include "id3_field.h"
- static ID3_FieldDef ID3FD_URL[] =
- {
- {ID3FN_URL, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD},
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_UserURL[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DESCRIPTION, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_URL, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Text[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_TEXT, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_UserText[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DESCRIPTION, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_TEXT, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_GeneralText[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_LANGUAGE, ID3FTY_ASCIISTRING, 3, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DESCRIPTION, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_TEXT, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Picture[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_IMAGEFORMAT, ID3FTY_ASCIISTRING, 3, 2, 0, ID3VC_LOWER, NULL, ID3FN_NOFIELD },
- {ID3FN_MIMETYPE, ID3FTY_ASCIISTRING, -1, 3, 0, ID3VC_HIGHER, ID3FF_NULL, ID3FN_NOFIELD },
- {ID3FN_PICTURETYPE, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DESCRIPTION, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_DATA, ID3FTY_BINARY, -1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_GEO[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_MIMETYPE, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL, ID3FN_NOFIELD },
- {ID3FN_FILENAME, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_DESCRIPTION, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_DATA, ID3FTY_BINARY, -1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_UFI[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_OWNER, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL, ID3FN_NOFIELD },
- {ID3FN_DATA, ID3FTY_BINARY, -1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_PRIVATE[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_OWNER, ID3FTY_ASCIISTRING, -1, 3, 0, ID3VC_HIGHER, ID3FF_NULL, ID3FN_NOFIELD },
- {ID3FN_DATA, ID3FTY_BINARY, -1, 3, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_PlayCounter[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_COUNTER, ID3FTY_INTEGER, 4, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Popularimeter[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_EMAIL, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL, ID3FN_NOFIELD },
- {ID3FN_RATING, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_COUNTER, ID3FTY_INTEGER, 4, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Registration[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_OWNER, ID3FTY_ASCIISTRING, -1, 3, 0, ID3VC_HIGHER, ID3FF_NULL, ID3FN_NOFIELD },
- {ID3FN_SYMBOL, ID3FTY_INTEGER, 1, 3, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DATA, ID3FTY_BINARY, -1, 3, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_InvolvedPeople[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_TEXT, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_NULLDIVIDE | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Volume[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_VOLUMEADJ, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NUMBITS, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_VOLCHGRIGHT, ID3FTY_BITFIELD, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTEDBY, ID3FN_NUMBITS },
- {ID3FN_VOLCHGLEFT, ID3FTY_BITFIELD, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTEDBY, ID3FN_NUMBITS },
- {ID3FN_PEAKVOLRIGHT, ID3FTY_BITFIELD, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTEDBY, ID3FN_NUMBITS },
- {ID3FN_PEAKVOLLEFT, ID3FTY_BITFIELD, -1, 2, 0, ID3VC_HIGHER, ID3FF_ADJUSTEDBY, ID3FN_NUMBITS },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_MCDI[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_CD_TOC, ID3FTY_BINARY, -1, 3, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD},
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Text_v2_4[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 4, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_TEXT, ID3FTY_ASCIISTRING, -1, 4, 0, ID3VC_HIGHER, ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Timestamp1[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TIMESTAMP, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DATA, ID3FTY_BINARY, -1, 3, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FieldDef ID3FD_Timestamp2[] =
- {
- // FIELD FIELD FIXED RENDER IF OR
- // NAME TYPE LEN VER REV WHAT? FLAGS LINKED FIELD
- {ID3FN_TEXTENC, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_LANGUAGE, ID3FTY_ASCIISTRING, 3, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_TIMESTAMP, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_CONTENTTYPE, ID3FTY_INTEGER, 1, 2, 0, ID3VC_HIGHER, NULL, ID3FN_NOFIELD },
- {ID3FN_DESCRIPTION, ID3FTY_ASCIISTRING, -1, 2, 0, ID3VC_HIGHER, ID3FF_NULL | ID3FF_ADJUSTENC, ID3FN_NOFIELD },
- {ID3FN_NOFIELD }
- };
- static ID3_FrameDef ID3_FrameDefs[] =
- {
- //FRAME ID SHORTID LONGID PRI TAGDISCARD FILEDISCARD HANDLER FIELDDEFS
- {ID3FID_ENCODEDBY, "TEN", "TENC", false, true, NULL, ID3FD_Text },
- {ID3FID_ORIGALBUM, "TOT", "TOAL", false, false, NULL, ID3FD_Text },
- {ID3FID_PUBLISHER, "TPB", "TPUB", false, false, NULL, ID3FD_Text },
- {ID3FID_ENCODERSETTINGS, "TSS", "TSSE", false, false, NULL, ID3FD_Text },
- {ID3FID_ORIGFILENAME, "TOF", "TOFN", false, false, NULL, ID3FD_Text },
- {ID3FID_LANGUAGE, "TLA", "TLAN", false, false, NULL, ID3FD_Text },
- {ID3FID_PARTINSET, "TPA", "TPOS", false, false, NULL, ID3FD_Text },
- {ID3FID_DATE, "TDA", "TDAT", false, false, NULL, ID3FD_Text },
- {ID3FID_TIME, "TIM", "TIME", false, false, NULL, ID3FD_Text },
- {ID3FID_RECORDINGDATES, "TRD", "TRDA", false, false, NULL, ID3FD_Text },
- {ID3FID_MEDIATYPE, "TMT", "TMED", false, false, NULL, ID3FD_Text },
- {ID3FID_FILETYPE, "TFT", "TFLT", false, false, NULL, ID3FD_Text },
- {ID3FID_NETRADIOSTATION, "TRN", "TRSN", false, false, NULL, ID3FD_Text },
- {ID3FID_NETRADIOOWNER, "TRO", "TRSO", false, false, NULL, ID3FD_Text },
- {ID3FID_LYRICIST, "TXT", "TEXT", false, false, NULL, ID3FD_Text },
- {ID3FID_ORIGARTIST, "TOA", "TOPE", false, false, NULL, ID3FD_Text },
- {ID3FID_ORIGLYRICIST, "TOL", "TOLY", false, false, NULL, ID3FD_Text },
- {ID3FID_CONTENTGROUP, "TT1", "TIT1", false, false, NULL, ID3FD_Text },
- {ID3FID_TITLE, "TT2", "TIT2", false, false, NULL, ID3FD_Text },
- {ID3FID_SUBTITLE, "TT3", "TIT3", false, false, NULL, ID3FD_Text },
- {ID3FID_LEADARTIST, "TP1", "TPE1", false, false, NULL, ID3FD_Text },
- {ID3FID_BAND, "TP2", "TPE2", false, false, NULL, ID3FD_Text },
- {ID3FID_CONDUCTOR, "TP3", "TPE3", false, false, NULL, ID3FD_Text },
- {ID3FID_MIXARTIST, "TP4", "TPE4", false, false, NULL, ID3FD_Text },
- {ID3FID_ALBUM, "TAL", "TALB", false, false, NULL, ID3FD_Text },
- {ID3FID_YEAR, "TYE", "TYER", false, false, NULL, ID3FD_Text },
- {ID3FID_COMPOSER, "TCM", "TCOM", false, false, NULL, ID3FD_Text },
- {ID3FID_COPYRIGHT, "TCR", "TCOP", false, false, NULL, ID3FD_Text },
- {ID3FID_PRODUCEDNOTICE, " ", "TPRO", false, false, NULL, ID3FD_Text },
- {ID3FID_CONTENTTYPE, "TCO", "TCON", false, false, NULL, ID3FD_Text },
- {ID3FID_TRACKNUM, "TRK", "TRCK", false, false, NULL, ID3FD_Text },
- {ID3FID_USERTEXT, "TXX", "TXXX", false, false, NULL, ID3FD_UserText },
- {ID3FID_COMMENT, "COM", "COMM", false, false, NULL, ID3FD_GeneralText },
- {ID3FID_TERMSOFUSE, " ", "USER", false, false, NULL, ID3FD_GeneralText },
- {ID3FID_UNSYNCEDLYRICS, "ULT", "USLT", false, false, NULL, ID3FD_GeneralText },
- {ID3FID_SYNCEDLYRICS, "SLT", "SYLT", false, false, NULL, ID3FD_Timestamp2 },
- {ID3FID_SYNCEDTEMPOCODE, "STC", "SYTC", false, false, NULL, ID3FD_Timestamp1 },
- // URL Frames
- {ID3FID_WWWAUDIOFILE, "WAF", "WOAF", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWARTIST, "WAR", "WOAR", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWAUDIOSOURCE, "WAS", "WOAS", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWCOMMERCIALINFO, "WCM", "WCOM", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWCOPYRIGHT, "WCP", "WCOP", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWPUBLISHER, "WPB", "WPUB", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWPAYMENT, "WPY", "WPAY", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWRADIOPAGE, "WRA", "WORS", false, false, NULL, ID3FD_URL },
- {ID3FID_WWWUSER, "WXX", "WXXX", false, false, NULL, ID3FD_UserURL },
- // misc frames
- {ID3FID_INVOLVEDPEOPLE, "IPL", "IPLS", false, false, NULL, ID3FD_InvolvedPeople },
- {ID3FID_PICTURE, "PIC", "APIC", false, false, NULL, ID3FD_Picture },
- {ID3FID_GENERALOBJECT, "GEO", "GEOB", false, false, NULL, ID3FD_GEO },
- {ID3FID_UNIQUEFILEID, "UFI", "UFID", false, false, NULL, ID3FD_UFI },
- {ID3FID_PRIVATE, " ", "PRIV", false, false, NULL, ID3FD_PRIVATE },
- {ID3FID_PLAYCOUNTER, "CNT", "PCNT", false, false, NULL, ID3FD_PlayCounter },
- {ID3FID_POPULARIMETER, "POP", "POPM", false, false, NULL, ID3FD_Popularimeter },
- {ID3FID_CRYPTOREG, " ", "ENCR", false, false, NULL, ID3FD_Registration },
- {ID3FID_GROUPINGREG, " ", "GRID", false, false, NULL, ID3FD_Registration },
- {ID3FID_SIGNATURE, " ", "SIGN", false, false, NULL, ID3FD_Registration },
- {ID3FID_MCDI, "MCI", "MCDI", false, false, NULL, ID3FD_MCDI},
- {ID3FID_BPM, "TBP", "TBPM", false, false, NULL, ID3FD_Text},
- {ID3FID_KEY, "TKE", "TKEY", false, false, NULL, ID3FD_Text},
- {ID3FID_MOOD, " ", "TMOO", false, false, NULL, ID3FD_Text},
- {ID3FID_ISRC, "TRC", "TSRC", false, false, NULL, ID3FD_Text},
- {ID3FID_RECORDINGTIME, " ", "TDRC", false, false, NULL, ID3FD_Text},
- {ID3FID_COMPILATION, "TCP", "TCMP", false, false, NULL, ID3FD_Text},
- {ID3FID_ALBUMSORT, "TSA", "TSOA", false, false, NULL, ID3FD_Text},
- {ID3FID_ALBUMARTISTSORT, "TS2", "TSO2", false, false, NULL, ID3FD_Text},
- {ID3FID_PERFORMERSORT, "TSP", "TSOP", false, false, NULL, ID3FD_Text},
- {ID3FID_COMPOSERSORT, "TSC", "TSOC", false, false, NULL, ID3FD_Text},
- {ID3FID_TITLESORT, "TST", "TSOT", false, false, NULL, ID3FD_Text},
- {ID3FID_REPLAYGAIN, " ", "RGAD", false, false, NULL, ID3FD_UserText },
- {ID3FID_VOLUMEADJ, "RVA", "RVAD", false, false, NULL, ID3FD_Volume },
- {ID3FID_INVOLVEDPEOPLE2, " ", "TIPL", false, false, NULL, ID3FD_InvolvedPeople },
- {ID3FID_CREDITS, " ", "TMCL", false, false, NULL, ID3FD_InvolvedPeople },
- {ID3FID_ENCODINGTIME, " ", "TDEN", false, false, NULL, ID3FD_Text },
- {ID3FID_FILEOWNER, " ", "TOWN", false, false, NULL, ID3FD_Text },
- {ID3FID_LENGTH, "TLE", "TLEN", false, false, NULL, ID3FD_Text },
- {ID3FID_ORIGYEAR, "TOR", "TORY", false, false, NULL, ID3FD_Text },
- {ID3FID_ORIGRELEASETIME, " ", "TDOR", false, false, NULL, ID3FD_Text },
- {ID3FID_RELEASETIME, " ", "TDRL", false, false, NULL, ID3FD_Text },
- {ID3FID_SETSUBTITLE, " ", "TSST", false, false, NULL, ID3FD_Text },
- {ID3FID_TAGGINGTIME, " ", "TDTG", false, false, NULL, ID3FD_Text },
- {ID3FID_PLAYLISTDELAY, "TDY", "TDLY", false, false, NULL, ID3FD_Text },
- {ID3FID_PODCAST, " ", "PCST", false, false, NULL, ID3FD_Text },
- {ID3FID_PODCASTCATEGORY, " ", "TCAT", false, false, NULL, ID3FD_Text },
- {ID3FID_PODCASTDESC, " ", "TDES", false, false, NULL, ID3FD_Text },
- {ID3FID_PODCASTID, " ", "TGID", false, false, NULL, ID3FD_Text },
- {ID3FID_PODCASTURL, " ", "WFED", false, false, NULL, ID3FD_URL },
- {ID3FID_NOFRAME }
- };
- ID3_Field::ID3_Field(void)
- {
- name = ID3FN_NOFIELD;
- type = ID3FTY_INTEGER;
- data = 0;
- size = 0;
- flags = 0;
- //SetVersion(3,0);
- version = 3;
- revision = 0;
- fixedLength = -1;
- ioVersion = 3;
- ioRevision = 0;
- control = ID3VC_HIGHER;
- Clear();
- }
- ID3_Field::~ID3_Field(void)
- {
- Clear();
- }
- void ID3_Field::Clear(void)
- {
- if (data && type != ID3FTY_INTEGER) free(data);
- type = ID3FTY_INTEGER;
- data = 0;
- size = sizeof (luint);
- hasChanged = true;
- return;
- }
- void ID3_Field::SetVersion (uchar ver, uchar rev)
- {
- if (version != ver || revision != rev) hasChanged = true;
- version = ver;
- revision = rev;
- return;
- }
- bool ID3_Field::HasChanged (void)
- {
- return hasChanged;
- }
- luint ID3_Field::Size(void)
- {
- return BinSize (false);
- }
- luint ID3_Field::BinSize(bool withExtras)
- {
- luint bytes = 0;
- if (control == ID3VC_HIGHER)
- {
- if (version < ioVersion || revision < ioRevision)
- return 0;
- }
- else
- {
- if (version > ioVersion || revision > ioRevision)
- return 0;
- }
- bytes = size;
- if (withExtras)
- {
- if (!data && size)
- {
- if (flags & ID3FF_NULL)
- bytes = 2;
- else
- bytes = 0;
- }
- // if we are a Unicode string, add 2 bytes for the BOM (but
- // only if there is a string to render - regardless of NULL)
- if (type == ID3FTY_UNICODESTRING && data && size) bytes += 2;
- // if we are an ASCII string, divide by sizeof (wchar_t)
- // because internally we store the string as Unicode, so
- // the ASCII version will only be half as long
- if (type == ID3FTY_UTF8STRING)
- {
- if (data && size)
- bytes = WideCharToMultiByte(CP_UTF8, 0, (const wchar_t *)data, (int)(size/sizeof(wchar_t)), 0, 0, 0, 0);
- else
- bytes /= sizeof(wchar_t);
- }
- if (type == ID3FTY_ASCIISTRING)
- {
- // TODO: this statement isn't correct (especially for double byte)
- // we could use WideCharToMultiByte to determine an exact byte count
- bytes /= sizeof (wchar_t);
- }
- }
- else
- {
- // because it seems that the application called us via ID3_Field::Size()
- // we are going to return the number of characters, not bytes, so if
- // the string is Unicode, we will half the 'bytes' variable because
- // Unicode strings have twice as many bytes as they do characters
- if (type == ID3FTY_UNICODESTRING)
- bytes /= sizeof(wchar_t);
- }
- // check to see if we are within the legal limit for this field
- // -1 means arbitrary length field
- if (fixedLength != -1)
- bytes = fixedLength;
- return bytes;
- }
- luint ID3_Field::Parse(uchar *buffer, luint posn, luint buffSize)
- {
- if (control == ID3VC_HIGHER)
- {
- if (version < ioVersion || revision < ioRevision)
- return 0;
- }
- else
- {
- if (version > ioVersion || revision > ioRevision)
- return 0;
- }
- switch(type)
- {
- case ID3FTY_INTEGER:
- return ParseInteger(buffer, posn, buffSize);
- case ID3FTY_BINARY:
- return ParseBinary(buffer, posn, buffSize);
- case ID3FTY_ASCIISTRING:
- return ParseASCIIString(buffer, posn, buffSize);
- case ID3FTY_UNICODESTRING:
- return ParseUnicodeString(buffer, posn, buffSize);
- case ID3FTY_UTF8STRING:
- return ParseUTF8String(buffer, posn, buffSize);
- default:
- //ID3_THROW (ID3E_UnknownFieldType);
- break;
- }
- return 0;
- }
- ID3_FrameDef *ID3_FindFrameDef(ID3_FrameID id)
- {
- luint cur = 0;
- while (1)
- {
- if (ID3_FrameDefs[cur].id == id)
- return &ID3_FrameDefs[cur];
- if (ID3_FrameDefs[cur].id == ID3FID_NOFRAME)
- return NULL;
- cur++;
- }
- }
- ID3_FrameID ID3_FindFrameID(const char *id)
- {
- luint cur = 0;
- while (1)
- {
- if (ID3_FrameDefs[cur].id == ID3FID_NOFRAME)
- return ID3FID_NOFRAME;
- if (((strncmp(ID3_FrameDefs[cur].shortTextID, id, 3) == 0) && strlen (id) == 3)
- || ((strncmp(ID3_FrameDefs[cur].longTextID, id, 4) == 0) && strlen (id) == 4))
- return ID3_FrameDefs[cur].id;
- cur++;
- }
- }
- luint ID3_Field::Render(uchar *buffer)
- {
- if (control == ID3VC_HIGHER)
- {
- if (version < ioVersion || revision < ioRevision)
- return 0;
- }
- else
- {
- if (version > ioVersion || revision > ioRevision)
- return 0;
- }
- switch(type)
- {
- case ID3FTY_INTEGER:
- return RenderInteger(buffer);
- case ID3FTY_BINARY:
- return RenderBinary(buffer);
- case ID3FTY_ASCIISTRING:
- return RenderLatinString(buffer);
- case ID3FTY_UNICODESTRING:
- return RenderUnicodeString(buffer);
- case ID3FTY_UTF8STRING:
- return RenderUTF8String(buffer);
- default:
- // ID3_THROW (ID3E_UnknownFieldType);
- break;
- }
- return 0;
- }
|