wppaste
WordPress

getid3_flac

Source
wp-includes/ID3/module.audio.flac.php:25

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Methods · 12

Source code

class getid3_flac extends getid3_handler{	const syncword = 'fLaC'; 	/**	 * @return bool	 */	public function Analyze() {		$info = &$this->getid3->info; 		$this->fseek($info['avdataoffset']);		$StreamMarker = $this->fread(4);		if ($StreamMarker != self::syncword) {			return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($StreamMarker).'"');		}		$info['fileformat']            = 'flac';		$info['audio']['dataformat']   = 'flac';		$info['audio']['bitrate_mode'] = 'vbr';		$info['audio']['lossless']     = true; 		// parse flac container		return $this->parseMETAdata();	} 	/**	 * @return bool	 */	public function parseMETAdata() {		$info = &$this->getid3->info;		do {			$BlockOffset   = $this->ftell();			$BlockHeader   = $this->fread(4);			$LBFBT         = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));  // LBFBT = LastBlockFlag + BlockType			$LastBlockFlag = (bool) ($LBFBT & 0x80);			$BlockType     =        ($LBFBT & 0x7F);			$BlockLength   = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3));			$BlockTypeText = self::metaBlockTypeLookup($BlockType); 			if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) {				$this->warning('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');				break;			}			if ($BlockLength < 1) {				if ($BlockTypeText != 'reserved') {					// probably supposed to be zero-length					$this->warning('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockTypeText.') at offset '.$BlockOffset.' is zero bytes');					continue;				}				$this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid');				break;			} 			$info['flac'][$BlockTypeText]['raw'] = array();			$BlockTypeText_raw = &$info['flac'][$BlockTypeText]['raw']; 			$BlockTypeText_raw['offset']          = $BlockOffset;			$BlockTypeText_raw['last_meta_block'] = $LastBlockFlag;			$BlockTypeText_raw['block_type']      = $BlockType;			$BlockTypeText_raw['block_type_text'] = $BlockTypeText;			$BlockTypeText_raw['block_length']    = $BlockLength;			if ($BlockTypeText_raw['block_type'] != 0x06) { // do not read attachment data automatically				$BlockTypeText_raw['block_data']  = $this->fread($BlockLength);			} 			switch ($BlockTypeText) {				case 'STREAMINFO':     // 0x00					if (!$this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) {						return false;					}					break; 				case 'PADDING':        // 0x01					unset($info['flac']['PADDING']); // ignore					break; 				case 'APPLICATION':    // 0x02					if (!$this->parseAPPLICATION($BlockTypeText_raw['block_data'])) {						return false;					}					break;

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/ID3/module.audio.flac.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.