module.audio.dss.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. class getid3_dss
  16. {
  17. function getid3_dss(&$fd, &$ThisFileInfo) {
  18. fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
  19. $DSSheader = fread($fd, 1256);
  20. if (substr($DSSheader, 0, 4) != "\x02".'dss') {
  21. $ThisFileInfo['error'][] = 'Expecting "[x02]dss" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($DSSheader, 0, 4).'"';
  22. return false;
  23. }
  24. // some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
  25. // shortcut
  26. $ThisFileInfo['dss'] = array();
  27. $thisfile_dss = &$ThisFileInfo['dss'];
  28. $ThisFileInfo['fileformat'] = 'dss';
  29. $ThisFileInfo['audio']['dataformat'] = 'dss';
  30. $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
  31. //$thisfile_dss['encoding'] = 'ISO-8859-1';
  32. $thisfile_dss['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
  33. $thisfile_dss['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
  34. $thisfile_dss['length'] = intval(substr($DSSheader, 62, 6));
  35. $thisfile_dss['priority'] = ord(substr($DSSheader, 793, 1));
  36. $thisfile_dss['comments'] = trim(substr($DSSheader, 798, 100));
  37. //$ThisFileInfo['audio']['bits_per_sample'] = ?;
  38. //$ThisFileInfo['audio']['sample_rate'] = ?;
  39. $ThisFileInfo['audio']['channels'] = 1;
  40. $ThisFileInfo['playtime_seconds'] = $thisfile_dss['length'];
  41. $ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['filesize'] * 8) / $ThisFileInfo['playtime_seconds'];
  42. return true;
  43. }
  44. function DSSdateStringToUnixDate($datestring) {
  45. $y = substr($datestring, 0, 2);
  46. $m = substr($datestring, 2, 2);
  47. $d = substr($datestring, 4, 2);
  48. $h = substr($datestring, 6, 2);
  49. $i = substr($datestring, 8, 2);
  50. $s = substr($datestring, 10, 2);
  51. $y += (($y < 95) ? 2000 : 1900);
  52. return mktime($h, $i, $s, $m, $d, $y);
  53. }
  54. }
  55. ?>