ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_dss Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Inheritance diagram for getid3_dss:
+ Collaboration diagram for getid3_dss:

Public Member Functions

 Analyze ()
 
 DSSdateStringToUnixDate ($datestring)
 
 DSSsampleRateLookup ($sample_rate_index)
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

Definition at line 18 of file module.audio.dss.php.

Member Function Documentation

◆ Analyze()

getid3_dss::Analyze ( )

Reimplemented from getid3_handler.

Definition at line 21 of file module.audio.dss.php.

21 {
22 $info = &$this->getid3->info;
23
24 $this->fseek($info['avdataoffset']);
25 $DSSheader = $this->fread(1540);
26
27 if (!preg_match('#^(\x02|\x03)ds[s2]#', $DSSheader)) {
28 $info['error'][] = 'Expecting "[02-03] 64 73 [73|32]" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)).'"';
29 return false;
30 }
31
32 // some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
33 $info['encoding'] = 'ISO-8859-1'; // not certain, but assumed
34 $info['dss'] = array();
35
36 $info['fileformat'] = 'dss';
37 $info['mime_type'] = 'audio/x-'.substr($DSSheader, 1, 3); // "audio/x-dss" or "audio/x-ds2"
38 $info['audio']['dataformat'] = substr($DSSheader, 1, 3); // "dss" or "ds2"
39 $info['audio']['bitrate_mode'] = 'cbr';
40
41 $info['dss']['version'] = ord(substr($DSSheader, 0, 1));
42 $info['dss']['hardware'] = trim(substr($DSSheader, 12, 16)); // identification string for hardware used to create the file, e.g. "DPM 9600", "DS2400"
43 $info['dss']['unknown1'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 28, 4));
44 // 32-37 = "FE FF FE FF F7 FF" in all the sample files I've seen
45 $info['dss']['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
46 $info['dss']['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
47 $info['dss']['playtime_sec'] = intval((substr($DSSheader, 62, 2) * 3600) + (substr($DSSheader, 64, 2) * 60) + substr($DSSheader, 66, 2)); // approximate file playtime in HHMMSS
48 $info['dss']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 512, 4)); // exact file playtime in milliseconds. Has also been observed at offset 530 in one sample file, with something else (unknown) at offset 512
49 $info['dss']['priority'] = ord(substr($DSSheader, 793, 1));
50 $info['dss']['comments'] = trim(substr($DSSheader, 798, 100));
51 $info['dss']['sample_rate_index'] = ord(substr($DSSheader, 1538, 1)); // this isn't certain, this may or may not be where the sample rate info is stored, but it seems consistent on my small selection of sample files
52
53 $info['audio']['bits_per_sample'] = 16; // maybe, maybe not -- most compressed audio formats don't have a fixed bits-per-sample value, but this is a reasonable approximation
54 $info['audio']['sample_rate'] = $this->DSSsampleRateLookup($info['dss']['sample_rate_index']);
55 $info['audio']['channels'] = 1;
56
57 $info['playtime_seconds'] = $info['dss']['playtime_ms'] / 1000;
58 if (floor($info['dss']['playtime_ms'] / 1000) != $info['dss']['playtime_sec']) {
59 // *should* just be playtime_ms / 1000 but at least one sample file has playtime_ms at offset 530 instead of offset 512, so safety check
60 $info['playtime_seconds'] = $info['dss']['playtime_sec'];
61 $this->getid3->warning('playtime_ms ('.number_format($info['dss']['playtime_ms'] / 1000, 3).') does not match playtime_sec ('.number_format($info['dss']['playtime_sec']).') - using playtime_sec value');
62 }
63 $info['audio']['bitrate'] = ($info['filesize'] * 8) / $info['playtime_seconds'];
64
65 return true;
66 }
DSSdateStringToUnixDate($datestring)
DSSsampleRateLookup($sample_rate_index)
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
fread($bytes)
Definition: getid3.php:1685
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
$info
Definition: example_052.php:80

References $info, DSSdateStringToUnixDate(), DSSsampleRateLookup(), getid3_handler\fread(), getid3_handler\fseek(), getid3_lib\LittleEndian2Int(), and getid3_lib\PrintHexBytes().

+ Here is the call graph for this function:

◆ DSSdateStringToUnixDate()

getid3_dss::DSSdateStringToUnixDate (   $datestring)

Definition at line 68 of file module.audio.dss.php.

68 {
69 $y = substr($datestring, 0, 2);
70 $m = substr($datestring, 2, 2);
71 $d = substr($datestring, 4, 2);
72 $h = substr($datestring, 6, 2);
73 $i = substr($datestring, 8, 2);
74 $s = substr($datestring, 10, 2);
75 $y += (($y < 95) ? 2000 : 1900);
76 return mktime($h, $i, $s, $m, $d, $y);
77 }
$y
Definition: example_007.php:83
$h

References $d, $h, and $y.

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ DSSsampleRateLookup()

getid3_dss::DSSsampleRateLookup (   $sample_rate_index)

Definition at line 79 of file module.audio.dss.php.

79 {
80 static $dssSampleRateLookup = array(
81 0x0A => 16000,
82 0x0C => 11025,
83 0x0D => 12000,
84 0x15 => 8000,
85 );
86 if (!array_key_exists($sample_rate_index, $dssSampleRateLookup)) {
87 $this->getid3->warning('unknown sample_rate_index: '.$sample_rate_index);
88 return false;
89 }
90 return $dssSampleRateLookup[$sample_rate_index];
91 }

Referenced by Analyze().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: