Small fixes, improve documentation
git-svn-id: http://php-reader.googlecode.com/svn/trunk@89 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
149
src/ISO14496.php
149
src/ISO14496.php
@@ -7,12 +7,12 @@
|
|||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright notice,
|
* <li>Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
* <li>Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
* - Neither the name of the project workgroup nor the names of its
|
* <li>Neither the name of the project workgroup nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from this
|
* contributors may be used to endorse or promote products derived from this
|
||||||
* software without specific prior written permission.
|
* software without specific prior written permission.
|
||||||
*
|
*
|
||||||
@@ -57,6 +57,149 @@ require_once("ISO14496/Box.php");
|
|||||||
* general.
|
* general.
|
||||||
*
|
*
|
||||||
* The ISO Base Media File Format is a base format for media file formats.
|
* The ISO Base Media File Format is a base format for media file formats.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* An overall view of the normal encapsulation structure is provided in the
|
||||||
|
* following table.
|
||||||
|
*
|
||||||
|
* The table shows those boxes that may occur at the top-level in the left-most
|
||||||
|
* column; indentation is used to show possible containment. Thus, for example,
|
||||||
|
* a {@link ISO14496_Box_TKHD Track Header Box} is found in a
|
||||||
|
* {@link ISO14496_Box_TRAK Track Box}, which is found in a
|
||||||
|
* {@link ISO14496_Box_MOOV Movie Box}. Not all boxes need be used in all files;
|
||||||
|
* the mandatory boxes are marked with bold typeface. See the description of the
|
||||||
|
* individual boxes for a discussion of what must be assumed if the optional
|
||||||
|
* boxes are not present.
|
||||||
|
*
|
||||||
|
* User data objects shall be placed only in {@link ISO14496_Box_MOOV Movie} or
|
||||||
|
* {@link ISO14496_Box_TRAK Track Boxes}, and objects using an extended type may
|
||||||
|
* be placed in a wide variety of containers, not just the top level.
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li><b>ftyp</b> -- <i>{@link ISO14496_Box_FTYP File Type Box}</i>; file type and compatibility
|
||||||
|
* <li>pdin -- <i>{@link ISO14496_Box_PDIN Progressive Download Information Box}</i>
|
||||||
|
* <li><b>moov</b> -- <i>{@link ISO14496_Box_MOOV Movie Box}</i>; container for all the metadata
|
||||||
|
* <ul>
|
||||||
|
* <li><b>mvhd</b> -- <i>{@link ISO14496_Box_MVHD Movie Header Box}</i>; overall declarations
|
||||||
|
* <li><b>trak</b> -- <i>{@link ISO14496_Box_TRAK Track Box}</i>; container for an individual track or stream
|
||||||
|
* <ul>
|
||||||
|
* <li><b>tkhd</b> -- <i>{@link ISO14496_Box_TKHD Track Header Box}</i>; overall information about the track
|
||||||
|
* <li>tref -- <i>{@link ISO14496_Box_TREF Track Reference Box}</i>
|
||||||
|
* <li>edts -- <i>{@link ISO14496_Box_EDTS Edit Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>elst -- <i>{@link ISO14496_Box_ELST Edit List Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* <li><b>mdia</b> -- <i>{@link ISO14496_Box_MDIA Media Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>mdhd</b> -- <i>{@link ISO14496_Box_MDHD Media Header Box}</i>; overall information about the media
|
||||||
|
* <li><b>hdlr</b> -- <i>{@link ISO14496_Box_HDLR Handler Reference Box}</i>; declares the media type
|
||||||
|
* <li><b>minf</b> -- <i>{@link ISO14496_Box_MINF Media Information Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>vmhd -- <i>{@link ISO14496_Box_VMHD Video Media Header Box}</i>; overall information (video track only)
|
||||||
|
* <li>smhd -- <i>{@link ISO14496_Box_SMHD Sound Media Header Box}</i>; overall information (sound track only)
|
||||||
|
* <li>hmhd -- <i>{@link ISO14496_Box_HMHD Hint Media Header Box}</i>; overall information (hint track only)
|
||||||
|
* <li>nmhd -- <i>{@link ISO14496_Box_NMHD Null Media Header Box}</i>; overall information (some tracks only)
|
||||||
|
* <li><b>dinf</b> -- <i>{@link ISO14496_Box_DINF Data Information Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>dref</b> -- <i>{@link ISO14496_Box_DREF Data Reference Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* <li><b>stbl</b> -- <i>{@link ISO14496_Box_STBL Sample Table Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>stsd</b> -- <i>{@link ISO14496_Box_STSD Sample Descriptions Box}</i>
|
||||||
|
* <li><b>stts</b> -- <i>{@link ISO14496_Box_STTS Decoding Time To Sample Box}</i>
|
||||||
|
* <li>ctts -- <i>{@link ISO14496_Box_CTTS Composition Time To Sample Box}</i>
|
||||||
|
* <li><b>stsc</b> -- <i>{@link ISO14496_Box_STSC Sample To Chunk Box}</i>
|
||||||
|
* <li>stsz -- <i>{@link ISO14496_Box_STSZ Sample Size Box}</i>
|
||||||
|
* <li>stz2 -- <i>{@link ISO14496_Box_STZ2 Compact Sample Size Box}</i>
|
||||||
|
* <li><b>stco</b> -- <i>{@link ISO14496_Box_STCO Chunk Offset Box}</i>; 32-bit
|
||||||
|
* <li>co64 -- <i>{@link ISO14496_Box_CO64 Chunk Ooffset Box}</i>; 64-bit
|
||||||
|
* <li>stss -- <i>{@link ISO14496_Box_STSS Sync Sample Table Box}</i>
|
||||||
|
* <li>stsh -- <i>{@link ISO14496_Box_STSH Shadow Sync Sample Table Box}</i>
|
||||||
|
* <li>padb -- <i>{@link ISO14496_Box_PADB Padding Bits Box}</i>
|
||||||
|
* <li>stdp -- <i>{@link ISO14496_Box_STDP Sample Degradation Priority Box}</i>
|
||||||
|
* <li>sdtp -- <i>{@link ISO14496_Box_SDTP Independent and Disposable Samples Box}</i>
|
||||||
|
* <li>sbgp -- <i>{@link ISO14496_Box_SBGP Sample To Group Box}</i>
|
||||||
|
* <li>sgpd -- <i>{@link ISO14496_Box_SGPD Sample Group Description}</i>
|
||||||
|
* <li>subs -- <i>{@link ISO14496_Box_SUBS Sub-Sample Information Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
* <li>mvex -- <i>{@link ISO14496_Box_MVEX Movie Extends Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>mehd -- <i>{@link ISO14496_Box_MEHD Movie Extends Header Box}</i>
|
||||||
|
* <li><b>trex</b> -- <i>{@link ISO14496_Box_TREX Track Extends Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* <li>ipmc -- <i>{@link ISO14496_Box_IPMC IPMP Control Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* <li>moof -- <i>{@link ISO14496_Box_MOOF Movie Fragment Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>mfhd</b> -- <i>{@link ISO14496_Box_MFHD Movie Fragment Header Box}</i>
|
||||||
|
* <li>traf -- <i>{@link ISO14496_Box_TRAF Track Fragment Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>tfhd</b> -- <i>{@link ISO14496_Box_TFHD Track Fragment Header Box}</i>
|
||||||
|
* <li>trun -- <i>{@link ISO14496_Box_TRUN Track Fragment Run}</i>
|
||||||
|
* <li>sdtp -- <i>{@link ISO14496_Box_SDTP Independent and Disposable Samples}</i>
|
||||||
|
* <li>sbgp -- <i>{@link ISO14496_Box_SBGP SampleToGroup Box}</i>
|
||||||
|
* <li>subs -- <i>{@link ISO14496_Box_SUBS Sub-Sample Information Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
* <li>mfra -- <i>{@link ISO14496_Box_MFRA Movie Fragment Random Access Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>tfra -- <i>{@link ISO14496_Box_TFRA Track Fragment Random Access Box}</i>
|
||||||
|
* <li><b>mfro</b> -- <i>{@link ISO14496_Box_MFRO Movie Fragment Random Access Offset Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* <li>mdat -- <i>{@link ISO14496_Box_MDAT Media Data Box}</i>
|
||||||
|
* <li>free -- <i>{@link ISO14496_Box_FREE Free Space Box}</i>
|
||||||
|
* <li>skip -- <i>{@link ISO14496_Box_SKIP Free Space Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>udta -- <i>{@link ISO14496_Box_UDTA User Data Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>cprt -- <i>{@link ISO14496_Box_CPRT Copyright Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
* <li>meta -- <i>{@link ISO14496_Box_META The Meta Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li><b>hdlr</b> -- <i>{@link ISO14496_Box_HDLR Handler Reference Box}</i>; declares the metadata type
|
||||||
|
* <li>dinf -- <i>{@link ISO14496_Box_DINF Data Information Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>dref -- <i>{@link ISO14496_Box_DREF Data Reference Box}</i>; declares source(s) of metadata items
|
||||||
|
* </ul>
|
||||||
|
* <li>ipmc -- <i>{@link ISO14496_Box_IPMC IPMP Control Box}</i>
|
||||||
|
* <li>iloc -- <i>{@link ISO14496_Box_ILOC Item Location Box}</i>
|
||||||
|
* <li>ipro -- <i>{@link ISO14496_Box_IPRO Item Protection Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>sinf -- <i>{@link ISO14496_Box_SINF Protection Scheme Information Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>frma -- <i>{@link ISO14496_Box_FRMA Original Format Box}</i>
|
||||||
|
* <li>imif -- <i>{@link ISO14496_Box_IMIF IPMP Information Box}</i>
|
||||||
|
* <li>schm -- <i>{@link ISO14496_Box_SCHM Scheme Type Box}</i>
|
||||||
|
* <li>schi -- <i>{@link ISO14496_Box_SCHI Scheme Information Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
* <li>iinf -- <i>{@link ISO14496_Box_IINF Item Information Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>infe -- <i>{@link ISO14496_Box_INFE Item Information Entry Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* <li>xml -- <i>{@link ISO14496_Box_XML XML Box}</i>
|
||||||
|
* <li>bxml -- <i>{@link ISO14496_Box_BXML Binary XML Box}</i>
|
||||||
|
* <li>pitm -- <i>{@link ISO14496_Box_PITM Primary Item Reference Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* There are two non-standard extensions to the ISO 14496 standard that add the
|
||||||
|
* ability to include file meta information. Both the boxes reside under
|
||||||
|
* moov.udta.meta.
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li><i>moov</i> -- <i>{@link ISO14496_Box_MOOV Movie Box}</i>; container for all the metadata
|
||||||
|
* <li><i>udta</i> -- <i>{@link ISO14496_Box_UDTA User Data Box}</i>
|
||||||
|
* <li><i>meta</i> -- <i>{@link ISO14496_Box_META The Meta Box}</i>
|
||||||
|
* <ul>
|
||||||
|
* <li>ilst -- <i>{@link ISO14496_Box_ILST The iTunes/iPod Tag Container Box}</i>
|
||||||
|
* <li>id32 -- <i>{@link ISO14496_Box_ID32 The ID3v2 Box}</i>
|
||||||
|
* </ul>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @package php-reader
|
* @package php-reader
|
||||||
* @subpackage ISO 14496
|
* @subpackage ISO 14496
|
||||||
|
|||||||
@@ -242,11 +242,25 @@ class ISO14496_Box
|
|||||||
* @param string $name The box or field name.
|
* @param string $name The box or field name.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get($name)
|
||||||
|
{
|
||||||
if ($this->isContainer() && isset($this->_boxes[$name]))
|
if ($this->isContainer() && isset($this->_boxes[$name]))
|
||||||
return $this->_boxes[$name][0];
|
return $this->_boxes[$name][0];
|
||||||
if (method_exists($this, "get" . ucfirst($name)))
|
if (method_exists($this, "get" . ucfirst($name)))
|
||||||
return call_user_func(array($this, "get" . ucfirst($name)));
|
return call_user_func(array($this, "get" . ucfirst($name)));
|
||||||
throw new ISO14496_Exception("Unknown box/field: " . $name);
|
throw new ISO14496_Exception("Unknown box/field: " . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic function so that isset($obj->value) will work. This method checks
|
||||||
|
* whether the box is a container and contains a box that matches the
|
||||||
|
* identifier.
|
||||||
|
*
|
||||||
|
* @param string $name The box name.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function __isset($name)
|
||||||
|
{
|
||||||
|
return ($this->isContainer() && isset($this->_boxes[$name]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ final class ISO14496_Box_BXML extends ISO14496_Box_Full
|
|||||||
* the ISO Base Media file.
|
* the ISO Base Media file.
|
||||||
*
|
*
|
||||||
* @param Reader $reader The reader object.
|
* @param Reader $reader The reader object.
|
||||||
* @todo The sample flags could be parsed further
|
|
||||||
*/
|
*/
|
||||||
public function __construct($reader)
|
public function __construct($reader)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,15 +80,13 @@ final class ISO14496_Box_CO64 extends ISO14496_Box_Full
|
|||||||
|
|
||||||
$entryCount = $this->_reader->readUInt32BE();
|
$entryCount = $this->_reader->readUInt32BE();
|
||||||
for ($i = 1; $i < $entryCount; $i++)
|
for ($i = 1; $i < $entryCount; $i++)
|
||||||
$this->_chunkOffsetTable[$i] = array
|
$this->_chunkOffsetTable[$i] = $this->_reader->readInt64BE();
|
||||||
("chunkOffset" => $this->_reader->readInt64BE());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of values. Each entry is an array containing the following
|
* Returns an array of values. Each entry has the entry number as its index
|
||||||
* keys.
|
* and a 64 bit integer that gives the offset of the start of a chunk into
|
||||||
* o chunkOffset -- a 64 bit integer that gives the offset of the start of a
|
* its containing media file as its value.
|
||||||
* chunk into its containing media file.
|
|
||||||
*
|
*
|
||||||
* @return Array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ final class ISO14496_Box_ELST extends ISO14496_Box_Full
|
|||||||
* media time scale units, in composition time). If this field is set to
|
* media time scale units, in composition time). If this field is set to
|
||||||
* –1, it is an empty edit. The last edit in a track shall never be an
|
* –1, it is an empty edit. The last edit in a track shall never be an
|
||||||
* empty edit. Any difference between the duration in the
|
* empty edit. Any difference between the duration in the
|
||||||
* {@link ISO14496_Box_MVHD Movie Header Box}, and the track’s duration is
|
* {@link ISO14496_Box_MVHD Movie Header Box}, and the track's duration is
|
||||||
* expressed as an implicit empty edit at the end.
|
* expressed as an implicit empty edit at the end.
|
||||||
* o mediaRate: the relative rate at which to play the media corresponding
|
* o mediaRate: the relative rate at which to play the media corresponding
|
||||||
* to this edit segment. If this value is 0, then the edit is specifying
|
* to this edit segment. If this value is 0, then the edit is specifying
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ final class ISO14496_Box_HDLR extends ISO14496_Box_Full
|
|||||||
$this->_reader->skip(4);
|
$this->_reader->skip(4);
|
||||||
$this->_handlerType = $this->_reader->read(4);
|
$this->_handlerType = $this->_reader->read(4);
|
||||||
$this->_reader->skip(12);
|
$this->_reader->skip(12);
|
||||||
$this->_name = $this->_reader->read
|
$this->_name = $this->_reader->readString8
|
||||||
($this->_offset + $this->_size - $this->_reader->getOffset());
|
($this->_offset + $this->_size - $this->_reader->getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,4 +52,16 @@ require_once("ISO14496/Box.php");
|
|||||||
*/
|
*/
|
||||||
final class ISO14496_Box_MINF extends ISO14496_Box
|
final class ISO14496_Box_MINF extends ISO14496_Box
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructs the class with given parameters and reads box related data from
|
||||||
|
* the ISO Base Media file.
|
||||||
|
*
|
||||||
|
* @param Reader $reader The reader object.
|
||||||
|
*/
|
||||||
|
public function __construct($reader)
|
||||||
|
{
|
||||||
|
parent::__construct($reader);
|
||||||
|
$this->setContainer(true);
|
||||||
|
$this->constructBoxes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ final class ISO14496_Box_MVHD extends ISO14496_Box_Full
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length of the presentation in the indicated timescale. This
|
* Returns the length of the presentation in the indicated timescale. This
|
||||||
* property is derived from the presentation’s tracks: the value of this field
|
* property is derived from the presentation's tracks: the value of this field
|
||||||
* corresponds to the duration of the longest track in the presentation.
|
* corresponds to the duration of the longest track in the presentation.
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ final class ISO14496_Box_PITM extends ISO14496_Box_Full
|
|||||||
* the ISO Base Media file.
|
* the ISO Base Media file.
|
||||||
*
|
*
|
||||||
* @param Reader $reader The reader object.
|
* @param Reader $reader The reader object.
|
||||||
* @todo The sample flags could be parsed further
|
|
||||||
*/
|
*/
|
||||||
public function __construct($reader)
|
public function __construct($reader)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ require_once("ISO14496/Box/Full.php");
|
|||||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||||
* @version $Rev$
|
* @version $Rev$
|
||||||
*/
|
*/
|
||||||
final class ISO14496_Box_STGP extends ISO14496_Box_Full
|
final class ISO14496_Box_SBGP extends ISO14496_Box_Full
|
||||||
{
|
{
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
private $_groupingType;
|
private $_groupingType;
|
||||||
@@ -79,16 +79,14 @@ final class ISO14496_Box_STCO extends ISO14496_Box_Full
|
|||||||
parent::__construct($reader);
|
parent::__construct($reader);
|
||||||
|
|
||||||
$entryCount = $this->_reader->readUInt32BE();
|
$entryCount = $this->_reader->readUInt32BE();
|
||||||
for ($i = 0; $i < $entryCount; $i++)
|
for ($i = 1; $i < $entryCount; $i++)
|
||||||
$this->_chunkOffsetTable[] = array
|
$this->_chunkOffsetTable[$i] = $this->_reader->readUInt32BE();
|
||||||
("chunkOffset" => $this->_reader->readUInt32BE());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of values. Each entry is an array containing the following
|
* Returns an array of values. Each entry has the entry number as its index
|
||||||
* keys.
|
* and a 32 bit integer that gives the offset of the start of a chunk into
|
||||||
* o chunkOffset -- a 32 bit integer that gives the offset of the start of a
|
* its containing media file as its value.
|
||||||
* chunk into its containing media file.
|
|
||||||
*
|
*
|
||||||
* @return Array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -69,15 +69,13 @@ final class ISO14496_Box_STSS extends ISO14496_Box_Full
|
|||||||
|
|
||||||
$entryCount = $this->_reader->readUInt32BE();
|
$entryCount = $this->_reader->readUInt32BE();
|
||||||
for ($i = 1; $i < $entryCount; $i++)
|
for ($i = 1; $i < $entryCount; $i++)
|
||||||
$this->_syncSampleTable[$i] = array
|
$this->_syncSampleTable[$i] = $this->_reader->readUInt32BE();
|
||||||
("sampleNumber" => $this->_reader->readUInt32BE());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of values. Each entry is an array containing the following
|
* Returns an array of values. Each entry has the entry number as its index
|
||||||
* keys.
|
* and an integer that gives the numbers of the samples that are random access
|
||||||
* o sampleNumber -- gives the numbers of the samples that are random access
|
* points in the stream as its value.
|
||||||
* points in the stream.
|
|
||||||
*
|
*
|
||||||
* @return Array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ final class ISO14496_Box_TKHD extends ISO14496_Box_Full
|
|||||||
/**
|
/**
|
||||||
* Returns the duration of this track (in the timescale indicated in the
|
* Returns the duration of this track (in the timescale indicated in the
|
||||||
* {@link MVHD Movie Header Box}). The value of this field is equal to the sum
|
* {@link MVHD Movie Header Box}). The value of this field is equal to the sum
|
||||||
* of the durations of all of the track’s edits. If there is no edit list,
|
* of the durations of all of the track's edits. If there is no edit list,
|
||||||
* then the duration is the sum of the sample durations, converted into the
|
* then the duration is the sum of the sample durations, converted into the
|
||||||
* timescale in the {@link MVHD Movie Header Box}. If the duration of this
|
* timescale in the {@link MVHD Movie Header Box}. If the duration of this
|
||||||
* track cannot be determined then duration is set to all 32-bit maxint.
|
* track cannot be determined then duration is set to all 32-bit maxint.
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ final class ISO14496_Box_XML extends ISO14496_Box_Full
|
|||||||
* the ISO Base Media file.
|
* the ISO Base Media file.
|
||||||
*
|
*
|
||||||
* @param Reader $reader The reader object.
|
* @param Reader $reader The reader object.
|
||||||
* @todo The sample flags could be parsed further
|
|
||||||
*/
|
*/
|
||||||
public function __construct($reader)
|
public function __construct($reader)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -133,6 +133,62 @@ final class Transform
|
|||||||
return $int;
|
return $int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns signed 32-bit integer as little-endian ordered binary data.
|
||||||
|
*
|
||||||
|
* @param integer $value The input value.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toInt32LE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt32("\x00\x00\x00\x01") == 1)
|
||||||
|
return strrev(self::toInt32($value));
|
||||||
|
else
|
||||||
|
return self::toInt32($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns little-endian ordered binary data as signed 32-bit integer.
|
||||||
|
*
|
||||||
|
* @param string $value The binary data string.
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function fromInt32LE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt32("\x00\x00\x00\x01") == 1)
|
||||||
|
return self::fromInt32(strrev($value));
|
||||||
|
else
|
||||||
|
return self::fromInt32($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns signed 32-bit integer as big-endian ordered binary data.
|
||||||
|
*
|
||||||
|
* @param integer $value The input value.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toInt32BE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt32("\x00\x00\x00\x01") == 1)
|
||||||
|
return self::toInt32($value);
|
||||||
|
else
|
||||||
|
return strrev(self::toInt32($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns big-endian ordered binary data as signed 32-bit integer.
|
||||||
|
*
|
||||||
|
* @param string $value The binary data string.
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function fromInt32BE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt32("\x00\x00\x00\x01") == 1)
|
||||||
|
return self::fromInt32($value);
|
||||||
|
else
|
||||||
|
return self::fromInt32(strrev($value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns unsigned 32-bit integer as little-endian ordered binary data.
|
* Returns unsigned 32-bit integer as little-endian ordered binary data.
|
||||||
*
|
*
|
||||||
@@ -202,6 +258,62 @@ final class Transform
|
|||||||
return $int;
|
return $int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns signed 16-bit integer as little-endian ordered binary data.
|
||||||
|
*
|
||||||
|
* @param integer $value The input value.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toInt16LE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt16("\x00\x01") == 1)
|
||||||
|
return strrev(self::toInt16($value));
|
||||||
|
else
|
||||||
|
return self::toInt16($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns little-endian ordered binary data as signed 16-bit integer.
|
||||||
|
*
|
||||||
|
* @param string $value The binary data string.
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function fromInt16LE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt16("\x00\x01") == 1)
|
||||||
|
return self::fromInt16(strrev($value));
|
||||||
|
else
|
||||||
|
return self::fromInt16($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns signed 16-bit integer as big-endian ordered binary data.
|
||||||
|
*
|
||||||
|
* @param integer $value The input value.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toInt16BE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt16("\x00\x01") == 1)
|
||||||
|
return self::toInt16($value);
|
||||||
|
else
|
||||||
|
return strrev(self::toInt16($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns big-endian ordered binary data as signed 16-bit integer.
|
||||||
|
*
|
||||||
|
* @param string $value The binary data string.
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function fromInt16BE($value)
|
||||||
|
{
|
||||||
|
if (self::fromInt16("\x00\x01") == 1)
|
||||||
|
return self::fromInt16($value);
|
||||||
|
else
|
||||||
|
return self::fromInt16(strrev($value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns machine endian ordered binary data as unsigned 16-bit integer.
|
* Returns machine endian ordered binary data as unsigned 16-bit integer.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -70,6 +70,23 @@ final class TestTransform extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals
|
$this->assertEquals
|
||||||
(0x7fffffff, Transform::fromInt32(Transform::toInt32(0x7fffffff)));
|
(0x7fffffff, Transform::fromInt32(Transform::toInt32(0x7fffffff)));
|
||||||
|
$this->assertEquals(-1, Transform::fromInt32(Transform::toInt32(-1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testInt32LE()
|
||||||
|
{
|
||||||
|
$this->assertEquals(1, Transform::fromInt32LE("\x01\x00\x00\x00"));
|
||||||
|
$this->assertEquals
|
||||||
|
(0x7fffffff, Transform::fromInt32LE(Transform::toInt32LE(0x7fffffff)));
|
||||||
|
$this->assertEquals(-1, Transform::fromInt32LE(Transform::toInt32LE(-1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testInt32BE()
|
||||||
|
{
|
||||||
|
$this->assertEquals(1, Transform::fromInt32BE("\x00\x00\x00\x01"));
|
||||||
|
$this->assertEquals
|
||||||
|
(0x7fffffff, Transform::fromInt32BE(Transform::toInt32BE(0x7fffffff)));
|
||||||
|
$this->assertEquals(-1, Transform::fromInt32BE(Transform::toInt32BE(-1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testUInt32LE()
|
function testUInt32LE()
|
||||||
@@ -92,6 +109,23 @@ final class TestTransform extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals
|
$this->assertEquals
|
||||||
(0x7fff, Transform::fromInt16(Transform::toInt16(0x7fff)));
|
(0x7fff, Transform::fromInt16(Transform::toInt16(0x7fff)));
|
||||||
|
$this->assertEquals(-1, Transform::fromInt16(Transform::toInt16(-1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testInt16LE()
|
||||||
|
{
|
||||||
|
$this->assertEquals(1, Transform::fromInt16LE("\x01\x00"));
|
||||||
|
$this->assertEquals
|
||||||
|
(0x7fff, Transform::fromInt16LE(Transform::toInt16LE(0x7fff)));
|
||||||
|
$this->assertEquals(-1, Transform::fromInt16LE(Transform::toInt16LE(-1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testInt16BE()
|
||||||
|
{
|
||||||
|
$this->assertEquals(1, Transform::fromInt16BE("\x00\x01"));
|
||||||
|
$this->assertEquals
|
||||||
|
(0x7fff, Transform::fromInt16BE(Transform::toInt16BE(0x7fff)));
|
||||||
|
$this->assertEquals(-1, Transform::fromInt16BE(Transform::toInt16BE(-1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testUInt16LE()
|
function testUInt16LE()
|
||||||
|
|||||||
Reference in New Issue
Block a user