1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Dave Chapman
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #include "metadata_common.h"
30 #include "metadata_parsers.h"
32 #include "rbunicode.h"
34 bool get_spc_metadata(int fd
, struct mp3entry
* id3
)
36 /* Use the trackname part of the id3 structure as a temporary buffer */
37 unsigned char * buf
= (unsigned char *)id3
->path
;
46 /* try to get the ID666 tag */
47 if ((lseek(fd
, 0x2e, SEEK_SET
) < 0)
48 || ((read_bytes
= read(fd
, buf
, 0xD2)) < 0xD2))
50 DEBUGF("lseek or read failed\n");
58 p
= iso_decode(buf
, p
, 0, 32);
63 p
= iso_decode(buf
, p
, 0, 32);
68 p
= iso_decode(buf
, p
, 0, 32);
72 if(buf
[2] == '/' && buf
[5] == '/')
75 /* Reserved bytes check */
76 if(buf
[0xD2 - 0x2E - 112] >= '0' &&
77 buf
[0xD2 - 0x2E - 112] <= '9' &&
78 buf
[0xD3 - 0x2E - 112] == 0x00)
81 /* is length & fade only digits? */
83 (buf
[0xA9 - 0x2E - 112+i
]>='0'&&buf
[0xA9 - 0x2E - 112+i
]<='9') ||
84 buf
[0xA9 - 0x2E - 112+i
]=='\0');
86 if (i
==8) isbinary
= false;
89 id3
->year
= buf
[0] | (buf
[1]<<8);
92 length
= (buf
[0] | (buf
[1]<<8) | (buf
[2]<<16)) * 1000;
95 fade
= (buf
[0] | (buf
[1]<<8) | (buf
[2]<<16) | (buf
[3]<<24));
102 id3
->year
= atoi(buf
);
105 memcpy(tbuf
, buf
, 3);
107 length
= atoi(tbuf
) * 1000;
110 memcpy(tbuf
, buf
, 5);
118 p
= iso_decode(buf
, p
, 0, 32);
121 length
=3*60*1000; /* 3 minutes */
122 fade
=5*1000; /* 5 seconds */
125 id3
->length
= length
+fade
;