PageRenderTime 32ms CodeModel.GetById 40ms RepoModel.GetById 1ms app.codeStats 0ms

/common/libraries/plugin/osflvplayer/flash/getid3.php

https://bitbucket.org/chamilo/chamilo/
PHP | 1261 lines | 869 code | 217 blank | 175 comment | 140 complexity | b9baf32d2ebc9c0347072923059ec161 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT
  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. // //
  8. // Please see readme.txt for more information //
  9. // ///
  10. /////////////////////////////////////////////////////////////////
  11. // Defines
  12. define('GETID3_VERSION', '1.7.7');
  13. define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes
  14. class getID3
  15. {
  16. // public: Settings
  17. var $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv())
  18. // Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
  19. var $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN'
  20. var $tempdir = '*'; // default '*' should use system temp dir
  21. // public: Optional tag checks - disable for speed.
  22. var $option_tag_id3v1 = true; // Read and process ID3v1 tags
  23. var $option_tag_id3v2 = true; // Read and process ID3v2 tags
  24. var $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
  25. var $option_tag_apetag = true; // Read and process APE tags
  26. var $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
  27. var $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
  28. // public: Optional tag/comment calucations
  29. var $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
  30. // public: Optional calculations
  31. var $option_md5_data = false; // Get MD5 sum of data part - slow
  32. var $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
  33. var $option_sha1_data = false; // Get SHA1 sum of data part - slow
  34. var $option_max_2gb_check = true; // Check whether file is larger than 2 Gb and thus not supported by PHP
  35. // private
  36. var $filename;
  37. // public: constructor
  38. function getID3()
  39. {
  40. $this->startup_error = '';
  41. $this->startup_warning = '';
  42. // Check for PHP version >= 4.1.0
  43. if (phpversion() < '4.1.0') {
  44. $this->startup_error .= 'getID3() requires PHP v4.1.0 or higher - you are running v'.phpversion();
  45. }
  46. // Check memory
  47. $memory_limit = ini_get('memory_limit');
  48. if (eregi('([0-9]+)M', $memory_limit, $matches)) {
  49. // could be stored as "16M" rather than 16777216 for example
  50. $memory_limit = $matches[1] * 1048576;
  51. }
  52. if ($memory_limit <= 0) {
  53. // memory limits probably disabled
  54. } elseif ($memory_limit <= 3145728) {
  55. $this->startup_error .= 'PHP has less than 3MB available memory and will very likely run out. Increase memory_limit in php.ini';
  56. } elseif ($memory_limit <= 12582912) {
  57. $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
  58. }
  59. // Check safe_mode off
  60. if ((bool) ini_get('safe_mode')) {
  61. $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
  62. }
  63. // define a constant rather than looking up every time it is needed
  64. if (!defined('GETID3_OS_ISWINDOWS')) {
  65. if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
  66. define('GETID3_OS_ISWINDOWS', true);
  67. } else {
  68. define('GETID3_OS_ISWINDOWS', false);
  69. }
  70. }
  71. // Get base path of getID3() - ONCE
  72. if (!defined('GETID3_INCLUDEPATH')) {
  73. foreach (get_included_files() as $key => $val) {
  74. if (basename($val) == 'getid3.php') {
  75. define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
  76. break;
  77. }
  78. }
  79. }
  80. // Load support library
  81. if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
  82. $this->startup_error .= 'getid3.lib.php is missing or corrupt';
  83. }
  84. }
  85. // public: setOption
  86. function setOption($optArray) {
  87. if (!is_array($optArray) || empty($optArray)) {
  88. return false;
  89. }
  90. foreach ($optArray as $opt => $val) {
  91. if (isset($this, $opt) === false) {
  92. continue;
  93. }
  94. $this->$opt = $val;
  95. }
  96. return true;
  97. }
  98. // public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
  99. function analyze($filename) {
  100. if (!empty($this->startup_error)) {
  101. return $this->error($this->startup_error);
  102. }
  103. if (!empty($this->startup_warning)) {
  104. $this->warning($this->startup_warning);
  105. }
  106. // init result array and set parameters
  107. $this->info = array();
  108. $this->info['GETID3_VERSION'] = GETID3_VERSION;
  109. // Check encoding/iconv support
  110. if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
  111. $errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
  112. if (GETID3_OS_ISWINDOWS) {
  113. $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
  114. } else {
  115. $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
  116. }
  117. return $this->error($errormessage);
  118. }
  119. // Disable magic_quotes_runtime, if neccesary
  120. $old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime
  121. if ($old_magic_quotes_runtime) {
  122. set_magic_quotes_runtime(0); // turn off magic_quotes_runtime
  123. if (get_magic_quotes_runtime()) {
  124. return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
  125. }
  126. }
  127. // remote files not supported
  128. if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
  129. return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
  130. }
  131. // open local file
  132. if (!$fp = @fopen($filename, 'rb')) {
  133. return $this->error('Could not open file "'.$filename.'"');
  134. }
  135. // set parameters
  136. $this->info['filesize'] = filesize($filename);
  137. // option_max_2gb_check
  138. if ($this->option_max_2gb_check) {
  139. // PHP doesn't support integers larger than 31-bit (~2GB)
  140. // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
  141. // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
  142. fseek($fp, 0, SEEK_END);
  143. if ((($this->info['filesize'] != 0) && (ftell($fp) == 0)) ||
  144. ($this->info['filesize'] < 0) ||
  145. (ftell($fp) < 0)) {
  146. unset($this->info['filesize']);
  147. fclose($fp);
  148. return $this->error('File is most likely larger than 2GB and is not supported by PHP');
  149. }
  150. }
  151. // set more parameters
  152. $this->info['avdataoffset'] = 0;
  153. $this->info['avdataend'] = $this->info['filesize'];
  154. $this->info['fileformat'] = ''; // filled in later
  155. $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
  156. $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
  157. $this->info['tags'] = array(); // filled in later, unset if not used
  158. $this->info['error'] = array(); // filled in later, unset if not used
  159. $this->info['warning'] = array(); // filled in later, unset if not used
  160. $this->info['comments'] = array(); // filled in later, unset if not used
  161. $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
  162. // set redundant parameters - might be needed in some include file
  163. $this->info['filename'] = basename($filename);
  164. $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
  165. $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
  166. // handle ID3v2 tag - done first - already at beginning of file
  167. // ID3v2 detection (even if not parsing) is always done otherwise fileformat is much harder to detect
  168. if ($this->option_tag_id3v2) {
  169. $GETID3_ERRORARRAY = &$this->info['warning'];
  170. if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, false)) {
  171. $tag = new getid3_id3v2($fp, $this->info);
  172. }
  173. } else {
  174. fseek($fp, 0, SEEK_SET);
  175. $header = fread($fp, 10);
  176. if (substr($header, 0, 3) == 'ID3') {
  177. $this->info['id3v2']['header'] = true;
  178. $this->info['id3v2']['majorversion'] = ord($header{3});
  179. $this->info['id3v2']['minorversion'] = ord($header{4});
  180. $this->info['id3v2']['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
  181. $this->info['id3v2']['tag_offset_start'] = 0;
  182. $this->info['id3v2']['tag_offset_end'] = $this->info['id3v2']['tag_offset_start'] + $this->info['id3v2']['headerlength'];
  183. $this->info['avdataoffset'] = $this->info['id3v2']['tag_offset_end'];
  184. }
  185. }
  186. // handle ID3v1 tag
  187. if ($this->option_tag_id3v1) {
  188. if (!@include_once(GETID3_INCLUDEPATH.'module.tag.id3v1.php')) {
  189. return $this->error('module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
  190. }
  191. $tag = new getid3_id3v1($fp, $this->info);
  192. }
  193. // handle APE tag
  194. if ($this->option_tag_apetag) {
  195. if (!@include_once(GETID3_INCLUDEPATH.'module.tag.apetag.php')) {
  196. return $this->error('module.tag.apetag.php is missing - you may disable option_tag_apetag.');
  197. }
  198. $tag = new getid3_apetag($fp, $this->info);
  199. }
  200. // handle lyrics3 tag
  201. if ($this->option_tag_lyrics3) {
  202. if (!@include_once(GETID3_INCLUDEPATH.'module.tag.lyrics3.php')) {
  203. return $this->error('module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
  204. }
  205. $tag = new getid3_lyrics3($fp, $this->info);
  206. }
  207. // read 32 kb file data
  208. fseek($fp, $this->info['avdataoffset'], SEEK_SET);
  209. $formattest = fread($fp, 32774);
  210. // determine format
  211. $determined_format = $this->GetFileFormat($formattest, $filename);
  212. // unable to determine file format
  213. if (!$determined_format) {
  214. fclose($fp);
  215. return $this->error('unable to determine file format');
  216. }
  217. // check for illegal ID3 tags
  218. if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
  219. if ($determined_format['fail_id3'] === 'ERROR') {
  220. fclose($fp);
  221. return $this->error('ID3 tags not allowed on this file type.');
  222. } elseif ($determined_format['fail_id3'] === 'WARNING') {
  223. $this->info['warning'][] = 'ID3 tags not allowed on this file type.';
  224. }
  225. }
  226. // check for illegal APE tags
  227. if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
  228. if ($determined_format['fail_ape'] === 'ERROR') {
  229. fclose($fp);
  230. return $this->error('APE tags not allowed on this file type.');
  231. } elseif ($determined_format['fail_ape'] === 'WARNING') {
  232. $this->info['warning'][] = 'APE tags not allowed on this file type.';
  233. }
  234. }
  235. // set mime type
  236. $this->info['mime_type'] = $determined_format['mime_type'];
  237. // supported format signature pattern detected, but module deleted
  238. if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
  239. fclose($fp);
  240. return $this->error('Format not supported, module, '.$determined_format['include'].', was removed.');
  241. }
  242. // module requires iconv support
  243. if (!function_exists('iconv') && @$determined_format['iconv_req']) {
  244. return $this->error('iconv support is required for this module ('.$determined_format['include'].').');
  245. }
  246. // include module
  247. include_once(GETID3_INCLUDEPATH.$determined_format['include']);
  248. // instantiate module class
  249. $class_name = 'getid3_'.$determined_format['module'];
  250. if (!class_exists($class_name)) {
  251. return $this->error('Format not supported, module, '.$determined_format['include'].', is corrupt.');
  252. }
  253. if (isset($determined_format['option'])) {
  254. $class = new $class_name($fp, $this->info, $determined_format['option']);
  255. } else {
  256. $class = new $class_name($fp, $this->info);
  257. }
  258. // close file
  259. fclose($fp);
  260. // process all tags - copy to 'tags' and convert charsets
  261. if ($this->option_tags_process) {
  262. $this->HandleAllTags();
  263. }
  264. // perform more calculations
  265. if ($this->option_extra_info) {
  266. $this->ChannelsBitratePlaytimeCalculations();
  267. $this->CalculateCompressionRatioVideo();
  268. $this->CalculateCompressionRatioAudio();
  269. $this->CalculateReplayGain();
  270. $this->ProcessAudioStreams();
  271. }
  272. // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
  273. if ($this->option_md5_data) {
  274. // do not cald md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
  275. if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
  276. $this->getHashdata('md5');
  277. }
  278. }
  279. // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
  280. if ($this->option_sha1_data) {
  281. $this->getHashdata('sha1');
  282. }
  283. // remove undesired keys
  284. $this->CleanUp();
  285. // restore magic_quotes_runtime setting
  286. set_magic_quotes_runtime($old_magic_quotes_runtime);
  287. // return info array
  288. return $this->info;
  289. }
  290. // private: error handling
  291. function error($message) {
  292. $this->CleanUp();
  293. $this->info['error'][] = $message;
  294. return $this->info;
  295. }
  296. // private: warning handling
  297. function warning($message) {
  298. $this->info['warning'][] = $message;
  299. return true;
  300. }
  301. // private: CleanUp
  302. function CleanUp() {
  303. // remove possible empty keys
  304. $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams');
  305. foreach ($AVpossibleEmptyKeys as $dummy => $key) {
  306. if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
  307. unset($this->info['audio'][$key]);
  308. }
  309. if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
  310. unset($this->info['video'][$key]);
  311. }
  312. }
  313. // remove empty root keys
  314. if (!empty($this->info)) {
  315. foreach ($this->info as $key => $value) {
  316. if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
  317. unset($this->info[$key]);
  318. }
  319. }
  320. }
  321. // remove meaningless entries from unknown-format files
  322. if (empty($this->info['fileformat'])) {
  323. if (isset($this->info['avdataoffset'])) {
  324. unset($this->info['avdataoffset']);
  325. }
  326. if (isset($this->info['avdataend'])) {
  327. unset($this->info['avdataend']);
  328. }
  329. }
  330. }
  331. // return array containing information about all supported formats
  332. function GetFileFormatArray() {
  333. static $format_info = array();
  334. if (empty($format_info)) {
  335. $format_info = array(
  336. // Audio formats
  337. // AC-3 - audio - Dolby AC-3 / Dolby Digital
  338. 'ac3' => array(
  339. 'pattern' => '^\x0B\x77',
  340. 'group' => 'audio',
  341. 'module' => 'ac3',
  342. 'mime_type' => 'audio/ac3',
  343. ),
  344. // AAC - audio - Advanced Audio Coding (AAC) - ADIF format
  345. 'adif' => array(
  346. 'pattern' => '^ADIF',
  347. 'group' => 'audio',
  348. 'module' => 'aac',
  349. 'option' => 'adif',
  350. 'mime_type' => 'application/octet-stream',
  351. 'fail_ape' => 'WARNING',
  352. ),
  353. // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
  354. 'adts' => array(
  355. 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
  356. 'group' => 'audio',
  357. 'module' => 'aac',
  358. 'option' => 'adts',
  359. 'mime_type' => 'application/octet-stream',
  360. 'fail_ape' => 'WARNING',
  361. ),
  362. // AU - audio - NeXT/Sun AUdio (AU)
  363. 'au' => array(
  364. 'pattern' => '^\.snd',
  365. 'group' => 'audio',
  366. 'module' => 'au',
  367. 'mime_type' => 'audio/basic',
  368. ),
  369. // AVR - audio - Audio Visual Research
  370. 'avr' => array(
  371. 'pattern' => '^2BIT',
  372. 'group' => 'audio',
  373. 'module' => 'avr',
  374. 'mime_type' => 'application/octet-stream',
  375. ),
  376. // BONK - audio - Bonk v0.9+
  377. 'bonk' => array(
  378. 'pattern' => '^\x00(BONK|INFO|META| ID3)',
  379. 'group' => 'audio',
  380. 'module' => 'bonk',
  381. 'mime_type' => 'audio/xmms-bonk',
  382. ),
  383. // FLAC - audio - Free Lossless Audio Codec
  384. 'flac' => array(
  385. 'pattern' => '^fLaC',
  386. 'group' => 'audio',
  387. 'module' => 'flac',
  388. 'mime_type' => 'audio/x-flac',
  389. ),
  390. // LA - audio - Lossless Audio (LA)
  391. 'la' => array(
  392. 'pattern' => '^LA0[2-4]',
  393. 'group' => 'audio',
  394. 'module' => 'la',
  395. 'mime_type' => 'application/octet-stream',
  396. ),
  397. // LPAC - audio - Lossless Predictive Audio Compression (LPAC)
  398. 'lpac' => array(
  399. 'pattern' => '^LPAC',
  400. 'group' => 'audio',
  401. 'module' => 'lpac',
  402. 'mime_type' => 'application/octet-stream',
  403. ),
  404. // MIDI - audio - MIDI (Musical Instrument Digital Interface)
  405. 'midi' => array(
  406. 'pattern' => '^MThd',
  407. 'group' => 'audio',
  408. 'module' => 'midi',
  409. 'mime_type' => 'audio/midi',
  410. ),
  411. // MAC - audio - Monkey's Audio Compressor
  412. 'mac' => array(
  413. 'pattern' => '^MAC ',
  414. 'group' => 'audio',
  415. 'module' => 'monkey',
  416. 'mime_type' => 'application/octet-stream',
  417. ),
  418. // MOD - audio - MODule (assorted sub-formats)
  419. 'mod' => array(
  420. 'pattern' => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)',
  421. 'group' => 'audio',
  422. 'module' => 'mod',
  423. 'option' => 'mod',
  424. 'mime_type' => 'audio/mod',
  425. ),
  426. // MOD - audio - MODule (Impulse Tracker)
  427. 'it' => array(
  428. 'pattern' => '^IMPM',
  429. 'group' => 'audio',
  430. 'module' => 'mod',
  431. 'option' => 'it',
  432. 'mime_type' => 'audio/it',
  433. ),
  434. // MOD - audio - MODule (eXtended Module, various sub-formats)
  435. 'xm' => array(
  436. 'pattern' => '^Extended Module',
  437. 'group' => 'audio',
  438. 'module' => 'mod',
  439. 'option' => 'xm',
  440. 'mime_type' => 'audio/xm',
  441. ),
  442. // MOD - audio - MODule (ScreamTracker)
  443. 's3m' => array(
  444. 'pattern' => '^.{44}SCRM',
  445. 'group' => 'audio',
  446. 'module' => 'mod',
  447. 'option' => 's3m',
  448. 'mime_type' => 'audio/s3m',
  449. ),
  450. // MPC - audio - Musepack / MPEGplus
  451. 'mpc' => array(
  452. 'pattern' => '^(MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
  453. 'group' => 'audio',
  454. 'module' => 'mpc',
  455. 'mime_type' => 'application/octet-stream',
  456. ),
  457. // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
  458. 'mp3' => array(
  459. 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
  460. 'group' => 'audio',
  461. 'module' => 'mp3',
  462. 'mime_type' => 'audio/mpeg',
  463. ),
  464. // OFR - audio - OptimFROG
  465. 'ofr' => array(
  466. 'pattern' => '^(\*RIFF|OFR)',
  467. 'group' => 'audio',
  468. 'module' => 'optimfrog',
  469. 'mime_type' => 'application/octet-stream',
  470. ),
  471. // RKAU - audio - RKive AUdio compressor
  472. 'rkau' => array(
  473. 'pattern' => '^RKA',
  474. 'group' => 'audio',
  475. 'module' => 'rkau',
  476. 'mime_type' => 'application/octet-stream',
  477. ),
  478. // SHN - audio - Shorten
  479. 'shn' => array(
  480. 'pattern' => '^ajkg',
  481. 'group' => 'audio',
  482. 'module' => 'shorten',
  483. 'mime_type' => 'audio/xmms-shn',
  484. 'fail_id3' => 'ERROR',
  485. 'fail_ape' => 'ERROR',
  486. ),
  487. // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
  488. 'tta' => array(
  489. 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
  490. 'group' => 'audio',
  491. 'module' => 'tta',
  492. 'mime_type' => 'application/octet-stream',
  493. ),
  494. // VOC - audio - Creative Voice (VOC)
  495. 'voc' => array(
  496. 'pattern' => '^Creative Voice File',
  497. 'group' => 'audio',
  498. 'module' => 'voc',
  499. 'mime_type' => 'audio/voc',
  500. ),
  501. // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
  502. 'vqf' => array(
  503. 'pattern' => '^TWIN',
  504. 'group' => 'audio',
  505. 'module' => 'vqf',
  506. 'mime_type' => 'application/octet-stream',
  507. ),
  508. // WV - audio - WavPack (v4.0+)
  509. 'wv' => array(
  510. 'pattern' => '^wvpk',
  511. 'group' => 'audio',
  512. 'module' => 'wavpack',
  513. 'mime_type' => 'application/octet-stream',
  514. ),
  515. // Audio-Video formats
  516. // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
  517. 'asf' => array(
  518. 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
  519. 'group' => 'audio-video',
  520. 'module' => 'asf',
  521. 'mime_type' => 'video/x-ms-asf',
  522. 'iconv_req' => false,
  523. ),
  524. // BINK - audio/video - Bink / Smacker
  525. 'bink' => array(
  526. 'pattern' => '^(BIK|SMK)',
  527. 'group' => 'audio-video',
  528. 'module' => 'bink',
  529. 'mime_type' => 'application/octet-stream',
  530. ),
  531. // FLV - audio/video - FLash Video
  532. 'flv' => array(
  533. 'pattern' => '^FLV\x01',
  534. 'group' => 'audio-video',
  535. 'module' => 'flv',
  536. 'mime_type' => 'video/x-flv',
  537. ),
  538. // MKAV - audio/video - Mastroka
  539. 'matroska' => array(
  540. 'pattern' => '^\x1A\x45\xDF\xA3',
  541. 'group' => 'audio-video',
  542. 'module' => 'matroska',
  543. 'mime_type' => 'application/octet-stream',
  544. ),
  545. // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
  546. 'mpeg' => array(
  547. 'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
  548. 'group' => 'audio-video',
  549. 'module' => 'mpeg',
  550. 'mime_type' => 'video/mpeg',
  551. ),
  552. // NSV - audio/video - Nullsoft Streaming Video (NSV)
  553. 'nsv' => array(
  554. 'pattern' => '^NSV[sf]',
  555. 'group' => 'audio-video',
  556. 'module' => 'nsv',
  557. 'mime_type' => 'application/octet-stream',
  558. ),
  559. // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
  560. 'ogg' => array(
  561. 'pattern' => '^OggS',
  562. 'group' => 'audio',
  563. 'module' => 'ogg',
  564. 'mime_type' => 'application/ogg',
  565. 'fail_id3' => 'WARNING',
  566. 'fail_ape' => 'WARNING',
  567. ),
  568. // QT - audio/video - Quicktime
  569. 'quicktime' => array(
  570. 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
  571. 'group' => 'audio-video',
  572. 'module' => 'quicktime',
  573. 'mime_type' => 'video/quicktime',
  574. ),
  575. // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
  576. 'riff' => array(
  577. 'pattern' => '^(RIFF|SDSS|FORM)',
  578. 'group' => 'audio-video',
  579. 'module' => 'riff',
  580. 'mime_type' => 'audio/x-wave',
  581. 'fail_ape' => 'WARNING',
  582. ),
  583. // Real - audio/video - RealAudio, RealVideo
  584. 'real' => array(
  585. 'pattern' => '^(\.RMF|.ra)',
  586. 'group' => 'audio-video',
  587. 'module' => 'real',
  588. 'mime_type' => 'audio/x-realaudio',
  589. ),
  590. // SWF - audio/video - ShockWave Flash
  591. 'swf' => array(
  592. 'pattern' => '^(F|C)WS',
  593. 'group' => 'audio-video',
  594. 'module' => 'swf',
  595. 'mime_type' => 'application/x-shockwave-flash',
  596. ),
  597. // Still-Image formats
  598. // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
  599. 'bmp' => array(
  600. 'pattern' => '^BM',
  601. 'group' => 'graphic',
  602. 'module' => 'bmp',
  603. 'mime_type' => 'image/bmp',
  604. 'fail_id3' => 'ERROR',
  605. 'fail_ape' => 'ERROR',
  606. ),
  607. // GIF - still image - Graphics Interchange Format
  608. 'gif' => array(
  609. 'pattern' => '^GIF',
  610. 'group' => 'graphic',
  611. 'module' => 'gif',
  612. 'mime_type' => 'image/gif',
  613. 'fail_id3' => 'ERROR',
  614. 'fail_ape' => 'ERROR',
  615. ),
  616. // JPEG - still image - Joint Photographic Experts Group (JPEG)
  617. 'jpg' => array(
  618. 'pattern' => '^\xFF\xD8\xFF',
  619. 'group' => 'graphic',
  620. 'module' => 'jpg',
  621. 'mime_type' => 'image/jpeg',
  622. 'fail_id3' => 'ERROR',
  623. 'fail_ape' => 'ERROR',
  624. ),
  625. // PCD - still image - Kodak Photo CD
  626. 'pcd' => array(
  627. 'pattern' => '^.{2048}PCD_IPI\x00',
  628. 'group' => 'graphic',
  629. 'module' => 'pcd',
  630. 'mime_type' => 'image/x-photo-cd',
  631. 'fail_id3' => 'ERROR',
  632. 'fail_ape' => 'ERROR',
  633. ),
  634. // PNG - still image - Portable Network Graphics (PNG)
  635. 'png' => array(
  636. 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
  637. 'group' => 'graphic',
  638. 'module' => 'png',
  639. 'mime_type' => 'image/png',
  640. 'fail_id3' => 'ERROR',
  641. 'fail_ape' => 'ERROR',
  642. ),
  643. // TIFF - still image - Tagged Information File Format (TIFF)
  644. 'tiff' => array(
  645. 'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
  646. 'group' => 'graphic',
  647. 'module' => 'tiff',
  648. 'mime_type' => 'image/tiff',
  649. 'fail_id3' => 'ERROR',
  650. 'fail_ape' => 'ERROR',
  651. ),
  652. // Data formats
  653. // ISO - data - International Standards Organization (ISO) CD-ROM Image
  654. 'iso' => array(
  655. 'pattern' => '^.{32769}CD001',
  656. 'group' => 'misc',
  657. 'module' => 'iso',
  658. 'mime_type' => 'application/octet-stream',
  659. 'fail_id3' => 'ERROR',
  660. 'fail_ape' => 'ERROR',
  661. 'iconv_req' => false,
  662. ),
  663. // RAR - data - RAR compressed data
  664. 'rar' => array(
  665. 'pattern' => '^Rar\!',
  666. 'group' => 'archive',
  667. 'module' => 'rar',
  668. 'mime_type' => 'application/octet-stream',
  669. 'fail_id3' => 'ERROR',
  670. 'fail_ape' => 'ERROR',
  671. ),
  672. // SZIP - audio/data - SZIP compressed data
  673. 'szip' => array(
  674. 'pattern' => '^SZ\x0A\x04',
  675. 'group' => 'archive',
  676. 'module' => 'szip',
  677. 'mime_type' => 'application/octet-stream',
  678. 'fail_id3' => 'ERROR',
  679. 'fail_ape' => 'ERROR',
  680. ),
  681. // TAR - data - TAR compressed data
  682. 'tar' => array(
  683. 'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
  684. 'group' => 'archive',
  685. 'module' => 'tar',
  686. 'mime_type' => 'application/x-tar',
  687. 'fail_id3' => 'ERROR',
  688. 'fail_ape' => 'ERROR',
  689. ),
  690. // GZIP - data - GZIP compressed data
  691. 'gz' => array(
  692. 'pattern' => '^\x1F\x8B\x08',
  693. 'group' => 'archive',
  694. 'module' => 'gzip',
  695. 'mime_type' => 'application/x-gzip',
  696. 'fail_id3' => 'ERROR',
  697. 'fail_ape' => 'ERROR',
  698. ),
  699. // ZIP - data - ZIP compressed data
  700. 'zip' => array(
  701. 'pattern' => '^PK\x03\x04',
  702. 'group' => 'archive',
  703. 'module' => 'zip',
  704. 'mime_type' => 'application/zip',
  705. 'fail_id3' => 'ERROR',
  706. 'fail_ape' => 'ERROR',
  707. ),
  708. // Misc other formats
  709. // PDF - data - ZIP compressed data
  710. 'pdf' => array(
  711. 'pattern' => '^\x25PDF',
  712. 'group' => 'misc',
  713. 'module' => 'pdf',
  714. 'mime_type' => 'application/pdf',
  715. 'fail_id3' => 'ERROR',
  716. 'fail_ape' => 'ERROR',
  717. ),
  718. // MSOFFICE - data - ZIP compressed data
  719. 'msoffice' => array(
  720. 'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
  721. 'group' => 'misc',
  722. 'module' => 'msoffice',
  723. 'mime_type' => 'application/octet-stream',
  724. 'fail_id3' => 'ERROR',
  725. 'fail_ape' => 'ERROR',
  726. ),
  727. );
  728. }
  729. return $format_info;
  730. }
  731. function GetFileFormat(&$filedata, $filename='') {
  732. // this function will determine the format of a file based on usually
  733. // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
  734. // and in the case of ISO CD image, 6 bytes offset 32kb from the start
  735. // of the file).
  736. // Identify file format - loop through $format_info and detect with reg expr
  737. foreach ($this->GetFileFormatArray() as $format_name => $info) {
  738. // Using preg_match() instead of ereg() - much faster
  739. // The /s switch on preg_match() forces preg_match() NOT to treat
  740. // newline (0x0A) characters as special chars but do a binary match
  741. if (preg_match('/'.$info['pattern'].'/s', $filedata)) {
  742. $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
  743. return $info;
  744. }
  745. }
  746. if (preg_match('/\.mp[123a]$/i', $filename)) {
  747. // Too many mp3 encoders on the market put gabage in front of mpeg files
  748. // use assume format on these if format detection failed
  749. $GetFileFormatArray = $this->GetFileFormatArray();
  750. $info = $GetFileFormatArray['mp3'];
  751. $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
  752. return $info;
  753. }
  754. return false;
  755. }
  756. // converts array to $encoding charset from $this->encoding
  757. function CharConvert(&$array, $encoding) {
  758. // identical encoding - end here
  759. if ($encoding == $this->encoding) {
  760. return;
  761. }
  762. // loop thru array
  763. foreach ($array as $key => $value) {
  764. // go recursive
  765. if (is_array($value)) {
  766. $this->CharConvert($array[$key], $encoding);
  767. }
  768. // convert string
  769. elseif (is_string($value)) {
  770. $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
  771. }
  772. }
  773. }
  774. function HandleAllTags() {
  775. // key name => array (tag name, character encoding)
  776. static $tags;
  777. if (empty($tags)) {
  778. $tags = array(
  779. 'asf' => array('asf' , 'UTF-16LE'),
  780. 'midi' => array('midi' , 'ISO-8859-1'),
  781. 'nsv' => array('nsv' , 'ISO-8859-1'),
  782. 'ogg' => array('vorbiscomment' , 'UTF-8'),
  783. 'png' => array('png' , 'UTF-8'),
  784. 'tiff' => array('tiff' , 'ISO-8859-1'),
  785. 'quicktime' => array('quicktime' , 'ISO-8859-1'),
  786. 'real' => array('real' , 'ISO-8859-1'),
  787. 'vqf' => array('vqf' , 'ISO-8859-1'),
  788. 'zip' => array('zip' , 'ISO-8859-1'),
  789. 'riff' => array('riff' , 'ISO-8859-1'),
  790. 'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
  791. 'id3v1' => array('id3v1' , $this->encoding_id3v1),
  792. 'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
  793. 'ape' => array('ape' , 'UTF-8')
  794. );
  795. }
  796. // loop thru comments array
  797. foreach ($tags as $comment_name => $tagname_encoding_array) {
  798. list($tag_name, $encoding) = $tagname_encoding_array;
  799. // fill in default encoding type if not already present
  800. if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
  801. $this->info[$comment_name]['encoding'] = $encoding;
  802. }
  803. // copy comments if key name set
  804. if (!empty($this->info[$comment_name]['comments'])) {
  805. foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
  806. foreach ($valuearray as $key => $value) {
  807. if (strlen(trim($value)) > 0) {
  808. $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; // do not trim!! Unicode characters will get mangled if trailing nulls are removed!
  809. }
  810. }
  811. }
  812. if (!isset($this->info['tags'][$tag_name])) {
  813. // comments are set but contain nothing but empty strings, so skip
  814. continue;
  815. }
  816. if ($this->option_tags_html) {
  817. foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
  818. foreach ($valuearray as $key => $value) {
  819. if (is_string($value)) {
  820. //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
  821. $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));
  822. } else {
  823. $this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
  824. }
  825. }
  826. }
  827. }
  828. $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
  829. }
  830. }
  831. return true;
  832. }
  833. function getHashdata($algorithm) {
  834. switch ($algorithm) {
  835. case 'md5':
  836. case 'sha1':
  837. break;
  838. default:
  839. return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
  840. break;
  841. }
  842. if ((@$this->info['fileformat'] == 'ogg') && (@$this->info['audio']['dataformat'] == 'vorbis')) {
  843. // We cannot get an identical md5_data value for Ogg files where the comments
  844. // span more than 1 Ogg page (compared to the same audio data with smaller
  845. // comments) using the normal getID3() method of MD5'ing the data between the
  846. // end of the comments and the end of the file (minus any trailing tags),
  847. // because the page sequence numbers of the pages that the audio data is on
  848. // do not match. Under normal circumstances, where comments are smaller than
  849. // the nominal 4-8kB page size, then this is not a problem, but if there are
  850. // very large comments, the only way around it is to strip off the comment
  851. // tags with vorbiscomment and MD5 that file.
  852. // This procedure must be applied to ALL Ogg files, not just the ones with
  853. // comments larger than 1 page, because the below method simply MD5's the
  854. // whole file with the comments stripped, not just the portion after the
  855. // comments block (which is the standard getID3() method.
  856. // The above-mentioned problem of comments spanning multiple pages and changing
  857. // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
  858. // currently vorbiscomment only works on OggVorbis files.
  859. if ((bool) ini_get('safe_mode')) {
  860. $this->info['warning'][] = 'Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';
  861. $this->info[$algorithm.'_data'] = false;
  862. } else {
  863. // Prevent user from aborting script
  864. $old_abort = ignore_user_abort(true);
  865. // Create empty file
  866. $empty = tempnam('*', 'getID3');
  867. touch($empty);
  868. // Use vorbiscomment to make temp file without comments
  869. $temp = tempnam('*', 'getID3');
  870. $file = $this->info['filenamepath'];
  871. if (GETID3_OS_ISWINDOWS) {
  872. if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
  873. $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
  874. $VorbisCommentError = `$commandline`;
  875. } else {
  876. $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
  877. }
  878. } else {
  879. $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
  880. $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
  881. $VorbisCommentError = `$commandline`;
  882. }
  883. if (!empty($VorbisCommentError)) {
  884. $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
  885. $this->info[$algorithm.'_data'] = false;
  886. } else {
  887. // Get hash of newly created file
  888. switch ($algorithm) {
  889. case 'md5':
  890. $this->info[$algorithm.'_data'] = getid3_lib::md5_file($temp);
  891. break;
  892. case 'sha1':
  893. $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($temp);
  894. break;
  895. }
  896. }
  897. // Clean up
  898. unlink($empty);
  899. unlink($temp);
  900. // Reset abort setting
  901. ignore_user_abort($old_abort);
  902. }
  903. } else {
  904. if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
  905. // get hash from part of file
  906. $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
  907. } else {
  908. // get hash from whole file
  909. switch ($algorithm) {
  910. case 'md5':
  911. $this->info[$algorithm.'_data'] = getid3_lib::md5_file($this->info['filenamepath']);
  912. break;
  913. case 'sha1':
  914. $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($this->info['filenamepath']);
  915. break;
  916. }
  917. }
  918. }
  919. return true;
  920. }
  921. function ChannelsBitratePlaytimeCalculations() {
  922. // set channelmode on audio
  923. if (@$this->info['audio']['channels'] == '1') {
  924. $this->info['audio']['channelmode'] = 'mono';
  925. } elseif (@$this->info['audio']['channels'] == '2') {
  926. $this->info['audio']['channelmode'] = 'stereo';
  927. }
  928. // Calculate combined bitrate - audio + video
  929. $CombinedBitrate = 0;
  930. $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
  931. $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
  932. if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
  933. $this->info['bitrate'] = $CombinedBitrate;
  934. }
  935. //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
  936. // // for example, VBR MPEG video files cannot determine video bitrate:
  937. // // should not set overall bitrate and playtime from audio bitrate only
  938. // unset($this->info['bitrate']);
  939. //}
  940. if (!isset($this->info['playtime_seconds']) && !empty($this->info['bitrate'])) {
  941. $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
  942. }
  943. // Set playtime string
  944. if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
  945. $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
  946. }
  947. }
  948. function CalculateCompressionRatioVideo() {
  949. if (empty($this->info['video'])) {
  950. return false;
  951. }
  952. if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
  953. return false;
  954. }
  955. if (empty($this->info['video']['bits_per_sample'])) {
  956. return false;
  957. }
  958. switch ($this->info['video']['dataformat']) {
  959. case 'bmp':
  960. case 'gif':
  961. case 'jpeg':
  962. case 'jpg':
  963. case 'png':
  964. case 'tiff':
  965. $FrameRate = 1;
  966. $PlaytimeSeconds = 1;
  967. $BitrateCompressed = $this->info['filesize'] * 8;
  968. break;
  969. default:
  970. if (!empty($this->info['video']['frame_rate'])) {
  971. $FrameRate = $this->info['video']['frame_rate'];
  972. } else {
  973. return false;
  974. }
  975. if (!empty($this->info['playtime_seconds'])) {
  976. $PlaytimeSeconds = $this->info['playtime_seconds'];
  977. } else {
  978. return false;
  979. }
  980. if (!empty($this->info['video']['bitrate'])) {
  981. $BitrateCompressed = $this->info['video']['bitrate'];
  982. } else {
  983. return false;
  984. }
  985. break;
  986. }
  987. $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
  988. $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
  989. return true;
  990. }
  991. function CalculateCompressionRatioAudio() {
  992. if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate'])) {
  993. return false;
  994. }
  995. $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
  996. if (!empty($this->info['audio']['streams'])) {
  997. foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
  998. if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
  999. $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
  1000. }
  1001. }
  1002. }
  1003. return true;
  1004. }
  1005. function CalculateReplayGain() {
  1006. if (isset($this->info['replay_gain'])) {
  1007. $this->info['replay_gain']['reference_volume'] = 89;
  1008. if (isset($this->info['replay_gain']['track']['adjustment'])) {
  1009. $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
  1010. }
  1011. if (isset($this->info['replay_gain']['album']['adjustment'])) {
  1012. $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
  1013. }
  1014. if (isset($this->info['replay_gain']['track']['peak'])) {
  1015. $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
  1016. }
  1017. if (isset($this->info['replay_gain']['album']['peak'])) {
  1018. $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
  1019. }
  1020. }
  1021. return true;
  1022. }
  1023. function ProcessAudioStreams() {
  1024. if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
  1025. if (!isset($this->info['audio']['streams'])) {
  1026. foreach ($this->info['audio'] as $key => $value) {
  1027. if ($key != 'streams') {
  1028. $this->info['audio']['streams'][0][$key] = $value;
  1029. }
  1030. }
  1031. }
  1032. }
  1033. return true;
  1034. }
  1035. function getid3_tempnam() {
  1036. return tempnam($this->tempdir, 'gI3');
  1037. }
  1038. }
  1039. ?>