wp/wp-includes/ID3/module.audio-video.matroska.php
changeset 19 3d72ae0968f4
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   222 	 * If true, do not return information about CLUSTER chunks, since there's a lot of them
   222 	 * If true, do not return information about CLUSTER chunks, since there's a lot of them
   223 	 * and they're not usually useful [default: TRUE].
   223 	 * and they're not usually useful [default: TRUE].
   224 	 *
   224 	 *
   225 	 * @var bool
   225 	 * @var bool
   226 	 */
   226 	 */
   227 	public static $hide_clusters    = true;
   227 	public $hide_clusters    = true;
   228 
   228 
   229 	/**
   229 	/**
   230 	 * True to parse the whole file, not only header [default: FALSE].
   230 	 * True to parse the whole file, not only header [default: FALSE].
   231 	 *
   231 	 *
   232 	 * @var bool
   232 	 * @var bool
   233 	 */
   233 	 */
   234 	public static $parse_whole_file = false;
   234 	public $parse_whole_file = false;
   235 
   235 
   236 	/*
   236 	/*
   237 	 * Private parser settings/placeholders.
   237 	 * Private parser settings/placeholders.
   238 	 */
   238 	 */
   239 	private $EBMLbuffer        = '';
   239 	private $EBMLbuffer        = '';
   584 				case EBML_ID_SEGMENT:
   584 				case EBML_ID_SEGMENT:
   585 					$info['matroska']['segment'][0]['offset'] = $top_element['offset'];
   585 					$info['matroska']['segment'][0]['offset'] = $top_element['offset'];
   586 					$info['matroska']['segment'][0]['length'] = $top_element['length'];
   586 					$info['matroska']['segment'][0]['length'] = $top_element['length'];
   587 
   587 
   588 					while ($this->getEBMLelement($element_data, $top_element['end'])) {
   588 					while ($this->getEBMLelement($element_data, $top_element['end'])) {
   589 						if ($element_data['id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
   589 						if ($element_data['id'] != EBML_ID_CLUSTER || !$this->hide_clusters) { // collect clusters only if required
   590 							$info['matroska']['segments'][] = $element_data;
   590 							$info['matroska']['segments'][] = $element_data;
   591 						}
   591 						}
   592 						switch ($element_data['id']) {
   592 						switch ($element_data['id']) {
   593 
   593 
   594 							case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements.
   594 							case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements.
   616 											}
   616 											}
   617 											if (!isset($seek_entry['target_id'])) {
   617 											if (!isset($seek_entry['target_id'])) {
   618 												$this->warning('seek_entry[target_id] unexpectedly not set at '.$seek_entry['offset']);
   618 												$this->warning('seek_entry[target_id] unexpectedly not set at '.$seek_entry['offset']);
   619 												break;
   619 												break;
   620 											}
   620 											}
   621 											if (($seek_entry['target_id'] != EBML_ID_CLUSTER) || !self::$hide_clusters) { // collect clusters only if required
   621 											if (($seek_entry['target_id'] != EBML_ID_CLUSTER) || !$this->hide_clusters) { // collect clusters only if required
   622 												$info['matroska']['seek'][] = $seek_entry;
   622 												$info['matroska']['seek'][] = $seek_entry;
   623 											}
   623 											}
   624 											break;
   624 											break;
   625 
   625 
   626 										default:
   626 										default:
   903 								}
   903 								}
   904 								$info['matroska']['info'][] = $info_entry;
   904 								$info['matroska']['info'][] = $info_entry;
   905 								break;
   905 								break;
   906 
   906 
   907 							case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.
   907 							case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.
   908 								if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
   908 								if ($this->hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
   909 									$this->current_offset = $element_data['end'];
   909 									$this->current_offset = $element_data['end'];
   910 									break;
   910 									break;
   911 								}
   911 								}
   912 								$cues_entry = array();
   912 								$cues_entry = array();
   913 
   913 
  1244 											$this->unhandledElement('cluster', __LINE__, $subelement);
  1244 											$this->unhandledElement('cluster', __LINE__, $subelement);
  1245 											break;
  1245 											break;
  1246 									}
  1246 									}
  1247 									$this->current_offset = $subelement['end'];
  1247 									$this->current_offset = $subelement['end'];
  1248 								}
  1248 								}
  1249 								if (!self::$hide_clusters) {
  1249 								if (!$this->hide_clusters) {
  1250 									$info['matroska']['cluster'][] = $cluster_entry;
  1250 									$info['matroska']['cluster'][] = $cluster_entry;
  1251 								}
  1251 								}
  1252 
  1252 
  1253 								// check to see if all the data we need exists already, if so, break out of the loop
  1253 								// check to see if all the data we need exists already, if so, break out of the loop
  1254 								if (!self::$parse_whole_file) {
  1254 								if (!$this->parse_whole_file) {
  1255 									if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
  1255 									if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
  1256 										if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
  1256 										if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
  1257 											if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) {
  1257 											if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) {
  1258 												return;
  1258 												return;
  1259 											}
  1259 											}