1 | <?php |
---|
2 | ///////////////////////////////////////////////////////////////// |
---|
3 | /// getID3() by James Heinrich <info@getid3.org> // |
---|
4 | // available at http://getid3.sourceforge.net // |
---|
5 | // or http://www.getid3.org // |
---|
6 | ///////////////////////////////////////////////////////////////// |
---|
7 | // See readme.txt for more details // |
---|
8 | ///////////////////////////////////////////////////////////////// |
---|
9 | // // |
---|
10 | // module.audio.au.php // |
---|
11 | // module for analyzing Digital Speech Standard (DSS) files // |
---|
12 | // dependencies: NONE // |
---|
13 | // /// |
---|
14 | ///////////////////////////////////////////////////////////////// |
---|
15 | |
---|
16 | |
---|
17 | class getid3_dss |
---|
18 | { |
---|
19 | |
---|
20 | function getid3_dss(&$fd, &$ThisFileInfo) { |
---|
21 | |
---|
22 | fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); |
---|
23 | $DSSheader = fread($fd, 1256); |
---|
24 | |
---|
25 | if (substr($DSSheader, 0, 4) != "\x02".'dss') { |
---|
26 | $ThisFileInfo['error'][] = 'Expecting "[x02]dss" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($DSSheader, 0, 4).'"'; |
---|
27 | return false; |
---|
28 | } |
---|
29 | |
---|
30 | // some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm |
---|
31 | |
---|
32 | // shortcut |
---|
33 | $ThisFileInfo['dss'] = array(); |
---|
34 | $thisfile_dss = &$ThisFileInfo['dss']; |
---|
35 | |
---|
36 | $ThisFileInfo['fileformat'] = 'dss'; |
---|
37 | $ThisFileInfo['audio']['dataformat'] = 'dss'; |
---|
38 | $ThisFileInfo['audio']['bitrate_mode'] = 'cbr'; |
---|
39 | //$thisfile_dss['encoding'] = 'ISO-8859-1'; |
---|
40 | |
---|
41 | $thisfile_dss['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12)); |
---|
42 | $thisfile_dss['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12)); |
---|
43 | $thisfile_dss['length'] = intval(substr($DSSheader, 62, 6)); |
---|
44 | $thisfile_dss['priority'] = ord(substr($DSSheader, 793, 1)); |
---|
45 | $thisfile_dss['comments'] = trim(substr($DSSheader, 798, 100)); |
---|
46 | |
---|
47 | |
---|
48 | //$ThisFileInfo['audio']['bits_per_sample'] = ?; |
---|
49 | //$ThisFileInfo['audio']['sample_rate'] = ?; |
---|
50 | $ThisFileInfo['audio']['channels'] = 1; |
---|
51 | |
---|
52 | $ThisFileInfo['playtime_seconds'] = $thisfile_dss['length']; |
---|
53 | $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['filesize'] * 8) / $ThisFileInfo['playtime_seconds']; |
---|
54 | |
---|
55 | return true; |
---|
56 | } |
---|
57 | |
---|
58 | function DSSdateStringToUnixDate($datestring) { |
---|
59 | $y = substr($datestring, 0, 2); |
---|
60 | $m = substr($datestring, 2, 2); |
---|
61 | $d = substr($datestring, 4, 2); |
---|
62 | $h = substr($datestring, 6, 2); |
---|
63 | $i = substr($datestring, 8, 2); |
---|
64 | $s = substr($datestring, 10, 2); |
---|
65 | $y += (($y < 95) ? 2000 : 1900); |
---|
66 | return mktime($h, $i, $s, $m, $d, $y); |
---|
67 | } |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | ?> |
---|