Add ISO 14496 boxes

git-svn-id: http://php-reader.googlecode.com/svn/branches/zend@162 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2010-02-19 21:17:47 +00:00
parent 2151daf867
commit 559220106a
13 changed files with 2213 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* When the primary data is in XML format and it is desired that the XML be
* stored directly in the meta-box, one of the <i>XML Box</i> forms may be used.
* The Binary XML Box may only be used when there is a single well-defined
* binarization of the XML for that defined format as identified by the handler.
*
* Within an XML box the data is in UTF-8 format unless the data starts with a
* byte-order-mark (BOM), which indicates that the data is in UTF-16 format.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Bxml extends Zend_Media_Iso14496_FullBox
{
/** @var string */
private $_xml;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
$this->_xml = $this->_reader->read
($this->getOffset() + $this->getSize() -
$this->_reader->getOffset());
}
/**
* Returns the XML data.
*
* @return string
*/
public function getXml()
{
return $this->_xml;
}
/**
* Sets the binary data.
*
* @param string $xml The XML data.
*/
public function setXml($xml)
{
$this->_xml = $xml;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + strlen($this->_xml);
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->write($this->_xml);
}
}

View File

@@ -0,0 +1,160 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>ID3v2 Box</i> resides under the
* {@link Zend_Media_Iso14496_Box_Meta Meta Box} and stores ID3 version 2
* meta-data. There may be more than one Id3v2 Box present each with a different
* language code.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Id32 extends Zend_Media_Iso14496_FullBox
{
/** @var string */
private $_language = 'und';
/** @var Zend_Media_Id3v2 */
private $_tag;
/**
* 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->_language =
chr(((($tmp = $this->_reader->readUInt16BE()) >> 10) & 0x1f) +
0x60) .
chr((($tmp >> 5) & 0x1f) + 0x60) . chr(($tmp & 0x1f) + 0x60);
$this->_tag = new Zend_Media_Id3v2
($this->_reader, array('readonly' => true));
}
/**
* Returns the three byte language code to describe the language of this
* media, according to {@link http://www.loc.gov/standards/iso639-2/
* ISO 639-2/T}.
*
* @return string
*/
public function getLanguage()
{
return $this->_language;
}
/**
* Sets the three byte language code as specified in the
* {@link http://www.loc.gov/standards/iso639-2/ ISO 639-2} standard.
*
* @param string $language The language code.
*/
public function setLanguage($language)
{
$this->_language = $language;
}
/**
* Returns the {@link Zend_Media_Id3v2 Id3v2} tag class instance.
*
* @return string
*/
public function getTag()
{
return $this->_tag;
}
/**
* Sets the {@link Zend_Media_Id3v2 Id3v2} tag class instance using given
* language.
*
* @param Zend_Media_Id3v2 $tag The tag instance.
* @param string $language The language code.
*/
public function setTag($tag, $language = null)
{
$this->_tag = $tag;
if ($language !== null) {
$this->_language = $language;
}
}
/**
* Returns the box heap size in bytes.
*
* @return integer
* @todo There has got to be a better way to do this
*/
public function getHeapSize()
{
$writer = new Zend_Io_StringWriter();
$this->_tag->write($writer);
return parent::getHeapSize() + 2 + $writer->getSize();
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->writeUInt16BE
(((ord($this->_language[0]) - 0x60) << 10) |
((ord($this->_language[1]) - 0x60) << 5) |
ord($this->_language[2]) - 0x60);
$this->_tag->write($writer);
}
}

View File

@@ -0,0 +1,326 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/Box.php';
/**#@-*/
/**
* A container box for all the iTunes/iPod specific boxes. A list of well known
* boxes is provided in the following table. The value for each box is contained
* in a nested {@link Zend_Media_Iso14496_Box_Data Data Box}.
*
* <ul>
* <li><b>_nam</b> -- <i>Name of the track</i></li>
* <li><b>_ART</b> -- <i>Name of the artist</i></li>
* <li><b>aART</b> -- <i>Name of the album artist</i></li>
* <li><b>_alb</b> -- <i>Name of the album</i></li>
* <li><b>_grp</b> -- <i>Grouping</i></li>
* <li><b>_day</b> -- <i>Year of publication</i></li>
* <li><b>trkn</b> -- <i>Track number (number/total)</i></li>
* <li><b>disk</b> -- <i>Disk number (number/total)</i></li>
* <li><b>tmpo</b> -- <i>BPM tempo</i></li>
* <li><b>_wrt</b> -- <i>Name of the composer</i></li>
* <li><b>_cmt</b> -- <i>Comments</i></li>
* <li><b>_gen</b> -- <i>Genre as string</i></li>
* <li><b>gnre</b> -- <i>Genre as an ID3v1 code, added by one</i></li>
* <li><b>cpil</b> -- <i>Part of a compilation (0/1)</i></li>
* <li><b>tvsh</b> -- <i>Name of the (television) show</i></li>
* <li><b>sonm</b> -- <i>Sort name of the track</i></li>
* <li><b>soar</b> -- <i>Sort name of the artist</i></li>
* <li><b>soaa</b> -- <i>Sort name of the album artist</i></li>
* <li><b>soal</b> -- <i>Sort name of the album</i></li>
* <li><b>soco</b> -- <i>Sort name of the composer</i></li>
* <li><b>sosn</b> -- <i>Sort name of the show</i></li>
* <li><b>_lyr</b> -- <i>Lyrics</i></li>
* <li><b>covr</b> -- <i>Cover (or other) artwork binary data</i></li>
* <li><b>_too</b> -- <i>Information about the software</i></li>
* </ul>
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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 <sven@vollbehr.eu>
* @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 <sven@vollbehr.eu>
* @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;
}
}
}

View File

@@ -0,0 +1,233 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Item Information Entry Box</i> contains the entry information.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Infe extends Zend_Media_Iso14496_FullBox
{
/** @var integer */
private $_itemId;
/** @var integer */
private $_itemProtectionIndex;
/** @var string */
private $_itemName;
/** @var string */
private $_contentType;
/** @var string */
private $_contentEncoding;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
$this->_itemId = $this->_reader->readUInt16BE();
$this->_itemProtectionIndex = $this->_reader->readUInt16BE();
list($this->_itemName, $this->_contentType, $this->_contentEncoding) =
preg_split
("/\\x00/", $this->_reader->read
($this->getOffset() + $this->getSize() -
$this->_reader->getOffset()));
}
/**
* Returns the item identifier. The value is either 0 for the primary
* resource (e.g. the XML contained in an
* {@link Zend_Media_Iso14496_Box_Xml XML Box}) or the ID of the item for
* which the following information is defined.
*
* @return integer
*/
public function getItemId()
{
return $this->_itemId;
}
/**
* Sets the item identifier. The value must be either 0 for the primary
* resource (e.g. the XML contained in an
* {@link Zend_Media_Iso14496_Box_Xml XML Box}) or the ID of the item for
* which the following information is defined.
*
* @param integer $itemId The item identifier.
*/
public function setItemId($itemId)
{
$this->_itemId = $itemId;
}
/**
* Returns the item protection index. The value is either 0 for an
* unprotected item, or the one-based index into the
* {@link Zend_Media_Iso14496_Box_Ipro Item Protection Box} defining the
* protection applied to this item (the first box in the item protection box
* has the index 1).
*
* @return integer
*/
public function getItemProtectionIndex()
{
return $this->_itemProtectionIndex;
}
/**
* Sets the item protection index. The value must be either 0 for an
* unprotected item, or the one-based index into the
* {@link Zend_Media_Iso14496_Box_Ipro Item Protection Box} defining the
* protection applied to this item (the first box in the item protection box
* has the index 1).
*
* @param integer $itemProtectionIndex The index.
*/
public function setItemProtectionIndex($itemProtectionIndex)
{
$this->_itemProtectionIndex = $itemProtectionIndex;
}
/**
* Returns the symbolic name of the item.
*
* @return string
*/
public function getItemName()
{
return $this->_itemName;
}
/**
* Sets the symbolic name of the item.
*
* @param string $itemName The item name.
*/
public function setItemName($itemName)
{
$this->_itemName = $itemName;
}
/**
* Returns the MIME type for the item.
*
* @return string
*/
public function getContentType()
{
return $this->_contentType;
}
/**
* Sets the MIME type for the item.
*
* @param string $contentType The content type.
*/
public function setContentType($contentType)
{
$this->_contentType = $contentType;
}
/**
* Returns the optional content encoding type as defined for
* Content-Encoding for HTTP /1.1. Some possible values are <i>gzip</i>,
* <i>compress</i> and <i>deflate</i>. An empty string indicates no content
* encoding.
*
* @return string
*/
public function getContentEncoding()
{
return $this->_contentEncoding;
}
/**
* Sets the optional content encoding type as defined for
* Content-Encoding for HTTP /1.1. Some possible values are <i>gzip</i>,
* <i>compress</i> and <i>deflate</i>. An empty string indicates no content
* encoding.
*
* @param string $contentEncoding The content encoding.
*/
public function setContentEncoding($contentEncoding)
{
$this->_contentEncoding = $contentEncoding;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + 7 + strlen($this->_itemName) +
strlen($this->_contentType) + strlen($this->_contentEncoding);
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->writeUInt16BE($this->_itemId)
->writeUInt16BE($this->_itemProtectionIndex)
->writeString8($this->_itemName, 1)
->writeString8($this->_contentType, 1)
->writeString8($this->_contentEncoding, 1);
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Movie Extends Header Box</i> is optional, and provides the overall
* duration, including fragments, of a fragmented movie. If this box is not
* present, the overall duration must be computed by examining each fragment.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Mehd extends Zend_Media_Iso14496_FullBox
{
/** @var integer */
private $_fragmentDuration;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
if ($this->getVersion() == 1) {
$this->_fragmentDuration = $this->_reader->readInt64BE();
} else {
$this->_fragmentDuration = $this->_reader->readUInt32BE();
}
}
/**
* Returns the length of the presentation of the whole movie including
* fragments (in the timescale indicated in the
* {@link Zend_Media_Iso14496_Box_Mvhd Movie Header Box}). The value of
* this field corresponds to the duration of the longest track, including
* movie fragments.
*
* @return integer
*/
public function getFragmentDuration()
{
return $this->_fragmentDuration;
}
/**
* Sets the length of the presentation of the whole movie including
* fragments (in the timescale indicated in the
* {@link Zend_Media_Iso14496_Box_Mvhd Movie Header Box}). The value of
* this field must correspond to the duration of the longest track,
* including movie fragments.
*
* @param integer $fragmentDuration The fragment duration.
*/
public function setFragmentDuration($fragmentDuration)
{
$this->_fragmentDuration = $fragmentDuration;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + ($this->getVersion() == 1 ? 8 : 4);
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
if ($this->getVersion() == 1) {
$writer->writeInt64BE($this->_fragmentDuration);
} else {
$writer->writeUInt32BE($this->_fragmentDuration);
}
}
}

View File

@@ -0,0 +1,114 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Movie Fragment Header Box</i> contains a sequence number, as a safety
* check. The sequence number usually starts at 1 and must increase for each
* movie fragment in the file, in the order in which they occur. This allows
* readers to verify integrity of the sequence; it is an error to construct a
* file where the fragments are out of sequence.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Mfhd extends Zend_Media_Iso14496_FullBox
{
/** @var integer */
private $_sequenceNumber;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
$this->_sequenceNumber = $this->_reader->readUInt32BE();
}
/**
* Returns the ordinal number of this fragment, in increasing order.
*
* @return integer
*/
public function getSequenceNumber()
{
return $this->_sequenceNumber;
}
/**
* Sets the ordinal number of this fragment, in increasing order.
*
* @param integer $sequenceNumber The sequence number.
*/
public function setSequenceNumber($sequenceNumber)
{
$this->_sequenceNumber = $sequenceNumber;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + 4;
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->writeUInt32BE($this->_sequenceNumber);
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Movie Fragment Random Access Offset Box</i> provides a copy of the
* length field from the enclosing {@link Zend_Media_Iso14496_Box_MFRA Movie Fragment
* Random Access Box}. It is placed last within that box, so that the size field
* is also last in the enclosing Movie Fragment Random Access Box. When the
* Movie Fragment Random Access Box is also last in the file this permits its
* easy location. The size field here must be correct. However, neither the
* presence of the Movie Fragment Random Access Box, nor its placement last in
* the file, are assured.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Mfro extends Zend_Media_Iso14496_FullBox
{
/** @var integer */
private $_parentSize;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
$this->_parentSize = $this->_reader->readUInt32BE();
}
/**
* Returns the number of bytes of the enclosing
* {@link Zend_Media_Iso14496_Box_Mfra} box. This field is placed at the
* last of the enclosing box to assist readers scanning from the end of the
* file in finding the <i>mfra</i> box.
*
* @return integer
*/
public function getParentSize()
{
return $this->_parentSize;
}
/**
* Sets the number of bytes of the enclosing
* {@link Zend_Media_Iso14496_Box_Mfra} box. This field is placed at the
* last of the enclosing box to assist readers scanning from the end of the
* file in finding the <i>mfra</i> box.
*
* @param integer $parentSize The number of bytes.
*/
public function setParentSize($parentSize)
{
$this->_parentSize = $parentSize;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + 4;
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->writeUInt32BE($this->_parentSize);
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/Box.php';
/**#@-*/
/**
* The metadata for a presentation is stored in the single <i>Movie Box</i>
* which occurs at the top-level of a file. Normally this box is close to the
* beginning or end of the file, though this is not required.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Moov 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();
}
}

View File

@@ -0,0 +1,343 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Movie Header Box</i> defines overall information which is
* media-independent, and relevant to the entire presentation considered as a
* whole.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Mvhd extends Zend_Media_Iso14496_FullBox
{
/** @var integer */
private $_creationTime;
/** @var integer */
private $_modificationTime;
/** @var integer */
private $_timescale;
/** @var integer */
private $_duration;
/** @var integer */
private $_rate = 1.0;
/** @var integer */
private $_volume = 1.0;
/** @var Array */
private $_matrix = array
(0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000);
/** @var integer */
private $_nextTrackId;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
if ($this->getVersion() == 1) {
$this->_creationTime = $this->_reader->readInt64BE();
$this->_modificationTime = $this->_reader->readInt64BE();
$this->_timescale = $this->_reader->readUInt32BE();
$this->_duration = $this->_reader->readInt64BE();
} else {
$this->_creationTime = $this->_reader->readUInt32BE();
$this->_modificationTime = $this->_reader->readUInt32BE();
$this->_timescale = $this->_reader->readUInt32BE();
$this->_duration = $this->_reader->readUInt32BE();
}
$this->_rate =
((($tmp = $this->_reader->readUInt32BE()) >> 16) & 0xffff) +
(float)("0." . ((string)($tmp & 0xffff)));
$this->_volume =
((($tmp = $this->_reader->readUInt16BE()) >> 8) & 0xff) +
(float)("0." . ((string)($tmp & 0xff)));
$this->_reader->skip(10);
for ($i = 0; $i < 9; $i++) {
$this->_matrix[$i] = $this->_reader->readUInt32BE();
}
$this->_reader->skip(24);
$this->_nextTrackId = $this->_reader->readUInt32BE();
}
/**
* Returns the creation time of the presentation. The value is in seconds
* since midnight, Jan. 1, 1904, in UTC time.
*
* @return integer
*/
public function getCreationTime()
{
return $this->_creationTime;
}
/**
* Sets the creation time of the presentation in seconds since midnight,
* Jan. 1, 1904, in UTC time.
*
* @param integer $creationTime The creation time.
*/
public function setCreationTime($creationTime)
{
$this->_creationTime = $creationTime;
}
/**
* Returns the most recent time the presentation was modified. The value is
* in seconds since midnight, Jan. 1, 1904, in UTC time.
*
* @return integer
*/
public function getModificationTime()
{
return $this->_modificationTime;
}
/**
* Sets the most recent time the presentation was modified in seconds since
* midnight, Jan. 1, 1904, in UTC time.
*
* @param integer $modificationTime The most recent time the presentation
* was modified.
*/
public function setModificationTime($modificationTime)
{
$this->_modificationTime = $modificationTime;
}
/**
* Returns the time-scale for the entire presentation. This is the number of
* time units that pass in one second. For example, a time coordinate system
* that measures time in sixtieths of a second has a time scale of 60.
*
* @return integer
*/
public function getTimescale()
{
return $this->_timescale;
}
/**
* Sets the time-scale for the entire presentation. This is the number of
* time units that pass in one second. For example, a time coordinate system
* that measures time in sixtieths of a second has a time scale of 60.
*
* @param integer $timescale The time-scale for the entire presentation.
*/
public function setTimescale($timescale)
{
$this->_timescale = $timescale;
}
/**
* Returns the length of the presentation in the indicated timescale. This
* property is derived from the presentation's tracks: the value of this
* field corresponds to the duration of the longest track in the
* presentation.
*
* @return integer
*/
public function getDuration()
{
return $this->_duration;
}
/**
* Sets the length of the presentation in the indicated timescale. This
* property must be derived from the presentation's tracks: the value of
* this field must correspond to the duration of the longest track in the
* presentation.
*
* @param integer $duration The length of the presentation.
*/
public function setDuration($duration)
{
$this->_duration = $duration;
}
/**
* Returns the preferred rate to play the presentation. 1.0 is normal
* forward playback.
*
* @return integer
*/
public function getRate()
{
return $this->_rate;
}
/**
* Sets the preferred rate to play the presentation. 1.0 is normal
* forward playback.
*
* @param integer $rate The preferred play rate.
*/
public function setRate($rate)
{
$this->_rate = $rate;
}
/**
* Returns the preferred playback volume. 1.0 is full volume.
*
* @return integer
*/
public function getVolume()
{
return $this->_volume;
}
/**
* Sets the preferred playback volume. 1.0 is full volume.
*
* @param integer $volume The playback volume.
*/
public function setVolume($volume)
{
$this->_volume = $volume;
}
/**
* Returns the transformation matrix for the video; (u,v,w) are restricted
* here to (0,0,1), hex values (0,0,0x40000000).
*
* @return Array
*/
public function getMatrix()
{
return $this->_matrix;
}
/**
* Sets the transformation matrix for the video; (u,v,w) are restricted
* here to (0,0,1), hex values (0,0,0x40000000).
*
* @param Array $matrix The transformation matrix array of 9 values
*/
public function setMatrix($matrix)
{
$this->_matrix = $matrix;
}
/**
* Returns a value to use for the track ID of the next track to be added to
* this presentation. Zero is not a valid track ID value. The value is
* larger than the largest track-ID in use. If this value is equal to or
* larger than 32-bit maxint, and a new media track is to be added, then a
* search must be made in the file for a unused track identifier.
*
* @return integer
*/
public function getNextTrackId()
{
return $this->_nextTrackId;
}
/**
* Sets a value to use for the track ID of the next track to be added to
* this presentation. Zero is not a valid track ID value. The value must be
* larger than the largest track-ID in use.
*
* @param integer $nextTrackId The next track ID.
*/
public function setNextTrackId($nextTrackId)
{
$this->_nextTrackId = $nextTrackId;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() +
($this->getVersion() == 1 ? 28 : 16) + 80;
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
if ($this->getVersion() == 1) {
$writer->writeInt64BE($this->_creationTime)
->writeInt64BE($this->_modificationTime)
->writeUInt32BE($this->_timescale)
->writeInt64BE($this->_duration);
} else {
$writer->writeUInt32BE($this->_creationTime)
->writeUInt32BE($this->_modificationTime)
->writeUInt32BE($this->_timescale)
->writeUInt32BE($this->_duration);
}
@list(, $rateDecimals) = explode('.', (float)$this->_rate);
@list(, $volumeDecimals) = explode('.', (float)$this->_volume);
$writer->writeUInt32BE(floor($this->_rate) << 16 | $rateDecimals)
->writeUInt16BE(floor($this->_volume) << 8 | $volumeDecimals)
->write(str_pad('', 10, "\0"));
for ($i = 0; $i < 9; $i++) {
$writer->writeUInt32BE($this->_matrix[$i]);
}
$writer->write(str_pad('', 24, "\0"))
->writeUInt32BE($this->_nextTrackId);
}
}

View File

@@ -0,0 +1,143 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Progressive Download Information Box</i> aids the progressive download
* of an ISO file. The box contains pairs of numbers (to the end of the box)
* specifying combinations of effective file download bitrate in units of
* bytes/sec and a suggested initial playback delay in units of milliseconds.
*
* A receiving party can estimate the download rate it is experiencing, and from
* that obtain an upper estimate for a suitable initial delay by linear
* interpolation between pairs, or by extrapolation from the first or last
* entry.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Pdin extends Zend_Media_Iso14496_FullBox
{
/** @var Array */
private $_progressiveDownloadInfo = array();
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
while ($this->_reader->getOffset() <
$this->getOffset() + $this->getSize()) {
$this->_progressiveDownloadInfo[] = array
('rate' => $this->_reader->readUInt32BE(),
'initialDelay' => $this->_reader->readUInt32BE());
}
}
/**
* Returns the progressive download information array. The array consists of
* items having two keys.
*
* o rate -- the download rate expressed in bytes/second
* o initialDelay -- the suggested delay to use when playing the file,
* such that if download continues at the given rate, all data within
* the file will arrive in time for its use and playback should not need
* to stall.
*
* @return Array
*/
public function getProgressiveDownloadInfo()
{
return $this->_progressiveDownloadInfo;
}
/**
* Sets the progressive download information array. The array must consist
* of items having two keys.
*
* o rate -- the download rate expressed in bytes/second
* o initialDelay -- the suggested delay to use when playing the file,
* such that if download continues at the given rate, all data within
* the file will arrive in time for its use and playback should not need
* to stall.
*
* @param Array $progressiveDownloadInfo The array of values.
*/
public function setProgressiveDownloadInfo($progressiveDownloadInfo)
{
$this->_progressiveDownloadInfo = $progressiveDownloadInfo;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() +
count($this->_progressiveDownloadInfo) * 8;
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
for ($i = 1; $i <= count($this->_timeToSampleTable); $i++) {
$writer->writeUInt32BE
($this->_progressiveDownloadInfo[$i]['rate'])
->writeUInt32BE
($this->_progressiveDownloadInfo[$i]['initialDelay']);
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* For a given handler, the primary data may be one of the referenced items when
* it is desired that it be stored elsewhere, or divided into extents; or the
* primary metadata may be contained in the meta-box (e.g. in an
* {@link Zend_Media_Iso14496_Box_Xml XML Box}). Either the <i>Primary Item
* Box</i> must occur, or there must be a box within the meta-box (e.g. an
* {@link Zend_Media_Iso14496_Box_Xml XML Box}) containing the primary
* information in the format required by the identified handler.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Pitm extends Zend_Media_Iso14496_FullBox
{
/** @var string */
private $_itemId;
/**
* 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, &$options = array())
{
parent::__construct($reader, $options);
$this->_itemId = $this->_reader->readUInt16BE();
}
/**
* Returns the identifier of the primary item.
*
* @return integer
*/
public function getItemId()
{
return $this->_itemId;
}
/**
* Sets the identifier of the primary item.
*
* @param integer $itemId The item identification.
*/
public function setItemId($itemId)
{
$this->_itemId = $itemId;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + 2;
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->writeUInt16BE($this->_itemId);
}
}

View File

@@ -0,0 +1,214 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* The <i>Track Extends Box</i> sets up default values used by the movie
* fragments. By setting defaults in this way, space and complexity can be saved
* in each {@link Zend_Media_Iso14496_Box_Traf Track Fragment Box}.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Trex extends Zend_Media_Iso14496_FullBox
{
/** @var integer */
private $_trackId;
/** @var integer */
private $_defaultSampleDescriptionIndex;
/** @var integer */
private $_defaultSampleDuration;
/** @var integer */
private $_defaultSampleSize;
/** @var integer */
private $_defaultSampleFlags;
/**
* 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.
* @todo The sample flags could be parsed further
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_trackId = $this->_reader->readUInt32BE();
$this->_defaultSampleDescriptionIndex = $this->_reader->readUInt32BE();
$this->_defaultSampleDuration = $this->_reader->readUInt32BE();
$this->_defaultSampleSize = $this->_reader->readUInt32BE();
$this->_defaultSampleFlags = $this->_reader->readUInt32BE();
}
/**
* Returns the default track identifier.
*
* @return integer
*/
public function getTrackId()
{
return $this->_trackId;
}
/**
* Sets the default track identifier.
*
* @param integer $trackId The track identifier.
*/
public function setTrackId($trackId)
{
$this->_trackId = $trackId;
}
/**
* Returns the default sample description index.
*
* @return integer
*/
public function getDefaultSampleDescriptionIndex()
{
return $this->_defaultSampleDescriptionIndex;
}
/**
* Sets the default sample description index.
*
* @param integer $defaultSampleDescriptionIndex The description index.
*/
public function getDefaultSampleDescriptionIndex
($defaultSampleDescriptionIndex)
{
$this->_defaultSampleDescriptionIndex = $defaultSampleDescriptionIndex;
}
/**
* Returns the default sample duration.
*
* @return integer
*/
public function getDefaultSampleDuration()
{
return $this->_defaultSampleDuration;
}
/**
* Sets the default sample duration.
*
* @param integer $defaultSampleDuration The sample duration.
*/
public function setDefaultSampleDuration($defaultSampleDuration)
{
$this->_defaultSampleDuration = $defaultSampleDuration;
}
/**
* Returns the default sample size.
*
* @return integer
*/
public function getDefaultSampleSize()
{
return $this->_defaultSampleSize;
}
/**
* Sets the default sample size.
*
* @param integer $defaultSampleSize The sample size.
*/
public function setDefaultSampleSize($defaultSampleSize)
{
$this->_defaultSampleSize = $defaultSampleSize;
}
/**
* Returns the default sample flags.
*
* @return integer
*/
public function getDefaultSampleFlags()
{
return $this->_defaultSampleFlags;
}
/**
* Sets the default sample flags.
*
* @param integer $defaultSampleFlags The sample flags.
*/
public function setDefaultSampleFlags()
{
$this->_defaultSampleFlags = $defaultSampleFlags;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + 20;
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->writeUInt32BE($this->_trackId)
->writeUInt32BE($this->_defaultSampleDescriptionIndex)
->writeUInt32BE($this->_defaultSampleDuration)
->writeUInt32BE($this->_defaultSampleSize)
->writeUInt32BE($this->_defaultSampleFlags);
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @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$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Iso14496/FullBox.php';
/**#@-*/
/**
* When the primary data is in XML format and it is desired that the XML be
* stored directly in the meta-box, one of the <i>XML Box</i> forms may be used.
* The {@link Zend_Media_Iso14496_Box_Bxml Binary XML Box} may only be used when
* there is a single well-defined binarization of the XML for that defined
* format as identified by the handler.
*
* Within an XML box the data is in UTF-8 format unless the data starts with a
* byte-order-mark (BOM), which indicates that the data is in UTF-16 format.
*
* @category Zend
* @package Zend_Media
* @subpackage ISO 14496
* @author Sven Vollbehr <sven@vollbehr.eu>
* @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$
*/
final class Zend_Media_Iso14496_Box_Xml extends Zend_Media_Iso14496_FullBox
{
/** @var string */
private $_xml;
/**
* 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->_xml = $this->_reader->read
($this->getOffset() + $this->getSize() -
$this->_reader->getOffset());
}
/**
* Returns the XML data.
*
* @return string
*/
public function getXml()
{
return $this->_xml;
}
/**
* Sets the XML data.
*
* @param string $xml The XML data.
*/
public function setXml($xml)
{
$this->_xml = $xml;
}
/**
* Returns the box heap size in bytes.
*
* @return integer
*/
public function getHeapSize()
{
return parent::getHeapSize() + strlen($this->_xml);
}
/**
* Writes the box data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
protected function _writeData($writer)
{
parent::_writeData($writer);
$writer->write($this->_xml);
}
}