ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Dss.php
Go to the documentation of this file.
1 <?php
2 
3 namespace GetId3\Module\Audio;
4 
7 
10 // available at http://getid3.sourceforge.net //
11 // or http://www.getid3.org //
13 // See readme.txt for more details //
15 // //
16 // module.audio.dss.php //
17 // module for analyzing Digital Speech Standard (DSS) files //
18 // dependencies: NONE //
19 // ///
21 
29 class Dss extends BaseHandler
30 {
35  public function analyze()
36  {
37  $info = &$this->getid3->info;
38 
39  fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
40  $DSSheader = fread($this->getid3->fp, 1256);
41 
42  if (!preg_match('#^(\x02|\x03)dss#', $DSSheader)) {
43  $info['error'][] = 'Expecting "[02-03] 64 73 73" at offset '.$info['avdataoffset'].', found "'.Helper::PrintHexBytes(substr($DSSheader, 0, 4)).'"';
44 
45  return false;
46  }
47 
48  // some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
49 
50  // shortcut
51  $info['dss'] = array();
52  $thisfile_dss = &$info['dss'];
53 
54  $info['fileformat'] = 'dss';
55  $info['audio']['dataformat'] = 'dss';
56  $info['audio']['bitrate_mode'] = 'cbr';
57  //$thisfile_dss['encoding'] = 'ISO-8859-1';
58 
59  $thisfile_dss['version'] = ord(substr($DSSheader, 0, 1));
60  $thisfile_dss['date_create'] = self::DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
61  $thisfile_dss['date_complete'] = self::DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
62  //$thisfile_dss['length'] = intval(substr($DSSheader, 62, 6)); // I thought time was in seconds, it's actually HHMMSS
63  $thisfile_dss['length'] = intval((substr($DSSheader, 62, 2) * 3600) + (substr($DSSheader, 64, 2) * 60) + substr($DSSheader, 66, 2));
64  $thisfile_dss['priority'] = ord(substr($DSSheader, 793, 1));
65  $thisfile_dss['comments'] = trim(substr($DSSheader, 798, 100));
66 
67 
68  //$info['audio']['bits_per_sample'] = ?;
69  //$info['audio']['sample_rate'] = ?;
70  $info['audio']['channels'] = 1;
71 
72  $info['playtime_seconds'] = $thisfile_dss['length'];
73  $info['audio']['bitrate'] = ($info['filesize'] * 8) / $info['playtime_seconds'];
74 
75  return true;
76  }
77 
83  protected static function DSSdateStringToUnixDate($datestring)
84  {
85  $y = substr($datestring, 0, 2);
86  $m = substr($datestring, 2, 2);
87  $d = substr($datestring, 4, 2);
88  $h = substr($datestring, 6, 2);
89  $i = substr($datestring, 8, 2);
90  $s = substr($datestring, 10, 2);
91  $y += (($y < 95) ? 2000 : 1900);
92 
93  return mktime($h, $i, $s, $m, $d, $y);
94  }
95 }
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: Helper.php:36
GetId3() by James Heinrich info@getid3.org //.
Definition: BaseHandler.php:25
$h
GetId3() by James Heinrich info@getid3.org //.
Definition: Dss.php:29
for($col=0; $col< 50; $col++) $d
fseek($bytes, $whence=SEEK_SET)
$info
Definition: example_052.php:80
$y
Definition: example_007.php:83
Create styles array
The data for the language used.
static DSSdateStringToUnixDate($datestring)
Definition: Dss.php:83