9 #include "metadata_common.h"
10 #include "metadata_parsers.h"
11 #include "rbunicode.h"
13 static bool parse_sgc_header(int fd
, struct mp3entry
* id3
)
15 /* Use the trackname part of the id3 structure as a temporary buffer */
16 unsigned char* buf
= (unsigned char *)id3
->path
;
18 lseek(fd
, 0, SEEK_SET
);
19 if (read(fd
, buf
, 0xA0) < 0xA0)
22 /* calculate track length with number of tracks */
23 id3
->length
= buf
[37] * 1000;
25 /* If meta info was found in the m3u skip next step */
26 if (id3
->title
&& id3
->title
[0]) return true;
28 char *p
= id3
->id3v2buf
;
30 /* Some metadata entries have 32 bytes length */
32 memcpy(p
, &buf
[64], 32); *(p
+ 33) = '\0';
37 memcpy(p
, &buf
[96], 32); *(p
+ 33) = '\0';
42 memcpy(p
, &buf
[128], 32); *(p
+ 33) = '\0';
49 bool get_sgc_metadata(int fd
, struct mp3entry
* id3
)
52 if ((lseek(fd
, 0, SEEK_SET
) < 0) ||
53 read_uint32be(fd
, &sgc_type
) != (int)sizeof(sgc_type
))
57 id3
->filesize
= filesize(fd
);
58 /* we only render 16 bits, 44.1KHz, Stereo */
60 id3
->frequency
= 44100;
62 /* Make sure this is an SGC file */
63 if (sgc_type
!= FOURCC('S','G','C',0x1A))
66 return parse_sgc_header(fd
, id3
);