1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Dave Chapman
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
27 #include "metadata_common.h"
30 #include "rbunicode.h"
32 bool get_spc_metadata(int fd
, struct mp3entry
* id3
)
34 /* Use the trackname part of the id3 structure as a temporary buffer */
35 unsigned char * buf
= (unsigned char *)id3
->path
;
44 /* try to get the ID666 tag */
45 if ((lseek(fd
, 0x2e, SEEK_SET
) < 0)
46 || ((read_bytes
= read(fd
, buf
, 0xD2)) < 0xD2))
48 DEBUGF("lseek or read failed\n");
56 p
= iso_decode(buf
, p
, 0, 32);
61 p
= iso_decode(buf
, p
, 0, 32);
66 p
= iso_decode(buf
, p
, 0, 32);
70 if(buf
[2] == '/' && buf
[5] == '/')
73 /* Reserved bytes check */
74 if(buf
[0xD2 - 0x2E - 112] >= '0' &&
75 buf
[0xD2 - 0x2E - 112] <= '9' &&
76 buf
[0xD3 - 0x2E - 112] == 0x00)
79 /* is length & fade only digits? */
81 (buf
[0xA9 - 0x2E - 112+i
]>='0'&&buf
[0xA9 - 0x2E - 112+i
]<='9') ||
82 buf
[0xA9 - 0x2E - 112+i
]=='\0');
84 if (i
==8) isbinary
= false;
87 id3
->year
= buf
[0] | (buf
[1]<<8);
90 length
= (buf
[0] | (buf
[1]<<8) | (buf
[2]<<16)) * 1000;
93 fade
= (buf
[0] | (buf
[1]<<8) | (buf
[2]<<16) | (buf
[3]<<24));
100 id3
->year
= atoi(buf
);
103 memcpy(tbuf
, buf
, 3);
105 length
= atoi(tbuf
) * 1000;
108 memcpy(tbuf
, buf
, 5);
116 p
= iso_decode(buf
, p
, 0, 32);
119 length
=3*60*1000; /* 3 minutes */
120 fade
=5*1000; /* 5 seconds */
123 id3
->length
= length
+fade
;