* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ abstract class Zend_Media_Flac_MetadataBlock { /** * The reader object. * * @var Zend_Io_Reader */ protected $_reader; /** @var integer */ private $_last; /** @var integer */ private $_type; /** @var integer */ private $_size; /** * Constructs the class with given parameters and reads object related data * from the Flac bitstream. * * @param Zend_Io_Reader $reader The reader object. */ public function __construct($reader) { $this->_reader = $reader; $this->_last = ($tmp = $this->_reader->readUInt8()) >> 7 & 0x1; $this->_type = $tmp & 0x7f; $this->_size = $this->_reader->readUInt24BE(); } /** * Returns the metadata block type. The type is one of the following. * * o 0: STREAMINFO * o 1: PADDING * o 2: APPLICATION * o 3: SEEKTABLE * o 4: VORBIS_COMMENT * o 5: CUESHEET * o 6: PICTURE * o 7-126: reserved * o 127: invalid, to avoid confusion with a frame sync code * * @return integer */ public function getType() { return $this->_type; } /** * Returns the metadata block length without the header, in bytes. * * @return integer */ public function getSize() { return $this->_size; } /** * Magic function so that $obj->value will work. * * @param string $name The field name. * @return mixed */ public function __get($name) { if (method_exists($this, 'get' . ucfirst($name))) { return call_user_func(array($this, 'get' . ucfirst($name))); } else { require_once 'Zend/Media/Flac/Exception.php'; throw new Zend_Media_Flac_Exception('Unknown field: ' . $name); } } /** * Magic function so that assignments with $obj->value will work. * * @param string $name The field name. * @param string $value The field value. * @return mixed */ public function __set($name, $value) { if (method_exists($this, 'set' . ucfirst($name))) { call_user_func(array($this, 'set' . ucfirst($name)), $value); } else { require_once 'Zend/Media/Flac/Exception.php'; throw new Zend_Media_Flac_Exception('Unknown field: ' . $name); } } }