Add ISO 14496 boxes
git-svn-id: http://php-reader.googlecode.com/svn/branches/zend@160 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
174
src/Zend/Media/Iso14496/Box/Hdlr.php
Normal file
174
src/Zend/Media/Iso14496/Box/Hdlr.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?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>Handler Reference Box</i> is within a
|
||||
* {@link Zend_Media_Iso14496_Box_Mdia Media Box} declares the process by which
|
||||
* the media-data in the track is presented, and thus, the nature of the media
|
||||
* in a track. For example, a video track would be handled by a video handler.
|
||||
*
|
||||
* This box when present within a {@link Zend_Media_Iso14496_Box_Meta Meta Box},
|
||||
* declares the structure or format of the <i>meta</i> box contents.
|
||||
*
|
||||
* @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_Hdlr extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var string */
|
||||
private $_handlerType;
|
||||
|
||||
/** @var string */
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
$this->_handlerType = $this->_reader->read(4);
|
||||
$this->_reader->skip(12);
|
||||
$this->_name = $this->_reader->readString8
|
||||
($this->getOffset() + $this->getSize() -
|
||||
$this->_reader->getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the handler type.
|
||||
*
|
||||
* When present in a media box, the returned value contains one of the
|
||||
* following values, or a value from a derived specification:
|
||||
* o <i>vide</i> Video track
|
||||
* o <i>soun</i> Audio track
|
||||
* o <i>hint</i> Hint track
|
||||
*
|
||||
* When present in a meta box, the returned value contains an appropriate
|
||||
* value to indicate the format of the meta box contents.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHandlerType()
|
||||
{
|
||||
return $this->_handlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the handler type.
|
||||
*
|
||||
* When present in a media box, the value must be set to one of the
|
||||
* following values, or a value from a derived specification:
|
||||
* o <i>vide</i> Video track
|
||||
* o <i>soun</i> Audio track
|
||||
* o <i>hint</i> Hint track
|
||||
*
|
||||
* When present in a meta box, the value must be set to an appropriate value
|
||||
* to indicate the format of the meta box contents.
|
||||
*
|
||||
* @param string $handlerType The handler type.
|
||||
*/
|
||||
public function setHandlerType($handlerType)
|
||||
{
|
||||
$this->_handlerType = $handlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name string. The name is in UTF-8 characters and gives a
|
||||
* human-readable name for the track type (for debugging and inspection
|
||||
* purposes).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name string. The name must be in UTF-8 and give a human-readable
|
||||
* name for the track type (for debugging and inspection purposes).
|
||||
*
|
||||
* @param string $name The human-readable description.
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->_name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 20 + strlen($this->_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->write(str_pad('', 4, "\0"))
|
||||
->write($this->_handlerType)
|
||||
->writeUInt32BE(0)
|
||||
->writeUInt32BE(0)
|
||||
->writeUInt32BE(0)
|
||||
->writeString8($this->_name);
|
||||
}
|
||||
}
|
||||
243
src/Zend/Media/Iso14496/Box/Mdhd.php
Normal file
243
src/Zend/Media/Iso14496/Box/Mdhd.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?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>Media Header Box</i> declares overall information that is
|
||||
* media-independent, and relevant to characteristics of the media in a track.
|
||||
*
|
||||
* @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_Mdhd extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var integer */
|
||||
private $_creationTime;
|
||||
|
||||
/** @var integer */
|
||||
private $_modificationTime;
|
||||
|
||||
/** @var integer */
|
||||
private $_timescale;
|
||||
|
||||
/** @var integer */
|
||||
private $_duration;
|
||||
|
||||
/** @var string */
|
||||
private $_language = 'und';
|
||||
|
||||
/**
|
||||
* 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->_language = chr
|
||||
(((($tmp = $this->_reader->readUInt16BE()) >> 10) & 0x1f) + 0x60) .
|
||||
chr((($tmp >> 5) & 0x1f) + 0x60) . chr(($tmp & 0x1f) + 0x60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the creation time of the media in this track, in seconds since
|
||||
* midnight, Jan. 1, 1904, in UTC time.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCreationTime()
|
||||
{
|
||||
return $this->_creationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the creation time of the media in this track, 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 media in this track was modified in
|
||||
* seconds since midnight, Jan. 1, 1904, in UTC time.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getModificationTime()
|
||||
{
|
||||
return $this->_modificationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the most recent time the media in this track was modified in
|
||||
* seconds since midnight, Jan. 1, 1904, in UTC time.
|
||||
*
|
||||
* @param integer $modificationTime The modification time.
|
||||
*/
|
||||
public function setModificationTime($modificationTime)
|
||||
{
|
||||
$this->_modificationTime = $modificationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time-scale for this media. 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 this media. 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.
|
||||
*/
|
||||
public function setTimescale($timescale)
|
||||
{
|
||||
$this->_timescale = $timescale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of this media (in the scale of the timescale).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getDuration()
|
||||
{
|
||||
return $this->_duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration of this media (in the scale of the timescale).
|
||||
*
|
||||
* @param integer $duration The duration.
|
||||
*/
|
||||
public function setDuration($duration)
|
||||
{
|
||||
$this->_duration = $duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 to describe the language of this
|
||||
* media, according to {@link http://www.loc.gov/standards/iso639-2/
|
||||
* ISO 639-2/T}.
|
||||
*
|
||||
* @param string $language The language code.
|
||||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->_language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() +
|
||||
($this->getVersion() == 1 ? 28 : 16) + 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->_creationTime)
|
||||
->writeInt64BE($this->_modificationTime)
|
||||
->writeUInt32BE($this->_timescale)
|
||||
->writeInt64BE($this->_duration);
|
||||
} else {
|
||||
$writer->writeUInt32BE($this->_creationTime)
|
||||
->writeUInt32BE($this->_modificationTime)
|
||||
->writeUInt32BE($this->_timescale)
|
||||
->writeUInt32BE($this->_duration);
|
||||
}
|
||||
$writer->writeUInt16BE((ord($this->_language[0]) - 0x60) << 10 |
|
||||
(ord($this->_language[1])- 0x60) << 5 |
|
||||
(ord($this->_language[2])- 0x60))
|
||||
->write(str_pad('', 2, "\0"));
|
||||
}
|
||||
}
|
||||
123
src/Zend/Media/Iso14496/Box/Smhd.php
Normal file
123
src/Zend/Media/Iso14496/Box/Smhd.php
Normal 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>Sound Media Header Box</i> contains general presentation information,
|
||||
* independent of the coding, for audio media. This header is used for all
|
||||
* tracks containing audio.
|
||||
*
|
||||
* @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_Smhd extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var integer */
|
||||
private $_balance = 0;
|
||||
|
||||
/**
|
||||
* 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->_balance =
|
||||
((($tmp = $this->_reader->readUInt16BE()) >> 8) & 0xff) +
|
||||
(float)("0." . ((string)($tmp & 0xff)));
|
||||
$this->_reader->skip(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number that places mono audio tracks in a stereo space; 0 is
|
||||
* center (the normal value); full left is -1.0 and full right is 1.0.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->_balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number that places mono audio tracks in a stereo space; 0 is
|
||||
* center (the normal value); full left is -1.0 and full right is 1.0.
|
||||
*
|
||||
* @param integer $balance The balance.
|
||||
*/
|
||||
public function setBalance($balance)
|
||||
{
|
||||
$this->_balance = $balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@list(, $balanceDecimals) = explode('.', (float)$this->_balance);
|
||||
$writer->writeInt16BE(floor($this->_balance) << 8 | $balanceDecimals)
|
||||
->writeInt16BE(0);
|
||||
}
|
||||
}
|
||||
134
src/Zend/Media/Iso14496/Box/Stco.php
Normal file
134
src/Zend/Media/Iso14496/Box/Stco.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?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>Chunk Offset Box</i> table gives the index of each chunk into the
|
||||
* containing file. There are two variants, permitting the use of 32-bit or
|
||||
* 64-bit offsets. The latter is useful when managing very large presentations.
|
||||
* At most one of these variants will occur in any single instance of a sample
|
||||
* table.
|
||||
*
|
||||
* Offsets are file offsets, not the offset into any box within the file (e.g.
|
||||
* {@link Zend_Media_Iso14496_Box_Mdat Media Data Box}). This permits referring
|
||||
* to media data in files without any box structure. It does also mean that care
|
||||
* must be taken when constructing a self-contained ISO file with its metadata
|
||||
* ({@link Zend_Media_Iso14496_Box_Moov Movie Box}) at the front, as the size of
|
||||
* the {@link Zend_Media_Iso14496_Box_Moov Movie Box} will affect the chunk
|
||||
* offsets to the media data.
|
||||
*
|
||||
* This box variant contains 32-bit offsets.
|
||||
*
|
||||
* @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_Stco extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var Array */
|
||||
private $_chunkOffsetTable = 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);
|
||||
|
||||
$entryCount = $this->_reader->readUInt32BE();
|
||||
for ($i = 0; $i < $entryCount; $i++) {
|
||||
$this->_chunkOffsetTable[$i + 1] = $reader->readUInt32BE();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of values. Each entry has the entry number as its index
|
||||
* and a 32 bit integer that gives the offset of the start of a chunk into
|
||||
* its containing media file as its value.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getChunkOffsetTable()
|
||||
{
|
||||
return $this->_chunkOffsetTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of chunk offsets. Each entry must have the entry number as
|
||||
* its index and a 32 bit integer that gives the offset of the start of a
|
||||
* chunk into its containing media file as its value.
|
||||
*
|
||||
* @param Array $chunkOffsetTable The chunk offset array.
|
||||
*/
|
||||
public function setChunkOffsetTable($chunkOffsetTable)
|
||||
{
|
||||
$this->_chunkOffsetTable = $chunkOffsetTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 4 + count($this->_chunkOffsetTable) * 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt32BE($entryCount = count($this->_chunkOffsetTable));
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$writer->writeUInt32BE($this->_chunkOffsetTable[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
122
src/Zend/Media/Iso14496/Box/Stdp.php
Normal file
122
src/Zend/Media/Iso14496/Box/Stdp.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?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>Degradation Priority Box</i> contains the degradation priority of each
|
||||
* sample. Specifications derived from this define the exact meaning and
|
||||
* acceptable range of the priority field.
|
||||
*
|
||||
* @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_Stdp extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var Array */
|
||||
private $_values = 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->_values[] = array
|
||||
('priority' => $this->_reader->readUInt16BE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of values. Each entry is an array containing the
|
||||
* following keys.
|
||||
* o priority: specifies the degradation priority for each sample segment.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return $this->_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of values. Each entry must have an array containing the
|
||||
* following keys.
|
||||
* o priority: specifies the degradation priority for each sample segment.
|
||||
*
|
||||
* @param Array $values The array of values.
|
||||
*/
|
||||
public function setValues($values)
|
||||
{
|
||||
$this->_values = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + count($this->_values) * 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
for ($i = 0; $i < count($this->_values); $i++) {
|
||||
$writer->writeUInt16BE($this->_values[$i]['priority']);
|
||||
}
|
||||
}
|
||||
}
|
||||
161
src/Zend/Media/Iso14496/Box/Stsc.php
Normal file
161
src/Zend/Media/Iso14496/Box/Stsc.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?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';
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Samples within the media data are grouped into chunks. Chunks can be of
|
||||
* different sizes, and the samples within a chunk can have different sizes.
|
||||
* The <i>Sample To Chunk Box</i> table can be used to find the chunk that
|
||||
* contains a sample, its position, and the associated sample description.
|
||||
*
|
||||
* The table is compactly coded. Each entry gives the index of the first chunk
|
||||
* of a run of chunks with the same characteristics. By subtracting one entry
|
||||
* here from the previous one, you can compute how many chunks are in this run.
|
||||
* You can convert this to a sample count by multiplying by the appropriate
|
||||
* samplesPerChunk.
|
||||
*
|
||||
* @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_Stsc extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var Array */
|
||||
private $_sampleToChunkTable = 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);
|
||||
|
||||
$entryCount = $this->_reader->readUInt32BE();
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$this->_sampleToChunkTable[$i] = array
|
||||
('firstChunk' => $this->_reader->readUInt32BE(),
|
||||
'samplesPerChunk' => $this->_reader->readUInt32BE(),
|
||||
'sampleDescriptionIndex' => $this->_reader->readUInt32BE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of values. Each entry is an array containing the
|
||||
* following keys.
|
||||
* o firstChunk -- an integer that gives the index of the first chunk in
|
||||
* this run of chunks that share the same samplesPerChunk and
|
||||
* sampleDescriptionIndex; the index of the first chunk in a track has
|
||||
* the value 1 (the firstChunk field in the first record of this box
|
||||
* has the value 1, identifying that the first sample maps to the first
|
||||
* chunk).
|
||||
* o samplesPerChunk is an integer that gives the number of samples in
|
||||
* each of these chunks.
|
||||
* o sampleDescriptionIndex is an integer that gives the index of the
|
||||
* sample entry that describes the samples in this chunk. The index
|
||||
* ranges from 1 to the number of sample entries in the
|
||||
* {@link Zend_Media_Iso14496_Box_Stsd Sample Description Box}.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getSampleToChunkTable()
|
||||
{
|
||||
return $this->_sampleToChunkTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of values. Each entry is an array containing the
|
||||
* following keys.
|
||||
* o firstChunk -- an integer that gives the index of the first chunk in
|
||||
* this run of chunks that share the same samplesPerChunk and
|
||||
* sampleDescriptionIndex; the index of the first chunk in a track has
|
||||
* the value 1 (the firstChunk field in the first record of this box
|
||||
* has the value 1, identifying that the first sample maps to the first
|
||||
* chunk).
|
||||
* o samplesPerChunk is an integer that gives the number of samples in
|
||||
* each of these chunks.
|
||||
* o sampleDescriptionIndex is an integer that gives the index of the
|
||||
* sample entry that describes the samples in this chunk. The index
|
||||
* ranges from 1 to the number of sample entries in the
|
||||
* {@link Zend_Media_Iso14496_Box_Stsd Sample Description Box}.
|
||||
*
|
||||
* @param Array $sampleToChunkTable The array of values.
|
||||
*/
|
||||
public function setSampleToChunkTable($sampleToChunkTable)
|
||||
{
|
||||
$this->_sampleToChunkTable = $sampleToChunkTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 4 +
|
||||
count($this->_sampleToChunkTable) * 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt32BE($entryCount = count($this->_sampleToChunkTable));
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$writer->writeUInt32BE
|
||||
($this->_sampleToChunkTable[$i]['firstChunk'])
|
||||
->writeUInt32BE
|
||||
($this->_sampleToChunkTable[$i]['samplesPerChunk'])
|
||||
->writeUInt32BE
|
||||
($this->_sampleToChunkTable[$i]
|
||||
['sampleDescriptionIndex']);
|
||||
}
|
||||
}
|
||||
}
|
||||
91
src/Zend/Media/Iso14496/Box/Stsd.php
Normal file
91
src/Zend/Media/Iso14496/Box/Stsd.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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>Sample Description Box</i> table gives detailed information about the
|
||||
* coding type used, and any initialization information needed for that coding.
|
||||
*
|
||||
* @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$
|
||||
* @todo Implementation
|
||||
*/
|
||||
final class Zend_Media_Iso14496_Box_Stsd extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* 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->_data = $reader->read($this->getSize() - 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + $this->getSize() - 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->write($this->_data);
|
||||
}
|
||||
}
|
||||
158
src/Zend/Media/Iso14496/Box/Stsh.php
Normal file
158
src/Zend/Media/Iso14496/Box/Stsh.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?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>Shadow Sync Sample Box</i> table provides an optional set of sync
|
||||
* samples that can be used when seeking or for similar purposes. In normal
|
||||
* forward play they are ignored.
|
||||
*
|
||||
* Each entry in the Shadow Sync Table consists of a pair of sample numbers. The
|
||||
* first entry (shadowedSampleNumber) indicates the number of the sample that a
|
||||
* shadow sync will be defined for. This should always be a non-sync sample
|
||||
* (e.g. a frame difference). The second sample number (syncSampleNumber)
|
||||
* indicates the sample number of the sync sample (i.e. key frame) that can be
|
||||
* used when there is a random access at, or before, the shadowedSampleNumber.
|
||||
*
|
||||
* The shadow sync samples are normally placed in an area of the track that is
|
||||
* not presented during normal play (edited out by means of an edit list),
|
||||
* though this is not a requirement. The shadow sync table can be ignored and
|
||||
* the track will play (and seek) correctly if it is ignored (though perhaps not
|
||||
* optimally).
|
||||
*
|
||||
* The Shadow Sync Sample replaces, not augments, the sample that it shadows
|
||||
* (i.e. the next sample sent is shadowedSampleNumber+1). The shadow sync sample
|
||||
* is treated as if it occurred at the time of the sample it shadows, having the
|
||||
* duration of the sample it shadows.
|
||||
*
|
||||
* Hinting and transmission might become more complex if a shadow sample is used
|
||||
* also as part of normal playback, or is used more than once as a shadow. In
|
||||
* this case the hint track might need separate shadow syncs, all of which can
|
||||
* get their media data from the one shadow sync in the media track, to allow
|
||||
* for the different time-stamps etc. needed in their headers.
|
||||
*
|
||||
* @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_Stsh extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var Array */
|
||||
private $_shadowSyncSampleTable = 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);
|
||||
|
||||
$entryCount = $this->_reader->readUInt32BE();
|
||||
for ($i = 0; $i < $entryCount; $i++) {
|
||||
$this->_shadowSyncSampleTable[$i] = array
|
||||
('shadowedSampleNumber' => $this->_reader->readUInt32BE(),
|
||||
'syncSampleNumber' => $this->_reader->readUInt32BE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of values. Each entry is an array containing the
|
||||
* following keys.
|
||||
* o shadowedSampleNumber - gives the number of a sample for which there
|
||||
* is an alternative sync sample.
|
||||
* o syncSampleNumber - gives the number of the alternative sync sample.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getShadowSyncSampleTable()
|
||||
{
|
||||
return $this->_shadowSyncSampleTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of values. Each entry must be an array containing the
|
||||
* following keys.
|
||||
* o shadowedSampleNumber - gives the number of a sample for which there
|
||||
* is an alternative sync sample.
|
||||
* o syncSampleNumber - gives the number of the alternative sync sample.
|
||||
*
|
||||
* @param Array $shadowSyncSampleTable The array of values.
|
||||
*/
|
||||
public function setShadowSyncSampleTable($shadowSyncSampleTable)
|
||||
{
|
||||
$this->_shadowSyncSampleTable = $shadowSyncSampleTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 4 +
|
||||
count($this->_shadowSyncSampleTable) * 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt32BE
|
||||
($entryCount = count($this->_shadowSyncSampleTable));
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$writer->writeUInt32BE
|
||||
($this->_shadowSyncSampleTable[$i]
|
||||
['shadowedSampleNumber'])
|
||||
->writeUInt32BE
|
||||
($this->_shadowSyncSampleTable[$i]['syncSampleNumber']);
|
||||
}
|
||||
}
|
||||
}
|
||||
123
src/Zend/Media/Iso14496/Box/Stss.php
Normal file
123
src/Zend/Media/Iso14496/Box/Stss.php
Normal 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>Sync Sample Box</i> provides a compact marking of the random access
|
||||
* points within the stream. The table is arranged in strictly increasing order
|
||||
* of sample number. If the sync sample box is not present, every sample is a
|
||||
* random access point.
|
||||
*
|
||||
* @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_Stss extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var Array */
|
||||
private $_syncSampleTable = 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);
|
||||
|
||||
$entryCount = $this->_reader->readUInt32BE();
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$this->_syncSampleTable[$i] = $this->_reader->readUInt32BE();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of values. Each entry has the entry number as its index
|
||||
* and an integer that gives the numbers of the samples that are random
|
||||
* access points in the stream as its value.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getSyncSampleTable()
|
||||
{
|
||||
return $this->_syncSampleTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of values. Each entry has the entry number as its index
|
||||
* and an integer that gives the numbers of the samples that are random
|
||||
* access points in the stream as its value.
|
||||
*
|
||||
* @param Array $syncSampleTable The array of values.
|
||||
*/
|
||||
public function setSyncSampleTable($syncSampleTable)
|
||||
{
|
||||
$this->_syncSampleTable = $syncSampleTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 4 + count($this->_syncSampleTable) * 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt32BE($entryCount = count($this->_syncSampleTable));
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$writer->writeUInt32BE($this->_syncSampleTable[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
164
src/Zend/Media/Iso14496/Box/Stsz.php
Normal file
164
src/Zend/Media/Iso14496/Box/Stsz.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?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>Sample Size Box</i> contains the sample count and a table giving the
|
||||
* size in bytes of each sample. This allows the media data itself to be
|
||||
* unframed. The total number of samples in the media is always indicated in the
|
||||
* sample count.
|
||||
*
|
||||
* There are two variants of the sample size box. The first variant has a fixed
|
||||
* size 32-bit field for representing the sample sizes; it permits defining a
|
||||
* constant size for all samples in a track. The second variant permits smaller
|
||||
* size fields, to save space when the sizes are varying but small. One of these
|
||||
* boxes must be present; the first version is preferred for maximum
|
||||
* compatibility.
|
||||
*
|
||||
* @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_Stsz extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var integer */
|
||||
private $_sampleSize;
|
||||
|
||||
/** @var Array */
|
||||
private $_sampleSizeTable = 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);
|
||||
|
||||
$this->_sampleSize = $this->_reader->readUInt32BE();
|
||||
$sampleCount = $this->_reader->readUInt32BE();
|
||||
if ($this->_sampleSize == 0) {
|
||||
for ($i = 1; $i <= $sampleCount; $i++) {
|
||||
$this->_sampleSizeTable[$i] = $this->_reader->readUInt32BE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default sample size. If all the samples are the same size,
|
||||
* this field contains that size value. If this field is set to 0, then the
|
||||
* samples have different sizes, and those sizes are stored in the sample
|
||||
* size table.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSampleSize()
|
||||
{
|
||||
return $this->_sampleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default sample size. If all the samples are the same size,
|
||||
* this field contains that size value. If this field is set to 0, then the
|
||||
* samples have different sizes, and those sizes are stored in the sample
|
||||
* size table.
|
||||
*
|
||||
* @param integer $sampleSize The default sample size.
|
||||
*/
|
||||
public function setSampleSize($sampleSize)
|
||||
{
|
||||
$this->_sampleSize = $sampleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of sample sizes specifying the size of a sample, indexed
|
||||
* by its number.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getSampleSizeTable()
|
||||
{
|
||||
return $this->_sampleSizeTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of sample sizes specifying the size of a sample, indexed
|
||||
* by its number.
|
||||
*
|
||||
* @param Array $sampleSizeTable The array of sample sizes.
|
||||
*/
|
||||
public function setSampleSizeTable($sampleSizeTable)
|
||||
{
|
||||
$this->_sampleSizeTable = $sampleSizeTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 8 +
|
||||
($this->_sampleSize == 0 ? count($this->_sampleSizeTable) * 4 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt32BE($this->_sampleSize);
|
||||
$writer->writeUInt32BE($entryCount = count($this->_sampleSizeTable));
|
||||
if ($this->_sampleSize == 0) {
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$writer->writeUInt32BE($this->_sampleSizeTable[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
148
src/Zend/Media/Iso14496/Box/Stts.php
Normal file
148
src/Zend/Media/Iso14496/Box/Stts.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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>Decoding Time to Sample Box</i> contains a compact version of a table
|
||||
* that allows indexing from decoding time to sample number. Other tables give
|
||||
* sample sizes and pointers, from the sample number. Each entry in the table
|
||||
* gives the number of consecutive samples with the same time delta, and the
|
||||
* delta of those samples. By adding the deltas a complete time-to-sample map
|
||||
* may be built.
|
||||
*
|
||||
* The Decoding Time to Sample Box contains decode time delta's: DT(n+1) = DT(n)
|
||||
* + STTS(n) where STTS(n) is the (uncompressed) table entry for sample n.
|
||||
*
|
||||
* The sample entries are ordered by decoding time stamps; therefore the deltas
|
||||
* are all non-negative.
|
||||
*
|
||||
* The DT axis has a zero origin; DT(i) = SUM(for j=0 to i-1 of delta(j)), and
|
||||
* the sum of all deltas gives the length of the media in the track (not mapped
|
||||
* to the overall timescale, and not considering any edit list).
|
||||
*
|
||||
* The {@link Zend_Media_Iso14496_Box_Elst Edit List Box} provides the initial
|
||||
* CT value if it is non-empty (non-zero).
|
||||
*
|
||||
* @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_Stts extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var Array */
|
||||
private $_timeToSampleTable = 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);
|
||||
|
||||
$entryCount = $this->_reader->readUInt32BE();
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$this->_timeToSampleTable[$i] = array
|
||||
('sampleCount' => $this->_reader->readUInt32BE(),
|
||||
'sampleDelta' => $this->_reader->readUInt32BE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of values. Each entry is an array containing the
|
||||
* following keys.
|
||||
* o sampleCount -- an integer that counts the number of consecutive
|
||||
* samples that have the given duration.
|
||||
* o sampleDelta -- an integer that gives the delta of these samples in
|
||||
* the time-scale of the media.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getTimeToSampleTable()
|
||||
{
|
||||
return $this->_timeToSampleTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an array of values. Each entry must be an array containing the
|
||||
* following keys.
|
||||
* o sampleCount -- an integer that counts the number of consecutive
|
||||
* samples that have the given duration.
|
||||
* o sampleDelta -- an integer that gives the delta of these samples in
|
||||
* the time-scale of the media.
|
||||
*
|
||||
* @param Array $timeToSampleTable The array of values.
|
||||
*/
|
||||
public function setTimeToSampleTable($timeToSampleTable)
|
||||
{
|
||||
$this->_timeToSampleTable = $timeToSampleTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 4 + count($this->_timeToSampleTable) * 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt32BE($entryCount = count($this->_timeToSampleTable));
|
||||
for ($i = 1; $i <= $entryCount; $i++) {
|
||||
$writer->writeUInt32BE($this->_timeToSampleTable[$i]['sampleCount'])
|
||||
->writeUInt32BE
|
||||
($this->_timeToSampleTable[$i]['sampleDelta']);
|
||||
}
|
||||
}
|
||||
}
|
||||
122
src/Zend/Media/Iso14496/Box/Url.php
Normal file
122
src/Zend/Media/Iso14496/Box/Url.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?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';
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* This box is a URL data reference.
|
||||
*
|
||||
* @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_Url extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var string */
|
||||
private $_location;
|
||||
|
||||
/**
|
||||
* Indicates that the media data is in the same file as the Movie Box
|
||||
* containing this data reference.
|
||||
*/
|
||||
const SELF_CONTAINED = 1;
|
||||
|
||||
/**
|
||||
* 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->_location = $this->_reader->read
|
||||
($this->getOffset() + $this->getSize() -
|
||||
$this->_reader->getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->_location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location.
|
||||
*
|
||||
* @param string $location The location string.
|
||||
*/
|
||||
public function setLocation($location)
|
||||
{
|
||||
$this->_location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + strlen($this->_location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->write($this->_location);
|
||||
}
|
||||
}
|
||||
148
src/Zend/Media/Iso14496/Box/Urn.php
Normal file
148
src/Zend/Media/Iso14496/Box/Urn.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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';
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* This box is a URN data reference.
|
||||
*
|
||||
* @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_Urn extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var string */
|
||||
private $_name;
|
||||
|
||||
/** @var string */
|
||||
private $_location;
|
||||
|
||||
/**
|
||||
* Indicates that the media data is in the same file as the Movie Box
|
||||
* containing this data reference.
|
||||
*/
|
||||
const SELF_CONTAINED = 1;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
list ($this->_name, $this->_location) = preg_split
|
||||
("/\\x00/", $this->_reader->read
|
||||
($this->getOffset() + $this->getSize() -
|
||||
$this->_reader->getOffset()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param string $name The name.
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->_name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->_location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location.
|
||||
*
|
||||
* @param string $location The location.
|
||||
*/
|
||||
public function setLocation($location)
|
||||
{
|
||||
$this->_location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() +
|
||||
strlen($this->_name) + 1 + strlen($this->_location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeString8($this->_name, 1)
|
||||
->write($this->_location);
|
||||
}
|
||||
}
|
||||
153
src/Zend/Media/Iso14496/Box/Vmhd.php
Normal file
153
src/Zend/Media/Iso14496/Box/Vmhd.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?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>Video Media Header Box</i> contains general presentation information,
|
||||
* independent of the coding, for video media.
|
||||
*
|
||||
* @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_Vmhd extends Zend_Media_Iso14496_FullBox
|
||||
{
|
||||
/** @var integer */
|
||||
private $_graphicsMode = 0;
|
||||
|
||||
/** @var Array */
|
||||
private $_opcolor = array(0, 0, 0);
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
$this->setFlags(1);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_graphicsMode = $this->_reader->readUInt16BE();
|
||||
$this->_opcolor = array
|
||||
($this->_reader->readUInt16BE(),
|
||||
$this->_reader->readUInt16BE(),
|
||||
$this->_reader->readUInt16BE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composition mode for this video track, from the following
|
||||
* enumerated set, which may be extended by derived specifications:
|
||||
*
|
||||
* <ul>
|
||||
* <li>copy = 0 copy over the existing image</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getGraphicsMode()
|
||||
{
|
||||
return $this->_graphicsMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the composition mode for this video track.
|
||||
*
|
||||
* @param integer $graphicsMode The composition mode.
|
||||
*/
|
||||
public function setGraphicsMode($graphicsMode)
|
||||
{
|
||||
$this->_graphicsMode = $graphicsMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of 3 colour values (red, green, blue) available for use
|
||||
* by graphics modes.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getOpcolor()
|
||||
{
|
||||
return $this->_opcolor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the array of 3 colour values (red, green, blue) available for use
|
||||
* by graphics modes.
|
||||
*
|
||||
* @param Array $opcolor An array of 3 colour values
|
||||
*/
|
||||
public function setOpcolor($opcolor)
|
||||
{
|
||||
$this->_opcolor = $opcolor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the box heap size in bytes.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeapSize()
|
||||
{
|
||||
return parent::getHeapSize() + 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the box data.
|
||||
*
|
||||
* @param Zend_Io_Writer $writer The writer object.
|
||||
* @return void
|
||||
*/
|
||||
protected function _writeData($writer)
|
||||
{
|
||||
parent::_writeData($writer);
|
||||
$writer->writeUInt16BE($this->_graphicsMode)
|
||||
->writeUInt16BE($this->_opcolor[0])
|
||||
->writeUInt16BE($this->_opcolor[1])
|
||||
->writeUInt16BE($this->_opcolor[2]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user