1 #ifndef _PLAYMP2_ID3_H 2 #define _PLAYMP2_ID3_H 3 4 struct ID3v1data_t /* no need to free */ 5 { 6 uint8_t title[61]; /* goes to the file-list as-is */ 7 uint8_t artist[61]; /* will replace composer in the file-list */ 8 uint8_t album[61]; /* will replace style in the file-list */ 9 uint8_t comment[46]; /* goes to the file-list as-is */ 10 uint8_t genre; 11 uint8_t subgenre[21]; 12 uint8_t year[5]; /* goes to the file-list as-is */ 13 int16_t track; 14 }; 15 16 struct ID3_pic_t 17 { 18 int is_jpeg; 19 int is_png; 20 int size; 21 uint8_t *data; 22 }; 23 24 struct ID3_t 25 { 26 int serial; 27 28 uint8_t *TIT1; /* Content Group */ 29 uint8_t *TIT2; /* Track Title */ 30 uint8_t *TIT3; /* Subtitle */ 31 uint8_t *TPE1; /* Lead Artist */ 32 uint8_t *TPE2; /* Band */ 33 uint8_t *TPE3; /* Conductor */ 34 uint8_t *TPE4; /* Interpretor */ 35 uint8_t *TALB; /* Album */ 36 uint8_t *TCOM; /* Composer */ 37 uint8_t *TEXT; /* Lyrics */ 38 uint8_t *TRCK; /* Track number */ 39 uint8_t *TCON; /* Content Type */ /* Needs further rendering */ 40 uint8_t *TDRC; // Recorded YYYY-MM-ddHH:mm:ss/next one or space (strip precision from the right / is duration, space is list*/ 41 uint8_t *TDRL; // Released YYYY-MM-ddHH:mm:ss/next one or space (strip precision from the right / is duration, space is list */ 42 uint8_t *TYER; // YEAR YYYY (recording) 43 uint8_t *TDAT; // DATE DDMM (recording) 44 uint8_t *TIME; // TIME HHMM (recording) 45 uint8_t *COMM; /* Comment */ 46 // TODO APIC 47 struct ID3_pic_t APIC[0x15]; 48 // TODO tag_is_an_update 49 int tag_is_an_update; 50 }; 51 52 extern const char *ID3_APIC_Titles[0x15]; 53 54 /* length should be 128 bytes 55 * source can point to single ID3v1.0 or ID3v1.1 block 56 * 57 * returns non-zero if invalid 58 */ 59 60 int parse_ID3v1x(struct ID3v1data_t *data, const unsigned char *source, unsigned int length); 61 62 /* length should be 128 bytes 63 * source should point to single ID3v1.2 block 64 * 65 * dest should be prefilled by parse_ID3v1x() 66 * 67 * returns non-zero if invalid 68 */ 69 int parse_ID3v12(struct ID3v1data_t *data, const unsigned char *source, unsigned int length); 70 71 /* destination is memset to zero initially 72 * 73 * returns -1 if something goes wrong, 0 if OK 74 */ 75 int finalize_ID3v1(struct ID3_t *destination, struct ID3v1data_t *data); 76 77 /* source data will likely be modified during unescaping sync sequences, but will touch data outside the original bounds 78 * 79 * returns non-zero if invalid 80 */ 81 int parse_ID3v2x(struct ID3_t *destination, unsigned char *source, uint32_t length); 82 83 /* calls free() on all members, and sets them back to zero */ 84 void ID3_clear(struct ID3_t *destination); 85 86 #endif 87