- Timestamp:
- 09/14/2019 07:06:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.audio-video.matroska.php
r41196 r46112 1 1 <?php 2 2 3 ///////////////////////////////////////////////////////////////// 3 4 /// getID3() by James Heinrich <info@getid3.org> // 4 // available at http://getid3.sourceforge.net // 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 7 ///////////////////////////////////////////////////////////////// 8 // See readme.txt for more details // 5 // available at https://github.com/JamesHeinrich/getID3 // 6 // or https://www.getid3.org // 7 // or http://getid3.sourceforge.net // 8 // see readme.txt for more details // 9 9 ///////////////////////////////////////////////////////////////// 10 10 // // … … 73 73 define('EBML_ID_FILEUID', 0x06AE); // [46][AE] -- Unique ID representing the file, as random as possible. 74 74 define('EBML_ID_CONTENTENCALGO', 0x07E1); // [47][E1] -- The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 75 define('EBML_ID_CONTENTENCKEYID', 0x07E2); // [47][E2] -- For public key algorithms this is the ID of the public key the thedata was encrypted with.75 define('EBML_ID_CONTENTENCKEYID', 0x07E2); // [47][E2] -- For public key algorithms this is the ID of the public key the data was encrypted with. 76 76 define('EBML_ID_CONTENTSIGNATURE', 0x07E3); // [47][E3] -- A cryptographic signature of the contents. 77 77 define('EBML_ID_CONTENTSIGKEYID', 0x07E4); // [47][E4] -- This is the ID of the private key the data was signed with. … … 216 216 class getid3_matroska extends getid3_handler 217 217 { 218 // public options 219 public static $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful [default: TRUE] 220 public static $parse_whole_file = false; // true to parse the whole file, not only header [default: FALSE] 221 222 // private parser settings/placeholders 218 /** 219 * If true, do not return information about CLUSTER chunks, since there's a lot of them 220 * and they're not usually useful [default: TRUE]. 221 * 222 * @var bool 223 */ 224 public static $hide_clusters = true; 225 226 /** 227 * True to parse the whole file, not only header [default: FALSE]. 228 * 229 * @var bool 230 */ 231 public static $parse_whole_file = false; 232 233 /* 234 * Private parser settings/placeholders. 235 */ 223 236 private $EBMLbuffer = ''; 224 237 private $EBMLbuffer_offset = 0; … … 227 240 private $unuseful_elements = array(EBML_ID_CRC32, EBML_ID_VOID); 228 241 242 /** 243 * @return bool 244 */ 229 245 public function Analyze() 230 246 { … … 367 383 $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info[$header_data_key]; 368 384 if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) { 369 foreach ($getid3_temp->info['audio'] as $ key => $value) {370 $track_info[$ key] = $value;385 foreach ($getid3_temp->info['audio'] as $sub_key => $value) { 386 $track_info[$sub_key] = $value; 371 387 } 372 388 } … … 422 438 $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ogg']; 423 439 if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) { 424 foreach ($getid3_temp->info['audio'] as $ key => $value) {425 $track_info[$ key] = $value;440 foreach ($getid3_temp->info['audio'] as $sub_key => $value) { 441 $track_info[$sub_key] = $value; 426 442 } 427 443 } … … 450 466 451 467 $parsed = getid3_riff::parseWAVEFORMATex($trackarray['CodecPrivate']); 452 foreach ($parsed as $ key => $value) {453 if ($ key != 'raw') {454 $track_info[$ key] = $value;468 foreach ($parsed as $sub_key => $value) { 469 if ($sub_key != 'raw') { 470 $track_info[$sub_key] = $value; 455 471 } 456 472 } … … 497 513 } 498 514 515 /** 516 * @param array $info 517 */ 499 518 private function parseEBML(&$info) { 500 519 // http://www.matroska.org/technical/specs/index.html#EBMLBasics … … 1229 1248 } 1230 1249 1250 /** 1251 * @param int $min_data 1252 * 1253 * @return bool 1254 */ 1231 1255 private function EnsureBufferHasEnoughData($min_data=1024) { 1232 1256 if (($this->current_offset - $this->EBMLbuffer_offset) >= ($this->EBMLbuffer_length - $min_data)) { … … 1250 1274 } 1251 1275 1276 /** 1277 * @return int|float|false 1278 */ 1252 1279 private function readEBMLint() { 1253 1280 $actual_offset = $this->current_offset - $this->EBMLbuffer_offset; … … 1282 1309 } 1283 1310 1311 /** 1312 * @param int $length 1313 * @param bool $check_buffer 1314 * 1315 * @return string|false 1316 */ 1284 1317 private function readEBMLelementData($length, $check_buffer=false) { 1285 1318 if ($check_buffer && !$this->EnsureBufferHasEnoughData($length)) { … … 1291 1324 } 1292 1325 1326 /** 1327 * @param array $element 1328 * @param int $parent_end 1329 * @param array|bool $get_data 1330 * 1331 * @return bool 1332 */ 1293 1333 private function getEBMLelement(&$element, $parent_end, $get_data=false) { 1294 1334 if ($this->current_offset >= $parent_end) { … … 1327 1367 } 1328 1368 1369 /** 1370 * @param string $type 1371 * @param int $line 1372 * @param array $element 1373 */ 1329 1374 private function unhandledElement($type, $line, $element) { 1330 1375 // warn only about unknown and missed elements, not about unuseful … … 1339 1384 } 1340 1385 1386 /** 1387 * @param array $SimpleTagArray 1388 * 1389 * @return bool 1390 */ 1341 1391 private function ExtractCommentsSimpleTag($SimpleTagArray) { 1342 1392 if (!empty($SimpleTagArray['SimpleTag'])) { … … 1354 1404 } 1355 1405 1406 /** 1407 * @param int $parent_end 1408 * 1409 * @return array 1410 */ 1356 1411 private function HandleEMBLSimpleTag($parent_end) { 1357 1412 $simpletag_entry = array(); … … 1384 1439 } 1385 1440 1441 /** 1442 * @param array $element 1443 * @param int $block_type 1444 * @param array $info 1445 * 1446 * @return array 1447 */ 1386 1448 private function HandleEMBLClusterBlock($element, $block_type, &$info) { 1387 1449 // http://www.matroska.org/technical/specs/index.html#block_structure … … 1447 1509 } 1448 1510 1511 /** 1512 * @param string $EBMLstring 1513 * 1514 * @return int|float|false 1515 */ 1449 1516 private static function EBML2Int($EBMLstring) { 1450 1517 // http://matroska.org/specs/ … … 1489 1556 } 1490 1557 1558 /** 1559 * @param int $EBMLdatestamp 1560 * 1561 * @return float 1562 */ 1491 1563 private static function EBMLdate2unix($EBMLdatestamp) { 1492 1564 // Date - signed 8 octets integer in nanoseconds with 0 indicating the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC) … … 1495 1567 } 1496 1568 1569 /** 1570 * @param int $target_type 1571 * 1572 * @return string|int 1573 */ 1497 1574 public static function TargetTypeValue($target_type) { 1498 1575 // http://www.matroska.org/technical/specs/tagging/index.html … … 1510 1587 } 1511 1588 1589 /** 1590 * @param int $lacingtype 1591 * 1592 * @return string|int 1593 */ 1512 1594 public static function BlockLacingType($lacingtype) { 1513 1595 // http://matroska.org/technical/specs/index.html#block_structure … … 1522 1604 } 1523 1605 1606 /** 1607 * @param string $codecid 1608 * 1609 * @return string 1610 */ 1524 1611 public static function CodecIDtoCommonName($codecid) { 1525 1612 // http://www.matroska.org/technical/specs/codecid/index.html … … 1558 1645 } 1559 1646 1647 /** 1648 * @param int $value 1649 * 1650 * @return string 1651 */ 1560 1652 private static function EBMLidName($value) { 1561 1653 static $EBMLidList = array(); … … 1756 1848 } 1757 1849 1850 /** 1851 * @param int $value 1852 * 1853 * @return string 1854 */ 1758 1855 public static function displayUnit($value) { 1759 1856 // http://www.matroska.org/technical/specs/index.html#DisplayUnit … … 1767 1864 } 1768 1865 1866 /** 1867 * @param array $streams 1868 * 1869 * @return array 1870 */ 1769 1871 private static function getDefaultStreamInfo($streams) 1770 1872 { 1873 $stream = array(); 1771 1874 foreach (array_reverse($streams) as $stream) { 1772 1875 if ($stream['default']) {
Note: See TracChangeset
for help on using the changeset viewer.