*
_nam -- Name of the track
* _ART -- Name of the artist
* aART -- Name of the album artist
* _alb -- Name of the album
* _grp -- Grouping
* _day -- Year of publication
* trkn -- Track number (number/total)
* disk -- Disk number (number/total)
* tmpo -- BPM tempo
* _wrt -- Name of the composer
* _cmt -- Comments
* _gen -- Genre as string
* gnre -- Genre as an ID3v1 code, added by one
* cpil -- Part of a compilation (0/1)
* tvsh -- Name of the (television) show
* sonm -- Sort name of the track
* soar -- Sort name of the artist
* soaa -- Sort name of the album artist
* soal -- Sort name of the album
* soco -- Sort name of the composer
* sosn -- Sort name of the show
* _lyr -- Lyrics
* covr -- Cover (or other) artwork binary data
* _too -- Information about the software
*
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @since iTunes/iPod specific
*/
final class Zend_Media_Iso14496_Box_Ilst extends Zend_Media_Iso14496_Box
{
/**
* Constructs the class with given parameters and reads box related data
* from the ISO Base Media file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
$this->setContainer(true);
if ($reader === null) {
return;
}
$this->constructBoxes('Zend_Media_Iso14496_Box_Ilst_Container');
}
/**
* Override magic function so that $obj->value on a box will return the data
* box instead of the data container box.
*
* @param string $name The box or field name.
* @return mixed
*/
public function __get($name)
{
if (strlen($name) == 3) {
$name = "\xa9" . $name;
}
if ($name[0] == '_') {
$name = "\xa9" . substr($name, 1, 3);
}
if ($this->hasBox($name)) {
$boxes = $this->getBoxesByIdentifier($name);
return $boxes[0]->data;
}
if (method_exists($this, 'get' . ucfirst($name))) {
return call_user_func(array($this, 'get' . ucfirst($name)));
}
return $this->addBox
(new Zend_Media_Iso14496_Box_Ilst_Container($name))->data;
}
}
/**
* Generic iTunes/iPod DATA Box container.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @since iTunes/iPod specific
* @ignore
*/
final class Zend_Media_Iso14496_Box_Ilst_Container
extends Zend_Media_Iso14496_Box
{
/**
* Constructs the class with given parameters and reads box related data
* from the ISO Base Media file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct(is_string($reader) ? null : $reader, $options);
$this->setContainer(true);
if (is_string($reader)) {
$this->setType($reader);
$this->addBox(new Zend_Media_Iso14496_Box_Data());
} else {
$this->constructBoxes();
}
}
}
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* A box that contains data for iTunes/iPod specific boxes.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @since iTunes/iPod specific
*/
final class Zend_Media_Iso14496_Box_Data extends Zend_Media_Iso14496_FullBox
{
/** @var mixed */
private $_value;
/** A flag to indicate that the data is an unsigned 8-bit integer. */
const INTEGER = 0x0;
/**
* A flag to indicate that the data is an unsigned 8-bit integer. Different
* value used in old versions of iTunes.
*/
const INTEGER_OLD_STYLE = 0x15;
/** A flag to indicate that the data is a string. */
const STRING = 0x1;
/** A flag to indicate that the data is the contents of an JPEG image. */
const JPEG = 0xd;
/** A flag to indicate that the data is the contents of a PNG image. */
const PNG = 0xe;
/**
* Constructs the class with given parameters and reads box related data
* from the ISO Base Media file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_reader->skip(4);
$data = $this->_reader->read
($this->getOffset() + $this->getSize() -
$this->_reader->getOffset());
switch ($this->getFlags()) {
case self::INTEGER:
// break intentionally omitted
case self::INTEGER_OLD_STYLE:
for ($i = 0; $i < strlen($data); $i++) {
$this->_value .= ord($data[$i]);
}
break;
case self::STRING:
// break intentionally omitted
default:
$this->_value = $data;
break;
}
}
/**
* Returns the value this box contains.
*
* @return mixed
*/
public function getValue()
{
return $this->_value;
}
/**
* Sets the value this box contains.
*
* @return mixed
*/
public function setValue($value, $type = null)
{
$this->_value = (string)$value;
if ($type === null && is_string($value)) {
$this->_flags = self::STRING;
}
if ($type === null && is_int($value)) {
$this->_flags = self::INTEGER;
}
if ($type !== null) {
$this->_flags = $type;
}
}
/**
* Override magic function so that $obj->data will return the current box
* instead of an error. For other values the method will attempt to call a
* getter method.
*
* If there are no getter methods with given name, the method will yield an
* exception.
*
* @param string $name The box or field name.
* @return mixed
*/
public function __get($name)
{
if ($name == 'data') {
return $this;
}
if (method_exists($this, 'get' . ucfirst($name))) {
return call_user_func(array($this, 'get' . ucfirst($name)));
}
require_once 'Zend/Media/Iso14496/Exception.php';
throw new Zend_Media_Iso14496_Exception('Unknown box/field: ' . $name);
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + 4 + strlen($this->_value);
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->write("\0\0\0\0");
switch ($this->getFlags()) {
case self::INTEGER:
// break intentionally omitted
case self::INTEGER_OLD_STYLE:
for ($i = 0; $i < strlen($this->_value); $i++) {
$writer->writeInt8($this->_value[$i]);
}
break;
case self::STRING:
// break intentionally omitted
default:
$writer->write($this->_value);
break;
}
}
}