Add enhanced support for ASF files
git-svn-id: http://php-reader.googlecode.com/svn/trunk@108 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
109
src/ASF/Object/AdvancedContentEncryption.php
Normal file
109
src/ASF/Object/AdvancedContentEncryption.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Advanced Content Encryption Object</i> lets authors protect content by
|
||||
* using Next Generation Windows Media Digital Rights Management for Network
|
||||
* Devices.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_AdvancedContentEncryption extends ASF_Object
|
||||
{
|
||||
const WINDOWS_MEDIA_DRM_NETWORK_DEVICES =
|
||||
"7a079bb6-daa4-4e12-a5ca-91d3 8dc11a8d";
|
||||
|
||||
/** @var Array */
|
||||
private $_contentEncryptionRecords = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
$contentEncryptionRecordsCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $contentEncryptionRecordsCount; $i++) {
|
||||
$entry = array("systemId" => $this->_reader->readGUID(),
|
||||
"systemVersion" => $this->_reader->readUInt32LE(),
|
||||
"streamNumbers" => array());
|
||||
$encryptedObjectRecordCount = $this->_reader->readUInt16LE();
|
||||
for ($j = 0; $j < $encryptedObjectRecordCount; $j++) {
|
||||
$this->_reader->skip(4);
|
||||
$entry["streamNumbers"][] = $this->_reader->readUInt16LE();
|
||||
}
|
||||
$dataCount = $this->_reader->readUInt32LE();
|
||||
$entry["data"] = $this->_reader->read($dataCount);
|
||||
$this->_contentEncryptionRecords[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of content encryption records. Each record consists of the
|
||||
* following keys.
|
||||
*
|
||||
* o systemId -- Specifies the unique identifier for the content encryption
|
||||
* system.
|
||||
*
|
||||
* o systemVersion -- Specifies the version of the content encryption
|
||||
* system.
|
||||
*
|
||||
* o streamNumbers -- An array of stream numbers a particular Content
|
||||
* Encryption Record is associated with.
|
||||
*
|
||||
* o data -- The content protection data for this Content Encryption Record.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getContentEncryptionRecords()
|
||||
{
|
||||
return $this->_contentEncryptionRecords;
|
||||
}
|
||||
}
|
||||
100
src/ASF/Object/AdvancedMutualExclusion.php
Normal file
100
src/ASF/Object/AdvancedMutualExclusion.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Advanced Mutual Exclusion Object</i> identifies streams that have a
|
||||
* mutual exclusion relationship to each other (in other words, only one of the
|
||||
* streams within such a relationship can be streamed—the rest are ignored).
|
||||
* There should be one instance of this object for each set of objects that
|
||||
* contain a mutual exclusion relationship. The exclusion type is used so that
|
||||
* implementations can allow user selection of common choices, such as language.
|
||||
* This object must be used if any of the streams in the mutual exclusion
|
||||
* relationship are hidden.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_AdvancedMutualExclusion extends ASF_Object
|
||||
{
|
||||
const MUTEX_LANGUAGE = "d6e22a00-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_BITRATE = "d6e22a01-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_UNKNOWN = "d6e22a02-35da-11d1-9034-00a0c90349be";
|
||||
|
||||
/** @var string */
|
||||
private $_exclusionType;
|
||||
|
||||
/** @var Array */
|
||||
private $_streamNumbers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
$this->_exclusionType = $this->_reader->readGUID();
|
||||
$streamNumbersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $streamNumbersCount; $i++)
|
||||
$this->_streamNumbers[] = $this->_reader->readUInt16LE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nature of the mutual exclusion relationship.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExclusionType() { return $this->_exclusionType; }
|
||||
|
||||
/**
|
||||
* Returns an array of stream numbers.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getStreamNumbers() { return $this->_streamNumbers; }
|
||||
}
|
||||
133
src/ASF/Object/BandwidthSharing.php
Normal file
133
src/ASF/Object/BandwidthSharing.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Bandwidth Sharing Object</i> indicates streams that share bandwidth in
|
||||
* such a way that the maximum bandwidth of the set of streams is less than the
|
||||
* sum of the maximum bandwidths of the individual streams. There should be one
|
||||
* instance of this object for each set of objects that share bandwidth. Whether
|
||||
* or not this object can be used meaningfully is content-dependent.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_BandwidthSharing extends ASF_Object
|
||||
{
|
||||
const SHARING_EXCLUSIVE = "af6060aa-5197-11d2-b6af-00c04fd908e9";
|
||||
const SHARING_PARTIAL = "af6060ab-5197-11d2-b6af-00c04fd908e9";
|
||||
|
||||
/** @var string */
|
||||
private $_sharingType;
|
||||
|
||||
/** @var integer */
|
||||
private $_dataBitrate;
|
||||
|
||||
/** @var integer */
|
||||
private $_bufferSize;
|
||||
|
||||
/** @var Array */
|
||||
private $_streamNumbers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_sharingType = $this->_reader->readGUID();
|
||||
$this->_dataBitrate = $this->_reader->readUInt32LE();
|
||||
$this->_bufferSize = $this->_reader->readUInt32LE();
|
||||
$streamNumbersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $streamNumbersCount; $i++)
|
||||
$this->_streamNumbers[] = $this->_reader->readUInt16LE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of sharing relationship for this object. Two types are
|
||||
* predefined: SHARING_PARTIAL, in which any number of the streams in the
|
||||
* relationship may be streaming data at any given time; and
|
||||
* SHARING_EXCLUSIVE, in which only one of the streams in the relationship
|
||||
* may be streaming data at any given time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSharingType() { return $this->_sharingType; }
|
||||
|
||||
/**
|
||||
* Returns the leak rate R, in bits per second, of a leaky bucket that
|
||||
* contains the data portion of all of the streams, excluding all ASF Data
|
||||
* Packet overhead, without overflowing. The size of the leaky bucket is
|
||||
* specified by the value of the Buffer Size field. This value can be less
|
||||
* than the sum of all of the data bit rates in the
|
||||
* {@link ASF_Object_ExtendedStreamProperties Extended Stream Properties}
|
||||
* Objects for the streams contained in this bandwidth-sharing relationship.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getDataBitrate() { return $this->_dataBitrate; }
|
||||
|
||||
/**
|
||||
* Specifies the size B, in bits, of the leaky bucket used in the Data Bitrate
|
||||
* definition. This value can be less than the sum of all of the buffer sizes
|
||||
* in the {@link ASF_Object_ExtendedStreamProperties Extended Stream
|
||||
* Properties} Objects for the streams contained in this bandwidth-sharing
|
||||
* relationship.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBufferSize() { return $this->_bufferSize; }
|
||||
|
||||
/**
|
||||
* Returns an array of stream numbers.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getStreamNumbers() { return $this->_streamNumbers; }
|
||||
}
|
||||
@@ -1,100 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Bitrate Mutual Exclusion Object</i> identifies video streams that have
|
||||
* a mutual exclusion relationship to each other (in other words, only one of
|
||||
* the streams within such a relationship can be streamed at any given time and
|
||||
* the rest are ignored). One instance of this object must be present for each
|
||||
* set of objects that contains a mutual exclusion relationship. All video
|
||||
* streams in this relationship must have the same frame size. The exclusion
|
||||
* type is used so that implementations can allow user selection of common
|
||||
* choices, such as bit rate.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_BitrateMutualExclusion extends ASF_Object
|
||||
{
|
||||
const MUTEX_LANGUAGE = "d6e22a00-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_BITRATE = "d6e22a01-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_UNKNOWN = "d6e22a02-35da-11d1-9034-00a0c90349be";
|
||||
|
||||
/** @var string */
|
||||
private $_exclusionType;
|
||||
|
||||
/** @var Array */
|
||||
private $_streamNumbers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
$this->_exclusionType = $this->_reader->readGUID();
|
||||
$streamNumbersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $streamNumbersCount; $i++)
|
||||
$this->_streamNumbers[] = $this->_reader->readUInt16LE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nature of the mutual exclusion relationship.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExclusionType() { return $this->_exclusionType; }
|
||||
|
||||
/**
|
||||
* Returns an array of stream numbers.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getStreamNumbers() { return $this->_streamNumbers; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Bitrate Mutual Exclusion Object</i> identifies video streams that have
|
||||
* a mutual exclusion relationship to each other (in other words, only one of
|
||||
* the streams within such a relationship can be streamed at any given time and
|
||||
* the rest are ignored). One instance of this object must be present for each
|
||||
* set of objects that contains a mutual exclusion relationship. All video
|
||||
* streams in this relationship must have the same frame size. The exclusion
|
||||
* type is used so that implementations can allow user selection of common
|
||||
* choices, such as bit rate.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_BitrateMutualExclusion extends ASF_Object
|
||||
{
|
||||
const MUTEX_LANGUAGE = "d6e22a00-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_BITRATE = "d6e22a01-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_UNKNOWN = "d6e22a02-35da-11d1-9034-00a0c90349be";
|
||||
|
||||
/** @var string */
|
||||
private $_exclusionType;
|
||||
|
||||
/** @var Array */
|
||||
private $_streamNumbers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
$this->_exclusionType = $this->_reader->readGUID();
|
||||
$streamNumbersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $streamNumbersCount; $i++)
|
||||
$this->_streamNumbers[] = $this->_reader->readUInt16LE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nature of the mutual exclusion relationship.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExclusionType() { return $this->_exclusionType; }
|
||||
|
||||
/**
|
||||
* Returns an array of stream numbers.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getStreamNumbers() { return $this->_streamNumbers; }
|
||||
}
|
||||
|
||||
88
src/ASF/Object/Compatibility.php
Normal file
88
src/ASF/Object/Compatibility.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Compatibility Object</i> is reserved for future use.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_Compatibility extends ASF_Object
|
||||
{
|
||||
/** @var integer */
|
||||
private $_profile;
|
||||
|
||||
/** @var integer */
|
||||
private $_mode;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_profile = $this->_reader->readUInt8();
|
||||
$this->_mode = $this->_reader->readUInt8();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profile field. This field is reserved and is set to 2.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getProfile() { return $this->_profile; }
|
||||
|
||||
/**
|
||||
* Returns the mode field. This field is reserved and is set to 1.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getMode() { return $this->_mode; }
|
||||
}
|
||||
@@ -174,4 +174,22 @@ abstract class ASF_Object_Container extends ASF_Object
|
||||
}
|
||||
throw new ASF_Exception("Unknown field/object: " . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic function so that isset($obj->value) will work. This method checks
|
||||
* whether the object by given identifier is contained by this container.
|
||||
*
|
||||
* @param string $name The object name.
|
||||
* @return boolean
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
if (defined($constname = get_class($this) . "::" . strtoupper
|
||||
(preg_replace("/[A-Z]/", "_$0", $name)))) {
|
||||
$objects = $this->getObjectsByIdentifier(constant($constname));
|
||||
return isset($objects[0]);
|
||||
}
|
||||
else
|
||||
return isset($this->_objects[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,135 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Content Branding Object</i> stores branding data for an ASF file,
|
||||
* including information about a banner image and copyright associated with the
|
||||
* file.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ContentBranding extends ASF_Object
|
||||
{
|
||||
/** Indicates that there is no banner */
|
||||
const TYPE_NONE = 0;
|
||||
|
||||
/** Indicates that the data represents a bitmap */
|
||||
const TYPE_BMP = 1;
|
||||
|
||||
/** Indicates that the data represents a JPEG */
|
||||
const TYPE_JPEG = 2;
|
||||
|
||||
/** Indicates that the data represents a GIF */
|
||||
const TYPE_GIF = 3;
|
||||
|
||||
|
||||
/** @var integer */
|
||||
private $_bannerImageType;
|
||||
|
||||
/** @var string */
|
||||
private $_bannerImageData;
|
||||
|
||||
/** @var string */
|
||||
private $_bannerImageUrl;
|
||||
|
||||
/** @var string */
|
||||
private $_copyrightUrl;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_bannerImageType = $this->_reader->readUInt32LE();
|
||||
$bannerImageDataSize = $this->_reader->readUInt32LE();
|
||||
$this->_bannerImageData = $this->_reader->read($bannerImageDataSize);
|
||||
$bannerImageUrlLength = $this->_reader->readUInt32LE();
|
||||
$this->_bannerImageUrl = $this->_reader->read($bannerImageUrlLength);
|
||||
$copyrightUrlLength = $this->_reader->readUInt32LE();
|
||||
$this->_copyrightUrl = $this->_reader->read($copyrightUrlLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of data contained in the <i>Banner Image Data</i>. Valid
|
||||
* values are 0 to indicate that there is no banner image data; 1 to indicate
|
||||
* that the data represent a bitmap; 2 to indicate that the data represents a
|
||||
* JPEG; and 3 to indicate that the data represents a GIF. If this value is
|
||||
* set to 0, then the <i>Banner Image Data Size field is set to 0, and the
|
||||
* <i>Banner Image Data</i> field is empty.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBannerImageType() { return $this->_bannerImageType; }
|
||||
|
||||
/**
|
||||
* Returns the entire banner image, including the header for the appropriate
|
||||
* image format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBannerImageData() { return $this->_bannerImageData; }
|
||||
|
||||
/**
|
||||
* Returns, if present, a link to more information about the banner image.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBannerImageUrl() { return $this->_bannerImageUrl; }
|
||||
|
||||
/**
|
||||
* Returns, if present, a link to more information about the copyright for the
|
||||
* content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCopyrightUrl() { return $this->_copyrightUrl; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Content Branding Object</i> stores branding data for an ASF file,
|
||||
* including information about a banner image and copyright associated with the
|
||||
* file.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ContentBranding extends ASF_Object
|
||||
{
|
||||
/** Indicates that there is no banner */
|
||||
const TYPE_NONE = 0;
|
||||
|
||||
/** Indicates that the data represents a bitmap */
|
||||
const TYPE_BMP = 1;
|
||||
|
||||
/** Indicates that the data represents a JPEG */
|
||||
const TYPE_JPEG = 2;
|
||||
|
||||
/** Indicates that the data represents a GIF */
|
||||
const TYPE_GIF = 3;
|
||||
|
||||
|
||||
/** @var integer */
|
||||
private $_bannerImageType;
|
||||
|
||||
/** @var string */
|
||||
private $_bannerImageData;
|
||||
|
||||
/** @var string */
|
||||
private $_bannerImageUrl;
|
||||
|
||||
/** @var string */
|
||||
private $_copyrightUrl;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_bannerImageType = $this->_reader->readUInt32LE();
|
||||
$bannerImageDataSize = $this->_reader->readUInt32LE();
|
||||
$this->_bannerImageData = $this->_reader->read($bannerImageDataSize);
|
||||
$bannerImageUrlLength = $this->_reader->readUInt32LE();
|
||||
$this->_bannerImageUrl = $this->_reader->read($bannerImageUrlLength);
|
||||
$copyrightUrlLength = $this->_reader->readUInt32LE();
|
||||
$this->_copyrightUrl = $this->_reader->read($copyrightUrlLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of data contained in the <i>Banner Image Data</i>. Valid
|
||||
* values are 0 to indicate that there is no banner image data; 1 to indicate
|
||||
* that the data represent a bitmap; 2 to indicate that the data represents a
|
||||
* JPEG; and 3 to indicate that the data represents a GIF. If this value is
|
||||
* set to 0, then the <i>Banner Image Data Size field is set to 0, and the
|
||||
* <i>Banner Image Data</i> field is empty.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBannerImageType() { return $this->_bannerImageType; }
|
||||
|
||||
/**
|
||||
* Returns the entire banner image, including the header for the appropriate
|
||||
* image format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBannerImageData() { return $this->_bannerImageData; }
|
||||
|
||||
/**
|
||||
* Returns, if present, a link to more information about the banner image.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBannerImageUrl() { return $this->_bannerImageUrl; }
|
||||
|
||||
/**
|
||||
* Returns, if present, a link to more information about the copyright for the
|
||||
* content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCopyrightUrl() { return $this->_copyrightUrl; }
|
||||
}
|
||||
|
||||
@@ -1,117 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Content Encryption Object</i> lets authors protect content by using
|
||||
* Microsoft® Digital Rights Manager version 1.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ContentEncryption extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_secretData;
|
||||
|
||||
/** @var string */
|
||||
private $_protectionType;
|
||||
|
||||
/** @var string */
|
||||
private $_keyId;
|
||||
|
||||
/** @var string */
|
||||
private $_licenseUrl;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$secretDataLength = $this->_reader->readUInt32LE();
|
||||
$this->_secretData = $this->_reader->read($secretDataLength);
|
||||
$protectionTypeLength = $this->_reader->readUInt32LE();
|
||||
$this->_protectionType = $this->_reader->readString8($protectionTypeLength);
|
||||
$keyIdLength = $this->_reader->readUInt32LE();
|
||||
$this->_keyId = $this->_reader->readString8($keyIdLength);
|
||||
$licenseUrlLength = $this->_reader->readUInt32LE();
|
||||
$this->_licenseUrl = $this->_reader->readString8($licenseUrlLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the secret data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSecretData() { return $this->_secretData; }
|
||||
|
||||
/**
|
||||
* Returns the type of protection mechanism used. The value of this field
|
||||
* is set to "DRM".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProtectionType() { return $this->_protectionType; }
|
||||
|
||||
/**
|
||||
* Returns the key ID used.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeyId() { return $this->_keyId; }
|
||||
|
||||
/**
|
||||
* Returns the URL from which a license to manipulate the content can be
|
||||
* acquired.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLicenseUrl() { return $this->_licenseUrl; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Content Encryption Object</i> lets authors protect content by using
|
||||
* Microsoft® Digital Rights Manager version 1.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ContentEncryption extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_secretData;
|
||||
|
||||
/** @var string */
|
||||
private $_protectionType;
|
||||
|
||||
/** @var string */
|
||||
private $_keyId;
|
||||
|
||||
/** @var string */
|
||||
private $_licenseUrl;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$secretDataLength = $this->_reader->readUInt32LE();
|
||||
$this->_secretData = $this->_reader->read($secretDataLength);
|
||||
$protectionTypeLength = $this->_reader->readUInt32LE();
|
||||
$this->_protectionType = $this->_reader->readString8($protectionTypeLength);
|
||||
$keyIdLength = $this->_reader->readUInt32LE();
|
||||
$this->_keyId = $this->_reader->readString8($keyIdLength);
|
||||
$licenseUrlLength = $this->_reader->readUInt32LE();
|
||||
$this->_licenseUrl = $this->_reader->readString8($licenseUrlLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the secret data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSecretData() { return $this->_secretData; }
|
||||
|
||||
/**
|
||||
* Returns the type of protection mechanism used. The value of this field
|
||||
* is set to "DRM".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProtectionType() { return $this->_protectionType; }
|
||||
|
||||
/**
|
||||
* Returns the key ID used.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeyId() { return $this->_keyId; }
|
||||
|
||||
/**
|
||||
* Returns the URL from which a license to manipulate the content can be
|
||||
* acquired.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLicenseUrl() { return $this->_licenseUrl; }
|
||||
}
|
||||
|
||||
126
src/ASF/Object/Data.php
Normal file
126
src/ASF/Object/Data.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
require_once("ASF/Object/Data/Packet.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Data Object</i> contains all of the <i>Data Packet</i>s for a file.
|
||||
* These Data Packets are organized in terms of increasing send times. A <i>Data
|
||||
* Packet</i> can contain interleaved data from several digital media streams.
|
||||
* This data can consist of entire objects from one or more streams.
|
||||
* Alternatively, it can consist of partial objects (fragmentation).
|
||||
*
|
||||
* Capabilities provided within the interleave packet definition include:
|
||||
* o Single or multiple payload types per Data Packet
|
||||
* o Fixed-size Data Packets
|
||||
* o Error correction information (optional)
|
||||
* o Clock information (optional)
|
||||
* o Redundant sample information, such as presentation time stamp (optional)
|
||||
*
|
||||
* @todo Implement optional support for ASF Data Packet parsing
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_Data extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_fileId;
|
||||
|
||||
/** @var integer */
|
||||
private $_totalDataPackets;
|
||||
|
||||
/** @var Array */
|
||||
private $_dataPackets;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_fileId = $this->_reader->readGUID();
|
||||
$this->_totalDataPackets = $this->_reader->readInt64LE();
|
||||
$this->_reader->skip(2);
|
||||
/* Data packets are not supported
|
||||
* for ($i = 0; $i < $this->_totalDataPackets; $i++) {
|
||||
* $this->_dataPackets[] = new ASF_Object_Data_Packet($reader);
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique identifier for this ASF file. The value of this field
|
||||
* is changed every time the file is modified in any way. The value of this
|
||||
* field is identical to the value of the <i>File ID</i> field of the
|
||||
* <i>Header Object</i>.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileId() { return $this->_fileId; }
|
||||
|
||||
/**
|
||||
* Returns the number of ASF Data Packet entries that exist within the <i>Data
|
||||
* Object</i>. It must be equal to the <i>Data Packet Count</i> field in the
|
||||
* <i>File Properties Object</i>. The value of this field is invalid if the
|
||||
* broadcast flag field of the <i>File Properties Object</i> is set to 1.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getTotalDataPackets() { return $this->_endTime; }
|
||||
|
||||
/**
|
||||
* Returns an array of Data Packets.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getDataPackets()
|
||||
{
|
||||
throw new ASF_Exception("Data packets are not parsed due to optimization.");
|
||||
}
|
||||
}
|
||||
@@ -1,91 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Digital Signature Object</i> lets authors sign the portion of their
|
||||
* header that lies between the end of the <i>File Properties Object</i> and the
|
||||
* beginning of the <i>Digital Signature Object</i>.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_DigitalSignature extends ASF_Object
|
||||
{
|
||||
/** @var integer */
|
||||
private $_signatureType;
|
||||
|
||||
/** @var string */
|
||||
private $_signatureData;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_signatureType = $this->_reader->readUInt32LE();
|
||||
$signatureDataLength = $this->_reader->readUInt32LE();
|
||||
$this->_signatureData = $this->_reader->read($signatureDataLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of digital signature used. This field is set to 2.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSignatureType() { return $this->_signatureType; }
|
||||
|
||||
/**
|
||||
* Returns the digital signature data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSignatureData() { return $this->_signatureData; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Digital Signature Object</i> lets authors sign the portion of their
|
||||
* header that lies between the end of the <i>File Properties Object</i> and the
|
||||
* beginning of the <i>Digital Signature Object</i>.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_DigitalSignature extends ASF_Object
|
||||
{
|
||||
/** @var integer */
|
||||
private $_signatureType;
|
||||
|
||||
/** @var string */
|
||||
private $_signatureData;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_signatureType = $this->_reader->readUInt32LE();
|
||||
$signatureDataLength = $this->_reader->readUInt32LE();
|
||||
$this->_signatureData = $this->_reader->read($signatureDataLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of digital signature used. This field is set to 2.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSignatureType() { return $this->_signatureType; }
|
||||
|
||||
/**
|
||||
* Returns the digital signature data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSignatureData() { return $this->_signatureData; }
|
||||
}
|
||||
|
||||
@@ -1,100 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Error Correction Object</i> defines the error correction method. This
|
||||
* enables different error correction schemes to be used during content
|
||||
* creation. The <i>Error Correction Object</i> contains provisions for opaque
|
||||
* information needed by the error correction engine for recovery. For example,
|
||||
* if the error correction scheme were a simple N+1 parity scheme, then the
|
||||
* value of N would have to be available in this object.
|
||||
*
|
||||
* Note that this does not refer to the same thing as the <i>Error Correction
|
||||
* Type</i> field in the <i>{@link ASF_Object_StreamProperties Stream Properties
|
||||
* Object}</i>.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ErrorCorrection extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_type;
|
||||
|
||||
/** @var string */
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_type = $this->_reader->readGUID();
|
||||
$dataLength = $this->_reader->readUInt32LE();
|
||||
$this->_data = $this->_reader->read($dataLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of error correction.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType() { return $this->_type; }
|
||||
|
||||
/**
|
||||
* Returns the data specific to the error correction scheme. The structure for
|
||||
* the <i>Error Correction Data</i> field is determined by the value stored in
|
||||
* the <i>Error Correction Type</i> field.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getData() { return $this->_data; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Error Correction Object</i> defines the error correction method. This
|
||||
* enables different error correction schemes to be used during content
|
||||
* creation. The <i>Error Correction Object</i> contains provisions for opaque
|
||||
* information needed by the error correction engine for recovery. For example,
|
||||
* if the error correction scheme were a simple N+1 parity scheme, then the
|
||||
* value of N would have to be available in this object.
|
||||
*
|
||||
* Note that this does not refer to the same thing as the <i>Error Correction
|
||||
* Type</i> field in the <i>{@link ASF_Object_StreamProperties Stream Properties
|
||||
* Object}</i>.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ErrorCorrection extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_type;
|
||||
|
||||
/** @var string */
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_type = $this->_reader->readGUID();
|
||||
$dataLength = $this->_reader->readUInt32LE();
|
||||
$this->_data = $this->_reader->read($dataLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of error correction.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType() { return $this->_type; }
|
||||
|
||||
/**
|
||||
* Returns the data specific to the error correction scheme. The structure for
|
||||
* the <i>Error Correction Data</i> field is determined by the value stored in
|
||||
* the <i>Error Correction Type</i> field.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getData() { return $this->_data; }
|
||||
}
|
||||
|
||||
@@ -111,4 +111,12 @@ final class ASF_Object_ExtendedContentDescription extends ASF_Object
|
||||
return $this->_contentDescriptors[$name];
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an associate array of all the descriptors defined having the names
|
||||
* of the descriptors as the keys.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getDescriptors() { return $this->_contentDescriptors; }
|
||||
}
|
||||
|
||||
@@ -1,80 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Extended Content Encryption Object</i> lets authors protect content by
|
||||
* using the Windows Media Rights Manager 7 Software Development Kit (SDK).
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ExtendedContentEncryption extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$dataSize = $this->_reader->readUInt32LE();
|
||||
$this->_data = $this->_reader->read($dataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of bytes required by the DRM client to manipulate the
|
||||
* protected content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getData() { return $this->_data; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Extended Content Encryption Object</i> lets authors protect content by
|
||||
* using the Windows Media Rights Manager 7 Software Development Kit (SDK).
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ExtendedContentEncryption extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$dataSize = $this->_reader->readUInt32LE();
|
||||
$this->_data = $this->_reader->read($dataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of bytes required by the DRM client to manipulate the
|
||||
* protected content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getData() { return $this->_data; }
|
||||
}
|
||||
|
||||
@@ -1,405 +1,418 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Extended Stream Properties Object</i> defines additional optional
|
||||
* properties and characteristics of a digital media stream that are not
|
||||
* described in the <i>Stream Properties Object</i>.
|
||||
*
|
||||
* Typically, the basic <i>Stream Properties Object</i> is present in the
|
||||
* <i>Header Object</i>, and the <i>Extended Stream Properties Object</i> is
|
||||
* present in the <i>Header Extension Object</i>. Sometimes, however, the
|
||||
* <i>Stream Properties Object</i> for a stream may be embedded inside the
|
||||
* <i>Extended Stream Properties Object</i> for that stream. This approach
|
||||
* facilitates the creation of backward-compatible content.
|
||||
*
|
||||
* This object has an optional provision to include application-specific or
|
||||
* implementation-specific data attached to the payloads of each digital media
|
||||
* sample stored within a <i>Data Packet</i>. This data can be looked at as
|
||||
* digital media sample properties and is stored in the <i>Replicated Data</i>
|
||||
* field of a payload header. The <i>Payload Extension Systems</i> fields of the
|
||||
* <i>Extended Stream Properties Object</i> describes what this data is and is
|
||||
* necessary for that data to be parsed, if present.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ExtendedStreamProperties extends ASF_Object
|
||||
{
|
||||
/**
|
||||
* Indicates, if set, that this digital media stream, if sent over a network,
|
||||
* must be carried over a reliable data communications transport mechanism.
|
||||
* This should be set for streams that cannot recover after a lost media
|
||||
* object.
|
||||
*/
|
||||
const RELIABLE = 1;
|
||||
|
||||
/**
|
||||
* This flag should be set only if the stream is seekable, either by using an
|
||||
* index object or by estimating according to bit rate (as can sometimes be
|
||||
* done with audio). This flag pertains to this stream only rather than to the
|
||||
* entire file.
|
||||
*/
|
||||
const SEEKABLE = 2;
|
||||
|
||||
/**
|
||||
* Indicates, if set, that the stream does not contain any cleanpoints. A
|
||||
* cleanpoint is any point at which playback could begin without having seen
|
||||
* the previous media objects. For streams that use key frames, the key frames
|
||||
* would be the cleanpoints.
|
||||
*/
|
||||
const NO_CLEANPOINT = 4;
|
||||
|
||||
/**
|
||||
* Specifies, if set, that when a stream is joined in mid-transmission, all
|
||||
* information from the most recent cleanpoint up to the current time should
|
||||
* be sent before normal streaming begins at the current time. The default
|
||||
* behavior (when this flag is not set) is to send only the data starting at
|
||||
* the current time. This flag should only be set for streams that are coming
|
||||
* from a live source.
|
||||
*/
|
||||
const RESEND_LIVE_CLEANPOINTS = 8;
|
||||
|
||||
const AUDIO_MEDIA = "f8699e40-5b4d-11cf-a8fd-00805f5c442b";
|
||||
const VIDEO_MEDIA = "bc19efc0-5b4d-11cf-a8fd-00805f5c442b";
|
||||
const COMMAND_MEDIA = "59dacfc0-59e6-11d0-a3ac-00a0c90348f6";
|
||||
const JFIF_MEDIA = "b61be100-5b4e-11cf-a8fD-00805f5c442b";
|
||||
const DEGRADABLE_JPEG_MEDIA = "35907dE0-e415-11cf-a917-00805f5c442b";
|
||||
const FILE_TRANSFER_MEDIA = "91bd222c-f21c-497a-8b6d-5aa86bfc0185";
|
||||
const BINARY_MEDIA = "3afb65e2-47ef-40f2-ac2c-70a90d71d343";
|
||||
|
||||
const NO_ERROR_CORRECTION = "20fb5700-5b55-11cf-a8fd-00805f5c442b";
|
||||
const AUDIO_SPREAD = "bfc3cd50-618f-11cf-8bb2-00aa00b4e220";
|
||||
|
||||
/** @var integer */
|
||||
private $_startTime;
|
||||
|
||||
/** @var integer */
|
||||
private $_endTime;
|
||||
|
||||
/** @var integer */
|
||||
private $_dataBitrate;
|
||||
|
||||
/** @var integer */
|
||||
private $_bufferSize;
|
||||
|
||||
/** @var integer */
|
||||
private $_initialBufferFullness;
|
||||
|
||||
/** @var integer */
|
||||
private $_alternateDataBitrate;
|
||||
|
||||
/** @var integer */
|
||||
private $_alternateBufferSize;
|
||||
|
||||
/** @var integer */
|
||||
private $_alternateInitialBufferFullness;
|
||||
|
||||
/** @var integer */
|
||||
private $_maximumObjectSize;
|
||||
|
||||
/** @var integer */
|
||||
private $_flags;
|
||||
|
||||
/** @var integer */
|
||||
private $_streamNumber;
|
||||
|
||||
/** @var integer */
|
||||
private $_streamLanguageIndex;
|
||||
|
||||
/** @var integer */
|
||||
private $_averageTimePerFrame;
|
||||
|
||||
/** @var Array */
|
||||
private $_streamNames = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_payloadExtensionSystems = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_startTime = $this->_reader->readInt64LE();
|
||||
$this->_endTime = $this->_reader->readInt64LE();
|
||||
$this->_dataBitrate = $this->_reader->readUInt32LE();
|
||||
$this->_bufferSize = $this->_reader->readUInt32LE();
|
||||
$this->_initialBufferFullness = $this->_reader->readUInt32LE();
|
||||
$this->_alternateDataBitrate = $this->_reader->readUInt32LE();
|
||||
$this->_alternateBufferSize = $this->_reader->readUInt32LE();
|
||||
$this->_alternateInitialBufferFullness = $this->_reader->readUInt32LE();
|
||||
$this->_maximumObjectSize = $this->_reader->readUInt32LE();
|
||||
$this->_flags = $this->_reader->readUInt32LE();
|
||||
$this->_streamNumber = $this->_reader->readUInt16LE();
|
||||
$this->_streamLanguageIndex = $this->_reader->readUInt16LE();
|
||||
$this->_averageTimePerFrame = $this->_reader->readInt64LE();
|
||||
$streamNameCount = $this->_reader->readUInt16LE();
|
||||
$payloadExtensionSystemCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $streamNameCount; $i++) {
|
||||
$streamName = array("languageIndex" => $this->_reader->readUInt16LE());
|
||||
$streamNameLength = $this->_reader->readUInt16LE();
|
||||
$streamName["streamName"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($streamNameLength));
|
||||
$this->_streamNames[] = $streamName;
|
||||
}
|
||||
for ($i = 0; $i < $payloadExtensionSystemCount; $i++) {
|
||||
$payloadExtensionSystem = array
|
||||
("extensionSystemId" => $this->_reader->readGUID(),
|
||||
"extensionDataSize" => $this->_reader->readUInt16LE());
|
||||
$extensionSystemInfoLength = $this->_reader->readUInt32LE();
|
||||
$payloadExtensionSystem["extensionSystemInfo"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($extensionSystemInfoLength));
|
||||
$this->_payloadExtensionSystems[] = $payloadExtensionSystem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the presentation time of the first object, indicating where this
|
||||
* digital media stream starts within the context of the timeline of the ASF
|
||||
* file as a whole. This time value corresponds to presentation times as they
|
||||
* appear in the data packets (adjusted by the preroll). This field is given
|
||||
* in units of milliseconds and can optionally be set to 0, in which case it
|
||||
* will be ignored.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStartTime() { return $this->_startTime; }
|
||||
|
||||
/**
|
||||
* Returns the presentation time of the last object plus the duration of play,
|
||||
* indicating where this digital media stream ends within the context of the
|
||||
* timeline of the ASF file as a whole. This time value corresponds to
|
||||
* presentation times as they appear in the data packets (adjusted by the
|
||||
* preroll). This field is given in units of milliseconds and can optionally
|
||||
* be set to 0, in which case it will be ignored.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getEndTime() { return $this->_endTime; }
|
||||
|
||||
/**
|
||||
* Returns the leak rate R, in bits per second, of a leaky bucket that
|
||||
* contains the data portion of the stream without overflowing, excluding all
|
||||
* ASF Data Packet overhead. The size of the leaky bucket is specified by the
|
||||
* value of the <i>Buffer Size</i> field. This field has a non-zero value.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getDataBitrate() { return $this->_dataBitrate; }
|
||||
|
||||
/**
|
||||
* Returns the size B, in milliseconds, of the leaky bucket used in the
|
||||
* <i>Data Bitrate</i> definition.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBufferSize() { return $this->_bufferSize; }
|
||||
|
||||
/**
|
||||
* Returns the initial fullness, in milliseconds, of the leaky bucket used in
|
||||
* the <i>Data Bitrate</i> definition. This is the fullness of the buffer at
|
||||
* the instant before the first bit in the stream is dumped into the bucket.
|
||||
* Typically, this value is set to 0. This value shall not exceed the value in
|
||||
* the <i>Buffer Size</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getInitialBufferFullness()
|
||||
{
|
||||
return $this->_initialBufferFullness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the leak rate RAlt, in bits per second, of a leaky bucket that
|
||||
* contains the data portion of the stream without overflowing, excluding all
|
||||
* ASF <i>Data Packet</i> overhead. The size of the leaky bucket is specified
|
||||
* by the value of the <i>Alternate Buffer Size</i> field. This value is
|
||||
* relevant in most scenarios where the bit rate is not exactly constant, but
|
||||
* it is especially useful for streams that have highly variable bit rates.
|
||||
* This field can optionally be set to the same value as the <i>Data
|
||||
* Bitrate</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlternateDataBitrate()
|
||||
{
|
||||
return $this->_alternateDataBitrate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size BAlt, in milliseconds, of the leaky bucket used in the
|
||||
* <i>Alternate Data Bitrate</i> definition. This value is relevant in most
|
||||
* scenarios where the bit rate is not exactly constant, but it is especially
|
||||
* useful for streams that have highly variable bit rates. This field can
|
||||
* optionally be set to the same value as the <i>Buffer Size</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlternateBufferSize()
|
||||
{
|
||||
return $this->_alternateBufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the initial fullness, in milliseconds, of the leaky bucket used in
|
||||
* the <i>Alternate Data Bitrate</i> definition. This is the fullness of the
|
||||
* buffer at the instant before the first bit in the stream is dumped into the
|
||||
* bucket. Typically, this value is set to 0. This value does not exceed the
|
||||
* value of the <i>Alternate Buffer Size</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlternateInitialBufferFullness()
|
||||
{
|
||||
return $this->_alternateInitialBufferFullness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum size of the largest sample stored in the data packets
|
||||
* for a stream. A value of 0 means unknown.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getMaximumObjectSize()
|
||||
{
|
||||
return $this->_maximumObjectSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the average time duration, measured in 100-nanosecond units, of
|
||||
* each frame. This number should be rounded to the nearest integer. This
|
||||
* field can optionally be set to 0 if the average time per frame is unknown
|
||||
* or unimportant. It is recommended that this field be set for video.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAverageTimePerFrame()
|
||||
{
|
||||
return $this->_averageTimePerFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of this stream. 0 is an invalid stream number (that is,
|
||||
* other <i>Header Objects</i> use stream number 0 to refer to the entire file
|
||||
* as a whole rather than to a specific media stream within the file). Valid
|
||||
* values are between 1 and 127.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStreamNumber()
|
||||
{
|
||||
return $this->_streamNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language, if any, which the content of the stream uses or
|
||||
* assumes. Refer to the {@link LanguageList Language List Object} description
|
||||
* for the details concerning how the <i>Stream Language Index</i> and
|
||||
* <i>Language Index</i> fields should be used. Note that this is an index
|
||||
* into the languages listed in the <i>Language List Object</i> rather than a
|
||||
* language identifier.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStreamLanguageIndex()
|
||||
{
|
||||
return $this->_streamLanguageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Stream Names. Each stream name instance is potentially
|
||||
* localized into a specific language. The <i>Language Index</i> field
|
||||
* indicates the language in which the <i>Stream Name</i> has been written.
|
||||
*
|
||||
* The array contains the following keys:
|
||||
* o languageIndex -- The language index
|
||||
* o streamName -- The localized stream name
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getStreamNames()
|
||||
{
|
||||
return $this->_streamNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of payload extension systems. Payload extensions provide a
|
||||
* way for content creators to specify kinds of data that will appear in the
|
||||
* payload header for every payload from this stream. This system is used when
|
||||
* stream properties must be conveyed at the media object level. The
|
||||
* <i>Replicated Data</i> bytes in the payload header will contain these
|
||||
* properties in the order in which the <i>Payload Extension Systems</i>
|
||||
* appear in this object. A <i>Payload Extension System</i> must appear in the
|
||||
* <i>Extended Stream Properties Object</i> for each type of per-media-object
|
||||
* properties that will appear with the payloads for this stream.
|
||||
*
|
||||
* The array contains the following keys:
|
||||
* o extensionSystemId -- Specifies a unique identifier for the extension
|
||||
* system.
|
||||
* o extensionDataSize -- Specifies the fixed size of the extension data for
|
||||
* this system that will appear in the replicated data alongside every
|
||||
* payload for this stream. If this extension system uses variable-size
|
||||
* data, then this should be set to 0xffff. Note, however, that replicated
|
||||
* data length is limited to 255 bytes, which limits the total size of all
|
||||
* extension systems for a particular stream.
|
||||
* o extensionSystemInfo -- Specifies additional information to describe
|
||||
* this extension system (optional).
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getPayloadExtensionSystems()
|
||||
{
|
||||
return $this->_payloadExtensionSystems;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Extended Stream Properties Object</i> defines additional optional
|
||||
* properties and characteristics of a digital media stream that are not
|
||||
* described in the <i>Stream Properties Object</i>.
|
||||
*
|
||||
* Typically, the basic <i>Stream Properties Object</i> is present in the
|
||||
* <i>Header Object</i>, and the <i>Extended Stream Properties Object</i> is
|
||||
* present in the <i>Header Extension Object</i>. Sometimes, however, the
|
||||
* <i>Stream Properties Object</i> for a stream may be embedded inside the
|
||||
* <i>Extended Stream Properties Object</i> for that stream. This approach
|
||||
* facilitates the creation of backward-compatible content.
|
||||
*
|
||||
* This object has an optional provision to include application-specific or
|
||||
* implementation-specific data attached to the payloads of each digital media
|
||||
* sample stored within a <i>Data Packet</i>. This data can be looked at as
|
||||
* digital media sample properties and is stored in the <i>Replicated Data</i>
|
||||
* field of a payload header. The <i>Payload Extension Systems</i> fields of the
|
||||
* <i>Extended Stream Properties Object</i> describes what this data is and is
|
||||
* necessary for that data to be parsed, if present.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ExtendedStreamProperties extends ASF_Object
|
||||
{
|
||||
/**
|
||||
* Indicates, if set, that this digital media stream, if sent over a network,
|
||||
* must be carried over a reliable data communications transport mechanism.
|
||||
* This should be set for streams that cannot recover after a lost media
|
||||
* object.
|
||||
*/
|
||||
const RELIABLE = 1;
|
||||
|
||||
/**
|
||||
* This flag should be set only if the stream is seekable, either by using an
|
||||
* index object or by estimating according to bit rate (as can sometimes be
|
||||
* done with audio). This flag pertains to this stream only rather than to the
|
||||
* entire file.
|
||||
*/
|
||||
const SEEKABLE = 2;
|
||||
|
||||
/**
|
||||
* Indicates, if set, that the stream does not contain any cleanpoints. A
|
||||
* cleanpoint is any point at which playback could begin without having seen
|
||||
* the previous media objects. For streams that use key frames, the key frames
|
||||
* would be the cleanpoints.
|
||||
*/
|
||||
const NO_CLEANPOINT = 4;
|
||||
|
||||
/**
|
||||
* Specifies, if set, that when a stream is joined in mid-transmission, all
|
||||
* information from the most recent cleanpoint up to the current time should
|
||||
* be sent before normal streaming begins at the current time. The default
|
||||
* behavior (when this flag is not set) is to send only the data starting at
|
||||
* the current time. This flag should only be set for streams that are coming
|
||||
* from a live source.
|
||||
*/
|
||||
const RESEND_LIVE_CLEANPOINTS = 8;
|
||||
|
||||
const AUDIO_MEDIA = "f8699e40-5b4d-11cf-a8fd-00805f5c442b";
|
||||
const VIDEO_MEDIA = "bc19efc0-5b4d-11cf-a8fd-00805f5c442b";
|
||||
const COMMAND_MEDIA = "59dacfc0-59e6-11d0-a3ac-00a0c90348f6";
|
||||
const JFIF_MEDIA = "b61be100-5b4e-11cf-a8fD-00805f5c442b";
|
||||
const DEGRADABLE_JPEG_MEDIA = "35907dE0-e415-11cf-a917-00805f5c442b";
|
||||
const FILE_TRANSFER_MEDIA = "91bd222c-f21c-497a-8b6d-5aa86bfc0185";
|
||||
const BINARY_MEDIA = "3afb65e2-47ef-40f2-ac2c-70a90d71d343";
|
||||
|
||||
const NO_ERROR_CORRECTION = "20fb5700-5b55-11cf-a8fd-00805f5c442b";
|
||||
const AUDIO_SPREAD = "bfc3cd50-618f-11cf-8bb2-00aa00b4e220";
|
||||
|
||||
const PAYLOAD_EXTENSION_SYSTEM_TIMECODE =
|
||||
"399595ec-8667-4e2d-8fdb-98814ce76c1e";
|
||||
const PAYLOAD_EXTENSION_SYSTEM_FILE_NAME =
|
||||
"e165ec0e-19ed-45d7-b4a7-25cbd1e28e9b";
|
||||
const PAYLOAD_EXTENSION_SYSTEM_CONTENT_TYPE =
|
||||
"d590dc20-07bc-436c-9cf7-f3bbfbf1a4dc";
|
||||
const PAYLOAD_EXTENSION_SYSTEM_PIXEL_ASPECT_RATIO =
|
||||
"1b1ee554-f9ea-4bc8-821a-376b74e4c4b8";
|
||||
const PAYLOAD_EXTENSION_SYSTEM_SAMPLE_DURATION =
|
||||
"c6bd9450-867f-4907-83a3-c77921b733ad";
|
||||
const PAYLOAD_EXTENSION_SYSTEM_ENCRYPTION_SAMPLE_ID =
|
||||
"6698b84e-0afa-4330-aeb2-1c0a98d7a44d";
|
||||
|
||||
/** @var integer */
|
||||
private $_startTime;
|
||||
|
||||
/** @var integer */
|
||||
private $_endTime;
|
||||
|
||||
/** @var integer */
|
||||
private $_dataBitrate;
|
||||
|
||||
/** @var integer */
|
||||
private $_bufferSize;
|
||||
|
||||
/** @var integer */
|
||||
private $_initialBufferFullness;
|
||||
|
||||
/** @var integer */
|
||||
private $_alternateDataBitrate;
|
||||
|
||||
/** @var integer */
|
||||
private $_alternateBufferSize;
|
||||
|
||||
/** @var integer */
|
||||
private $_alternateInitialBufferFullness;
|
||||
|
||||
/** @var integer */
|
||||
private $_maximumObjectSize;
|
||||
|
||||
/** @var integer */
|
||||
private $_flags;
|
||||
|
||||
/** @var integer */
|
||||
private $_streamNumber;
|
||||
|
||||
/** @var integer */
|
||||
private $_streamLanguageIndex;
|
||||
|
||||
/** @var integer */
|
||||
private $_averageTimePerFrame;
|
||||
|
||||
/** @var Array */
|
||||
private $_streamNames = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_payloadExtensionSystems = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_startTime = $this->_reader->readInt64LE();
|
||||
$this->_endTime = $this->_reader->readInt64LE();
|
||||
$this->_dataBitrate = $this->_reader->readUInt32LE();
|
||||
$this->_bufferSize = $this->_reader->readUInt32LE();
|
||||
$this->_initialBufferFullness = $this->_reader->readUInt32LE();
|
||||
$this->_alternateDataBitrate = $this->_reader->readUInt32LE();
|
||||
$this->_alternateBufferSize = $this->_reader->readUInt32LE();
|
||||
$this->_alternateInitialBufferFullness = $this->_reader->readUInt32LE();
|
||||
$this->_maximumObjectSize = $this->_reader->readUInt32LE();
|
||||
$this->_flags = $this->_reader->readUInt32LE();
|
||||
$this->_streamNumber = $this->_reader->readUInt16LE();
|
||||
$this->_streamLanguageIndex = $this->_reader->readUInt16LE();
|
||||
$this->_averageTimePerFrame = $this->_reader->readInt64LE();
|
||||
$streamNameCount = $this->_reader->readUInt16LE();
|
||||
$payloadExtensionSystemCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $streamNameCount; $i++) {
|
||||
$streamName = array("languageIndex" => $this->_reader->readUInt16LE());
|
||||
$streamNameLength = $this->_reader->readUInt16LE();
|
||||
$streamName["streamName"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($streamNameLength));
|
||||
$this->_streamNames[] = $streamName;
|
||||
}
|
||||
for ($i = 0; $i < $payloadExtensionSystemCount; $i++) {
|
||||
$payloadExtensionSystem = array
|
||||
("extensionSystemId" => $this->_reader->readGUID(),
|
||||
"extensionDataSize" => $this->_reader->readUInt16LE());
|
||||
$extensionSystemInfoLength = $this->_reader->readUInt32LE();
|
||||
$payloadExtensionSystem["extensionSystemInfo"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($extensionSystemInfoLength));
|
||||
$this->_payloadExtensionSystems[] = $payloadExtensionSystem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the presentation time of the first object, indicating where this
|
||||
* digital media stream starts within the context of the timeline of the ASF
|
||||
* file as a whole. This time value corresponds to presentation times as they
|
||||
* appear in the data packets (adjusted by the preroll). This field is given
|
||||
* in units of milliseconds and can optionally be set to 0, in which case it
|
||||
* will be ignored.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStartTime() { return $this->_startTime; }
|
||||
|
||||
/**
|
||||
* Returns the presentation time of the last object plus the duration of play,
|
||||
* indicating where this digital media stream ends within the context of the
|
||||
* timeline of the ASF file as a whole. This time value corresponds to
|
||||
* presentation times as they appear in the data packets (adjusted by the
|
||||
* preroll). This field is given in units of milliseconds and can optionally
|
||||
* be set to 0, in which case it will be ignored.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getEndTime() { return $this->_endTime; }
|
||||
|
||||
/**
|
||||
* Returns the leak rate R, in bits per second, of a leaky bucket that
|
||||
* contains the data portion of the stream without overflowing, excluding all
|
||||
* ASF Data Packet overhead. The size of the leaky bucket is specified by the
|
||||
* value of the <i>Buffer Size</i> field. This field has a non-zero value.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getDataBitrate() { return $this->_dataBitrate; }
|
||||
|
||||
/**
|
||||
* Returns the size B, in milliseconds, of the leaky bucket used in the
|
||||
* <i>Data Bitrate</i> definition.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBufferSize() { return $this->_bufferSize; }
|
||||
|
||||
/**
|
||||
* Returns the initial fullness, in milliseconds, of the leaky bucket used in
|
||||
* the <i>Data Bitrate</i> definition. This is the fullness of the buffer at
|
||||
* the instant before the first bit in the stream is dumped into the bucket.
|
||||
* Typically, this value is set to 0. This value shall not exceed the value in
|
||||
* the <i>Buffer Size</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getInitialBufferFullness()
|
||||
{
|
||||
return $this->_initialBufferFullness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the leak rate RAlt, in bits per second, of a leaky bucket that
|
||||
* contains the data portion of the stream without overflowing, excluding all
|
||||
* ASF <i>Data Packet</i> overhead. The size of the leaky bucket is specified
|
||||
* by the value of the <i>Alternate Buffer Size</i> field. This value is
|
||||
* relevant in most scenarios where the bit rate is not exactly constant, but
|
||||
* it is especially useful for streams that have highly variable bit rates.
|
||||
* This field can optionally be set to the same value as the <i>Data
|
||||
* Bitrate</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlternateDataBitrate()
|
||||
{
|
||||
return $this->_alternateDataBitrate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size BAlt, in milliseconds, of the leaky bucket used in the
|
||||
* <i>Alternate Data Bitrate</i> definition. This value is relevant in most
|
||||
* scenarios where the bit rate is not exactly constant, but it is especially
|
||||
* useful for streams that have highly variable bit rates. This field can
|
||||
* optionally be set to the same value as the <i>Buffer Size</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlternateBufferSize()
|
||||
{
|
||||
return $this->_alternateBufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the initial fullness, in milliseconds, of the leaky bucket used in
|
||||
* the <i>Alternate Data Bitrate</i> definition. This is the fullness of the
|
||||
* buffer at the instant before the first bit in the stream is dumped into the
|
||||
* bucket. Typically, this value is set to 0. This value does not exceed the
|
||||
* value of the <i>Alternate Buffer Size</i> field.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlternateInitialBufferFullness()
|
||||
{
|
||||
return $this->_alternateInitialBufferFullness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum size of the largest sample stored in the data packets
|
||||
* for a stream. A value of 0 means unknown.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getMaximumObjectSize()
|
||||
{
|
||||
return $this->_maximumObjectSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the average time duration, measured in 100-nanosecond units, of
|
||||
* each frame. This number should be rounded to the nearest integer. This
|
||||
* field can optionally be set to 0 if the average time per frame is unknown
|
||||
* or unimportant. It is recommended that this field be set for video.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAverageTimePerFrame()
|
||||
{
|
||||
return $this->_averageTimePerFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of this stream. 0 is an invalid stream number (that is,
|
||||
* other <i>Header Objects</i> use stream number 0 to refer to the entire file
|
||||
* as a whole rather than to a specific media stream within the file). Valid
|
||||
* values are between 1 and 127.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStreamNumber()
|
||||
{
|
||||
return $this->_streamNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language, if any, which the content of the stream uses or
|
||||
* assumes. Refer to the {@link LanguageList Language List Object} description
|
||||
* for the details concerning how the <i>Stream Language Index</i> and
|
||||
* <i>Language Index</i> fields should be used. Note that this is an index
|
||||
* into the languages listed in the <i>Language List Object</i> rather than a
|
||||
* language identifier.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStreamLanguageIndex()
|
||||
{
|
||||
return $this->_streamLanguageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Stream Names. Each stream name instance is potentially
|
||||
* localized into a specific language. The <i>Language Index</i> field
|
||||
* indicates the language in which the <i>Stream Name</i> has been written.
|
||||
*
|
||||
* The array contains the following keys:
|
||||
* o languageIndex -- The language index
|
||||
* o streamName -- The localized stream name
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getStreamNames()
|
||||
{
|
||||
return $this->_streamNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of payload extension systems. Payload extensions provide a
|
||||
* way for content creators to specify kinds of data that will appear in the
|
||||
* payload header for every payload from this stream. This system is used when
|
||||
* stream properties must be conveyed at the media object level. The
|
||||
* <i>Replicated Data</i> bytes in the payload header will contain these
|
||||
* properties in the order in which the <i>Payload Extension Systems</i>
|
||||
* appear in this object. A <i>Payload Extension System</i> must appear in the
|
||||
* <i>Extended Stream Properties Object</i> for each type of per-media-object
|
||||
* properties that will appear with the payloads for this stream.
|
||||
*
|
||||
* The array contains the following keys:
|
||||
* o extensionSystemId -- Specifies a unique identifier for the extension
|
||||
* system.
|
||||
* o extensionDataSize -- Specifies the fixed size of the extension data for
|
||||
* this system that will appear in the replicated data alongside every
|
||||
* payload for this stream. If this extension system uses variable-size
|
||||
* data, then this should be set to 0xffff. Note, however, that replicated
|
||||
* data length is limited to 255 bytes, which limits the total size of all
|
||||
* extension systems for a particular stream.
|
||||
* o extensionSystemInfo -- Specifies additional information to describe
|
||||
* this extension system (optional).
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getPayloadExtensionSystems()
|
||||
{
|
||||
return $this->_payloadExtensionSystems;
|
||||
}
|
||||
}
|
||||
|
||||
108
src/ASF/Object/GroupMutualExclusion.php
Normal file
108
src/ASF/Object/GroupMutualExclusion.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Group Mutual Exclusion Object</i> is used to describe mutual exclusion
|
||||
* relationships between groups of streams. This object is organized in terms of
|
||||
* records, each containing one or more streams, where a stream in record N
|
||||
* cannot coexist with a stream in record M for N != M (however, streams in the
|
||||
* same record can coexist). This mutual exclusion object would be used
|
||||
* typically for the purpose of language mutual exclusion, and a record would
|
||||
* consist of all streams for a particular language.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_GroupMutualExclusion extends ASF_Object
|
||||
{
|
||||
const MUTEX_LANGUAGE = "d6e22a00-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_BITRATE = "d6e22a01-35da-11d1-9034-00a0c90349be";
|
||||
const MUTEX_UNKNOWN = "d6e22a02-35da-11d1-9034-00a0c90349be";
|
||||
|
||||
/** @var string */
|
||||
private $_exclusionType;
|
||||
|
||||
/** @var Array */
|
||||
private $_records = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
$this->_exclusionType = $this->_reader->readGUID();
|
||||
$recordCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $recordCount; $i++) {
|
||||
$streamNumbersCount = $this->_reader->readUInt16LE();
|
||||
$streamNumbers = array();
|
||||
for ($j = 0; $j < $streamNumbersCount; $j++)
|
||||
$streamNumbers[] = array
|
||||
("streamNumbers" => $this->_reader->readUInt16LE());
|
||||
$this->_records[] = $streamNumbers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nature of the mutual exclusion relationship.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExclusionType() { return $this->_exclusionType; }
|
||||
|
||||
/**
|
||||
* Returns an array of records. Each record consists of the following keys.
|
||||
*
|
||||
* o streamNumbers -- Specifies the stream numbers for this record. Valid
|
||||
* values are between 1 and 127.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getRecords() { return $this->_records; }
|
||||
}
|
||||
@@ -40,10 +40,10 @@ require_once("ASF/Object/Container.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Header Extension Object<i> allows additional functionality to be added
|
||||
* to an ASF file while maintaining backward compatibility. The Header Extension
|
||||
* Object is a container containing 0 or more additional extended header
|
||||
* objects.
|
||||
* The <i>Header Extension Object</i> allows additional functionality to be
|
||||
* added to an ASF file while maintaining backward compatibility. The Header
|
||||
* Extension Object is a container containing zero or more additional extended
|
||||
* header objects.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
|
||||
185
src/ASF/Object/Index.php
Normal file
185
src/ASF/Object/Index.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* This top-level ASF object supplies the necessary indexing information for an
|
||||
* ASF file that contains more than just a plain script-audio-video combination.
|
||||
* It includes stream-specific indexing information based on an adjustable index
|
||||
* entry time interval. The index is designed to be broken into blocks to
|
||||
* facilitate storage that is more space-efficient by using 32-bit offsets
|
||||
* relative to a 64-bit base. That is, each index block has a full 64-bit offset
|
||||
* in the block header that is added to the 32-bit offsets found in each index
|
||||
* entry. If a file is larger than 2^32 bytes, then multiple index blocks can be
|
||||
* used to fully index the entire large file while still keeping index entry
|
||||
* offsets at 32 bits.
|
||||
*
|
||||
* Indices into the <i>Index Object</i> are in terms of presentation times. The
|
||||
* corresponding <i>Offset</i> field values of the <i>Index Entry</i> byte
|
||||
* offsets that, when combined with the <i>Block Position</i> value of the
|
||||
* <i>Index Block</i>, indicate the starting location in bytes of an ASF Data
|
||||
* Packet relative to the start of the first ASF Data Packet in the file.
|
||||
*
|
||||
* An offset value of 0xFFFFFFFF is used to indicate an invalid offset value.
|
||||
* Invalid offsets signify that this particular index entry does not identify a
|
||||
* valid indexible point. Invalid offsets may occur for the initial index
|
||||
* entries of a digital media stream whose first ASF Data Packet has a non-zero
|
||||
* send time. Invalid offsets may also occur in the case where a digital media
|
||||
* stream has a large gap in the presentation time of successive objects.
|
||||
*
|
||||
* The <i>Index Object</i> is not recommended for use with files where the
|
||||
* <i>Send Time</i> of the first <i>Data Packet</i> within the <i>Data
|
||||
* Object</i> has a <i>Send Time</i> value significantly greater than zero
|
||||
* (otherwise the index itself will be sparse and inefficient).
|
||||
*
|
||||
* Any ASF file containing an <i>Index Object</i> does also contain an <i>Index
|
||||
* Parameters Object</i> in its {@link ASF_Object_Header ASF Header}.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_Index extends ASF_Object
|
||||
{
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Data Packet. The Nearest
|
||||
* Past Data Packet indexes point to the data packet whose presentation time
|
||||
* is closest to the index entry time.
|
||||
*/
|
||||
const NEAREST_PAST_DATA_PACKET = 1;
|
||||
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Media. The Nearest Past
|
||||
* Object indexes point to the closest data packet containing an entire object
|
||||
* or first fragment of an object.
|
||||
*/
|
||||
const NEAREST_PAST_MEDIA = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Cleanpoint. The Nearest Past
|
||||
* Cleanpoint indexes point to the closest data packet containing an entire
|
||||
* object (or first fragment of an object) that has the Cleanpoint Flag set.
|
||||
*
|
||||
* Nearest Past Cleanpoint is the most common type of index.
|
||||
*/
|
||||
const NEAREST_PAST_CLEANPOINT = 3;
|
||||
|
||||
/** @var integer */
|
||||
private $_indexEntryTimeInterval;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexSpecifiers = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_indexBlocks = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_indexEntryTimeInterval = $this->_reader->readUInt32LE();
|
||||
$indexSpecifiersCount = $this->_reader->readUInt16LE();
|
||||
$indexBlocksCount = $this->_reader->readUInt32LE();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$this->_indexSpecifiers[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"indexType" => $this->_reader->readUInt16LE());
|
||||
for ($i = 0; $i < $indexBlocksCount; $i++) {
|
||||
$indexEntryCount = $this->_reader->readUInt32LE();
|
||||
$blockPositions = array();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$blockPositions[] = $this->_reader->readInt64LE();
|
||||
$offsets = array();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$offsets[] = $this->_reader->readUInt32LE();
|
||||
$this->_indexBlocks[] = array
|
||||
("blockPositions" => $blockPositions,
|
||||
"indexEntryOffsets" => $offsets);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time interval between each index entry in ms.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryTimeInterval()
|
||||
{
|
||||
return $this->_indexEntryTimeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of index specifiers. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number that the <i>Index
|
||||
* Specifiers</i> refer to. Valid values are between 1 and 127.
|
||||
*
|
||||
* o indexType -- Specifies the type of index.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexSpecifiers() { return $this->_indexSpecifiers; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o blockPositions -- Specifies a list of byte offsets of the beginnings of
|
||||
* the blocks relative to the beginning of the first Data Packet (for
|
||||
* example, the beginning of the Data Object + 50 bytes).
|
||||
*
|
||||
* o indexEntryOffsets -- Specifies the offset. An offset value of
|
||||
* 0xffffffff indicates an invalid offset value.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexBlocks() { return $this->_indexBlocks; }
|
||||
}
|
||||
121
src/ASF/Object/IndexParameters.php
Normal file
121
src/ASF/Object/IndexParameters.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Index Parameters Object</i> supplies information about those streams
|
||||
* that are actually indexed (there must be at least one stream in an index) by
|
||||
* the {@link ASF_Object_Index Index Object} and how they are being indexed.
|
||||
* This object shall be present in the {@link ASF_Object_Header Header Object}
|
||||
* if there is an {@link ASF_Object_Index Index Object} present in the file.
|
||||
*
|
||||
* An Index Specifier is required for each stream that will be indexed by the
|
||||
* {@link ASF_Object_Index Index Object}. These specifiers must exactly match
|
||||
* those in the {@link ASF_Object_Index Index Object}.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_IndexParameters extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_indexEntryTimeInterval;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexSpecifiers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_indexEntryTimeInterval = $this->_reader->readUInt32LE();
|
||||
$indexSpecifiersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++) {
|
||||
$this->_indexSpecifiers[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"indexType" => $this->_reader->readUInt16LE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time interval between index entries in milliseconds. This value
|
||||
* cannot be 0.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryTimeInterval()
|
||||
{
|
||||
return $this->_indexEntryTimeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number that the Index Specifiers
|
||||
* refer to. Valid values are between 1 and 127.
|
||||
*
|
||||
* o indexType -- Specifies the type of index. Values are as follows:
|
||||
* 1 = Nearest Past Data Packet,
|
||||
* 2 = Nearest Past Media Object, and
|
||||
* 3 = Nearest Past Cleanpoint.
|
||||
* The Nearest Past Data Packet indexes point to the data packet whose
|
||||
* presentation time is closest to the index entry time. The Nearest Past
|
||||
* Object indexes point to the closest data packet containing an entire
|
||||
* object or first fragment of an object. The Nearest Past Cleanpoint
|
||||
* indexes point to the closest data packet containing an entire object
|
||||
* (or first fragment of an object) that has the Cleanpoint Flag set.
|
||||
* Nearest Past Cleanpoint is the most common type of index.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexSpecifiers() { return $this->_indexSpecifiers; }
|
||||
}
|
||||
@@ -1,121 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Marker Object</i> class.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_Marker extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_name;
|
||||
|
||||
/** @var Array */
|
||||
private $_markers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_reader->skip(16);
|
||||
$markersCount = $this->_reader->readUInt32LE();
|
||||
$this->_reader->skip(2);
|
||||
$nameLength = $this->_reader->readUInt16LE();
|
||||
$this->_name = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($nameLength));
|
||||
for ($i = 0; $i < $markersCount; $i++) {
|
||||
$marker = array
|
||||
("offset" => $this->_reader->readInt64LE(),
|
||||
"presentationTime" => $this->_reader->readInt64LE());
|
||||
$this->_reader->skip(2);
|
||||
$marker["sendTime"] = $this->_reader->readUInt32LE();
|
||||
$marker["flags"] = $this->_reader->readUInt32LE();
|
||||
$descriptionLength = $this->_reader->readUInt32LE();
|
||||
$marker["description"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($descriptionLength));
|
||||
$this->_markers[] = $marker;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the Marker Object.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getName() { return $this->_name; }
|
||||
|
||||
/**
|
||||
* Returns an array of markers. Each entry consists of the following keys.
|
||||
*
|
||||
* o offset -- Specifies a byte offset into the <i>Data Object</i> to the
|
||||
* actual position of the marker in the <i>Data Object</i>. ASF parsers
|
||||
* must seek to this position to properly display data at the specified
|
||||
* marker <i>Presentation Time</i>.
|
||||
*
|
||||
* o presentationTime -- Specifies the presentation time of the marker, in
|
||||
* 100-nanosecond units.
|
||||
*
|
||||
* o sendTime -- Specifies the send time of the marker entry, in
|
||||
* milliseconds.
|
||||
*
|
||||
* o flags -- Flags are reserved and should be set to 0.
|
||||
*
|
||||
* o description -- Specifies a description of the marker entry.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getMarkers() { return $this->_markers; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Marker Object</i> class.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_Marker extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_name;
|
||||
|
||||
/** @var Array */
|
||||
private $_markers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_reader->skip(16);
|
||||
$markersCount = $this->_reader->readUInt32LE();
|
||||
$this->_reader->skip(2);
|
||||
$nameLength = $this->_reader->readUInt16LE();
|
||||
$this->_name = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($nameLength));
|
||||
for ($i = 0; $i < $markersCount; $i++) {
|
||||
$marker = array
|
||||
("offset" => $this->_reader->readInt64LE(),
|
||||
"presentationTime" => $this->_reader->readInt64LE());
|
||||
$this->_reader->skip(2);
|
||||
$marker["sendTime"] = $this->_reader->readUInt32LE();
|
||||
$marker["flags"] = $this->_reader->readUInt32LE();
|
||||
$descriptionLength = $this->_reader->readUInt32LE();
|
||||
$marker["description"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($descriptionLength));
|
||||
$this->_markers[] = $marker;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the Marker Object.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getName() { return $this->_name; }
|
||||
|
||||
/**
|
||||
* Returns an array of markers. Each entry consists of the following keys.
|
||||
*
|
||||
* o offset -- Specifies a byte offset into the <i>Data Object</i> to the
|
||||
* actual position of the marker in the <i>Data Object</i>. ASF parsers
|
||||
* must seek to this position to properly display data at the specified
|
||||
* marker <i>Presentation Time</i>.
|
||||
*
|
||||
* o presentationTime -- Specifies the presentation time of the marker, in
|
||||
* 100-nanosecond units.
|
||||
*
|
||||
* o sendTime -- Specifies the send time of the marker entry, in
|
||||
* milliseconds.
|
||||
*
|
||||
* o flags -- Flags are reserved and should be set to 0.
|
||||
*
|
||||
* o description -- Specifies a description of the marker entry.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getMarkers() { return $this->_markers; }
|
||||
}
|
||||
|
||||
176
src/ASF/Object/MediaObjectIndex.php
Normal file
176
src/ASF/Object/MediaObjectIndex.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* This top-level ASF object supplies media object indexing information for the
|
||||
* streams of an ASF file. It includes stream-specific indexing information
|
||||
* based on an adjustable index entry media object count interval. This object
|
||||
* can be used to index all the video frames or key frames in a video stream.
|
||||
* The index is designed to be broken into blocks to facilitate storage that is
|
||||
* more space-efficient by using 32-bit offsets relative to a 64-bit base. That
|
||||
* is, each index block has a full 64-bit offset in the block header that is
|
||||
* added to the 32-bit offset found in each index entry. If a file is larger
|
||||
* than 2^32 bytes, then multiple index blocks can be used to fully index the
|
||||
* entire large file while still keeping index entry offsets at 32 bits.
|
||||
*
|
||||
* Indices into the <i>Media Object Index Object</i> are in terms of media
|
||||
* object numbers, with the first frame for a given stream in the ASF file
|
||||
* corresponding to entry 0 in the <i>Media Object Index Object</i>. The
|
||||
* corresponding <i>Offset</i> field values of the <i>Index Entry</i> are byte
|
||||
* offsets that, when combined with the <i>Block Position</i> value of the
|
||||
* Index Block, indicate the starting location in bytes of an ASF Data Packet
|
||||
* relative to the start of the first ASF Data Packet in the file.
|
||||
*
|
||||
* Any ASF file containing a <i>Media Object Index Object</i> shall also contain
|
||||
* a <i>Media Object Index Parameters Object</i> in its
|
||||
* {@link ASF_Object_Header ASF Header}.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_MediaObjectIndex extends ASF_Object
|
||||
{
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Data Packet. The Nearest
|
||||
* Past Data Packet indexes point to the data packet whose presentation time
|
||||
* is closest to the index entry time.
|
||||
*/
|
||||
const NEAREST_PAST_DATA_PACKET = 1;
|
||||
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Media. The Nearest Past
|
||||
* Object indexes point to the closest data packet containing an entire object
|
||||
* or first fragment of an object.
|
||||
*/
|
||||
const NEAREST_PAST_MEDIA = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Cleanpoint. The Nearest Past
|
||||
* Cleanpoint indexes point to the closest data packet containing an entire
|
||||
* object (or first fragment of an object) that has the Cleanpoint Flag set.
|
||||
*
|
||||
* Nearest Past Cleanpoint is the most common type of index.
|
||||
*/
|
||||
const NEAREST_PAST_CLEANPOINT = 3;
|
||||
|
||||
/** @var integer */
|
||||
private $_indexEntryCountInterval;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexSpecifiers = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_indexBlocks = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_indexEntryCountInterval = $this->_reader->readUInt32LE();
|
||||
$indexSpecifiersCount = $this->_reader->readUInt16LE();
|
||||
$indexBlocksCount = $this->_reader->readUInt32LE();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$this->_indexSpecifiers[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"indexType" => $this->_reader->readUInt16LE());
|
||||
for ($i = 0; $i < $indexBlocksCount; $i++) {
|
||||
$indexEntryCount = $this->_reader->readUInt32LE();
|
||||
$blockPositions = array();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$blockPositions[] = $this->_reader->readInt64LE();
|
||||
$offsets = array();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$offsets[] = $this->_reader->readUInt32LE();
|
||||
$this->_indexBlocks[] = array
|
||||
("blockPositions" => $blockPositions,
|
||||
"indexEntryOffsets" => $offsets);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the interval between each index entry in number of media objects.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryCountInterval()
|
||||
{
|
||||
return $this->_indexEntryCountInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of index specifiers. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number that the <i>Index
|
||||
* Specifiers</i> refer to. Valid values are between 1 and 127.
|
||||
*
|
||||
* o indexType -- Specifies the type of index.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexSpecifiers() { return $this->_indexSpecifiers; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o blockPositions -- Specifies a list of byte offsets of the beginnings of
|
||||
* the blocks relative to the beginning of the first Data Packet (for
|
||||
* example, the beginning of the Data Object + 50 bytes).
|
||||
*
|
||||
* o indexEntryOffsets -- Specifies the offset. An offset value of
|
||||
* 0xffffffff indicates an invalid offset value.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexBlocks() { return $this->_indexBlocks; }
|
||||
}
|
||||
130
src/ASF/Object/MediaObjectIndexParameters.php
Normal file
130
src/ASF/Object/MediaObjectIndexParameters.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Media Object Index Parameters Object</i> supplies information about
|
||||
* those streams that actually indexed (there must be at least one stream in an
|
||||
* index) by media objects. This object shall be present in the
|
||||
* {@link ASF_Object_Header Header Object} if there is a
|
||||
* {@link ASF_Object_MediaObjectIndex Media Object Index Object} present in the
|
||||
* file.
|
||||
*
|
||||
* An Index Specifier is required for each stream that will be indexed by the
|
||||
* {@link ASF_Object_MediaObjectIndex Media Object Index Object}. These
|
||||
* specifiers must exactly match those in the
|
||||
* {@link ASF_Object_MediaObjectIndex Media Object Index Object}.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_MediaObjectIndexParameters extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_indexEntryCountInterval;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexSpecifiers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_indexEntryCountInterval = $this->_reader->readUInt32LE();
|
||||
$indexSpecifiersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++) {
|
||||
$this->_indexSpecifiers[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"indexType" => $this->_reader->readUInt16LE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the interval between each index entry by the number of media
|
||||
* objects. This value cannot be 0.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryCountInterval()
|
||||
{
|
||||
return $this->_indexEntryCountInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number that the Index Specifiers
|
||||
* refer to. Valid values are between 1 and 127.
|
||||
*
|
||||
* o indexType -- Specifies the type of index. Values are defined as
|
||||
* follows:
|
||||
* 1 = Nearest Past Data Packet,
|
||||
* 2 = Nearest Past Media Object,
|
||||
* 3 = Nearest Past Cleanpoint,
|
||||
* 0xff = Frame Number Offset.
|
||||
* For a video stream, the Nearest Past Media Object and Nearest Past Data
|
||||
* Packet indexes point to the closest data packet containing an entire
|
||||
* video frame or first fragment of a video frame; Nearest Past Cleanpoint
|
||||
* indexes point to the closest data packet containing an entire video
|
||||
* frame (or first fragment of a video frame) that is a key frame; and
|
||||
* Frame Number Offset indicates how many more frames need to be read for
|
||||
* the given stream, starting with the first frame in the packet pointed
|
||||
* to by the index entry, in order to get to the requested frame. Nearest
|
||||
* Past Media Object is the most common value. Because ASF payloads do not
|
||||
* contain the full frame number, there is often a Frame Number Offset
|
||||
* index alongside one of the other types of indexes to allow the user to
|
||||
* identify the exact frame being seeked to.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexSpecifiers() { return $this->_indexSpecifiers; }
|
||||
}
|
||||
@@ -1,137 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Metadata Library Object</i> lets authors store stream-based,
|
||||
* language-attributed, multiply defined, and large metadata attributes in a
|
||||
* file.
|
||||
*
|
||||
* This object supports the same types of metadata as the
|
||||
* <i>{@link ASF_Object_Metadata Metadata Object}</i>, as well as attributes
|
||||
* with language IDs, attributes that are defined more than once, large
|
||||
* attributes, and attributes with the GUID data type.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_MetadataLibrary extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_descriptionRecords = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$descriptionRecordsCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
|
||||
$descriptionRecord = array
|
||||
("languageIndex" => $this->_reader->readUInt16LE(),
|
||||
"streamNumber" => $this->_reader->readUInt16LE());
|
||||
$nameLength = $this->_reader->readUInt16LE();
|
||||
$dataType = $this->_reader->readUInt16LE();
|
||||
$dataLength = $this->_reader->readUInt32LE();
|
||||
$descriptionRecord["name"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($nameLength));
|
||||
switch ($dataType) {
|
||||
case 0: // Unicode string
|
||||
$descriptionRecord["data"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($dataLength));
|
||||
break;
|
||||
case 1: // BYTE array
|
||||
$descriptionRecord["data"] = $this->_reader->read($dataLength);
|
||||
break;
|
||||
case 2: // BOOL
|
||||
$descriptionRecord["data"] = $this->_reader->readUInt16LE() == 1;
|
||||
break;
|
||||
case 3: // DWORD
|
||||
$descriptionRecord["data"] = $this->_reader->readUInt32LE();
|
||||
break;
|
||||
case 4: // QWORD
|
||||
$descriptionRecord["data"] = $this->_reader->readInt64LE();
|
||||
break;
|
||||
case 5: // WORD
|
||||
$descriptionRecord["data"] = $this->_reader->readUInt16LE();
|
||||
break;
|
||||
case 6: // GUID
|
||||
$descriptionRecord["data"] = $this->_reader->readGUID();
|
||||
break;
|
||||
}
|
||||
$this->_descriptionRecords[] = $descriptionRecord;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of description records. Each record consists of the
|
||||
* following keys.
|
||||
*
|
||||
* o languageIndex -- Specifies the index into the <i>Language List
|
||||
* Object</i> that identifies the language of this attribute. If there is
|
||||
* no <i>Language List Object</i> present, this field is zero.
|
||||
*
|
||||
* o streamNumber -- Specifies whether the entry applies to a specific
|
||||
* digital media stream or whether it applies to the whole file. A value
|
||||
* of 0 in this field indicates that it applies to the whole file;
|
||||
* otherwise, the entry applies only to the indicated stream number. Valid
|
||||
* values are between 1 and 127.
|
||||
*
|
||||
* o name -- Specifies the name that identifies the attribute being
|
||||
* described.
|
||||
*
|
||||
* o data -- Specifies the actual metadata being stored.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getDescriptionRecords() { return $this->_descriptionRecords; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Metadata Library Object</i> lets authors store stream-based,
|
||||
* language-attributed, multiply defined, and large metadata attributes in a
|
||||
* file.
|
||||
*
|
||||
* This object supports the same types of metadata as the
|
||||
* <i>{@link ASF_Object_Metadata Metadata Object}</i>, as well as attributes
|
||||
* with language IDs, attributes that are defined more than once, large
|
||||
* attributes, and attributes with the GUID data type.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_MetadataLibrary extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_descriptionRecords = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$descriptionRecordsCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
|
||||
$descriptionRecord = array
|
||||
("languageIndex" => $this->_reader->readUInt16LE(),
|
||||
"streamNumber" => $this->_reader->readUInt16LE());
|
||||
$nameLength = $this->_reader->readUInt16LE();
|
||||
$dataType = $this->_reader->readUInt16LE();
|
||||
$dataLength = $this->_reader->readUInt32LE();
|
||||
$descriptionRecord["name"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($nameLength));
|
||||
switch ($dataType) {
|
||||
case 0: // Unicode string
|
||||
$descriptionRecord["data"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($dataLength));
|
||||
break;
|
||||
case 1: // BYTE array
|
||||
$descriptionRecord["data"] = $this->_reader->read($dataLength);
|
||||
break;
|
||||
case 2: // BOOL
|
||||
$descriptionRecord["data"] = $this->_reader->readUInt16LE() == 1;
|
||||
break;
|
||||
case 3: // DWORD
|
||||
$descriptionRecord["data"] = $this->_reader->readUInt32LE();
|
||||
break;
|
||||
case 4: // QWORD
|
||||
$descriptionRecord["data"] = $this->_reader->readInt64LE();
|
||||
break;
|
||||
case 5: // WORD
|
||||
$descriptionRecord["data"] = $this->_reader->readUInt16LE();
|
||||
break;
|
||||
case 6: // GUID
|
||||
$descriptionRecord["data"] = $this->_reader->readGUID();
|
||||
break;
|
||||
}
|
||||
$this->_descriptionRecords[] = $descriptionRecord;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of description records. Each record consists of the
|
||||
* following keys.
|
||||
*
|
||||
* o languageIndex -- Specifies the index into the <i>Language List
|
||||
* Object</i> that identifies the language of this attribute. If there is
|
||||
* no <i>Language List Object</i> present, this field is zero.
|
||||
*
|
||||
* o streamNumber -- Specifies whether the entry applies to a specific
|
||||
* digital media stream or whether it applies to the whole file. A value
|
||||
* of 0 in this field indicates that it applies to the whole file;
|
||||
* otherwise, the entry applies only to the indicated stream number. Valid
|
||||
* values are between 1 and 127.
|
||||
*
|
||||
* o name -- Specifies the name that identifies the attribute being
|
||||
* described.
|
||||
*
|
||||
* o data -- Specifies the actual metadata being stored.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getDescriptionRecords() { return $this->_descriptionRecords; }
|
||||
}
|
||||
|
||||
@@ -1,124 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Script Command Object</i> provides a list of type/parameter pairs of
|
||||
* strings that are synchronized to the ASF file's timeline. Types can include
|
||||
* URL or FILENAME values. Other type values may also be freely defined and
|
||||
* used. The semantics and treatment of this set of types are defined by the
|
||||
* local implementations. The parameter value is specific to the type field. You
|
||||
* can use this type/parameter pairing for many purposes, including sending URLs
|
||||
* to be launched by a client into an HTML frame (in other words, the URL type)
|
||||
* or launching another ASF file for the chained continuous play of audio or
|
||||
* video presentations (in other words, the FILENAME type). This object is also
|
||||
* used as a method to stream text, as well as to provide script commands that
|
||||
* you can use to control elements within the client environment.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ScriptCommand extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_commandTypes = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_commands = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_reader->skip(16);
|
||||
$commandsCount = $this->_reader->readUInt16LE();
|
||||
$commandTypesCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $commandTypesCount; $i++) {
|
||||
$commandTypeNameLength = $this->_reader->readUInt16LE();
|
||||
$this->_commandTypes[] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($commandTypeNameLength * 2));
|
||||
}
|
||||
for ($i = 0; $i < $commandsCount; $i++) {
|
||||
$command = array
|
||||
("presentationTime" => $this->_reader->readUInt32LE(),
|
||||
"typeIndex" => $this->_reader->readUInt16LE());
|
||||
$commandNameLength = $this->_reader->readUInt16LE();
|
||||
$command["name"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($commandNameLength * 2));
|
||||
$this->_commands[] = $command;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of command type names.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getCommandTypes() { return $this->_commandTypes; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o presentationTime -- Specifies the presentation time of the command, in
|
||||
* milliseconds.
|
||||
*
|
||||
* o typeIndex -- Specifies the type of this command, as a zero-based index
|
||||
* into the array of Command Types of this object.
|
||||
*
|
||||
* o name -- Specifies the name of this command.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getCommands() { return $this->_commands; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Script Command Object</i> provides a list of type/parameter pairs of
|
||||
* strings that are synchronized to the ASF file's timeline. Types can include
|
||||
* URL or FILENAME values. Other type values may also be freely defined and
|
||||
* used. The semantics and treatment of this set of types are defined by the
|
||||
* local implementations. The parameter value is specific to the type field. You
|
||||
* can use this type/parameter pairing for many purposes, including sending URLs
|
||||
* to be launched by a client into an HTML frame (in other words, the URL type)
|
||||
* or launching another ASF file for the chained continuous play of audio or
|
||||
* video presentations (in other words, the FILENAME type). This object is also
|
||||
* used as a method to stream text, as well as to provide script commands that
|
||||
* you can use to control elements within the client environment.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_ScriptCommand extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_commandTypes = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_commands = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_reader->skip(16);
|
||||
$commandsCount = $this->_reader->readUInt16LE();
|
||||
$commandTypesCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $commandTypesCount; $i++) {
|
||||
$commandTypeNameLength = $this->_reader->readUInt16LE();
|
||||
$this->_commandTypes[] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($commandTypeNameLength * 2));
|
||||
}
|
||||
for ($i = 0; $i < $commandsCount; $i++) {
|
||||
$command = array
|
||||
("presentationTime" => $this->_reader->readUInt32LE(),
|
||||
"typeIndex" => $this->_reader->readUInt16LE());
|
||||
$commandNameLength = $this->_reader->readUInt16LE();
|
||||
$command["name"] = iconv
|
||||
("utf-16le", $this->getOption("encoding"),
|
||||
$this->_reader->readString16LE($commandNameLength * 2));
|
||||
$this->_commands[] = $command;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of command type names.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getCommandTypes() { return $this->_commandTypes; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o presentationTime -- Specifies the presentation time of the command, in
|
||||
* milliseconds.
|
||||
*
|
||||
* o typeIndex -- Specifies the type of this command, as a zero-based index
|
||||
* into the array of Command Types of this object.
|
||||
*
|
||||
* o name -- Specifies the name of this command.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getCommands() { return $this->_commands; }
|
||||
}
|
||||
|
||||
@@ -1,143 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* For each video stream in an ASF file, there should be one instance of the
|
||||
* <i>Simple Index Object</i>. Additionally, the instances of the <i>Simple
|
||||
* Index Object</i> shall be ordered by stream number.
|
||||
*
|
||||
* Index entries in the <i>Simple Index Object</i> are in terms of
|
||||
* <i>Presentation Times</i>. The corresponding <i>Packet Number</i> field
|
||||
* values (of the <i>Index Entry</i>, see below) indicate the packet number of
|
||||
* the ASF <i>Data Packet</i> with the closest past key frame. Note that for
|
||||
* video streams that contain both key frames and non-key frames, the <i>Packet
|
||||
* Number</i> field will always point to the closest past key frame.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_SimpleIndex extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_fileId;
|
||||
|
||||
/** @var integer */
|
||||
private $_indexEntryTimeInterval;
|
||||
|
||||
/** @var integer */
|
||||
private $_maximumPacketCount;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexEntries = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_fileId = $this->_reader->readGUID();
|
||||
$this->_indexEntryTimeInterval = $this->_reader->readInt64LE();
|
||||
$this->_maximumPacketCount = $this->_reader->readUInt32LE();
|
||||
$indexEntriesCount = $this->_reader->readUInt32LE();
|
||||
for ($i = 1; $i < $indexEntriesCount; $i++) {
|
||||
$this->_indexEntries[] = array
|
||||
("packetNumber" => $this->_reader->readUInt32LE(),
|
||||
"packetCount" => $this->_reader->readUInt16LE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique identifier for this ASF file. The value of this field
|
||||
* should be changed every time the file is modified in any way. The value of
|
||||
* this field may be set to 0 or set to be identical to the value of the
|
||||
* <i>File ID</i> field of the <i>Data Object</i> and the <i>Header
|
||||
* Object</i>.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileId() { return $this->_fileId; }
|
||||
|
||||
/**
|
||||
* Returns the time interval between each index entry in 100-nanosecond units.
|
||||
* The most common value is 10000000, to indicate that the index entries are
|
||||
* in 1-second intervals, though other values can be used as well.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryTimeInterval()
|
||||
{
|
||||
return $this->_indexEntryTimeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum <i>Packet Count</i> value of all <i>Index Entries</i>.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getMaximumPacketCount() { return $this->_maximumPacketCount; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o packetNumber -- Specifies the number of the Data Packet associated
|
||||
* with this index entry. Note that for video streams that contain both
|
||||
* key frames and non-key frames, this field will always point to the
|
||||
* closest key frame prior to the time interval.
|
||||
*
|
||||
* o packetCount -- Specifies the number of Data Packets to send at this
|
||||
* index entry. If a video key frame has been fragmented into two <i>Data
|
||||
* Packets</i>, the value of this field will be equal to 2.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexEntries() { return $this->_indexEntries; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* For each video stream in an ASF file, there should be one instance of the
|
||||
* <i>Simple Index Object</i>. Additionally, the instances of the <i>Simple
|
||||
* Index Object</i> shall be ordered by stream number.
|
||||
*
|
||||
* Index entries in the <i>Simple Index Object</i> are in terms of
|
||||
* <i>Presentation Times</i>. The corresponding <i>Packet Number</i> field
|
||||
* values (of the <i>Index Entry</i>, see below) indicate the packet number of
|
||||
* the ASF <i>Data Packet</i> with the closest past key frame. Note that for
|
||||
* video streams that contain both key frames and non-key frames, the <i>Packet
|
||||
* Number</i> field will always point to the closest past key frame.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_SimpleIndex extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_fileId;
|
||||
|
||||
/** @var integer */
|
||||
private $_indexEntryTimeInterval;
|
||||
|
||||
/** @var integer */
|
||||
private $_maximumPacketCount;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexEntries = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_fileId = $this->_reader->readGUID();
|
||||
$this->_indexEntryTimeInterval = $this->_reader->readInt64LE();
|
||||
$this->_maximumPacketCount = $this->_reader->readUInt32LE();
|
||||
$indexEntriesCount = $this->_reader->readUInt32LE();
|
||||
for ($i = 0; $i < $indexEntriesCount; $i++) {
|
||||
$this->_indexEntries[] = array
|
||||
("packetNumber" => $this->_reader->readUInt32LE(),
|
||||
"packetCount" => $this->_reader->readUInt16LE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique identifier for this ASF file. The value of this field
|
||||
* should be changed every time the file is modified in any way. The value of
|
||||
* this field may be set to 0 or set to be identical to the value of the
|
||||
* <i>File ID</i> field of the <i>Data Object</i> and the <i>Header
|
||||
* Object</i>.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileId() { return $this->_fileId; }
|
||||
|
||||
/**
|
||||
* Returns the time interval between each index entry in 100-nanosecond units.
|
||||
* The most common value is 10000000, to indicate that the index entries are
|
||||
* in 1-second intervals, though other values can be used as well.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryTimeInterval()
|
||||
{
|
||||
return $this->_indexEntryTimeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum <i>Packet Count</i> value of all <i>Index Entries</i>.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getMaximumPacketCount() { return $this->_maximumPacketCount; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o packetNumber -- Specifies the number of the Data Packet associated
|
||||
* with this index entry. Note that for video streams that contain both
|
||||
* key frames and non-key frames, this field will always point to the
|
||||
* closest key frame prior to the time interval.
|
||||
*
|
||||
* o packetCount -- Specifies the number of <i>Data Packets</i> to send at
|
||||
* this index entry. If a video key frame has been fragmented into two
|
||||
* Data Packets, the value of this field will be equal to 2.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexEntries() { return $this->_indexEntries; }
|
||||
}
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Stream Bitrate Properties Object</i> defines the average bit rate of
|
||||
* each digital media stream.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_StreamBitrateProperties extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_bitrateRecords = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$bitrateRecordsCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $bitrateRecordsCount; $i++)
|
||||
$this->_bitrateRecords[] = array
|
||||
("streamNumber" => ($tmp = $this->_reader->readInt16LE()) & 0x1f,
|
||||
"flags" => $tmp >> 5,
|
||||
"averageBitrate" => $this->_reader->readUInt32LE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of bitrate records. Each record consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the number of this stream described by this
|
||||
* record. 0 is an invalid stream. Valid values are between 1 and 127.
|
||||
*
|
||||
* o flags -- These bits are reserved and should be set to 0.
|
||||
*
|
||||
* o averageBitrate -- Specifies the average bit rate of the stream in bits
|
||||
* per second. This value should include an estimate of ASF packet and
|
||||
* payload overhead associated with this stream.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getBitrateRecords() { return $this->_bitrateRecords; }
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Stream Bitrate Properties Object</i> defines the average bit rate of
|
||||
* each digital media stream.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_StreamBitrateProperties extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_bitrateRecords = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$bitrateRecordsCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $bitrateRecordsCount; $i++)
|
||||
$this->_bitrateRecords[] = array
|
||||
("streamNumber" => ($tmp = $this->_reader->readInt16LE()) & 0x1f,
|
||||
"flags" => $tmp >> 5,
|
||||
"averageBitrate" => $this->_reader->readUInt32LE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of bitrate records. Each record consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the number of this stream described by this
|
||||
* record. 0 is an invalid stream. Valid values are between 1 and 127.
|
||||
*
|
||||
* o flags -- These bits are reserved and should be set to 0.
|
||||
*
|
||||
* o averageBitrate -- Specifies the average bit rate of the stream in bits
|
||||
* per second. This value should include an estimate of ASF packet and
|
||||
* payload overhead associated with this stream.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getBitrateRecords() { return $this->_bitrateRecords; }
|
||||
}
|
||||
|
||||
99
src/ASF/Object/StreamPrioritization.php
Normal file
99
src/ASF/Object/StreamPrioritization.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Stream Prioritization Object</i> indicates the author's intentions as
|
||||
* to which streams should or should not be dropped in response to varying
|
||||
* network congestion situations. There may be special cases where this
|
||||
* preferential order may be ignored (for example, the user hits the "mute"
|
||||
* button). Generally it is expected that implementations will try to honor the
|
||||
* author's preference.
|
||||
*
|
||||
* The priority of each stream is indicated by how early in the list that
|
||||
* stream's stream number is listed (in other words, the list is ordered in
|
||||
* terms of decreasing priority).
|
||||
*
|
||||
* The Mandatory flag field shall be set if the author wants that stream kept
|
||||
* "regardless". If this flag is not set, then that indicates that the stream
|
||||
* should be dropped in response to network congestion situations. Non-mandatory
|
||||
* streams must never be assigned a higher priority than mandatory streams.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_StreamPrioritization extends ASF_Object
|
||||
{
|
||||
/** @var Array */
|
||||
private $_priorityRecords = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
$priorityRecordCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $priorityRecordCount; $i++)
|
||||
$this->_priorityRecords[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"flags" => $this->_reader->readUInt16LE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of records. Each record consists of the following keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number. Valid values are between
|
||||
* 1 and 127.
|
||||
*
|
||||
* o flags -- Specifies the flags. The mandatory flag is the bit 1 (LSB).
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getPriorityRecords() { return $this->_priorityRecords; }
|
||||
}
|
||||
181
src/ASF/Object/TimecodeIndex.php
Normal file
181
src/ASF/Object/TimecodeIndex.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* This top-level ASF object supplies timecode indexing information for the
|
||||
* streams of an ASF file. It includes stream-specific indexing information
|
||||
* based on the timecodes found in the file. If the <i>Timecode Index Object</i>
|
||||
* is used, it is recommended that timecodes be stored as a <i>Payload Extension
|
||||
* System</i> on the appropriate stream. It is also recommended that every
|
||||
* timecode appearing in the ASF file have a corresponging index entry.
|
||||
*
|
||||
* The index is designed to be broken into blocks to facilitate storage that is
|
||||
* more space-efficient by using 32-bit offsets relative to a 64-bit base. That
|
||||
* is, each index block has a full 64-bit offset in the block header that is
|
||||
* added to the 32-bit offsets found in each index entry. If a file is larger
|
||||
* than 2^32 bytes, then multiple index blocks can be used to fully index the
|
||||
* entire large file while still keeping index entry offsets at 32 bits.
|
||||
*
|
||||
* To locate an object with a particular timecode in an ASF file, one would
|
||||
* typically look through the <i>Timecode Index Object</i> in blocks of the
|
||||
* appropriate range and try to locate the nearest possible timecode. The
|
||||
* corresponding <i>Offset</i> field values of the <i>Index Entry</i> are byte
|
||||
* offsets that, when combined with the <i>Block Position</i> value of the Index
|
||||
* Block, indicate the starting location in bytes of an ASF Data Packet relative
|
||||
* to the start of the first ASF Data Packet in the file.
|
||||
*
|
||||
* Any ASF file containing a <i>Timecode Index Object</i> shall also contain a
|
||||
* <i>Timecode Index Parameters Object</i> in its
|
||||
* {@link ASF_Object_Header ASF Header}.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_TimecodeIndex extends ASF_Object
|
||||
{
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Data Packet. The Nearest
|
||||
* Past Data Packet indexes point to the data packet whose presentation time
|
||||
* is closest to the index entry time.
|
||||
*/
|
||||
const NEAREST_PAST_DATA_PACKET = 1;
|
||||
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Media. The Nearest Past
|
||||
* Object indexes point to the closest data packet containing an entire object
|
||||
* or first fragment of an object.
|
||||
*/
|
||||
const NEAREST_PAST_MEDIA = 2;
|
||||
|
||||
/**
|
||||
* Indicates that the index type is Nearest Past Cleanpoint. The Nearest Past
|
||||
* Cleanpoint indexes point to the closest data packet containing an entire
|
||||
* object (or first fragment of an object) that has the Cleanpoint Flag set.
|
||||
*
|
||||
* Nearest Past Cleanpoint is the most common type of index.
|
||||
*/
|
||||
const NEAREST_PAST_CLEANPOINT = 3;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexSpecifiers = array();
|
||||
|
||||
/** @var Array */
|
||||
private $_indexBlocks = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_reader->skip(4);
|
||||
$indexSpecifiersCount = $this->_reader->readUInt16LE();
|
||||
$indexBlocksCount = $this->_reader->readUInt32LE();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$this->_indexSpecifiers[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"indexType" => $this->_reader->readUInt16LE());
|
||||
for ($i = 0; $i < $indexBlocksCount; $i++) {
|
||||
$indexEntryCount = $this->_reader->readUInt32LE();
|
||||
$timecodeRange = $this->_reader->readUInt16LE();
|
||||
$blockPositions = array();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$blockPositions[] = $this->_reader->readInt64LE();
|
||||
$indexEntries = array();
|
||||
for ($i = 0; $i < $indexEntryCount; $i++) {
|
||||
$timecode = $this->_reader->readUInt32LE();
|
||||
$offsets = array();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++)
|
||||
$offsets[] = $this->_reader->readUInt32LE();
|
||||
$indexEntries[] = array
|
||||
("timecode" => $timecode,
|
||||
"offsets" => $offsets);
|
||||
}
|
||||
$this->_indexBlocks[] = array
|
||||
("timecodeRange" => $timecodeRange,
|
||||
"blockPositions" => $blockPositions,
|
||||
"indexEntries" => $indexEntries);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of index specifiers. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number that the <i>Index
|
||||
* Specifiers</i> refer to. Valid values are between 1 and 127.
|
||||
*
|
||||
* o indexType -- Specifies the type of index.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexSpecifiers() { return $this->_indexSpecifiers; }
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o timecodeRange -- Specifies the timecode range for this block.
|
||||
* Subsequent blocks must contain range numbers greater than or equal to
|
||||
* this one.
|
||||
*
|
||||
* o blockPositions -- Specifies a list of byte offsets of the beginnings of
|
||||
* the blocks relative to the beginning of the first Data Packet (for
|
||||
* example, the beginning of the Data Object + 50 bytes).
|
||||
*
|
||||
* o indexEntries -- An array that consists of the following keys
|
||||
* o timecode -- This is the 4-byte timecode for these entries.
|
||||
* o offsets -- Specifies the offset. An offset value of 0xffffffff
|
||||
* indicates an invalid offset value.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexBlocks() { return $this->_indexBlocks; }
|
||||
}
|
||||
125
src/ASF/Object/TimecodeIndexParameters.php
Normal file
125
src/ASF/Object/TimecodeIndexParameters.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Reader Library
|
||||
*
|
||||
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the project workgroup nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ASF/Object.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Timecode Index Parameters Object</i> supplies information about those
|
||||
* streams that are actually indexed (there must be at least one stream in an
|
||||
* index) by timecodes. All streams referred to in the
|
||||
* {@link ASF_Object_TimecodeIndexParameters Timecode Index Parameters Object}
|
||||
* must have timecode Payload Extension Systems associated with them in the
|
||||
* {@link ASF_Object_ExtendedStreamProperties Extended Stream Properties
|
||||
* Object}. This object shall be present in the {@link ASF_Object_Header Header
|
||||
* Object} if there is a {@link ASF_Object_TimecodeIndex Timecode Index Object}
|
||||
* present in the file.
|
||||
*
|
||||
* An Index Specifier is required for each stream that will be indexed by the
|
||||
* {@link ASF_Object_TimecodeIndex Timecode Index Object}. These specifiers must
|
||||
* exactly match those in the {@link ASF_Object_TimecodeIndex Timecode Index
|
||||
* Object}.
|
||||
*
|
||||
* @package php-reader
|
||||
* @subpackage ASF
|
||||
* @author Sven Vollbehr <svollbehr@gmail.com>
|
||||
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
|
||||
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
|
||||
* @version $Rev$
|
||||
*/
|
||||
final class ASF_Object_TimecodeIndexParameters extends ASF_Object
|
||||
{
|
||||
/** @var string */
|
||||
private $_indexEntryCountInterval;
|
||||
|
||||
/** @var Array */
|
||||
private $_indexSpecifiers = array();
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and reads object related data
|
||||
* from the ASF file.
|
||||
*
|
||||
* @param Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader, &$options = array())
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_indexEntryCountInterval = $this->_reader->readUInt32LE();
|
||||
$indexSpecifiersCount = $this->_reader->readUInt16LE();
|
||||
for ($i = 0; $i < $indexSpecifiersCount; $i++) {
|
||||
$this->_indexSpecifiers[] = array
|
||||
("streamNumber" => $this->_reader->readUInt16LE(),
|
||||
"indexType" => $this->_reader->readUInt16LE());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the interval between each index entry by the number of media
|
||||
* objects. This value cannot be 0.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getIndexEntryCountInterval()
|
||||
{
|
||||
return $this->_indexEntryCountInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of index entries. Each entry consists of the following
|
||||
* keys.
|
||||
*
|
||||
* o streamNumber -- Specifies the stream number that the Index Specifiers
|
||||
* refer to. Valid values are between 1 and 127.
|
||||
*
|
||||
* o indexType -- Specifies the type of index. Values are defined as
|
||||
* follows:
|
||||
* 2 = Nearest Past Media Object,
|
||||
* 3 = Nearest Past Cleanpoint (1 is not a valid value).
|
||||
* For a video stream, The Nearest Past Media Object indexes point to the
|
||||
* closest data packet containing an entire video frame or the first
|
||||
* fragment of a video frame, and the Nearest Past Cleanpoint indexes
|
||||
* point to the closest data packet containing an entire video frame (or
|
||||
* first fragment of a video frame) that is a key frame. Nearest Past
|
||||
* Media Object is the most common value.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getIndexSpecifiers() { return $this->_indexSpecifiers; }
|
||||
}
|
||||
Reference in New Issue
Block a user