Add Zend_Media_Asf class proposal

git-svn-id: http://php-reader.googlecode.com/svn/branches/zend@168 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2010-03-06 09:06:20 +00:00
parent 2d57b1fd24
commit ebe67fdf7f
80 changed files with 7805 additions and 8057 deletions

View File

@@ -1,216 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2006-2009 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) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once("Reader.php");
require_once("ASF/Object/Container.php");
/**#@-*/
/**
* This class represents a file in Advanced Systems Format (ASF) as described in
* {@link http://go.microsoft.com/fwlink/?LinkId=31334 The Advanced Systems
* Format (ASF) Specification}. It is a file format that can contain various
* types of information ranging from audio and video to script commands and
* developer defined custom streams.
*
* The ASF file consists of code blocks that are called content objects. Each
* of these objects have a format of their own. They may contain other objects
* or other specific data. Each supported object has been implemented as their
* own classes to ease the correct use of the information.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
class ASF extends ASF_Object_Container
{
/** @var string */
private $_filename;
/**
* Constructs the ASF class with given file and options.
*
* The following options are currently recognized:
* o encoding -- Indicates the encoding that all the texts are presented
* with. By default this is set to utf-8. See the documentation of iconv
* for accepted values.
* o readonly -- Indicates that the file is read from a temporary location
* or another source it cannot be written back to.
*
* @param string $filename The path to the file or file descriptor of an
* opened file.
* @param Array $options The options array.
*/
public function __construct($filename, $options = array())
{
$this->_reader = new Reader($this->_filename = $filename);
$this->setOptions($options);
if ($this->getOption("encoding", false) === false)
$this->setOption("encoding", "utf-8");
$this->setOffset(0);
$this->setSize($this->_reader->getSize());
$this->constructObjects
(array
(self::HEADER => "Header",
self::DATA => "Data",
self::SIMPLE_INDEX => "SimpleIndex",
self::INDEX => "Index",
self::MEDIA_OBJECT_INDEX => "MediaObjectIndex",
self::TIMECODE_INDEX => "TimecodeIndex"));
}
/**
* Returns the mandatory header object contained in this file.
*
* @return ASF_Object_Header
*/
public function getHeader()
{
$header = $this->getObjectsByIdentifier(self::HEADER);
return $header[0];
}
/**
* Returns the mandatory data object contained in this file.
*
* @return ASF_Object_Data
*/
public function getData()
{
$data = $this->getObjectsByIdentifier(self::DATA);
return $data[0];
}
/**
* Returns an array of index objects contained in this file.
*
* @return Array
*/
public function getIndices()
{
return $this->getObjectsByIdentifier
(self::SIMPLE_INDEX . "|" . self::INDEX . "|" .
self::MEDIA_OBJECT_INDEX . "|" . self::TIMECODE_INDEX);
}
/**
* Writes the changes back to the original media file.
*/
public function write($filename = false)
{
if ($filename === false)
$filename = $this->_filename;
if ($filename !== false && $this->_filename !== false &&
realpath($filename) != realpath($this->_filename) &&
!copy($this->_filename, $filename)) {
require_once("ASF/Exception.php");
throw new ASF_Exception("Unable to copy source to destination: " .
realpath($this->_filename) . "->" . realpath($filename));
}
if (($fd = fopen
($filename, file_exists($filename) ? "r+b" : "wb")) === false) {
require_once("ASF/Exception.php");
throw new ASF_Exception("Unable to open file for writing: " . $filename);
}
$header = $this->getHeader();
$headerLengthOld = $header->getSize();
$header->removeObjectsByIdentifier(ASF_Object::PADDING);
$header->headerExtension->removeObjectsByIdentifier(ASF_Object::PADDING);
$headerData = $header->__toString();
$headerLengthNew = $header->getSize();
// Fits right in
if ($headerLengthOld == $headerLengthNew) {
}
// Fits with adjusted padding
else if ($headerLengthOld >= $headerLengthNew + 24 /* for header */) {
$header->headerExtension->padding->setSize
($headerLengthOld - $headerLengthNew);
$headerData = $header->__toString();
$headerLengthNew = $header->getSize();
}
// Must expand
else {
$header->headerExtension->padding->setSize(4096);
$headerData = $header->__toString();
$headerLengthNew = $header->getSize();
fseek($fd, 0, SEEK_END);
$oldFileSize = ftell($fd);
ftruncate
($fd, $newFileSize = $headerLengthNew - $headerLengthOld +
$oldFileSize);
for ($i = 1, $cur = $oldFileSize; $cur > 0; $cur -= 1024, $i++) {
fseek($fd, -(($i * 1024) + ($newFileSize - $oldFileSize)), SEEK_END);
$buffer = fread($fd, 1024);
fseek($fd, -($i * 1024), SEEK_END);
fwrite($fd, $buffer, 1024);
}
}
fseek($fd, 0);
fwrite($fd, $headerData, $headerLengthNew);
fclose($fd);
$this->_filename = $filename;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return true; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
}

View File

@@ -1,51 +0,0 @@
<?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 ISO 14496
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Id$
*/
/**
* The ASF_Exception is thrown whenever an error occurs within the {@link ASF}
* 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$
*/
class ASF_Exception extends Exception
{
}

View File

@@ -1,301 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2006-2009 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) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Id$
*/
/**
* The base unit of organization for ASF files is called the ASF object. It
* consists of a 128-bit GUID for the object, a 64-bit integer object size, and
* the variable-length object data.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
abstract class ASF_Object
{
/* ASF Objects */
const HEADER = "75b22630-668e-11cf-a6d9-00aa0062ce6c";
const DATA = "75b22636-668e-11cf-a6d9-00aa0062ce6c";
const SIMPLE_INDEX = "33000890-e5b1-11cf-89f4-00a0c90349cb";
const INDEX = "d6e229d3-35da-11d1-9034-00a0c90349be";
const MEDIA_OBJECT_INDEX = "feb103f8-12ad-4c64-840f-2a1d2f7ad48c";
const TIMECODE_INDEX = "3cb73fd0-0c4a-4803-953d-edf7b6228f0c";
/* Header Objects */
const FILE_PROPERTIES = "8cabdca1-a947-11cf-8ee4-00c00c205365";
const STREAM_PROPERTIES = "b7dc0791-a9b7-11cf-8ee6-00c00c205365";
const HEADER_EXTENSION = "5fbf03b5-a92e-11cf-8ee3-00c00c205365";
const CODEC_LIST = "86d15240-311d-11d0-a3a4-00a0c90348f6";
const SCRIPT_COMMAND = "1efb1a30-0b62-11d0-a39b-00a0c90348f6";
const MARKER = "f487cd01-a951-11cf-8ee6-00c00c205365";
const BITRATE_MUTUAL_EXCLUSION = "d6e229dc-35da-11d1-9034-00a0c90349be";
const ERROR_CORRECTION = "75b22635-668e-11cf-a6d9-00aa0062ce6c";
const CONTENT_DESCRIPTION = "75b22633-668e-11cf-a6d9-00aa0062ce6c";
const EXTENDED_CONTENT_DESCRIPTION = "d2d0a440-e307-11d2-97f0-00a0c95ea850";
const CONTENT_BRANDING = "2211b3fa-bd23-11d2-b4b7-00a0c955fc6e";
const STREAM_BITRATE_PROPERTIES = "7bf875ce-468d-11d1-8d82-006097c9a2b2";
const CONTENT_ENCRYPTION = "2211b3fb-bd23-11d2-b4b7-00a0c955fc6e";
const EXTENDED_CONTENT_ENCRYPTION = "298ae614-2622-4c17-b935-dae07ee9289c";
const DIGITAL_SIGNATURE = "2211b3fc-bd23-11d2-b4b7-00a0c955fc6e";
const PADDING = "1806d474-cadf-4509-a4ba-9aabcb96aae8";
/* Header Extension Objects */
const EXTENDED_STREAM_PROPERTIES = "14e6a5cb-c672-4332-8399-a96952065b5a";
const ADVANCED_MUTUAL_EXCLUSION = "a08649cf-4775-4670-8a16-6e35357566cd";
const GROUP_MUTUAL_EXCLUSION = "d1465a40-5a79-4338-b71b-e36b8fd6c249";
const STREAM_PRIORITIZATION = "d4fed15b-88d3-454f-81f0-ed5c45999e24";
const BANDWIDTH_SHARING = "a69609e6-517b-11d2-b6af-00c04fd908e9";
const LANGUAGE_LIST = "7c4346a9-efe0-4bfc-b229-393ede415c85";
const METADATA = "c5f8cbea-5baf-4877-8467-aa8c44fa4cca";
const METADATA_LIBRARY = "44231c94-9498-49d1-a141-1d134e457054";
const INDEX_PARAMETERS = "d6e229df-35da-11d1-9034-00a0c90349be";
const MEDIA_OBJECT_INDEX_PARAMETERS = "6b203bad-3f11-48e4-aca8-d7613de2cfa7";
const TIMECODE_INDEX_PARAMETERS = "f55e496d-9797-4b5d-8c8b-604dfe9bfb24";
const COMPATIBILITY = "75b22630-668e-11cf-a6d9-00aa0062ce6c";
const ADVANCED_CONTENT_ENCRYPTION = "43058533-6981-49e6-9b74-ad12cb86d58c";
/**
* The reader object.
*
* @var Reader
*/
protected $_reader;
/**
* The options array.
*
* @var Array
*/
protected $_options;
/** @var integer */
private $_offset = false;
/** @var string */
private $_identifier = false;
/** @var integer */
private $_size = false;
/** @var ASF_Object */
private $_parent = null;
/**
* Constructs the class with given parameters and options.
*
* @param Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
$this->_reader = $reader;
$this->_options = &$options;
if ($reader === null) {
if (defined($constant = "self::" . strtoupper
(preg_replace
("/(?<=[a-z])[A-Z]/", "_$0", substr(get_class($this), 11)))))
$this->_identifier = constant($constant);
else {
require_once("ASF/Exception.php");
throw new ASF_Exception("Object identifier could not be determined");
}
} else {
$this->_offset = $this->_reader->getOffset();
$this->_identifier = $this->_reader->readGUID();
$this->_size = $this->_reader->readInt64LE();
}
}
/**
* Returns the file offset to object start, or <var>false</var> if the object
* was created on heap.
*
* @return integer
*/
public final function getOffset() { return $this->_offset; }
/**
* Sets the file offset where the object starts.
*
* @param integer $offset The file offset to object start.
*/
public final function setOffset($offset) { $this->_offset = $offset; }
/**
* Returns the GUID of the ASF object.
*
* @return string
*/
public final function getIdentifier() { return $this->_identifier; }
/**
* Set the GUID of the ASF object.
*
* @param string $id The GUID
*/
public final function setIdentifier($identifier)
{
$this->_identifier = $identifier;
}
/**
* Returns the object size in bytes, including the header.
*
* @return integer
*/
public final function getSize() { return $this->_size; }
/**
* Sets the object size. The size must include the 24 byte header.
*
* @param integer $size The object size.
*/
public final function setSize($size)
{
if ($this->_parent !== null)
$this->_parent->setSize
(($this->_parent->getSize() > 0 ? $this->_parent->getSize() : 0) +
$size - ($this->_size > 0 ? $this->_size : 0));
$this->_size = $size;
}
/**
* Returns the options array.
*
* @return Array
*/
public final function getOptions() { return $this->_options; }
/**
* Returns the given option value, or the default value if the option is not
* defined.
*
* @param string $option The name of the option.
* @param mixed $defaultValue The default value to be returned.
*/
public final function getOption($option, $defaultValue = false)
{
if (isset($this->_options[$option]))
return $this->_options[$option];
return $defaultValue;
}
/**
* Sets the options array. See {@link ASF} class for available options.
*
* @param Array $options The options array.
*/
public final function setOptions(&$options) { $this->_options = &$options; }
/**
* Sets the given option the given value.
*
* @param string $option The name of the option.
* @param mixed $value The value to set for the option.
*/
public final function setOption($option, $value)
{
$this->_options[$option] = $value;
}
/**
* Returns the parent object containing this object.
*
* @return ASF_Object
*/
public final function getParent() { return $this->_parent; }
/**
* Sets the parent containing object.
*
* @param ASF_Object $parent The parent object.
*/
public final function setParent(&$parent) { $this->_parent = $parent; }
/**
* Magic function so that $obj->value will work.
*
* @param string $name The field name.
* @return mixed
*/
public function __get($name)
{
if (method_exists($this, "get" . ucfirst($name)))
return call_user_func(array($this, "get" . ucfirst($name)));
if (method_exists($this, "is" . ucfirst($name)))
return call_user_func(array($this, "is" . ucfirst($name)));
require_once("ASF/Exception.php");
throw new ASF_Exception("Unknown field: " . $name);
}
/**
* Magic function so that assignments with $obj->value will work.
*
* @param string $name The field name.
* @param string $value The field value.
* @return mixed
*/
public function __set($name, $value)
{
if (method_exists($this, "set" . ucfirst($name)))
call_user_func(array($this, "set" . ucfirst($name)), $value);
else {
require_once("ASF/Exception.php");
throw new ASF_Exception("Unknown field: " . $name);
}
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public abstract function isMandatory();
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public abstract function isMultiple();
}

View File

@@ -1,186 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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. 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.
*
* o data -- The content protection data for this Content Encryption Record.
*
* @return Array
*/
public function getContentEncryptionRecords()
{
return $this->_contentEncryptionRecords;
}
/**
* Sets the array of content encryption records. Each record must consist 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. 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.
*
* o data -- The content protection data for this Content Encryption Record.
*
* @param Array $contentEncryptionRecords The array of content encryption
* records.
*/
public function setContentEncryptionRecords($contentEncryptionRecords)
{
$this->_contentEncryptionRecords = $contentEncryptionRecords;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toUInt16LE
($contentEncryptionRecordsCount =
count($this->_contentEncryptionRecords));
for ($i = 0; $i < $contentEncryptionRecordsCount; $i++) {
$data .=
Transform::toGUID($this->_contentEncryptionRecords["systemId"]) .
Transform::toUInt32LE
($this->_contentEncryptionRecords["systemVersion"]) .
Transform::toUInt16LE
($encryptedObjectRecordCount =
$this->_contentEncryptionRecords["streamNumbers"]);
for ($j = 0; $j < $encryptedObjectRecordCount; $j++)
$data .=
Transform::toUInt16LE(1) . Transform::toUInt16LE(2) .
Transform::toUInt16LE
($this->_contentEncryptionRecords["streamNumbers"][$j]);
$data .= strlen($this->_contentEncryptionRecords["data"]) .
$this->_contentEncryptionRecords;
}
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,159 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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 the nature of the mutual exclusion relationship.
*
* @return string
*/
public function setExclusionType($exclusionType)
{
$this->_exclusionType = $exclusionType;
}
/**
* Returns an array of stream numbers.
*
* @return Array
*/
public function getStreamNumbers() { return $this->_streamNumbers; }
/**
* Sets the array of stream numbers.
*
* @return Array
*/
public function setStreamNumbers($streamNumbers)
{
$this->_streamNumbers = $streamNumbers;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_exclusionType) .
Transform::toUInt16LE($streamNumbersCount = count($this->_streamNumbers));
for ($i = 0; $i < $streamNumbersCount; $i++)
$data .= Transform::toUInt16LE($this->_streamNumbers[$i]);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,226 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, $options);
if ($reader === null)
return;
$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; }
/**
* Sets 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 setSharingType($sharingType)
{
$this->_sharingType = $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; }
/**
* Sets 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.
*
* @param integer $dataBitrate The data bitrate.
*/
public function setDataBitrate($dataBitrate)
{
$this->_dataBitrate = $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; }
/**
* Sets 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.
*
* @param integer $bufferSize The buffer size.
*/
public function setBufferSize($bufferSize)
{
$this->_bufferSize = $bufferSize;
}
/**
* Returns an array of stream numbers.
*
* @return Array
*/
public function getStreamNumbers() { return $this->_streamNumbers; }
/**
* Sets the array of stream numbers.
*
* @param Array $streamNumbers The array of stream numbers.
*/
public function setStreamNumbers($streamNumbers)
{
$this->_streamNumbers = $streamNumbers;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_sharingType) .
Transform::toUInt32LE($this->_dataBitrate) .
Transform::toUInt32LE($this->_bufferSize) .
Transform::toUInt16LE($streamNumbersCount = count($this->_streamNumber));
for ($i = 0; $i < $streamNumbersCount; $i++)
$data .= Transform::toUInt16LE($this->_streamNumbers[$i]);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,160 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets the nature of the mutual exclusion relationship.
*
* @param string $exclusionType The nature of the mutual exclusion
* relationship.
*/
public function setExclusionType($exclusionType)
{
$this->_exclusionType = $exclusionType;
}
/**
* Returns an array of stream numbers.
*
* @return Array
*/
public function getStreamNumbers() { return $this->_streamNumbers; }
/**
* Sets the array of stream numbers.
*
* @param Array $streamNumbers The array of stream numbers.
*/
public function setStreamNumbers($streamNumbers)
{
$this->_streamNumbers = $streamNumbers;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_exclusionType) .
Transform::toUInt16LE($streamNumbersCount = count($this->_streamNumbers));
for ($i = 0; $i < $streamNumbersCount; $i++)
$data .= Transform::toUInt16LE($this->_streamNumbers[$i]);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,181 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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>Codec List Object</i> provides user-friendly information about the
* codecs and formats used to encode the content found in the ASF file.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_CodecList extends ASF_Object
{
const VIDEO_CODEC = 0x1;
const AUDIO_CODEC = 0x2;
const UNKNOWN_CODEC = 0xffff;
/** @var string */
private $_reserved;
/** @var Array */
private $_entries = 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$this->_reserved = $this->_reader->readGUID();
$codecEntriesCount = $this->_reader->readUInt32LE();
for ($i = 0; $i < $codecEntriesCount; $i++) {
$entry = array("type" => $this->_reader->readUInt16LE());
$codecNameLength = $this->_reader->readUInt16LE() * 2;
$entry["codecName"] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($codecNameLength));
$codecDescriptionLength = $this->_reader->readUInt16LE() * 2;
$entry["codecDescription"] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($codecDescriptionLength));
$codecInformationLength = $this->_reader->readUInt16LE();
$entry["codecInformation"] =
$this->_reader->read($codecInformationLength);
$this->_entries[] = $entry;
}
}
/**
* Returns the array of codec entries. Each record consists of the following
* keys.
*
* o type -- Specifies the type of the codec used. Use one of the following
* values: VIDEO_CODEC, AUDIO_CODEC, or UNKNOWN_CODEC.
*
* o codecName -- Specifies the name of the codec used to create the
* content.
*
* o codecDescription -- Specifies the description of the format used to
* create the content.
*
* o codecInformation -- Specifies an opaque array of information bytes
* about the codec used to create the content. The meaning of these bytes
* is determined by the codec.
*
* @return Array
*/
public function getEntries() { return $this->_entries; }
/**
* Sets the array of codec entries. Each record must consist of the following
* keys.
*
* o codecName -- Specifies the name of the codec used to create the
* content.
*
* o codecDescription -- Specifies the description of the format used to
* create the content.
*
* o codecInformation -- Specifies an opaque array of information bytes
* about the codec used to create the content. The meaning of these bytes
* is determined by the codec.
*
* @param Array $entries The array of codec entries.
*/
public function setEntries($entries) { $this->_entries = $entries; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toGUID($this->_reserved) .
Transform::toUInt32LE($codecEntriesCount = count($this->_entries));
for ($i = 0; $i < $codecEntriesCount; $i++) {
$data .= Transform::toUInt16LE($this->_entries[$i]["type"]) .
Transform::toUInt16LE(strlen($codecName = iconv
($this->getOption("encoding"), "utf-16le",
$this->_entries[$i]["codecName"]) . "\0\0") / 2) .
Transform::toString16($codecName) .
Transform::toUInt16LE(strlen($codecDescription = iconv
($this->getOption("encoding"), "utf-16le",
$this->_entries[$i]["codecDescription"]) . "\0\0") / 2) .
Transform::toString16($codecDescription) .
Transform::toUInt16LE(strlen($this->_entries[$i]["codecInformation"])) .
$this->_entries[$i]["codecInformation"];
}
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,138 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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 profile field. This field is reserved and is set to 2.
*
* @param integer $profile The profile.
*/
public function setProfile($profile) { $this->_profile = $profile; }
/**
* Returns the mode field. This field is reserved and is set to 1.
*
* @return integer
*/
public function getMode() { return $this->_mode; }
/**
* Sets the mode field. This field is reserved and is set to 1.
*
* @param integer $mode The mode.
*/
public function setMode($mode) { $this->_mode = $mode; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toUInt8($this->_profile) .
Transform::toUInt8($this->_mode);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,330 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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/Unknown.php");
/**#@-*/
/**
* An abstract base container class that contains other ASF objects.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
abstract class ASF_Object_Container extends ASF_Object
{
/** @var Array */
private $_objects = array();
/**
* Reads and constructs the objects found within this object.
*/
protected final function constructObjects($defaultclassnames = array())
{
while (true) {
$offset = $this->_reader->getOffset();
if ($offset >= $this->getOffset() + $this->getSize())
break;
$guid = $this->_reader->readGUID();
$size = $this->_reader->readInt64LE();
$this->_reader->setOffset($offset);
if (isset($defaultclassnames[$guid])) {
if (@fopen($filename = "ASF/Object/" . $defaultclassnames[$guid] .
".php", "r", true) !== false)
require_once($filename);
if (class_exists
($classname = "ASF_Object_" . $defaultclassnames[$guid]))
$object = new $classname($this->_reader, $this->_options);
else
$object = new ASF_Object_Unknown($this->_reader, $this->_options);
} else
$object = new ASF_Object_Unknown($this->_reader, $this->_options);
$object->setParent($this);
if (!$this->hasObject($object->getIdentifier()))
$this->_objects[$object->getIdentifier()] = array();
$this->_objects[$object->getIdentifier()][] = $object;
$this->_reader->setOffset($offset + $size);
}
}
/**
* Checks whether the object with given identifier is present in the file. The
* identifier can either be the object GUID, or name of the constant
* containing the GUID, or the name of the object class.
*
* Returns <var>true</var> if one or more objects are present,
* <var>false</var> otherwise.
*
* @param string $identifier The object GUID, name of the GUID constant, or
* object class name.
* @return boolean
*/
public final function hasObject($identifier)
{
if (defined($constname = get_class($this) . "::" . strtoupper
(preg_replace("/[A-Z]/", "_$0", $identifier)))) {
$objects = $this->getObjectsByIdentifier(constant($constname));
return isset($objects[0]);
}
else
return isset($this->_objects[$identifier]);
}
/**
* Returns all the objects the file contains as an associate array. The object
* identifiers work as keys having an array of ASF objects as associated
* value.
*
* @return Array
*/
public final function getObjects() { return $this->_objects; }
/**
* Returns an array of objects matching the given object GUID or an empty
* array if no object matched the identifier.
*
* The identifier may contain wildcard characters "*" and "?". The asterisk
* matches against zero or more characters, and the question mark matches any
* single character.
*
* @param string $identifier The object GUID.
* @return Array
*/
public final function getObjectsByIdentifier($identifier)
{
$matches = array();
$searchPattern = "/^" .
str_replace(array("*", "?"), array(".*", "."), $identifier) . "$/i";
foreach ($this->_objects as $identifier => $objects)
if (preg_match($searchPattern, $identifier))
foreach ($objects as $object)
$matches[] = $object;
return $matches;
}
/**
* Returns an array of objects matching the given object constant name or an
* empty array if no object matched the name.
*
* The object constant name can be given in three forms; either using the full
* name of the constant, the name of the class or the shorthand style of the
* class name having its first letter in lower case.
*
* One may use the shorthand $obj->name to access the first box with the name
* given directly. Shorthands will not work with user defined uuid types.
*
* The name may not contain wildcard characters.
*
* @param string $name The object constant name or class name.
* @return Array
*/
public final function getObjectsByName($name)
{
if (defined($constname = get_class($this) . "::" . $name) ||
defined($constname = get_class($this) . "::" . strtoupper
(preg_replace
("/^_/", "", preg_replace("/[A-Z]/", "_$0", $name)))))
return $this->getObjectsByIdentifier(constant($constname));
return array();
}
/**
* Removes any objects matching the given object GUID.
*
* The identifier may contain wildcard characters "*" and "?". The asterisk
* matches against zero or more characters, and the question mark matches any
* single character.
*
* One may also use the shorthand unset($obj->name) to achieve the same
* result. Wildcards cannot be used with the shorthand method.
*
* @param string $identifier The object GUID.
*/
public final function removeObjectsByIdentifier($identifier)
{
$searchPattern = "/^" .
str_replace(array("*", "?"), array(".*", "."), $identifier) . "$/i";
foreach ($this->_objects as $identifier => $objects)
if (preg_match($searchPattern, $identifier))
unset($this->_objects[$identifier]);
}
/**
* Removes any objects matching the given object name.
*
* The name can be given in three forms; either using the full name of the
* constant, the name of the class or the shorthand style of the class name
* having its first letter in lower case.
*
* One may also use the shorthand unset($obj->name) to achieve the same
* result.
*
* The name may not contain wildcard characters.
*
* @param string $name The object constant name or class name.
*/
public final function removeObjectsByName($name)
{
if (defined($constname = get_class($this) . "::" . strtoupper
(preg_replace("/[A-Z]/", "_$0", $name))))
unset($this->_objects[constant($constname)]);
}
/**
* Adds a new object into the current object and returns it.
*
* @param ASF_Object $object The object to add
* @return ASF_Object
*/
public final function addObject($object)
{
$object->setParent($this);
$object->setOptions($this->_options);
if (!$this->hasObject($object->getIdentifier()))
$this->_objects[$object->getIdentifier()] = array();
return $this->_objects[$object->getIdentifier()][] = $object;
}
/**
* Removes the object.
*
* @param ASF_Object $object The object to remove
*/
public final function removeObject($object)
{
if ($this->hasObject($object->getIdentifier())) {
foreach ($this->_objects[$object->getIdentifier()] as $key => $value)
if ($object === $value)
unset($this->_objects[$object->getIdentifier()][$key]);
}
}
/**
* Override magic function so that $obj->value will work as expected.
*
* The method first attempts to call the appropriate getter method. If no
* field with given name is found, the method attempts to return the right
* object instead. In other words, calling $obj->value will attempt to return
* the first object returned by $this->getObjectsByIdentifier(self::value).
* If no object is found by the given value, a respective class name is tried
* to instantiate and add to the container.
*
* @param string $name The field or object name.
* @return mixed
*/
public function __get($name)
{
if (method_exists($this, "get" . ucfirst($name)))
return call_user_func(array($this, "get" . ucfirst($name)));
if (method_exists($this, "is" . ucfirst($name)))
return call_user_func(array($this, "is" . ucfirst($name)));
if (defined($constname = get_class($this) . "::" . strtoupper
(preg_replace("/[A-Z]/", "_$0", $name)))) {
$objects = $this->getObjectsByIdentifier(constant($constname));
if (isset($objects[0]))
return $objects[0];
else {
if (@fopen($filename = "ASF/Object/" . ucfirst($name) .
".php", "r", true) !== false)
require_once($filename);
if (class_exists
($classname = "ASF_Object_" . ucfirst($name))) {
$obj = new $classname();
$obj->setIdentifier(constant($constname));
return $this->addObject($obj);
}
}
}
require_once("ASF/Exception.php");
throw new ASF_Exception("Unknown field/object: " . $name);
}
/**
* Override magic function so that $obj->value will work as expected.
*
* The method first attempts to call the appropriate setter method. If no
* field with given name is found, the method attempts to set the right
* object instead. In other words, assigning to $obj->value will attempt to
* set the object with given value's identifier.
*
* Please note that using this method will override any prior objects having
* the same object identifier.
*
* @param string $name The field or object name.
* @param string $value The field value or object.
* @return mixed
*/
public function __set($name, $value)
{
if (method_exists($this, "set" . ucfirst($name)))
call_user_func(array($this, "set" . ucfirst($name)), $value);
if (defined($constname = get_class($this) . "::" . strtoupper
(preg_replace("/[A-Z]/", "_$0", $name)))) {
$value->setOptions($this->_options);
$this->_objects[constant($constname)] = array($value);
}
else {
require_once("ASF/Exception.php");
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 or name is contained by this
* container.
*
* @param string $name The object identifier or logical name.
* @return boolean
*/
public function __isset($name) { return $this->hasObject($name); }
/**
* Magic function so that unset($obj->value) will work. This method removes
* all the objects with the given identifier or name.
*
* @param string $name The object identifier or logical name.
*/
public function __unset($name) { $this->removeObjectsByName($name); }
}

View File

@@ -1,219 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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; }
/**
* Sets 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.
*
* @param integer $bannerImageType The type of data.
*/
public function setBannerImageType($bannerImageType)
{
$this->_bannerImageType = $bannerImageType;
}
/**
* Returns the entire banner image, including the header for the appropriate
* image format.
*
* @return string
*/
public function getBannerImageData() { return $this->_bannerImageData; }
/**
* Sets the entire banner image, including the header for the appropriate
* image format.
*
* @param string $bannerImageData The entire banner image.
*/
public function setBannerImageData($bannerImageData)
{
$this->_bannerImageData = $bannerImageData;
}
/**
* Returns, if present, a link to more information about the banner image.
*
* @return string
*/
public function getBannerImageUrl() { return $this->_bannerImageUrl; }
/**
* Sets a link to more information about the banner image.
*
* @param string $bannerImageUrl The link.
*/
public function setBannerImageUrl($bannerImageUrl)
{
$this->_bannerImageUrl = $bannerImageUrl;
}
/**
* Returns, if present, a link to more information about the copyright for the
* content.
*
* @return string
*/
public function getCopyrightUrl() { return $this->_copyrightUrl; }
/**
* Sets a link to more information about the copyright for the content.
*
* @param string $copyrightUrl The copyright link.
*/
public function setCopyrightUrl($copyrightUrl)
{
$this->_copyrightUrl = $copyrightUrl;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toUInt32LE($this->_bannerImageType) .
Transform::toUInt32LE(count($this->_bannerImageData)) .
$this->_bannerImageData .
Transform::toUInt32LE(count($this->_bannerImageUrl)) .
$this->_bannerImageUrl .
Transform::toUInt32LE(count($this->_copyrightUrl)) .
$this->_copyrightUrl;
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,238 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2006-2009 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) 2006-2009 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 Description Object</i> lets authors record well-known data
* describing the file and its contents. This object is used to store standard
* bibliographic information such as title, author, copyright, description, and
* rating information. This information is pertinent to the entire file.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_ContentDescription extends ASF_Object
{
/** @var string */
private $_title;
/** @var string */
private $_author;
/** @var string */
private $_copyright;
/** @var string */
private $_description;
/** @var string */
private $_rating;
/**
* 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$titleLen = $this->_reader->readUInt16LE();
$authorLen = $this->_reader->readUInt16LE();
$copyrightLen = $this->_reader->readUInt16LE();
$descriptionLen = $this->_reader->readUInt16LE();
$ratingLen = $this->_reader->readUInt16LE();
$this->_title = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($titleLen));
$this->_author = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($authorLen));
$this->_copyright = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($copyrightLen));
$this->_description = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($descriptionLen));
$this->_rating = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($ratingLen));
}
/**
* Returns the title information.
*
* @return string
*/
public function getTitle() { return $this->_title; }
/**
* Sets the title information.
*
* @param string $title The title information.
*/
public function setTitle($title) { $this->_title = $title; }
/**
* Returns the author information.
*
* @return string
*/
public function getAuthor() { return $this->_author; }
/**
* Sets the author information.
*
* @param string $author The author information.
*/
public function setAuthor($author) { $this->_author = $author; }
/**
* Returns the copyright information.
*
* @return string
*/
public function getCopyright() { return $this->_copyright; }
/**
* Sets the copyright information.
*
* @param string $copyright The copyright information.
*/
public function setCopyright($copyright) { $this->_copyright = $copyright; }
/**
* Returns the description information.
*
* @return string
*/
public function getDescription() { return $this->_description; }
/**
* Sets the description information.
*
* @param string $description The description information.
*/
public function setDescription($description)
{
$this->_description = $description;
}
/**
* Returns the rating information.
*
* @return string
*/
public function getRating() { return $this->_rating; }
/**
* Sets the rating information.
*
* @param string $rating The rating information.
*/
public function setRating($rating) { $this->_rating = $rating; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$title = iconv
($this->getOption("encoding"), "utf-16le",
$this->_title ? $this->_title . "\0" : "");
$author = iconv
($this->getOption("encoding"), "utf-16le",
$this->_author ? $this->_author . "\0" : "");
$copyright = iconv
($this->getOption("encoding"), "utf-16le",
$this->_copyright ? $this->_copyright . "\0" : "");
$description = iconv
($this->getOption("encoding"), "utf-16le",
$this->_description ? $this->_description . "\0" : "");
$rating = iconv
($this->getOption("encoding"), "utf-16le",
$this->_rating ? $this->_rating . "\0" : "");
$data =
Transform::toUInt16LE(strlen($title)) .
Transform::toUInt16LE(strlen($author)) .
Transform::toUInt16LE(strlen($copyright)) .
Transform::toUInt16LE(strlen($description)) .
Transform::toUInt16LE(strlen($rating)) .
Transform::toString16($title) .
Transform::toString16($author) .
Transform::toString16($copyright) .
Transform::toString16($description) .
Transform::toString16($rating);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,198 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets the secret data.
*
* @param string $secretData The secret data.
*/
public function setSecretData($secretData)
{
$this->_secretData = $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; }
/**
* Sets the type of protection mechanism used. The value of this field
* is to be set to "DRM".
*
* @param string $protectionType The protection mechanism used.
*/
public function setProtectionType($protectionType)
{
$this->_protectionType = $protectionType;
}
/**
* Returns the key ID used.
*
* @return string
*/
public function getKeyId() { return $this->_keyId; }
/**
* Sets the key ID used.
*
* @param string $keyId The key ID used.
*/
public function setKeyId($keyId) { $this->_keyId = $keyId; }
/**
* Returns the URL from which a license to manipulate the content can be
* acquired.
*
* @return string
*/
public function getLicenseUrl() { return $this->_licenseUrl; }
/**
* Returns the URL from which a license to manipulate the content can be
* acquired.
*
* @param string $licenseUrl The URL from which a license can be acquired.
*/
public function setLicenseUrl($licenseUrl)
{
$this->_licenseUrl = $licenseUrl;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toUInt32LE(strlen($this->_secretData)) .
$this->_secretData .
Transform::toUInt32LE($len = strlen($this->_protectionType) + 1) .
Transform::toString8($this->_protectionType, $len) .
Transform::toUInt32LE($len = strlen($this->_keyId) + 1) .
Transform::toString8($this->_keyId, $len) .
Transform::toUInt32LE($len = strlen($this->_licenseUrl) + 1) .
Transform::toString8($this->_licenseUrl, $len);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,142 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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>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 support for ASF Data Packets
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 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);
/* Support for Data Packets is not done yet
* 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->_totalDataPackets; }
/**
* Returns an array of Data Packets.
*
* @return Array
*/
public function getDataPackets()
{
require_once("ASF/Exception.php");
throw new ASF_Exception("Support for Data Packets is not done yet");
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return true; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
}

View File

@@ -1,141 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 $_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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$this->_type = $this->_reader->readUInt32LE();
$dataLength = $this->_reader->readUInt32LE();
$this->_data = $this->_reader->read($dataLength);
}
/**
* Returns the type of digital signature used. This field is set to 2.
*
* @return integer
*/
public function getType() { return $this->_type; }
/**
* Sets the type of digital signature used. This field must be set to 2.
*
* @param integer $type The type of digital signature used.
*/
public function setType($type) { $this->_type = $type; }
/**
* Returns the digital signature data.
*
* @return string
*/
public function getData() { return $this->_data; }
/**
* Sets the digital signature data.
*
* @return string
*/
public function setData($data) { $this->_data = $data; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toUInt32LE($this->_type) .
Transform::toUInt32LE(strlen($this->_data)) . $this->_data;
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,152 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets the type of error correction.
*
* @param string $type The type of error correction.
*/
public function setType($type) { $this->_type = $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; }
/**
* Sets 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.
*
* @param Array $data The error correction specific data.
*/
public function setData($data) { $this->_data = $data; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_type) .
Transform::toUInt32LE(strlen($this->_data)) . $this->_data;
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,232 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2006-2009 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) 2006-2009 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>ASF_Extended_Content_Description_Object</i> object implementation.
* This object contains unlimited number of attribute fields giving more
* information about the file.
*
* @todo Implement better handling of various types of attributes
* according to http://msdn.microsoft.com/en-us/library/aa384495(VS.85).aspx
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_ExtendedContentDescription extends ASF_Object
{
/** @var Array */
private $_contentDescriptors = 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$contentDescriptorsCount = $this->_reader->readUInt16LE();
for ($i = 0; $i < $contentDescriptorsCount; $i++) {
$nameLen = $this->_reader->readUInt16LE();
$name = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($nameLen));
$valueDataType = $this->_reader->readUInt16LE();
$valueLen = $this->_reader->readUInt16LE();
switch ($valueDataType) {
case 0: // string
$this->_contentDescriptors[$name] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($valueLen));
break;
case 1: // byte array
$this->_contentDescriptors[$name] = $this->_reader->read($valueLen);
break;
case 2: // bool
$this->_contentDescriptors[$name] =
$this->_reader->readUInt32LE() == 1 ? true : false;
break;
case 3: // 32-bit integer
$this->_contentDescriptors[$name] = $this->_reader->readUInt32LE();
break;
case 4: // 64-bit integer
$this->_contentDescriptors[$name] = $this->_reader->readInt64LE();
break;
case 5: // 16-bit integer
$this->_contentDescriptors[$name] = $this->_reader->readUInt16LE();
break;
default:
}
}
}
/**
* Returns the value of the specified descriptor or <var>false</var> if there
* is no such descriptor defined.
*
* @param string $name The name of the descriptor (ie the name of the field).
* @return string|false
*/
public function getDescriptor($name)
{
if (isset($this->_contentDescriptors[$name]))
return $this->_contentDescriptors[$name];
return false;
}
/**
* Sets the given descriptor a new value.
*
* @param string $name The name of the descriptor.
* @param string $value The value of the field.
* @return string|false
*/
public function setDescriptor($name, $value)
{
$this->_contentDescriptors[$name] = $value;
}
/**
* 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; }
/**
* Sets the content descriptor associate array having the descriptor names as
* array keys and their values as associated value. The descriptor names and
* all string values must be encoded in the default character encoding given
* as an option to {@link ASF} class.
*
* @param Array $contentDescriptors The content descriptors
*/
public function setDescriptors($contentDescriptors)
{
$this->_contentDescriptors = $contentDescriptors;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt16LE(count($this->_contentDescriptors));
foreach ($this->_contentDescriptors as $name => $value) {
$descriptor = iconv
($this->getOption("encoding"), "utf-16le", $name ? $name . "\0" : "");
$data .= Transform::toUInt16LE(strlen($descriptor)) .
Transform::toString16($descriptor);
if (is_string($value)) {
/* There is no way to distinguish byte arrays from unicode strings and
* hence the need for a list of fields of type byte array */
static $byteArray = array (
"W\0M\0/\0M\0C\0D\0I\0\0\0",
"W\0M\0/\0U\0s\0e\0r\0W\0e\0b\0U\0R\0L\0\0\0",
"W\0M\0/\0L\0y\0r\0i\0c\0s\0_\0S\0y\0n\0c\0h\0r\0o\0n\0i\0s\0e\0d\0\0\0",
"W\0M\0/\0P\0i\0c\0t\0u\0r\0e\0\0\0"
); // TODO: Add to the list if you encounter one
if (in_array($descriptor, $byteArray))
$data .= Transform::toUInt16LE(1) .
Transform::toUInt16LE(strlen($value)) . $value;
else {
$value = iconv
($this->getOption("encoding"), "utf-16le", $value) . "\0\0";
$data .= Transform::toUInt16LE(0) .
Transform::toUInt16LE(strlen($value)) .
Transform::toString16($value);
}
}
else if (is_bool($value))
$data .= Transform::toUInt16LE(2) . Transform::toUInt16LE(4) .
Transform::toUInt32LE($value ? 1 : 0);
else if (is_int($value))
$data .= Transform::toUInt16LE(3) . Transform::toUInt16LE(4) .
Transform::toUInt32LE($value);
else if (is_float($value))
$data .= Transform::toUInt16LE(4) . Transform::toUInt16LE(8) .
Transform::toInt64LE($value);
else {
// Invalid value and there is nothing to be done so cause a fatal error
require_once("ASF/Exception.php");
throw new ASF_Exception("Invalid data type");
}
}
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,121 +0,0 @@
<?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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets the array of bytes required by the DRM client to manipulate the
* protected content.
*
* @param string $data The data.
*/
public function setData($data) { $this->_data = $data; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt32LE(strlen($this->_data)) . $this->_data;
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,697 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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->readString16($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->readString16($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; }
/**
* Sets 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).
*
* The given value must be in units of milliseconds or optionally be set to 0,
* in which case the field will be ignored.
*
* @param integer $startTime The presentation time of the first object.
*/
public function setStartTime($startTime) { $this->_startTime = $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; }
/**
* Sets 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).
*
* The given value must be given in units of milliseconds or optionally be set
* to 0, in which case the field will be ignored.
*
* @param integer $endTime The presentation time of the last object plus the
* duration of play.
*/
public function setEndTime($endTime) { $this->_endTime = $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; }
/**
* Sets 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 must be given a non-zero value.
*
* @param integer $dataBitrate The leak rate.
*/
public function setDataBitrate($dataBitrate)
{
$this->_dataBitrate = $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; }
/**
* Sets the size B, in milliseconds, of the leaky bucket used in the
* <i>Data Bitrate</i> definition.
*
* @param integer $bufferSize The size.
*/
public function setBufferSize($bufferSize)
{
$this->_bufferSize = $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;
}
/**
* Sets 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.
*
* @param integer $initialBufferFullness The initial fullness.
*/
public function setInitialBufferFullness($initialBufferFullness)
{
$this->_initialBufferFullness = $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;
}
/**
* Sets 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.
*
* @param integer $alternateDataBitrate The alternate leak rate.
*/
public function setAlternateDataBitrate($alternateDataBitrate)
{
$this->_alternateDataBitrate = $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;
}
/**
* Sets 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.
*
* @param integer $alternateBufferSize
*/
public function setAlternateBufferSize($alternateBufferSize)
{
$this->_alternateBufferSize = $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;
}
/**
* Sets 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.
*
* @param integer $alternateInitialBufferFullness The alternate initial
* fullness.
*/
public function setAlternateInitialBufferFullness
($alternateInitialBufferFullness)
{
$this->_alternateInitialBufferFullness = $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;
}
/**
* Sets the maximum size of the largest sample stored in the data packets for
* a stream. A value of 0 means unknown.
*
* @param integer $maximumObjectSize The maximum size of the largest sample.
*/
public function setMaximumObjectSize($maximumObjectSize)
{
$this->_maximumObjectSize = $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;
}
/**
* Sets 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.
*
* @param integer $averageTimePerFrame The average time duration.
*/
public function setAverageTimePerFrame($averageTimePerFrame)
{
$this->_averageTimePerFrame = $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;
}
/**
* Sets 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.
*
* @param integer $streamNumber The number of this stream.
*/
public function setStreamNumber($streamNumber)
{
$this->_streamNumber = $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;
}
/**
* Sets 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.
*
* @param integer $streamLanguageIndex The language index.
*/
public function setStreamLanguageIndex($streamLanguageIndex)
{
$this->_streamLanguageIndex = $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 entry contains the following keys:
* o languageIndex -- The language index
* o streamName -- The localized stream name
*
* @return Array
*/
public function getStreamNames()
{
return $this->_streamNames;
}
/**
* Sets the 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 entries are to contain the following keys:
* o languageIndex -- The language index
* o streamName -- The localized stream name
*
* @param Array $streamNames The array of stream names
*/
public function setStreamNames($streamNames)
{
$this->_streamNames = $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 entry 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;
}
/**
* Sets 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 enties are to contain 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).
*
* @param Array $payloadExtensionSystems The array of payload extension
* systems.
*/
public function setPayloadExtensionSystems($payloadExtensionSystems)
{
$this->_payloadExtensionSystems = $payloadExtensionSystems;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toInt64LE($this->_startTime) .
Transform::toInt64LE($this->_endTime) .
Transform::toUInt32LE($this->_dataBitrate) .
Transform::toUInt32LE($this->_bufferSize) .
Transform::toUInt32LE($this->_initialBufferFullness) .
Transform::toUInt32LE($this->_alternateDataBitrate) .
Transform::toUInt32LE($this->_alternateBufferSize) .
Transform::toUInt32LE($this->_alternateInitialBufferFullness) .
Transform::toUInt32LE($this->_maximumObjectSize) .
Transform::toUInt32LE($this->_flags) .
Transform::toUInt16LE($this->_streamNumber) .
Transform::toUInt16LE($this->_streamLanguageIndex) .
Transform::toInt64LE($this->_averageTimePerFrame) .
Transform::toUInt16LE($streamNameCount = count($this->_streamNames)) .
Transform::toUInt16LE
($payloadExtensionSystemCount = count($this->_payloadExtensionSystems));
for ($i = 0; $i < $streamNameCount; $i++)
$data .=
Transform::toUInt16LE($this->_streamNames["languageIndex"]) .
Transform::toUInt16LE(strlen($streamName = iconv
($this->getOption("encoding"), "utf-16le",
$this->_streamNames["streamName"]) . "\0\0")) .
Transform::toString16($streamName);
for ($i = 0; $i < $payloadExtensionSystemCount; $i++)
$data .=
Transform::toGUID($this->_streamNames["extensionSystemId"]) .
Transform::toUInt16LE($this->_streamNames["extensionDataSize"]) .
Transform::toUInt16LE(strlen($extensionSystemInfo = iconv
($this->getOption("encoding"), "utf-16le",
$this->_streamNames["extensionSystemInfo"]) . "\0\0")) .
Transform::toString16($extensionSystemInfo);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,429 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2006-2009 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) 2006-2009 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>File Properties Object</i> defines the global characteristics of the
* combined digital media streams found within the Data Object.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_FileProperties extends ASF_Object
{
/**
* Indicates, if set, that a file is in the process of being created (for
* example, for recording applications), and thus that various values stored
* in the header objects are invalid. It is highly recommended that
* post-processing be performed to remove this condition at the earliest
* opportunity.
*/
const BROADCAST = 1;
/**
* Indicates, if set, that a file is seekable. Note that for files containing
* a single audio stream and a <i>Minimum Data Packet Size</i> field equal to
* the <i>Maximum Data Packet Size</i> field, this flag shall always be set to
* 1. For files containing a single audio stream and a video stream or
* mutually exclusive video streams, this flag is only set to 1 if the file
* contains a matching <i>Simple Index Object</i> for each regular video
* stream.
*/
const SEEKABLE = 2;
/** @var string */
private $_fileId;
/** @var integer */
private $_fileSize;
/** @var integer */
private $_creationDate;
/** @var integer */
private $_dataPacketsCount;
/** @var integer */
private $_playDuration;
/** @var integer */
private $_sendDuration;
/** @var integer */
private $_preroll;
/** @var integer */
private $_flags;
/** @var integer */
private $_minimumDataPacketSize;
/** @var integer */
private $_maximumDataPacketSize;
/** @var integer */
private $_maximumBitrate;
/**
* 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->_fileSize = $this->_reader->readInt64LE();
$this->_creationDate = $this->_reader->readInt64LE();
$this->_dataPacketsCount = $this->_reader->readInt64LE();
$this->_playDuration = $this->_reader->readInt64LE();
$this->_sendDuration = $this->_reader->readInt64LE();
$this->_preroll = $this->_reader->readInt64LE();
$this->_flags = $this->_reader->readUInt32LE();
$this->_minimumDataPacketSize = $this->_reader->readUInt32LE();
$this->_maximumDataPacketSize = $this->_reader->readUInt32LE();
$this->_maximumBitrate = $this->_reader->readUInt32LE();
}
/**
* Returns the file id field.
*
* @return integer
*/
public function getFileId() { return $this->_fileId; }
/**
* Sets the file id field.
*
* @param GUID $fileId The new file id.
*/
public function setFileId($fileId) { $this->_fileId = $fileId; }
/**
* Returns the size, in bytes, of the entire file. The value of this field is
* invalid if the broadcast flag bit in the flags field is set to 1.
*
* @return integer
*/
public function getFileSize() { return $this->_fileSize; }
/**
* Sets the size, in bytes, of the entire file. The value of this field is
* invalid if the broadcast flag bit in the flags field is set to 1.
*
* @param integer $fileSize The size of the entire file.
*/
public function setFileSize($fileSize) { $this->_fileSize = $fileSize; }
/**
* Returns the date and time of the initial creation of the file. The value is
* given as the number of 100-nanosecond intervals since January 1, 1601,
* according to Coordinated Universal Time (Greenwich Mean Time). The value of
* this field may be invalid if the broadcast flag bit in the flags field is
* set to 1.
*
* @return integer
*/
public function getCreationDate() { return $this->_creationDate; }
/**
* Sets the date and time of the initial creation of the file. The value is
* given as the number of 100-nanosecond intervals since January 1, 1601,
* according to Coordinated Universal Time (Greenwich Mean Time). The value of
* this field may be invalid if the broadcast flag bit in the flags field is
* set to 1.
*
* @param integer $creationDate The date and time of the initial creation of
* the file.
*/
public function setCreationDate($creationDate)
{
$this->_creationDate = $creationDate;
}
/**
* Returns the number of Data Packet entries that exist within the
* {@link ASF_Object_Data Data Object}. The value of this field is invalid if
* the broadcast flag bit in the flags field is set to 1.
*
* @return integer
*/
public function getDataPacketsCount() { return $this->_dataPacketsCount; }
/**
* Sets the number of Data Packet entries that exist within the
* {@link ASF_Object_Data Data Object}. The value of this field is invalid if
* the broadcast flag bit in the flags field is set to 1.
*
* @param integer $dataPacketsCount The number of Data Packet entries.
*/
public function setDataPacketsCount($dataPacketsCount)
{
$this->_dataPacketsCount = $dataPacketsCount;
}
/**
* Returns the time needed to play the file in 100-nanosecond units. This
* value should include the duration (estimated, if an exact value is
* unavailable) of the the last media object in the presentation. The value of
* this field is invalid if the broadcast flag bit in the flags field is set
* to 1.
*
* @return integer
*/
public function getPlayDuration() { return $this->_playDuration; }
/**
* Sets the time needed to play the file in 100-nanosecond units. This
* value should include the duration (estimated, if an exact value is
* unavailable) of the the last media object in the presentation. The value of
* this field is invalid if the broadcast flag bit in the flags field is set
* to 1.
*
* @param integer $playDuration The time needed to play the file.
*/
public function setPlayDuration($playDuration)
{
$this->_playDuration = $playDuration;
}
/**
* Returns the time needed to send the file in 100-nanosecond units. This
* value should include the duration of the last packet in the content. The
* value of this field is invalid if the broadcast flag bit in the flags field
* is set to 1.
*
* @return integer
*/
public function getSendDuration() { return $this->_sendDuration; }
/**
* Sets the time needed to send the file in 100-nanosecond units. This
* value should include the duration of the last packet in the content. The
* value of this field is invalid if the broadcast flag bit in the flags field
* is set to 1.
*
* @param integer $sendDuration The time needed to send the file.
*/
public function setSendDuration($sendDuration)
{
$this->_sendDuration = $sendDuration;
}
/**
* Returns the amount of time to buffer data before starting to play the file,
* in millisecond units. If this value is nonzero, the <i>Play Duration</i>
* field and all of the payload <i>Presentation Time</i> fields have been
* offset by this amount. Therefore, player software must subtract the value
* in the preroll field from the play duration and presentation times to
* calculate their actual values.
*
* @return integer
*/
public function getPreroll() { return $this->_preroll; }
/**
* Sets the amount of time to buffer data before starting to play the file,
* in millisecond units. If this value is nonzero, the <i>Play Duration</i>
* field and all of the payload <i>Presentation Time</i> fields have been
* offset by this amount. Therefore, player software must subtract the value
* in the preroll field from the play duration and presentation times to
* calculate their actual values.
*
* @param integer $preroll The amount of time to buffer data.
*/
public function setPreroll($preroll) { $this->_preroll = $preroll; }
/**
* Checks whether or not the flag is set. Returns <var>true</var> if the flag
* is set, <var>false</var> otherwise.
*
* @param integer $flag The flag to query.
* @return boolean
*/
public function hasFlag($flag) { return ($this->_flags & $flag) == $flag; }
/**
* Returns the flags field.
*
* @return integer
*/
public function getFlags() { return $this->_flags; }
/**
* Sets the flags field.
*
* @param integer $flags The flags field.
*/
public function setFlags($flags) { $this->_flags = $flags; }
/**
* Returns the minimum <i>Data Packet</i> size in bytes. In general, the value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1. However, the values for the <i>Minimum Data Packet Size</i> and
* <i>Maximum Data Packet Size</i> fields shall be set to the same value, and
* this value should be set to the packet size, even when the broadcast flag
* in the flags field is set to 1.
*
* @return integer
*/
public function getMinimumDataPacketSize()
{
return $this->_minimumDataPacketSize;
}
/**
* Sets the minimum <i>Data Packet</i> size in bytes. In general, the value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1. However, the values for the <i>Minimum Data Packet Size</i> and
* <i>Maximum Data Packet Size</i> fields shall be set to the same value, and
* this value should be set to the packet size, even when the broadcast flag
* in the flags field is set to 1.
*
* @param integer $minimumDataPacketSize The minimum <i>Data Packet</i> size
* in bytes.
*/
public function setMinimumDataPacketSize($minimumDataPacketSize)
{
$this->_minimumDataPacketSize = $minimumDataPacketSize;
}
/**
* Returns the maximum <i>Data Packet</i> size in bytes. In general, the value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1. However, the values for the <i>Minimum Data Packet Size</i> and
* <i>Maximum Data Packet Size</i> fields shall be set to the same value, and
* this value should be set to the packet size, even when the broadcast flag
* in the flags field is set to 1.
*
* @return integer
*/
public function getMaximumDataPacketSize()
{
return $this->_maximumDataPacketSize;
}
/**
* Sets the maximum <i>Data Packet</i> size in bytes. In general, the value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1. However, the values for the <i>Minimum Data Packet Size</i> and
* <i>Maximum Data Packet Size</i> fields shall be set to the same value, and
* this value should be set to the packet size, even when the broadcast flag
* in the flags field is set to 1.
*
* @param integer $maximumDataPacketSize The maximum <i>Data Packet</i> size
* in bytes
*/
public function setMaximumDataPacketSize($maximumDataPacketSize)
{
$this->_maximumDataPacketSize = $maximumDataPacketSize;
}
/**
* Returns the maximum instantaneous bit rate in bits per second for the
* entire file. This is equal the sum of the bit rates of the individual
* digital media streams.
*
* @return integer
*/
public function getMaximumBitrate() { return $this->_maximumBitrate; }
/**
* Sets the maximum instantaneous bit rate in bits per second for the
* entire file. This is equal the sum of the bit rates of the individual
* digital media streams.
*
* @param integer $maximumBitrate The maximum instantaneous bit rate in bits
* per second.
*/
public function setMaximumBitrate($maximumBitrate)
{
$this->_maximumBitrate = $maximumBitrate;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return true; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_fileId) .
Transform::toInt64LE($this->_fileSize) .
Transform::toInt64LE($this->_creationDate) .
Transform::toInt64LE($this->_dataPacketsCount) .
Transform::toInt64LE($this->_playDuration) .
Transform::toInt64LE($this->_sendDuration) .
Transform::toInt64LE($this->_preroll) .
Transform::toUInt32LE($this->_flags) .
Transform::toUInt32LE($this->_minimumDataPacketSize) .
Transform::toUInt32LE($this->_maximumDataPacketSize) .
Transform::toUInt32LE($this->_maximumBitrate);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,171 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets the nature of the mutual exclusion relationship.
*
* @param string $exclusionType The exclusion type.
*/
public function setExclusionType($exclusionType)
{
$this->_exclusionType = $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; }
/**
* Sets an array of records. Each record is to consist of the following keys.
*
* o streamNumbers -- Specifies the stream numbers for this record. Valid
* values are between 1 and 127.
*
* @param Array $records The array of records
*/
public function setRecords($records) { $this->_records = $records; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_exclusionType) .
Transform::toUInt16LE($recordCount = count($this->_records));
for ($i = 0; $i < $recordCount; $i++) {
$data .=
Transform::toUInt16LE($streamNumbersCount = count($this->_records[$i]));
for ($j = 0; $j < $streamNumbersCount; $j++)
$data .= Transform::toUInt16LE($this->_records[$i][$j]["streamNumbers"]);
}
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,153 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2006-2009 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) 2006-2009 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/Container.php");
/**#@-*/
/**
* The role of the header object is to provide a well-known byte sequence at the
* beginning of ASF files and to contain all the information that is needed to
* properly interpret the information within the data object. The header object
* can optionally contain metadata such as bibliographic information.
*
* Of the three top-level ASF objects, the header object is the only one that
* contains other ASF objects. The header object may include a number of
* standard objects including, but not limited to:
*
* o File Properties Object -- Contains global file attributes.
* o Stream Properties Object -- Defines a digital media stream and its
* characteristics.
* o Header Extension Object -- Allows additional functionality to be added to
* an ASF file while maintaining backward compatibility.
* o Content Description Object -- Contains bibliographic information.
* o Script Command Object -- Contains commands that can be executed on the
* playback timeline.
* o Marker Object -- Provides named jump points within a file.
*
* Note that objects in the header object may appear in any order. To be valid,
* the header object must contain a {@link ASF_Object_FileProperties File
* Properties Object}, a {@link ASF_Object_HeaderExtension Header Extension
* Object}, and at least one {@link ASF_Object_StreamProperties Stream
* Properties Object}.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2006-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_Header extends ASF_Object_Container
{
/** @var integer */
private $_reserved1;
/** @var integer */
private $_reserved2;
/**
* Constructs the class with given parameters and options.
*
* @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);
$this->_reserved1 = $this->_reader->readInt8();
$this->_reserved2 = $this->_reader->readInt8();
$this->constructObjects
(array
(self::FILE_PROPERTIES => "FileProperties",
self::STREAM_PROPERTIES => "StreamProperties",
self::HEADER_EXTENSION => "HeaderExtension",
self::CODEC_LIST => "CodecList",
self::SCRIPT_COMMAND => "ScriptCommand",
self::MARKER => "Marker",
self::BITRATE_MUTUAL_EXCLUSION => "BitrateMutualExclusion",
self::ERROR_CORRECTION => "ErrorCorrection",
self::CONTENT_DESCRIPTION => "ContentDescription",
self::EXTENDED_CONTENT_DESCRIPTION => "ExtendedContentDescription",
self::CONTENT_BRANDING => "ContentBranding",
self::STREAM_BITRATE_PROPERTIES => "StreamBitrateProperties",
self::CONTENT_ENCRYPTION => "ContentEncryption",
self::EXTENDED_CONTENT_ENCRYPTION => "ExtendedContentEncryption",
self::DIGITAL_SIGNATURE => "DigitalSignature",
self::PADDING => "Padding"));
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return true; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = "";
foreach ($this->getObjects() as $objects)
foreach ($objects as $object)
$data .= $object->__toString();
$this->setSize
(24 /* for header */ + 6 + strlen($data) /* for object data */);
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) .
Transform::toUInt32LE(count($this->getObjects())) .
Transform::toInt8($this->_reserved1) .
Transform::toInt8($this->_reserved2) . $data;
}
}

View File

@@ -1,132 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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/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 zero or more additional extended
* header objects.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_HeaderExtension extends ASF_Object_Container
{
/** @var string */
private $_reserved1;
/** @var integer */
private $_reserved2;
/**
* 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->_reserved1 = $this->_reader->readGUID();
$this->_reserved2 = $this->_reader->readUInt16LE();
$this->_reader->skip(4);
$this->constructObjects
(array
(self::EXTENDED_STREAM_PROPERTIES => "ExtendedStreamProperties",
self::ADVANCED_MUTUAL_EXCLUSION => "AdvancedMutualExclusion",
self::GROUP_MUTUAL_EXCLUSION => "GroupMutualExclusion",
self::STREAM_PRIORITIZATION => "StreamPrioritization",
self::BANDWIDTH_SHARING => "BandwidthSharing",
self::LANGUAGE_LIST => "LanguageList",
self::METADATA => "Metadata",
self::METADATA_LIBRARY => "MetadataLibrary",
self::INDEX_PARAMETERS => "IndexParameters",
self::MEDIA_OBJECT_INDEX_PARAMETERS => "MediaObjectIndexParameters",
self::TIMECODE_INDEX_PARAMETERS => "TimecodeIndexParameters",
self::COMPATIBILITY => "Compatibility",
self::ADVANCED_CONTENT_ENCRYPTION => "AdvancedContentEncryption",
self::PADDING => "Padding"));
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return true; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = "";
foreach ($this->getObjects() as $objects)
foreach ($objects as $object)
$data .= $object->__toString();
$this->setSize
(24 /* for header */ + 22 + strlen($data) /* for object data */);
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) .
Transform::toGUID($this->_reserved1) .
Transform::toUInt16LE($this->_reserved2) .
Transform::toUInt32LE(strlen($data)) . $data;
}
}

View File

@@ -1,185 +0,0 @@
<?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; }
}

View File

@@ -1,121 +0,0 @@
<?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; }
}

View File

@@ -1,132 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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>Language List Object</i> contains an array of Unicode-based language
* IDs. All other header objects refer to languages through zero-based positions
* in this array.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_LanguageList extends ASF_Object
{
/** @var Array */
private $_languages = 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$languageIdRecordsCount = $this->_reader->readUInt16LE();
for ($i = 0; $i < $languageIdRecordsCount; $i++) {
$languageIdLength = $this->_reader->readInt8();
$languageId = $this->_reader->readString16($languageIdLength);
$this->_languages[] = iconv
("utf-16le", $this->getOption("encoding"), $languageId);
}
}
/**
* Returns the array of language ids.
*
* @return Array
*/
public function getLanguages() { return $this->_languages; }
/**
* Sets the array of language ids.
*
* @param Array $languages The array of language ids.
*/
public function setLanguages($languages) { $this->_languages = $languages; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt16LE
($languageIdRecordsCount = count($this->_languages));
for ($i = 0; $i < $languageIdRecordsCount; $i++)
$data .=
Transform::toInt8(strlen($languageId = iconv
($this->getOption("encoding"), "utf-16le", $this->_languages[$i]) .
"\0\0")) . Transform::toString16($languageId);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,207 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 $_reserved1;
/** @var integer */
private $_reserved2;
/** @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->_reserved1 = $this->_reader->readGUID();
$markersCount = $this->_reader->readUInt32LE();
$this->_reserved2 = $this->_reader->readUInt16LE();
$nameLength = $this->_reader->readUInt16LE();
$this->_name = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($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->readString16($descriptionLength));
$this->_markers[] = $marker;
}
}
/**
* Returns the name of the Marker Object.
*
* @return Array
*/
public function getName() { return $this->_name; }
/**
* Returns the name of the Marker Object.
*
* @param string $name The name.
*/
public function setName($name) { $this->_name = $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; }
/**
* Sets the array of markers. Each entry is to consist 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.
*
* @param Array $markers The array of markers.
*/
public function setMarkers($markers) { $this->_markers = $markers; }
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_reserved1) .
Transform::toUInt32LE($markersCount = count($this->_markers)) .
Transform::toUInt16LE($this->_reserved2) .
Transform::toUInt16LE
(strlen($name = iconv
($this->getOption("encoding"), "utf-16le", $this->_name) . "\0\0")) .
Transform::toString16($name);
for ($i = 0; $i < $markersCount; $i++)
$data .=
Transform::toInt64LE($this->_markers[$i]["offset"]) .
Transform::toInt64LE($this->_markers[$i]["presentationTime"]) .
Transform::toUInt16LE
(12 + ($descriptionLength = strlen($description = iconv
("utf-16le", $this->getOption("encoding"),
$this->_markers[$i]["description"]) . "\0\0"))) .
Transform::toUInt32LE($this->_markers[$i]["sendTime"]) .
Transform::toUInt32LE($this->_markers[$i]["flags"]) .
Transform::toUInt32LE($descriptionLength) .
Transform::toString16($description);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,176 +0,0 @@
<?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; }
}

View File

@@ -1,130 +0,0 @@
<?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; }
}

View File

@@ -1,223 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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 Object</i> permits authors to store stream-based metadata in
* a file. This object supports the same types of metadata information as the
* <i>Extended Content Description Object</i> except that it also allows a
* stream number to be specified.
*
* @todo Implement better handling of various types of attributes
* according to http://msdn.microsoft.com/en-us/library/aa384495(VS.85).aspx
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_Metadata 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$descriptionRecordsCount = $this->_reader->readUInt16LE();
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
$this->_reader->skip(2);
$descriptionRecord = array("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->readString16($nameLength));
switch ($dataType) {
case 0: // Unicode string
$descriptionRecord["data"] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($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;
}
$this->_descriptionRecords[] = $descriptionRecord;
}
}
/**
* Returns the array of description records. Each record consists of the
* following keys.
*
* o streamNumber -- Specifies the stream number. Valid values are between
* 1 and 127.
*
* o name -- Specifies the name that uniquely identifies the attribute being
* described. Names are case-sensitive.
*
* o data -- Specifies the actual metadata being stored.
*
* @return Array
*/
public function getDescriptionRecords() { return $this->_descriptionRecords; }
/**
* Sets the array of description records. Each record must consist of the
* following keys.
*
* o streamNumber -- Specifies the stream number. Valid values are between
* 1 and 127.
*
* o name -- Specifies the name that uniquely identifies the attribute being
* described. Names are case-sensitive.
*
* o data -- Specifies the actual metadata being stored.
*
* @param Array $descriptionRecords The array of description records.
*/
public function setDescriptionRecords($descriptionRecords)
{
$this->_descriptionRecords = $descriptionRecords;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt16LE
($descriptionRecordsCount = count($this->_descriptionRecords));
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
$data .= Transform::toUInt16LE(0) .
Transform::toUInt16LE($this->_descriptionRecords[$i]["streamNumber"]) .
Transform::toUInt16LE(strlen($name = iconv
($this->getOption("encoding"), "utf-16le",
$this->_descriptionRecords[$i]["name"]) . "\0\0"));
if (is_string($this->_descriptionRecords[$i]["data"])) {
/* There is no way to distinguish byte arrays from unicode strings and
* hence the need for a list of fields of type byte array */
static $byteArray = array (
""
); // TODO: Add to the list if you encounter one
if (in_array($name, $byteArray))
$data .= Transform::toUInt16LE(1) . Transform::toUInt32LE
(strlen($this->_descriptionRecords[$i]["data"])) . $name .
$this->_descriptionRecords[$i]["data"];
else {
$value = iconv
($this->getOption("encoding"), "utf-16le",
$this->_descriptionRecords[$i]["data"]);
$value = ($value ? $value . "\0\0" : "");
$data .= Transform::toUInt16LE(0) .
Transform::toUInt32LE(strlen($value)) . $name .
Transform::toString16($value);
}
}
else if (is_bool($this->_descriptionRecords[$i]["data"])) {
$data .= Transform::toUInt16LE(2) . Transform::toUInt32LE(2) . $name .
Transform::toUInt16LE($this->_descriptionRecords[$i]["data"] ? 1 : 0);
}
else if (is_int($this->_descriptionRecords[$i]["data"])) {
$data .= Transform::toUInt16LE(3) . Transform::toUInt32LE(4) . $name .
Transform::toUInt32LE($this->_descriptionRecords[$i]["data"]);
}
else if (is_float($this->_descriptionRecords[$i]["data"])) {
$data .= Transform::toUInt16LE(4) . Transform::toUInt32LE(8) . $name .
Transform::toInt64LE($this->_descriptionRecords[$i]["data"]);
}
else {
// Invalid value and there is nothing to be done so cause a fatal error
require_once("ASF/Exception.php");
throw new ASF_Exception("Invalid data type");
}
}
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,256 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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.
*
* @todo Implement better handling of various types of attributes
* according to http://msdn.microsoft.com/en-us/library/aa384495(VS.85).aspx
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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->readString16($nameLength));
switch ($dataType) {
case 0: // Unicode string
$descriptionRecord["data"] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($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
* {@link LanguageList Language List Object} 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; }
/**
* Sets an array of description records. Each record must consist 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 setDescriptionRecords($descriptionRecords)
{
$this->_descriptionRecords = $descriptionRecords;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt16LE
($descriptionRecordsCount = count($this->_descriptionRecords));
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
$data .=
Transform::toUInt16LE($this->_descriptionRecords[$i]["languageIndex"]) .
Transform::toUInt16LE($this->_descriptionRecords[$i]["streamNumber"]) .
Transform::toUInt16LE(strlen($name = iconv
($this->getOption("encoding"), "utf-16le",
$this->_descriptionRecords[$i]["name"]) . "\0\0"));
if (is_string($this->_descriptionRecords[$i]["data"])) {
$chunks = array();
if (preg_match
("/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i",
$this->_descriptionRecords[$i]["data"]))
$data .= Transform::toUInt16LE(6) . Transform::toUInt32LE(16) .
$name . Transform::toGUID($this->_descriptionRecords[$i]["data"]);
else {
/* There is no way to distinguish byte arrays from unicode strings and
* hence the need for a list of fields of type byte array */
static $byteArray = array (
"W\0M\0/\0L\0y\0r\0i\0c\0s\0_\0S\0y\0n\0c\0h\0r\0o\0n\0i\0s\0e\0d\0\0\0",
"W\0M\0/\0P\0i\0c\0t\0u\0r\0e\0\0\0"
); // TODO: Add to the list if you encounter one
if (in_array($name, $byteArray))
$data .= Transform::toUInt16LE(1) . Transform::toUInt32LE
(strlen($this->_descriptionRecords[$i]["data"])) . $name .
$this->_descriptionRecords[$i]["data"];
else {
$value = iconv
($this->getOption("encoding"), "utf-16le",
$this->_descriptionRecords[$i]["data"]);
$value = ($value ? $value . "\0\0" : "");
$data .= Transform::toUInt16LE(0) .
Transform::toUInt32LE(strlen($value)) . $name .
Transform::toString16($value);
}
}
}
else if (is_bool($this->_descriptionRecords[$i]["data"])) {
$data .= Transform::toUInt16LE(2) . Transform::toUInt32LE(2) . $name .
Transform::toUInt16LE($this->_descriptionRecords[$i]["data"] ? 1 : 0);
}
else if (is_int($this->_descriptionRecords[$i]["data"])) {
$data .= Transform::toUInt16LE(3) . Transform::toUInt32LE(4) . $name .
Transform::toUInt32LE($this->_descriptionRecords[$i]["data"]);
}
else if (is_float($this->_descriptionRecords[$i]["data"])) {
$data .= Transform::toUInt16LE(4) . Transform::toUInt32LE(8) . $name .
Transform::toInt64LE($this->_descriptionRecords[$i]["data"]);
}
else {
// Invalid value and there is nothing to be done so cause a fatal error
require_once("ASF/Exception.php");
throw new ASF_Exception("Invalid data type");
}
}
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,107 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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>Padding Object</i> is a dummy object that is used to pad the size of
* the <i>Header Object</i>. This object enables the size of any object stored
* in the <i>Header Object</i> to grow or shrink without having to rewrite the
* entire <i>Data Object</i> and <i>Index Object</i> sections of the ASF file.
* For instance, if entries in the <i>Content Description Object</i> or
* <i>Extended Content Description Object</i> need to be removed or shortened,
* the size of the <i>Padding Object</i> can be increased to compensate for the
* reduction in size of the <i>Content Description Object</i>. The ASF file can
* then be updated by overwriting the previous <i>Header Object</i> with the
* edited <i>Header Object</i> of identical size, without having to move or
* rewrite the data contained in the <i>Data Object</i>.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_Padding extends ASF_Object
{
/**
* 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 = null, &$options = array())
{
parent::__construct($reader, $options);
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
if ($this->getSize() == 0)
$this->setSize(24);
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) .
str_pad("", $this->getSize() - 24 /* header */, "\0");
}
}

View File

@@ -1,188 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 string */
private $_reserved;
/** @var Array */
private $_commands = array();
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$this->_reserved = $this->_reader->readGUID();
$commandsCount = $this->_reader->readUInt16LE();
$commandTypesCount = $this->_reader->readUInt16LE();
$commandTypes = array();
for ($i = 0; $i < $commandTypesCount; $i++) {
$commandTypeNameLength = $this->_reader->readUInt16LE();
$commandTypes[] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($commandTypeNameLength * 2));
}
for ($i = 0; $i < $commandsCount; $i++) {
$command = array
("presentationTime" => $this->_reader->readUInt32LE(),
"type" => $commandTypes[$this->_reader->readUInt16LE()]);
$commandNameLength = $this->_reader->readUInt16LE();
$command["name"] = iconv
("utf-16le", $this->getOption("encoding"),
$this->_reader->readString16($commandNameLength * 2));
$this->_commands[] = $command;
}
}
/**
* 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 type -- Specifies the type of this command.
*
* o name -- Specifies the name of this command.
*
* @return Array
*/
public function getCommands() { return $this->_commands; }
/**
* Sets the array of index entries. Each entry is to consist of the following
* keys.
*
* o presentationTime -- Specifies the presentation time of the command, in
* milliseconds.
*
* o type -- Specifies the type of this command.
*
* o name -- Specifies the name of this command.
*
* @param Array $commands The array of index entries.
*/
public function setCommands($commands) { $this->_commands = $commands; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$commandTypes = array();
foreach ($this->_commands as $command)
if (!in_array($command["type"], $commandTypes))
$commandTypes[] = $command["type"];
$data =
Transform::toGUID($this->_reserved) .
Transform::toUInt16LE($commandsCount = count($this->_commands)) .
Transform::toUInt16LE($commandTypesCount = count($commandTypes));
for ($i = 0; $i < $commandTypesCount; $i++)
$data .=
Transform::toUInt16LE
(strlen($commandType = iconv
($this->getOption("encoding"), "utf-16le",
$commandTypes[$i])) / 2) . $commandType;
for ($i = 0; $i < $commandsCount; $i++)
$data .=
Transform::toUInt32LE($this->_commands[$i]["presentationTime"]) .
Transform::toUInt16LE
(array_search($this->_commands[$i]["type"], $commandTypes)) .
Transform::toUInt16LE
(strlen($command = iconv
($this->getOption("encoding"), "utf-16le",
$this->_commands[$i]["name"])) / 2) . $command;
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,143 +0,0 @@
<?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; }
}

View File

@@ -1,153 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets 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.
*
* @param Array $bitrateRecords The array of bitrate records.
*/
public function setBitrateRecords($bitrateRecords)
{
$this->_bitrateRecords = $bitrateRecords;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt16LE
($bitrateRecordsCount = count($this->_bitrateRecords));
for ($i = 0; $i < $bitrateRecordsCount; $i++)
$data .= Transform::toUInt16LE
(($this->_bitrateRecords[$i]["flags"] << 5) |
($this->_bitrateRecords[$i]["streamNumber"] & 0x1f)) .
Transform::toUInt32LE($this->_bitrateRecords[$i]["averageBitrate"]);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,154 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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-2009 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 = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null)
return;
$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; }
/**
* Sets the 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).
*
* @param Array $priorityRecords The array of records.
*/
public function setPriorityRecords($priorityRecords)
{
$this->_priorityRecords = $priorityRecords;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data = Transform::toUInt16LE
($priorityRecordCount = count($this->_priorityRecords));
for ($i = 0; $i < $priorityRecordCount; $i++)
$data .=
Transform::toUInt16LE($this->_priorityRecords[$i]["streamNumber"]) .
Transform::toUInt16LE($this->_priorityRecords[$i]["flags"]);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,516 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2008-2009 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-2009 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 Properties Object</i> defines the specific properties and
* characteristics of a digital media stream. This object defines how a digital
* media stream within the <i>Data Object</i> is interpreted, as well as the
* specific format (of elements) of the <i>Data Packet</i> itself.
*
* Whereas every stream in an ASF presentation, including each stream in a
* mutual exclusion relationship, must be represented by a <i>Stream Properties
* Object</i>, in certain cases, this object might be found embedded in the
* <i>Extended Stream Properties Object</i>.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008-2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_StreamProperties extends ASF_Object
{
/**
* Indicates, if set, that the data contained in this stream is encrypted and
* will be unreadable unless there is a way to decrypt the stream.
*/
const ENCRYPTED_CONTENT = 0x8000;
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 string */
private $_streamType;
/** @var string */
private $_errorCorrectionType;
/** @var integer */
private $_timeOffset;
/** @var integer */
private $_flags;
/** @var integer */
private $_reserved;
/** @var Array */
private $_typeSpecificData = array();
/** @var Array */
private $_errorCorrectionData = 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->_streamType = $this->_reader->readGUID();
$this->_errorCorrectionType = $this->_reader->readGUID();
$this->_timeOffset = $this->_reader->readInt64LE();
$typeSpecificDataLength = $this->_reader->readUInt32LE();
$errorCorrectionDataLength = $this->_reader->readUInt32LE();
$this->_flags = $this->_reader->readUInt16LE();
$this->_reserved = $this->_reader->readUInt32LE();
switch ($this->_streamType) {
case self::AUDIO_MEDIA:
$this->_typeSpecificData = array
("codecId" => $this->_reader->readUInt16LE(),
"numberOfChannels" => $this->_reader->readUInt16LE(),
"samplesPerSecond" => $this->_reader->readUInt32LE(),
"avgNumBytesPerSecond" => $this->_reader->readUInt32LE(),
"blockAlignment" => $this->_reader->readUInt16LE(),
"bitsPerSample" => $this->_reader->readUInt16LE());
$codecSpecificDataSize = $this->_reader->readUInt16LE();
$this->_typeSpecificData["codecSpecificData"] =
$this->_reader->read($codecSpecificDataSize);
break;
case self::VIDEO_MEDIA:
$this->_typeSpecificData = array
("encodedImageWidth" => $this->_reader->readUInt32LE(),
"encodedImageHeight" => $this->_reader->readUInt32LE(),
"reservedFlags" => $this->_reader->readInt8());
$this->_reader->skip(2);
$formatDataSize = $this->_reader->readUInt32LE();
$this->_typeSpecificData = array_merge
($this->_typeSpecificData, array
("imageWidth" => $this->_reader->readUInt32LE(),
"imageHeight" => $this->_reader->readUInt32LE(),
"reserved" => $this->_reader->readUInt16LE(),
"bitsPerPixelCount" => $this->_reader->readUInt16LE(),
"compressionId" => $this->_reader->readUInt32LE(),
"imageSize" => $this->_reader->readUInt32LE(),
"horizontalPixelsPerMeter" => $this->_reader->readUInt32LE(),
"verticalPixelsPerMeter" => $this->_reader->readUInt32LE(),
"colorsUsedCount" => $this->_reader->readUInt32LE(),
"importantColorsCount" => $this->_reader->readUInt32LE(),
"codecSpecificData" => $this->_reader->read($formatDataSize - 38)));
break;
case self::JFIF_MEDIA:
$this->_typeSpecificData = array
("imageWidth" => $this->_reader->readUInt32LE(),
"imageHeight" => $this->_reader->readUInt32LE(),
"reserved" => $this->_reader->readUInt32LE());
break;
case self::DEGRADABLE_JPEG_MEDIA:
$this->_typeSpecificData = array
("imageWidth" => $this->_reader->readUInt32LE(),
"imageHeight" => $this->_reader->readUInt32LE(),
$this->_reader->readUInt16LE(),
$this->_reader->readUInt16LE(),
$this->_reader->readUInt16LE());
$interchangeDataSize = $this->_reader->readUInt16LE();
if ($interchangeDataSize == 0)
$interchangeDataSize++;
$this->_typeSpecificData["interchangeData"] =
$this->_reader->read($interchangeDataSize);
break;
case self::FILE_TRANSFER_MEDIA:
case self::BINARY_MEDIA:
$this->_typeSpecificData = array
("majorMediaType" => $this->_reader->getGUID(),
"mediaSubtype" => $this->_reader->getGUID(),
"fixedSizeSamples" => $this->_reader->readUInt32LE(),
"temporalCompression" => $this->_reader->readUInt32LE(),
"sampleSize" => $this->_reader->readUInt32LE(),
"formatType" => $this->_reader->getGUID());
$formatDataSize = $this->_reader->readUInt32LE();
$this->_typeSpecificData["formatData"] =
$this->_reader->read($formatDataSize);
break;
case self::COMMAND_MEDIA:
default:
$this->_reader->skip($typeSpecificDataLength);
}
switch ($this->_errorCorrectionType) {
case self::AUDIO_SPREAD:
$this->_errorCorrectionData = array
("span" => $this->_reader->readInt8(),
"virtualPacketLength" => $this->_reader->readUInt16LE(),
"virtualChunkLength" => $this->_reader->readUInt16LE());
$silenceDataSize = $this->_reader->readUInt16LE();
$this->_errorCorrectionData["silenceData"] =
$this->_reader->read($silenceDataSize);
break;
case self::NO_ERROR_CORRECTION:
default:
$this->_reader->skip($errorCorrectionDataLength);
}
}
/**
* Returns the number of this stream. 0 is an invalid stream. Valid values are
* between 1 and 127. The numbers assigned to streams in an ASF presentation
* may be any combination of unique values; parsing logic must not assume that
* streams are numbered sequentially.
*
* @return integer
*/
public function getStreamNumber() { return $this->_flags & 0x3f; }
/**
* Returns the number of this stream. 0 is an invalid stream. Valid values are
* between 1 and 127. The numbers assigned to streams in an ASF presentation
* may be any combination of unique values; parsing logic must not assume that
* streams are numbered sequentially.
*
* @param integer $streamNumber The number of this stream.
*/
public function setStreamNumber($streamNumber)
{
if ($streamNumber < 1 || $streamNumber > 127) {
require_once("ASF/Exception.php");
throw new ASF_Exception("Invalid argument");
}
$this->_flags = ($this->_flags & 0xffc0) | ($streamNumber & 0x3f);
}
/**
* Returns the type of the stream (for example, audio, video, and so on).
*
* @return string
*/
public function getStreamType() { return $this->_streamType; }
/**
* Sets the type of the stream (for example, audio, video, and so on).
*
* @param integer $streamType The type of the stream.
*/
public function setStreamType($streamType)
{
$this->_streamType = $streamType;
}
/**
* Returns the error correction type used by this digital media stream. For
* streams other than audio, this value should be set to NO_ERROR_CORRECTION.
* For audio streams, this value should be set to AUDIO_SPREAD.
*
* @return string
*/
public function getErrorCorrectionType()
{
return $this->_errorCorrectionType;
}
/**
* Sets the error correction type used by this digital media stream. For
* streams other than audio, this value should be set to NO_ERROR_CORRECTION.
* For audio streams, this value should be set to AUDIO_SPREAD.
*
* @param integer $errorCorrectionType The error correction type used by this
* digital media stream.
*/
public function setErrorCorrectionType($errorCorrectionType)
{
$this->_errorCorrectionType = $errorCorrectionType;
}
/**
* Returns the presentation time offset of the stream in 100-nanosecond units.
* The value of this field is added to all of the timestamps of the samples in
* the stream. This value shall be equal to the send time of the first
* interleaved packet in the data section. The value of this field is
* typically 0. It is non-zero in the case when an ASF file is edited and it
* is not possible for the editor to change the presentation times and send
* times of ASF packets. Note that if more than one stream is present in an
* ASF file the offset values of all stream properties objects must be equal.
*
* @return integer
*/
public function getTimeOffset() { return $this->_timeOffset; }
/**
* Sets the presentation time offset of the stream in 100-nanosecond units.
* The value of this field is added to all of the timestamps of the samples in
* the stream. This value shall be equal to the send time of the first
* interleaved packet in the data section. The value of this field is
* typically 0. It is non-zero in the case when an ASF file is edited and it
* is not possible for the editor to change the presentation times and send
* times of ASF packets. Note that if more than one stream is present in an
* ASF file the offset values of all stream properties objects must be equal.
*
* @param integer $timeOffset The presentation time offset of the stream.
*/
public function setTimeOffset($timeOffset)
{
$this->_timeOffset = $timeOffset;
}
/**
* Checks whether or not the flag is set. Returns <var>true</var> if the flag
* is set, <var>false</var> otherwise.
*
* @param integer $flag The flag to query.
* @return boolean
*/
public function hasFlag($flag) { return ($this->_flags & $flag) == $flag; }
/**
* Returns the flags field.
*
* @return integer
*/
public function getFlags() { return $this->_flags; }
/**
* Sets the flags field.
*
* @param integer $flags The flags field.
*/
public function setFlags($flags) { $this->_flags = $flags; }
/**
* Returns type-specific format data. The structure for the <i>Type-Specific
* Data</i> field is determined by the value stored in the <i>Stream Type</i>
* field.
*
* The type-specific data is returned as key-value pairs of an associate
* array.
*
* @return Array
*/
public function getTypeSpecificData() { return $this->_typeSpecificData; }
/**
* Sets type-specific format data. The structure for the <i>Type-Specific
* Data</i> field is determined by the value stored in the <i>Stream Type</i>
* field.
*
* @param Array $typeSpecificData The type-specific data as key-value pairs of
* an associate array.
*/
public function setTypeSpecificData($typeSpecificData)
{
$this->_typeSpecificData = $typeSpecificData;
}
/**
* Returns data specific to the error correction type. The structure for the
* <i>Error Correction Data</i> field is determined by the value stored in the
* <i>Error Correction Type</i> field. For example, an audio data stream might
* need to know how codec chunks were redistributed, or it might need a sample
* of encoded silence.
*
* The error correction type-specific data is returned as key-value pairs of
* an associate array.
*
* @return integer
*/
public function getErrorCorrectionData()
{
return $this->_errorCorrectionData;
}
/**
* Sets data specific to the error correction type. The structure for the
* <i>Error Correction Data</i> field is determined by the value stored in the
* <i>Error Correction Type</i> field. For example, an audio data stream might
* need to know how codec chunks were redistributed, or it might need a sample
* of encoded silence.
*
* @param Array $errorCorrectionData The error correction type-specific data
* as key-value pairs of an associate array.
*/
public function setErrorCorrectionData($errorCorrectionData)
{
$this->_errorCorrectionData = $errorCorrectionData;
}
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return true; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return false; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$data =
Transform::toGUID($this->_streamType) .
Transform::toGUID($this->_errorCorrectionType) .
Transform::toInt64LE($this->_timeOffset);
switch ($this->_streamType) {
case self::AUDIO_MEDIA:
$typeSpecificData =
Transform::toUInt16LE($this->_typeSpecificData["codecId"]) .
Transform::toUInt16LE($this->_typeSpecificData["numberOfChannels"]) .
Transform::toUInt32LE($this->_typeSpecificData["samplesPerSecond"]) .
Transform::toUInt32LE
($this->_typeSpecificData["avgNumBytesPerSecond"]) .
Transform::toUInt16LE($this->_typeSpecificData["blockAlignment"]) .
Transform::toUInt16LE($this->_typeSpecificData["bitsPerSample"]) .
Transform::toUInt16LE
(strlen($this->_typeSpecificData["codecSpecificData"])) .
$this->_typeSpecificData["codecSpecificData"];
break;
case self::VIDEO_MEDIA:
$typeSpecificData =
Transform::toUInt32LE($this->_typeSpecificData["encodedImageWidth"]) .
Transform::toUInt32LE($this->_typeSpecificData["encodedImageHeight"]) .
Transform::toInt8($this->_typeSpecificData["reservedFlags"]) .
Transform::toUInt16LE(0) . // Reserved
Transform::toUInt32LE
(38 + strlen($this->_typeSpecificData["codecSpecificData"])) .
Transform::toUInt32LE($this->_typeSpecificData["imageWidth"]) .
Transform::toUInt32LE($this->_typeSpecificData["imageHeight"]) .
Transform::toUInt16LE($this->_typeSpecificData["reserved"]) .
Transform::toUInt16LE($this->_typeSpecificData["bitsPerPixelCount"]) .
Transform::toUInt32LE($this->_typeSpecificData["compressionId"]) .
Transform::toUInt32LE($this->_typeSpecificData["imageSize"]) .
Transform::toUInt32LE
($this->_typeSpecificData["horizontalPixelsPerMeter"]) .
Transform::toUInt32LE
($this->_typeSpecificData["verticalPixelsPerMeter"]) .
Transform::toUInt32LE($this->_typeSpecificData["colorsUsedCount"]) .
Transform::toUInt32LE
($this->_typeSpecificData["importantColorsCount"]) .
$this->_typeSpecificData["codecSpecificData"];
break;
case self::JFIF_MEDIA:
$typeSpecificData =
Transform::toUInt32LE($this->_typeSpecificData["imageWidth"]) .
Transform::toUInt32LE($this->_typeSpecificData["imageHeight"]) .
Transform::toUInt32LE(0);
break;
case self::DEGRADABLE_JPEG_MEDIA:
$typeSpecificData =
Transform::toUInt32LE($this->_typeSpecificData["imageWidth"]) .
Transform::toUInt32LE($this->_typeSpecificData["imageHeight"]) .
Transform::toUInt16LE(0) .
Transform::toUInt16LE(0) .
Transform::toUInt16LE(0);
$interchangeDataSize = strlen
($this->_typeSpecificData["interchangeData"]);
if ($interchangeDataSize == 1)
$interchangeDataSize = 0;
$typeSpecificData .=
Transform::toUInt16LE($interchangeDataSize) .
$this->_typeSpecificData["interchangeData"];
break;
case self::FILE_TRANSFER_MEDIA:
case self::BINARY_MEDIA:
$typeSpecificData =
Transform::toGUID($this->_typeSpecificData["majorMediaType"]) .
Transform::toGUID($this->_typeSpecificData["mediaSubtype"]) .
Transform::toUInt32LE($this->_typeSpecificData["fixedSizeSamples"]) .
Transform::toUInt32LE($this->_typeSpecificData["temporalCompression"]) .
Transform::toUInt32LE($this->_typeSpecificData["sampleSize"]) .
Transform::toGUID($this->_typeSpecificData["formatType"]) .
Transform::toUInt32LE(strlen($this->_typeSpecificData["formatData"])) .
$this->_typeSpecificData["formatData"];
break;
case self::COMMAND_MEDIA:
default:
$typeSpecificData = "";
}
switch ($this->_errorCorrectionType) {
case self::AUDIO_SPREAD:
$errorCorrectionData =
Transform::toInt8($this->_errorCorrectionData["span"]) .
Transform::toUInt16LE
($this->_errorCorrectionData["virtualPacketLength"]) .
Transform::toUInt16LE
($this->_errorCorrectionData["virtualChunkLength"]) .
Transform::toUInt16LE
(strlen($this->_errorCorrectionData["silenceData"])) .
$this->_errorCorrectionData["silenceData"];
break;
case self::NO_ERROR_CORRECTION:
default:
$errorCorrectionData = "";
}
$data .=
Transform::toUInt32LE(strlen($typeSpecificData)) .
Transform::toUInt32LE(strlen($errorCorrectionData)) .
Transform::toUInt16LE($this->_flags) .
Transform::toUInt32LE($this->_reserved) .
$typeSpecificData . $errorCorrectionData;
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

View File

@@ -1,181 +0,0 @@
<?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; }
}

View File

@@ -1,125 +0,0 @@
<?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; }
}

View File

@@ -1,87 +0,0 @@
<?php
/**
* PHP Reader Library
*
* Copyright (c) 2009 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) 2009 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>Unknown Object</i> represents objects that are not known to the
* library.
*
* @package php-reader
* @subpackage ASF
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2009 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
final class ASF_Object_Unknown extends ASF_Object
{
/**
* Returns the whether the object is required to be present, or whether
* minimum cardinality is 1.
*
* @return boolean
*/
public function isMandatory() { return false; }
/**
* Returns whether multiple instances of this object can be present, or
* whether maximum cardinality is greater than 1.
*
* @return boolean
*/
public function isMultiple() { return true; }
/**
* Returns the object data with headers.
*
* @return string
*/
public function __toString()
{
$offset = $this->_reader->getOffset();
$this->_reader->setOffset($this->getOffset() + 24 /* for header */);
$data = $this->_reader->read($this->getSize() - 24 /* for header */);
$this->_reader->setOffset($offset);
$this->setSize(24 /* for header */ + strlen($data));
return
Transform::toGUID($this->getIdentifier()) .
Transform::toInt64LE($this->getSize()) . $data;
}
}

214
src/Zend/Media/Asf.php Normal file
View File

@@ -0,0 +1,214 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object/Container.php';
/**#@-*/
/**
* This class represents a file in Advanced Systems Format (ASF) as described in
* {@link http://go.microsoft.com/fwlink/?LinkId=31334 The Advanced Systems
* Format (ASF) Specification}. It is a file format that can contain various
* types of information ranging from audio and video to script commands and
* developer defined custom streams.
*
* The ASF file consists of code blocks that are called content objects. Each
* of these objects have a format of their own. They may contain other objects
* or other specific data. Each supported object has been implemented as their
* own classes to ease the correct use of the information.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class Zend_Media_Asf extends Zend_Media_Asf_Object_Container
{
/** @var string */
private $_filename;
/**
* Constructs the ASF class with given file and options.
*
* The following options are currently recognized:
* o encoding -- Indicates the encoding that all the texts are presented
* with. By default this is set to utf-8. See the documentation of iconv
* for accepted values.
* o readonly -- Indicates that the file is read from a temporary location
* or another source it cannot be written back to.
*
* @param string|resource|Zend_Io_Reader $filename The path to the file,
* file descriptor of an opened file, or a {@link Zend_Io_Reader} instance.
* @param Array $options The options array.
*/
public function __construct($filename, $options = array())
{
if ($filename instanceof Zend_Io_Reader) {
$this->_reader = &$filename;
} else {
require_once 'Zend/Io/FileReader.php';
try {
$this->_reader = new Zend_Io_FileReader($filename);
} catch (Zend_Io_Exception $e) {
$this->_reader = null;
require_once 'Zend/Media/Id3/Exception.php';
throw new Zend_Media_Asf_Exception($e->getMessage());
}
if (is_string($filename) && !isset($options['readonly'])) {
$this->_filename = $filename;
}
}
$this->setOptions($options);
if ($this->getOption('encoding', null) === null) {
$this->setOption('encoding', 'utf-8');
}
$this->setOffset(0);
$this->setSize($this->_reader->getSize());
$this->constructObjects
(array
(self::HEADER => 'Header',
self::DATA => 'Data',
self::SIMPLE_INDEX => 'SimpleIndex',
self::INDEX => 'Index',
self::MEDIA_OBJECT_INDEX => 'MediaObjectIndex',
self::TIMECODE_INDEX => 'TimecodeIndex'));
}
/**
* Returns the mandatory header object contained in this file.
*
* @return Zend_Media_Asf_Object_Header
*/
public function getHeader()
{
$header = $this->getObjectsByIdentifier(self::HEADER);
return $header[0];
}
/**
* Returns the mandatory data object contained in this file.
*
* @return Zend_Media_Asf_Object_Data
*/
public function getData()
{
$data = $this->getObjectsByIdentifier(self::DATA);
return $data[0];
}
/**
* Returns an array of index objects contained in this file.
*
* @return Array
*/
public function getIndices()
{
return $this->getObjectsByIdentifier
(self::SIMPLE_INDEX . '|' . self::INDEX . '|' .
self::MEDIA_OBJECT_INDEX . '|' . self::TIMECODE_INDEX);
}
/**
* Writes the changes to given media file. All object offsets must be
* assumed to be invalid after the write operation.
*
* @param string $filename The optional path to the file, use null to save
* to the same file.
*/
public function write($filename)
{
if ($filename === null && ($filename = $this->_filename) === null) {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception
('No file given to write to');
} else if ($filename !== null && $this->_filename !== null &&
realpath($filename) != realpath($this->_filename) &&
!copy($this->_filename, $filename)) {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception
('Unable to copy source to destination: ' .
realpath($this->_filename) . '->' . realpath($filename));
}
if (($fd = fopen
($filename, file_exists($filename) ? 'r+b' : 'wb')) === false) {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception
('Unable to open file for writing: ' . $filename);
}
$header = $this->getHeader();
$headerLengthOld = $header->getSize();
$header->removeObjectsByIdentifier(Zend_Media_Asf_Object::PADDING);
$header->headerExtension->removeObjectsByIdentifier
(Zend_Media_Asf_Object::PADDING);
require_once 'Zend/Io/StringWriter.php';
$buffer = new Zend_Io_StringWriter();
$header->write($buffer);
$headerData = $buffer->toString();
$headerLengthNew = $header->getSize();
// Fits right in
if ($headerLengthOld == $headerLengthNew) {
}
// Fits with adjusted padding
else if ($headerLengthOld >= $headerLengthNew + 24 /* for header */) {
$header->headerExtension->padding->setSize
($headerLengthOld - $headerLengthNew);
$buffer = new Zend_Io_StringWriter();
$header->write($buffer);
$headerData = $buffer->toString();
$headerLengthNew = $header->getSize();
}
// Must expand
else {
$header->headerExtension->padding->setSize(4096);
$buffer = new Zend_Io_StringWriter();
$header->write($buffer);
$headerData = $buffer->toString();
$headerLengthNew = $header->getSize();
fseek($fd, 0, SEEK_END);
$oldFileSize = ftell($fd);
ftruncate
($fd, $newFileSize = $headerLengthNew - $headerLengthOld +
$oldFileSize);
for ($i = 1, $cur = $oldFileSize; $cur > 0; $cur -= 1024, $i++) {
fseek($fd, -(($i * 1024) +
($newFileSize - $oldFileSize)), SEEK_END);
$buffer = fread($fd, 1024);
fseek($fd, -($i * 1024), SEEK_END);
fwrite($fd, $buffer, 1024);
}
}
fseek($fd, 0);
fwrite($fd, $headerData, $headerLengthNew);
fclose($fd);
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Exception.php';
/**#@-*/
/**
* The Zend_Media_Asf_Exception is thrown whenever an error occurs within the
* {@link Zend_Media_Asf} family of classes.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class Zend_Media_Asf_Exception extends Zend_Media_Exception
{}

View File

@@ -0,0 +1,322 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* The base unit of organization for ASF files is called the ASF object. It
* consists of a 128-bit GUID for the object, a 64-bit integer object size, and
* the variable-length object data.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
abstract class Zend_Media_Asf_Object
{
/* ASF Objects */
const HEADER = '75b22630-668e-11cf-a6d9-00aa0062ce6c';
const DATA = '75b22636-668e-11cf-a6d9-00aa0062ce6c';
const SIMPLE_INDEX = '33000890-e5b1-11cf-89f4-00a0c90349cb';
const INDEX = 'd6e229d3-35da-11d1-9034-00a0c90349be';
const MEDIA_OBJECT_INDEX = 'feb103f8-12ad-4c64-840f-2a1d2f7ad48c';
const TIMECODE_INDEX = '3cb73fd0-0c4a-4803-953d-edf7b6228f0c';
/* Header Objects */
const FILE_PROPERTIES = '8cabdca1-a947-11cf-8ee4-00c00c205365';
const STREAM_PROPERTIES = 'b7dc0791-a9b7-11cf-8ee6-00c00c205365';
const HEADER_EXTENSION = '5fbf03b5-a92e-11cf-8ee3-00c00c205365';
const CODEC_LIST = '86d15240-311d-11d0-a3a4-00a0c90348f6';
const SCRIPT_COMMAND = '1efb1a30-0b62-11d0-a39b-00a0c90348f6';
const MARKER = 'f487cd01-a951-11cf-8ee6-00c00c205365';
const BITRATE_MUTUAL_EXCLUSION = 'd6e229dc-35da-11d1-9034-00a0c90349be';
const ERROR_CORRECTION = '75b22635-668e-11cf-a6d9-00aa0062ce6c';
const CONTENT_DESCRIPTION = '75b22633-668e-11cf-a6d9-00aa0062ce6c';
const EXTENDED_CONTENT_DESCRIPTION = 'd2d0a440-e307-11d2-97f0-00a0c95ea850';
const CONTENT_BRANDING = '2211b3fa-bd23-11d2-b4b7-00a0c955fc6e';
const STREAM_BITRATE_PROPERTIES = '7bf875ce-468d-11d1-8d82-006097c9a2b2';
const CONTENT_ENCRYPTION = '2211b3fb-bd23-11d2-b4b7-00a0c955fc6e';
const EXTENDED_CONTENT_ENCRYPTION = '298ae614-2622-4c17-b935-dae07ee9289c';
const DIGITAL_SIGNATURE = '2211b3fc-bd23-11d2-b4b7-00a0c955fc6e';
const PADDING = '1806d474-cadf-4509-a4ba-9aabcb96aae8';
/* Header Extension Objects */
const EXTENDED_STREAM_PROPERTIES = '14e6a5cb-c672-4332-8399-a96952065b5a';
const ADVANCED_MUTUAL_EXCLUSION = 'a08649cf-4775-4670-8a16-6e35357566cd';
const GROUP_MUTUAL_EXCLUSION = 'd1465a40-5a79-4338-b71b-e36b8fd6c249';
const STREAM_PRIORITIZATION = 'd4fed15b-88d3-454f-81f0-ed5c45999e24';
const BANDWIDTH_SHARING = 'a69609e6-517b-11d2-b6af-00c04fd908e9';
const LANGUAGE_LIST = '7c4346a9-efe0-4bfc-b229-393ede415c85';
const METADATA = 'c5f8cbea-5baf-4877-8467-aa8c44fa4cca';
const METADATA_LIBRARY = '44231c94-9498-49d1-a141-1d134e457054';
const INDEX_PARAMETERS = 'd6e229df-35da-11d1-9034-00a0c90349be';
const MEDIA_OBJECT_INDEX_PARAMETERS =
'6b203bad-3f11-48e4-aca8-d7613de2cfa7';
const TIMECODE_INDEX_PARAMETERS = 'f55e496d-9797-4b5d-8c8b-604dfe9bfb24';
const COMPATIBILITY = '75b22630-668e-11cf-a6d9-00aa0062ce6c';
const ADVANCED_CONTENT_ENCRYPTION = '43058533-6981-49e6-9b74-ad12cb86d58c';
/**
* The reader object.
*
* @var Zend_Io_Reader
*/
protected $_reader;
/**
* The options array.
*
* @var Array
*/
protected $_options;
/** @var integer */
private $_offset = false;
/** @var string */
private $_identifier = false;
/** @var integer */
private $_size = false;
/** @var Zend_Media_Asf_Object */
private $_parent = null;
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
$this->_reader = $reader;
$this->_options = &$options;
if (($this->_reader = $reader) === null) {
if (defined($constant = 'self::' . strtoupper
(preg_replace
('/(?<=[a-z])[A-Z]/', '_$0', substr(get_class($this), 22))))) {
$this->_identifier = constant($constant);
} else {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception
('Object identifier could not be determined');
}
} else {
$this->_offset = $this->_reader->getOffset();
$this->_identifier = $this->_reader->readGuid();
$this->_size = $this->_reader->readInt64LE();
}
}
/**
* Returns the options array.
*
* @return Array
*/
public final function &getOptions()
{
return $this->_options;
}
/**
* Returns the given option value, or the default value if the option is not
* defined.
*
* @param string $option The name of the option.
* @param mixed $defaultValue The default value to be returned.
*/
public final function getOption($option, $defaultValue = null)
{
if (isset($this->_options[$option])) {
return $this->_options[$option];
}
return $defaultValue;
}
/**
* Sets the options array. See {@link Zend_Media_Asf} class for available
* options.
*
* @param Array $options The options array.
*/
public final function setOptions(&$options)
{
$this->_options = &$options;
}
/**
* Sets the given option the given value.
*
* @param string $option The name of the option.
* @param mixed $value The value to set for the option.
*/
public final function setOption($option, $value)
{
$this->_options[$option] = $value;
}
/**
* Clears the given option value.
*
* @param string $option The name of the option.
*/
public final function clearOption($option)
{
unset($this->_options[$option]);
}
/**
* Returns the file offset to object start, or <var>false</var> if the
* object was created on heap.
*
* @return integer
*/
public final function getOffset()
{
return $this->_offset;
}
/**
* Sets the file offset where the object starts.
*
* @param integer $offset The file offset to object start.
*/
public final function setOffset($offset)
{
$this->_offset = $offset;
}
/**
* Returns the GUID of the ASF object.
*
* @return string
*/
public final function getIdentifier()
{
return $this->_identifier;
}
/**
* Set the GUID of the ASF object.
*
* @param string $identifier The GUID
*/
public final function setIdentifier($identifier)
{
$this->_identifier = $identifier;
}
/**
* Returns the object size in bytes, including the header.
*
* @return integer
*/
public final function getSize()
{
return $this->_size;
}
/**
* Sets the object size. The size must include the 24 byte header.
*
* @param integer $size The object size.
*/
public final function setSize($size)
{
if ($this->_parent !== null) {
$this->_parent->setSize
(($this->_parent->getSize() > 0 ?
$this->_parent->getSize() : 0) +
$size - ($this->_size > 0 ? $this->_size : 0));
}
$this->_size = $size;
}
/**
* Returns the parent object containing this object.
*
* @return Zend_Media_Asf_Object
*/
public final function getParent()
{
return $this->_parent;
}
/**
* Sets the parent containing object.
*
* @param Zend_Media_Asf_Object $parent The parent object.
*/
public final function setParent(&$parent)
{
$this->_parent = $parent;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
abstract public function write($writer);
/**
* Magic function so that $obj->value will work. The method will attempt to
* invoke a getter method. If there are no getter methods with given name,
* an exception is thrown.
*
* @param string $name The field name.
* @return mixed
*/
public function __get($name)
{
if (method_exists($this, 'get' . ucfirst($name))) {
return call_user_func(array($this, 'get' . ucfirst($name)));
}
if (method_exists($this, 'is' . ucfirst($name))) {
return call_user_func(array($this, 'is' . ucfirst($name)));
}
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Unknown field: ' . $name);
}
/**
* Magic function so that assignments with $obj->value will work.
*
* @param string $name The field name.
* @param string $value The field value.
* @return mixed
*/
public function __set($name, $value)
{
if (method_exists($this, 'set' . ucfirst($name))) {
call_user_func(array($this, 'set' . ucfirst($name)), $value);
} else {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Unknown field: ' . $name);
}
}
}

View File

@@ -0,0 +1,168 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_AdvancedContentEncryption
extends Zend_Media_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 Zend_Io_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. 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.
*
* o data -- The content protection data for this Content Encryption
* Record.
*
* @return Array
*/
public function getContentEncryptionRecords()
{
return $this->_contentEncryptionRecords;
}
/**
* Sets the array of content encryption records. Each record must consist 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. 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.
*
* o data -- The content protection data for this Content Encryption
* Record.
*
* @param Array $contentEncryptionRecords The array of content encryption
* records.
*/
public function setContentEncryptionRecords($contentEncryptionRecords)
{
$this->_contentEncryptionRecords = $contentEncryptionRecords;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$contentEncryptionRecordsCount =
count($this->_contentEncryptionRecords);
$contentEncryptionRecordsWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $contentEncryptionRecordsCount; $i++) {
$contentEncryptionRecordsWriter
->writeGuid($this->_contentEncryptionRecords['systemId'])
->writeUInt32LE
($this->_contentEncryptionRecords['systemVersion'])
->writeUInt16LE
($encryptedObjectRecordCount =
$this->_contentEncryptionRecords['streamNumbers']);
for ($j = 0; $j < $encryptedObjectRecordCount; $j++) {
$contentEncryptionRecordsWriter
->writeUInt16LE(1)
->writeUInt16LE(2)
->writeUInt16LE
($this->_contentEncryptionRecords['streamNumbers'][$j]);
}
$contentEncryptionRecordsWriter
->writeUInt32LE
(strlen($this->_contentEncryptionRecords['data']))
->write($this->_contentEncryptionRecords['data']);
}
$this->setSize
(24 /* for header */ + 2 +
$contentEncryptionRecordsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($contentEncryptionRecordsCount)
->write($contentEncryptionRecordsWriter->toString());
}
}

View File

@@ -0,0 +1,140 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_AdvancedMutualExclusion
extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_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 the nature of the mutual exclusion relationship.
*
* @return string
*/
public function setExclusionType($exclusionType)
{
$this->_exclusionType = $exclusionType;
}
/**
* Returns an array of stream numbers.
*
* @return Array
*/
public function getStreamNumbers()
{
return $this->_streamNumbers;
}
/**
* Sets the array of stream numbers.
*
* @return Array
*/
public function setStreamNumbers($streamNumbers)
{
$this->_streamNumbers = $streamNumbers;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$streamNumbersCount = count($this->_streamNumbers);
$this->setSize(24 /* for header */ + 18 + $streamNumbersCount * 2);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_exclusionType)
->writeUInt16LE($streamNumbersCount);
for ($i = 0; $i < $streamNumbersCount; $i++) {
$writer->writeUInt16LE($this->_streamNumbers[$i]);
}
}
}

View File

@@ -0,0 +1,217 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_BandwidthSharing extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader = null, $options);
if ($reader === null) {
return;
}
$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;
}
/**
* Sets 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 setSharingType($sharingType)
{
$this->_sharingType = $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 Zend_Media_Asf_Object_ExtendedStreamProperties Extended Stream
* Properties} Objects for the streams contained in this bandwidth-sharing
* relationship.
*
* @return integer
*/
public function getDataBitrate()
{
return $this->_dataBitrate;
}
/**
* Sets 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 Zend_Media_Asf_Object_ExtendedStreamProperties Extended Stream
* Properties} Objects for the streams contained in this bandwidth-sharing
* relationship.
*
* @param integer $dataBitrate The data bitrate.
*/
public function setDataBitrate($dataBitrate)
{
$this->_dataBitrate = $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 Zend_Media_Asf_Object_ExtendedStreamProperties Extended Stream
* Properties} Objects for the streams contained in this bandwidth-sharing
* relationship.
*
* @return integer
*/
public function getBufferSize()
{
return $this->_bufferSize;
}
/**
* Sets 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 Zend_Media_Asf_Object_ExtendedStreamProperties Extended Stream
* Properties} Objects for the streams contained in this bandwidth-sharing
* relationship.
*
* @param integer $bufferSize The buffer size.
*/
public function setBufferSize($bufferSize)
{
$this->_bufferSize = $bufferSize;
}
/**
* Returns an array of stream numbers.
*
* @return Array
*/
public function getStreamNumbers()
{
return $this->_streamNumbers;
}
/**
* Sets the array of stream numbers.
*
* @param Array $streamNumbers The array of stream numbers.
*/
public function setStreamNumbers($streamNumbers)
{
$this->_streamNumbers = $streamNumbers;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$streamNumbersCount = count($this->_streamNumber);
$this->setSize(24 /* for header */ + 28 + $streamNumbersCount * 2);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_sharingType)
->writeUInt32LE($this->_dataBitrate)
->writeUInt32LE($this->_bufferSize)
->writeUInt16LE($streamNumbersCount);
for ($i = 0; $i < $streamNumbersCount; $i++) {
$writer->writeUInt16LE($this->_streamNumbers[$i]);
}
}
}

View File

@@ -0,0 +1,141 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_BitrateMutualExclusion
extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_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;
}
/**
* Sets the nature of the mutual exclusion relationship.
*
* @param string $exclusionType The nature of the mutual exclusion
* relationship.
*/
public function setExclusionType($exclusionType)
{
$this->_exclusionType = $exclusionType;
}
/**
* Returns an array of stream numbers.
*
* @return Array
*/
public function getStreamNumbers()
{
return $this->_streamNumbers;
}
/**
* Sets the array of stream numbers.
*
* @param Array $streamNumbers The array of stream numbers.
*/
public function setStreamNumbers($streamNumbers)
{
$this->_streamNumbers = $streamNumbers;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$streamNumbersCount = count($this->_streamNumbers);
$this->setSize(24 /* for header */ + 18 + $streamNumbersCount * 2);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_exclusionType)
->writeUInt16LE($streamNumbersCount);
for ($i = 0; $i < $streamNumbersCount; $i++) {
$writer->writeUInt16LE($this->_streamNumbers[$i]);
}
}
}

View File

@@ -0,0 +1,165 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Codec List Object</i> provides user-friendly information about the
* codecs and formats used to encode the content found in the ASF file.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_CodecList extends Zend_Media_Asf_Object
{
const VIDEO_CODEC = 0x1;
const AUDIO_CODEC = 0x2;
const UNKNOWN_CODEC = 0xffff;
/** @var string */
private $_reserved;
/** @var Array */
private $_entries = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_reserved = $this->_reader->readGuid();
$codecEntriesCount = $this->_reader->readUInt32LE();
for ($i = 0; $i < $codecEntriesCount; $i++) {
$entry = array('type' => $this->_reader->readUInt16LE());
$codecNameLength = $this->_reader->readUInt16LE() * 2;
$entry['codecName'] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($codecNameLength));
$codecDescriptionLength = $this->_reader->readUInt16LE() * 2;
$entry['codecDescription'] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($codecDescriptionLength));
$codecInformationLength = $this->_reader->readUInt16LE();
$entry['codecInformation'] =
$this->_reader->read($codecInformationLength);
$this->_entries[] = $entry;
}
}
/**
* Returns the array of codec entries. Each record consists of the following
* keys.
*
* o type -- Specifies the type of the codec used. Use one of the
* following values: VIDEO_CODEC, AUDIO_CODEC, or UNKNOWN_CODEC.
*
* o codecName -- Specifies the name of the codec used to create the
* content.
*
* o codecDescription -- Specifies the description of the format used to
* create the content.
*
* o codecInformation -- Specifies an opaque array of information bytes
* about the codec used to create the content. The meaning of these
* bytes is determined by the codec.
*
* @return Array
*/
public function getEntries()
{
return $this->_entries;
}
/**
* Sets the array of codec entries. Each record must consist of the
* following keys.
*
* o codecName -- Specifies the name of the codec used to create the
* content.
*
* o codecDescription -- Specifies the description of the format used to
* create the content.
*
* o codecInformation -- Specifies an opaque array of information bytes
* about the codec used to create the content. The meaning of these
* bytes is determined by the codec.
*
* @param Array $entries The array of codec entries.
*/
public function setEntries($entries)
{
$this->_entries = $entries;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$codecEntriesCount = count($this->_entries);
$codecEntriesWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $codecEntriesCount; $i++) {
$codecEntriesWriter
->writeUInt16LE($this->_entries[$i]['type'])
->writeUInt16LE(strlen($codecName = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_entries[$i]['codecName']) . "\0\0") / 2)
->writeString16($codecName)
->writeUInt16LE(strlen($codecDescription = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_entries[$i]['codecDescription']) . "\0\0") / 2)
->writeString16($codecDescription)
->writeUInt16LE(strlen($this->_entries[$i]['codecInformation']))
->write($this->_entries[$i]['codecInformation']);
}
$this->setSize
(24 /* for header */ + 20 + $codecEntriesWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_reserved)
->writeUInt32LE($codecEntriesCount)
->write($codecEntriesWriter->toString());
}
}

View File

@@ -0,0 +1,120 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Compatibility Object</i> is reserved for future use.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Compatibility extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_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 profile field. This field is reserved and is set to 2.
*
* @param integer $profile The profile.
*/
public function setProfile($profile)
{
$this->_profile = $profile;
}
/**
* Returns the mode field. This field is reserved and is set to 1.
*
* @return integer
*/
public function getMode()
{
return $this->_mode;
}
/**
* Sets the mode field. This field is reserved and is set to 1.
*
* @param integer $mode The mode.
*/
public function setMode($mode)
{
$this->_mode = $mode;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$this->setSize(24 /* for header */ + 2);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt8($this->_profile)
->writeUInt8($this->_mode);
}
}

View File

@@ -0,0 +1,361 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* An abstract base container class that contains other ASF objects.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
abstract class Zend_Media_Asf_Object_Container extends Zend_Media_Asf_Object
{
/** @var Array */
private $_objects = array();
/**
* Reads and constructs the objects found within this object.
*/
protected final function constructObjects($defaultclassnames = array())
{
while (true) {
$offset = $this->_reader->getOffset();
if ($offset >= $this->getOffset() + $this->getSize()) {
break;
}
$guid = $this->_reader->readGuid();
$size = $this->_reader->readInt64LE();
$this->_reader->setOffset($offset);
if (isset($defaultclassnames[$guid])) {
if (@fopen($filename = 'Zend/Media/Asf/Object/' .
$defaultclassnames[$guid] . '.php',
'r', true) !== false) {
require_once($filename);
}
if (class_exists
($classname = 'Zend_Media_Asf_Object_' .
$defaultclassnames[$guid])) {
$object = new $classname($this->_reader, $this->_options);
} else {
require_once 'Zend/Media/Asf/Object/Unknown.php';
$object = new Zend_Media_Asf_Object_Unknown
($this->_reader, $this->_options);
}
} else {
require_once 'Zend/Media/Asf/Object/Unknown.php';
$object = new Zend_Media_Asf_Object_Unknown
($this->_reader, $this->_options);
}
$object->setParent($this);
if (!$this->hasObject($object->getIdentifier())) {
$this->_objects[$object->getIdentifier()] = array();
}
$this->_objects[$object->getIdentifier()][] = $object;
$this->_reader->setOffset($offset + $size);
}
}
/**
* Checks whether the object with given identifier is present in the file.
* The identifier can either be the object GUID, or name of the constant
* containing the GUID, or the name of the object class.
*
* Returns <var>true</var> if one or more objects are present,
* <var>false</var> otherwise.
*
* @param string $identifier The object GUID, name of the GUID constant, or
* object class name.
* @return boolean
*/
public final function hasObject($identifier)
{
if (defined($constname = get_class($this) . '::' . strtoupper
(preg_replace('/[A-Z]/', '_$0', $identifier)))) {
$objects = $this->getObjectsByIdentifier(constant($constname));
return isset($objects[0]);
} else {
return isset($this->_objects[$identifier]);
}
}
/**
* Returns all the objects the file contains as an associate array. The
* object identifiers work as keys having an array of ASF objects as
* associated value.
*
* @return Array
*/
public final function getObjects()
{
return $this->_objects;
}
/**
* Returns an array of objects matching the given object GUID or an empty
* array if no object matched the identifier.
*
* The identifier may contain wildcard characters '*' and '?'. The asterisk
* matches against zero or more characters, and the question mark matches
* any single character.
*
* @param string $identifier The object GUID.
* @return Array
*/
public final function getObjectsByIdentifier($identifier)
{
$matches = array();
$searchPattern = '/^' .
str_replace(array("*", "?"), array(".*", "."), $identifier) . "$/i";
foreach ($this->_objects as $identifier => $objects) {
if (preg_match($searchPattern, $identifier)) {
foreach ($objects as $object) {
$matches[] = $object;
}
}
}
return $matches;
}
/**
* Returns an array of objects matching the given object constant name or an
* empty array if no object matched the name.
*
* The object constant name can be given in three forms; either using the
* full name of the constant, the name of the class or the shorthand style
* of the class name having its first letter in lower case.
*
* One may use the shorthand $obj->name to access the first box with the
* name given directly. Shorthands will not work with user defined uuid
* types.
*
* The name may not contain wildcard characters.
*
* @param string $name The object constant name or class name.
* @return Array
*/
public final function getObjectsByName($name)
{
if (defined($constname = get_class($this) . '::' . $name) ||
defined($constname = get_class($this) . '::' . strtoupper
(preg_replace
('/^_/', '', preg_replace('/[A-Z]/', '_$0', $name))))) {
return $this->getObjectsByIdentifier(constant($constname));
}
return array();
}
/**
* Removes any objects matching the given object GUID.
*
* The identifier may contain wildcard characters '*' and '?'. The asterisk
* matches against zero or more characters, and the question mark matches
* any single character.
*
* One may also use the shorthand unset($obj->name) to achieve the same
* result. Wildcards cannot be used with the shorthand method.
*
* @param string $identifier The object GUID.
*/
public final function removeObjectsByIdentifier($identifier)
{
$searchPattern = '/^' .
str_replace(array("*", "?"), array(".*", "."), $identifier) . "$/i";
foreach ($this->_objects as $identifier => $objects) {
if (preg_match($searchPattern, $identifier)) {
unset($this->_objects[$identifier]);
}
}
}
/**
* Removes any objects matching the given object name.
*
* The name can be given in three forms; either using the full name of the
* constant, the name of the class or the shorthand style of the class name
* having its first letter in lower case.
*
* One may also use the shorthand unset($obj->name) to achieve the same
* result.
*
* The name may not contain wildcard characters.
*
* @param string $name The object constant name or class name.
*/
public final function removeObjectsByName($name)
{
if (defined($constname = get_class($this) . '::' . strtoupper
(preg_replace('/[A-Z]/', '_$0', $name)))) {
unset($this->_objects[constant($constname)]);
}
}
/**
* Adds a new object into the current object and returns it.
*
* @param Zend_Media_Asf_Object $object The object to add
* @return Zend_Media_Asf_Object
*/
public final function addObject($object)
{
$object->setParent($this);
$object->setOptions($this->_options);
if (!$this->hasObject($object->getIdentifier())) {
$this->_objects[$object->getIdentifier()] = array();
}
return $this->_objects[$object->getIdentifier()][] = $object;
}
/**
* Removes the object.
*
* @param Zend_Media_Asf_Object $object The object to remove
*/
public final function removeObject($object)
{
if ($this->hasObject($object->getIdentifier())) {
foreach ($this->_objects
[$object->getIdentifier()] as $key => $value) {
if ($object === $value) {
unset($this->_objects[$object->getIdentifier()][$key]);
}
}
}
}
/**
* Returns the number of objects this container has.
*
* @return integer
*/
public final function getObjectCount()
{
return count($this->_objects);
}
/**
* Override magic function so that $obj->value will work as expected.
*
* The method first attempts to call the appropriate getter method. If no
* field with given name is found, the method attempts to return the right
* object instead. In other words, calling $obj->value will attempt to
* return the first object returned by
* $this->getObjectsByIdentifier(self::value). If no object is found by the
* given value, a respective class name is tried to instantiate and add to
* the container.
*
* @param string $name The field or object name.
* @return mixed
*/
public function __get($name)
{
if (method_exists($this, 'get' . ucfirst($name))) {
return call_user_func(array($this, 'get' . ucfirst($name)));
}
if (method_exists($this, 'is' . ucfirst($name))) {
return call_user_func(array($this, 'is' . ucfirst($name)));
}
if (defined($constname = get_class($this) . '::' . strtoupper
(preg_replace('/[A-Z]/', '_$0', $name)))) {
$objects = $this->getObjectsByIdentifier(constant($constname));
if (isset($objects[0])) {
return $objects[0];
} else {
if (@fopen($filename = 'Zend/Media/Asf/Object/' .
ucfirst($name) . '.php', 'r', true) !== false) {
require_once($filename);
}
if (class_exists
($classname = 'Zend_Media_Asf_Object_' . ucfirst($name))) {
$obj = new $classname();
$obj->setIdentifier(constant($constname));
return $this->addObject($obj);
}
}
}
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Unknown field/object: ' . $name);
}
/**
* Override magic function so that $obj->value will work as expected.
*
* The method first attempts to call the appropriate setter method. If no
* field with given name is found, the method attempts to set the right
* object instead. In other words, assigning to $obj->value will attempt to
* set the object with given value's identifier.
*
* Please note that using this method will override any prior objects having
* the same object identifier.
*
* @param string $name The field or object name.
* @param string $value The field value or object.
* @return mixed
*/
public function __set($name, $value)
{
if (method_exists($this, 'set' . ucfirst($name))) {
call_user_func(array($this, 'set' . ucfirst($name)), $value);
}
if (defined($constname = get_class($this) . '::' . strtoupper
(preg_replace('/[A-Z]/', '_$0', $name)))) {
$value->setOptions($this->_options);
$this->_objects[constant($constname)] = array($value);
} else {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception
('Unknown field/object: ' . $name);
}
}
/**
* Magic function so that isset($obj->value) will work. This method checks
* whether the object by given identifier or name is contained by this
* container.
*
* @param string $name The object identifier or logical name.
* @return boolean
*/
public function __isset($name)
{
return $this->hasObject($name);
}
/**
* Magic function so that unset($obj->value) will work. This method removes
* all the objects with the given identifier or name.
*
* @param string $name The object identifier or logical name.
*/
public function __unset($name)
{
$this->removeObjectsByName($name);
}
}

View File

@@ -0,0 +1,203 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ContentBranding extends Zend_Media_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 Zend_Io_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;
}
/**
* Sets 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.
*
* @param integer $bannerImageType The type of data.
*/
public function setBannerImageType($bannerImageType)
{
$this->_bannerImageType = $bannerImageType;
}
/**
* Returns the entire banner image, including the header for the appropriate
* image format.
*
* @return string
*/
public function getBannerImageData()
{
return $this->_bannerImageData;
}
/**
* Sets the entire banner image, including the header for the appropriate
* image format.
*
* @param string $bannerImageData The entire banner image.
*/
public function setBannerImageData($bannerImageData)
{
$this->_bannerImageData = $bannerImageData;
}
/**
* Returns, if present, a link to more information about the banner image.
*
* @return string
*/
public function getBannerImageUrl()
{
return $this->_bannerImageUrl;
}
/**
* Sets a link to more information about the banner image.
*
* @param string $bannerImageUrl The link.
*/
public function setBannerImageUrl($bannerImageUrl)
{
$this->_bannerImageUrl = $bannerImageUrl;
}
/**
* Returns, if present, a link to more information about the copyright for
* the content.
*
* @return string
*/
public function getCopyrightUrl()
{
return $this->_copyrightUrl;
}
/**
* Sets a link to more information about the copyright for the content.
*
* @param string $copyrightUrl The copyright link.
*/
public function setCopyrightUrl($copyrightUrl)
{
$this->_copyrightUrl = $copyrightUrl;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$buffer = new Zend_Io_StringWriter();
$buffer->writeUInt32LE($this->_bannerImageType)
->writeUInt32LE(count($this->_bannerImageData))
->write($this->_bannerImageData)
->writeUInt32LE(count($this->_bannerImageUrl))
->write($this->_bannerImageUrl)
->writeUInt32LE(count($this->_copyrightUrl))
->write($this->_copyrightUrl);
$this->setSize(24 /* for header */ + $buffer->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->write($buffer->toString());
}
}

View File

@@ -0,0 +1,240 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Content Description Object</i> lets authors record well-known data
* describing the file and its contents. This object is used to store standard
* bibliographic information such as title, author, copyright, description, and
* rating information. This information is pertinent to the entire file.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ContentDescription
extends Zend_Media_Asf_Object
{
/** @var string */
private $_title;
/** @var string */
private $_author;
/** @var string */
private $_copyright;
/** @var string */
private $_description;
/** @var string */
private $_rating;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$titleLen = $this->_reader->readUInt16LE();
$authorLen = $this->_reader->readUInt16LE();
$copyrightLen = $this->_reader->readUInt16LE();
$descriptionLen = $this->_reader->readUInt16LE();
$ratingLen = $this->_reader->readUInt16LE();
$this->_title = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($titleLen));
$this->_author = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($authorLen));
$this->_copyright = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($copyrightLen));
$this->_description = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($descriptionLen));
$this->_rating = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($ratingLen));
}
/**
* Returns the title information.
*
* @return string
*/
public function getTitle()
{
return $this->_title;
}
/**
* Sets the title information.
*
* @param string $title The title information.
*/
public function setTitle($title)
{
$this->_title = $title;
}
/**
* Returns the author information.
*
* @return string
*/
public function getAuthor()
{
return $this->_author;
}
/**
* Sets the author information.
*
* @param string $author The author information.
*/
public function setAuthor($author)
{
$this->_author = $author;
}
/**
* Returns the copyright information.
*
* @return string
*/
public function getCopyright()
{
return $this->_copyright;
}
/**
* Sets the copyright information.
*
* @param string $copyright The copyright information.
*/
public function setCopyright($copyright)
{
$this->_copyright = $copyright;
}
/**
* Returns the description information.
*
* @return string
*/
public function getDescription()
{
return $this->_description;
}
/**
* Sets the description information.
*
* @param string $description The description information.
*/
public function setDescription($description)
{
$this->_description = $description;
}
/**
* Returns the rating information.
*
* @return string
*/
public function getRating()
{
return $this->_rating;
}
/**
* Sets the rating information.
*
* @param string $rating The rating information.
*/
public function setRating($rating)
{
$this->_rating = $rating;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$title = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_title ? $this->_title . "\0" : '');
$author = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_author ? $this->_author . "\0" : '');
$copyright = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_copyright ? $this->_copyright . "\0" : '');
$description = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_description ? $this->_description . "\0" : '');
$rating = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_rating ? $this->_rating . "\0" : '');
require_once 'Zend/Io/StringWriter.php';
$buffer = new Zend_Io_StringWriter();
$buffer->writeUInt16LE(strlen($title))
->writeUInt16LE(strlen($author))
->writeUInt16LE(strlen($copyright))
->writeUInt16LE(strlen($description))
->writeUInt16LE(strlen($rating))
->writeString16($title)
->writeString16($author)
->writeString16($copyright)
->writeString16($description)
->writeString16($rating);
$this->setSize(24 /* for header */ + $buffer->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->write($buffer->toString());
}
}

View File

@@ -0,0 +1,189 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Content Encryption Object</i> lets authors protect content by using
* Microsoft® Digital Rights Manager version 1.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ContentEncryption
extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$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;
}
/**
* Sets the secret data.
*
* @param string $secretData The secret data.
*/
public function setSecretData($secretData)
{
$this->_secretData = $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;
}
/**
* Sets the type of protection mechanism used. The value of this field
* is to be set to 'DRM'.
*
* @param string $protectionType The protection mechanism used.
*/
public function setProtectionType($protectionType)
{
$this->_protectionType = $protectionType;
}
/**
* Returns the key ID used.
*
* @return string
*/
public function getKeyId()
{
return $this->_keyId;
}
/**
* Sets the key ID used.
*
* @param string $keyId The key ID used.
*/
public function setKeyId($keyId)
{
$this->_keyId = $keyId;
}
/**
* Returns the URL from which a license to manipulate the content can be
* acquired.
*
* @return string
*/
public function getLicenseUrl()
{
return $this->_licenseUrl;
}
/**
* Returns the URL from which a license to manipulate the content can be
* acquired.
*
* @param string $licenseUrl The URL from which a license can be acquired.
*/
public function setLicenseUrl($licenseUrl)
{
$this->_licenseUrl = $licenseUrl;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$buffer = new Zend_Io_StringWriter();
$buffer->writeUInt32LE(strlen($this->_secretData))
->write($this->_secretData)
->writeUInt32LE($len = strlen($this->_protectionType) + 1)
->writeString8($this->_protectionType, $len)
->writeUInt32LE($len = strlen($this->_keyId) + 1)
->writeString8($this->_keyId, $len)
->writeUInt32LE($len = strlen($this->_licenseUrl) + 1)
->writeString8($this->_licenseUrl, $len);
$this->setSize(24 /* for header */ + $buffer->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->write($buffer->toString());
}
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.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)
*
* Please note that the data packets are not parsed.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Data extends Zend_Media_Asf_Object
{
/** @var string */
private $_fileId;
/** @var integer */
private $_totalDataPackets;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_fileId = $this->_reader->readGuid();
$this->_totalDataPackets = $this->_reader->readInt64LE();
$this->_reader->skip(2);
// No support for Data Packets as of yet (if ever)
// for ($i = 0; $i < $this->_totalDataPackets; $i++)
// $this->_dataPackets[] =
// new Zend_Media_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->_totalDataPackets;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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>.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_DigitalSignature extends Zend_Media_Asf_Object
{
/** @var integer */
private $_type;
/** @var string */
private $_data;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_type = $this->_reader->readUInt32LE();
$dataLength = $this->_reader->readUInt32LE();
$this->_data = $this->_reader->read($dataLength);
}
/**
* Returns the type of digital signature used. This field is set to 2.
*
* @return integer
*/
public function getType()
{
return $this->_type;
}
/**
* Sets the type of digital signature used. This field must be set to 2.
*
* @param integer $type The type of digital signature used.
*/
public function setType($type)
{
$this->_type = $type;
}
/**
* Returns the digital signature data.
*
* @return string
*/
public function getData()
{
return $this->_data;
}
/**
* Sets the digital signature data.
*
* @return string
*/
public function setData($data)
{
$this->_data = $data;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$this->setSize(24 /* for header */ + 8 + strlen($this->_data));
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt32LE($this->_type)
->writeUInt32LE(strlen($this->_data))
->write($this->_data);
}
}

View File

@@ -0,0 +1,136 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_StreamProperties Stream
* Properties Object}</i>.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ErrorCorrection extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_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;
}
/**
* Sets the type of error correction.
*
* @param string $type The type of error correction.
*/
public function setType($type)
{
$this->_type = $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;
}
/**
* Sets 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.
*
* @param Array $data The error correction specific data.
*/
public function setData($data)
{
$this->_data = $data;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$this->setSize(24 /* for header */ + 20 + strlen($this->_data));
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_type)
->writeUInt32LE(strlen($this->_data))
->write($this->_data);
}
}

View File

@@ -0,0 +1,230 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Extended Content Description Object</i> object implementation. This
* object contains unlimited number of attribute fields giving more information
* about the file.
*
* @todo Implement better handling of various types of attributes
* according to http://msdn.microsoft.com/en-us/library/aa384495(VS.85).aspx
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ExtendedContentDescription
extends Zend_Media_Asf_Object
{
/** @var Array */
private $_contentDescriptors = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$contentDescriptorsCount = $this->_reader->readUInt16LE();
for ($i = 0; $i < $contentDescriptorsCount; $i++) {
$nameLen = $this->_reader->readUInt16LE();
$name = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($nameLen));
$valueDataType = $this->_reader->readUInt16LE();
$valueLen = $this->_reader->readUInt16LE();
switch ($valueDataType) {
case 0: // string
$this->_contentDescriptors[$name] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($valueLen));
break;
case 1: // byte array
$this->_contentDescriptors[$name] =
$this->_reader->read($valueLen);
break;
case 2: // bool
$this->_contentDescriptors[$name] =
$this->_reader->readUInt32LE() == 1 ? true : false;
break;
case 3: // 32-bit integer
$this->_contentDescriptors[$name] =
$this->_reader->readUInt32LE();
break;
case 4: // 64-bit integer
$this->_contentDescriptors[$name] =
$this->_reader->readInt64LE();
break;
case 5: // 16-bit integer
$this->_contentDescriptors[$name] =
$this->_reader->readUInt16LE();
break;
default:
break;
}
}
}
/**
* Returns the value of the specified descriptor or <var>false</var> if
* there is no such descriptor defined.
*
* @param string $name The name of the descriptor (ie the name of the
* field).
* @return string|false
*/
public function getDescriptor($name)
{
if (isset($this->_contentDescriptors[$name])) {
return $this->_contentDescriptors[$name];
}
return false;
}
/**
* Sets the given descriptor a new value.
*
* @param string $name The name of the descriptor.
* @param string $value The value of the field.
* @return string|false
*/
public function setDescriptor($name, $value)
{
$this->_contentDescriptors[$name] = $value;
}
/**
* 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;
}
/**
* Sets the content descriptor associate array having the descriptor names
* as array keys and their values as associated value. The descriptor names
* and all string values must be encoded in the default character encoding
* given as an option to {@link Zend_Media_Asf} class.
*
* @param Array $contentDescriptors The content descriptors
*/
public function setDescriptors($contentDescriptors)
{
$this->_contentDescriptors = $contentDescriptors;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$contentDescriptorsCount = count($this->_contentDescriptors);
$contentDescriptorsWriter = new Zend_Io_StringWriter();
foreach ($this->_contentDescriptors as $name => $value) {
$descriptor = iconv
($this->getOption('encoding'), 'utf-16le',
$name ? $name . "\0" : '');
$contentDescriptorsWriter
->writeUInt16LE(strlen($descriptor))
->writeString16($descriptor);
if (is_string($value)) {
/* There is no way to distinguish byte arrays from unicode
* strings and hence the need for a list of fields of type
* byte array */
static $byteArray = array (
"W\0M\0/\0M\0C\0D\0I\0\0\0",
"W\0M\0/\0U\0s\0e\0r\0W\0e\0b\0U\0R\0L\0\0\0",
"W\0M\0/\0L\0y\0r\0i\0c\0s\0_\0S\0y\0n\0c\0h\0r\0o\0n\0i\0s\0e\0d\0\0\0",
"W\0M\0/\0P\0i\0c\0t\0u\0r\0e\0\0\0"
); // TODO: Add to the list if you encounter one
if (in_array($descriptor, $byteArray)) {
$contentDescriptorsWriter
->writeUInt16LE(1)
->writeUInt16LE(strlen($value))
->write($value);
} else {
$value = iconv
($this->getOption('encoding'), 'utf-16le', $value) .
"\0\0";
$contentDescriptorsWriter
->writeUInt16LE(0)
->writeUInt16LE(strlen($value))
->writeString16($value);
}
} else if (is_bool($value)) {
$contentDescriptorsWriter
->writeUInt16LE(2)
->writeUInt16LE(4)
->writeUInt32LE($value ? 1 : 0);
} else if (is_int($value)) {
$contentDescriptorsWriter
->writeUInt16LE(3)
->writeUInt16LE(4)
->writeUInt32LE($value);
} else if (is_float($value)) {
$contentDescriptorsWriter
->writeUInt16LE(4)
->writeUInt16LE(8)
->writeInt64LE($value);
} else {
// Invalid value and there is nothing to be done
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Invalid data type');
}
}
$this->setSize
(24 /* for header */ + 2 + $contentDescriptorsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($contentDescriptorsCount)
->write($contentDescriptorsWriter->toString());
}
}

View File

@@ -0,0 +1,101 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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).
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ExtendedContentEncryption
extends Zend_Media_Asf_Object
{
/** @var string */
private $_data;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$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;
}
/**
* Sets the array of bytes required by the DRM client to manipulate the
* protected content.
*
* @param string $data The data.
*/
public function setData($data)
{
$this->_data = $data;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$this->setSize(24 /* for header */ + 4 + strlen($this->_data));
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt32LE(strlen($this->_data))
->write($this->_data);
}
}

View File

@@ -0,0 +1,709 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ExtendedStreamProperties
extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_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->readString16($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->readString16($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;
}
/**
* Sets 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).
*
* The given value must be in units of milliseconds or optionally be set to
* 0, in which case the field will be ignored.
*
* @param integer $startTime The presentation time of the first object.
*/
public function setStartTime($startTime)
{
$this->_startTime = $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;
}
/**
* Sets 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).
*
* The given value must be given in units of milliseconds or optionally be
* set to 0, in which case the field will be ignored.
*
* @param integer $endTime The presentation time of the last object plus the
* duration of play.
*/
public function setEndTime($endTime)
{
$this->_endTime = $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;
}
/**
* Sets 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 must be given a non-zero value.
*
* @param integer $dataBitrate The leak rate.
*/
public function setDataBitrate($dataBitrate)
{
$this->_dataBitrate = $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;
}
/**
* Sets the size B, in milliseconds, of the leaky bucket used in the
* <i>Data Bitrate</i> definition.
*
* @param integer $bufferSize The size.
*/
public function setBufferSize($bufferSize)
{
$this->_bufferSize = $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;
}
/**
* Sets 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.
*
* @param integer $initialBufferFullness The initial fullness.
*/
public function setInitialBufferFullness($initialBufferFullness)
{
$this->_initialBufferFullness = $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;
}
/**
* Sets 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.
*
* @param integer $alternateDataBitrate The alternate leak rate.
*/
public function setAlternateDataBitrate($alternateDataBitrate)
{
$this->_alternateDataBitrate = $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;
}
/**
* Sets 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.
*
* @param integer $alternateBufferSize
*/
public function setAlternateBufferSize($alternateBufferSize)
{
$this->_alternateBufferSize = $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;
}
/**
* Sets 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.
*
* @param integer $alternateInitialBufferFullness The alternate initial
* fullness.
*/
public function setAlternateInitialBufferFullness
($alternateInitialBufferFullness)
{
$this->_alternateInitialBufferFullness =
$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;
}
/**
* Sets the maximum size of the largest sample stored in the data packets
* for a stream. A value of 0 means unknown.
*
* @param integer $maximumObjectSize The maximum size of the largest sample.
*/
public function setMaximumObjectSize($maximumObjectSize)
{
$this->_maximumObjectSize = $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;
}
/**
* Sets 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.
*
* @param integer $averageTimePerFrame The average time duration.
*/
public function setAverageTimePerFrame($averageTimePerFrame)
{
$this->_averageTimePerFrame = $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;
}
/**
* Sets 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.
*
* @param integer $streamNumber The number of this stream.
*/
public function setStreamNumber($streamNumber)
{
$this->_streamNumber = $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;
}
/**
* Sets 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.
*
* @param integer $streamLanguageIndex The language index.
*/
public function setStreamLanguageIndex($streamLanguageIndex)
{
$this->_streamLanguageIndex = $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 entry contains the following keys:
* o languageIndex -- The language index
* o streamName -- The localized stream name
*
* @return Array
*/
public function getStreamNames()
{
return $this->_streamNames;
}
/**
* Sets the 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 entries are to contain the following keys:
* o languageIndex -- The language index
* o streamName -- The localized stream name
*
* @param Array $streamNames The array of stream names
*/
public function setStreamNames($streamNames)
{
$this->_streamNames = $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 entry 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;
}
/**
* Sets 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 enties are to contain 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).
*
* @param Array $payloadExtensionSystems The array of payload extension
* systems.
*/
public function setPayloadExtensionSystems($payloadExtensionSystems)
{
$this->_payloadExtensionSystems = $payloadExtensionSystems;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$streamNameCount = count($this->_streamNames);
$streamNameWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $streamNameCount; $i++) {
$streamNameWriter
->writeUInt16LE($this->_streamNames['languageIndex'])
->writeUInt16LE(strlen($streamName = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_streamNames['streamName']) . "\0\0"))
->writeString16($streamName);
}
$payloadExtensionSystemCount = count($this->_payloadExtensionSystems);
$payloadExtensionSystemWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $payloadExtensionSystemCount; $i++) {
$payloadExtensionSystemWriter
->writeGuid($this->_streamNames['extensionSystemId'])
->writeUInt16LE($this->_streamNames['extensionDataSize'])
->writeUInt16LE(strlen($extensionSystemInfo = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_streamNames['extensionSystemInfo']) . "\0\0"))
->writeString16($extensionSystemInfo);
}
$this->setSize
(24 /* for header */ + 64 + $streamNameWriter->getSize() +
$payloadExtensionSystemWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeInt64LE($this->_startTime)
->writeInt64LE($this->_endTime)
->writeUInt32LE($this->_dataBitrate)
->writeUInt32LE($this->_bufferSize)
->writeUInt32LE($this->_initialBufferFullness)
->writeUInt32LE($this->_alternateDataBitrate)
->writeUInt32LE($this->_alternateBufferSize)
->writeUInt32LE($this->_alternateInitialBufferFullness)
->writeUInt32LE($this->_maximumObjectSize)
->writeUInt32LE($this->_flags)
->writeUInt16LE($this->_streamNumber)
->writeUInt16LE($this->_streamLanguageIndex)
->writeInt64LE($this->_averageTimePerFrame)
->writeUInt16LE($streamNameCount)
->writeUInt16LE($payloadExtensionSystemCount)
->write($streamNameWriter->toString())
->write($payloadExtensionSystemWriter->toString());
}
}

View File

@@ -0,0 +1,440 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>File Properties Object</i> defines the global characteristics of the
* combined digital media streams found within the Data Object.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_FileProperties extends Zend_Media_Asf_Object
{
/**
* Indicates, if set, that a file is in the process of being created (for
* example, for recording applications), and thus that various values stored
* in the header objects are invalid. It is highly recommended that
* post-processing be performed to remove this condition at the earliest
* opportunity.
*/
const BROADCAST = 1;
/**
* Indicates, if set, that a file is seekable. Note that for files
* containing a single audio stream and a <i>Minimum Data Packet Size</i>
* field equal to the <i>Maximum Data Packet Size</i> field, this flag shall
* always be set to 1. For files containing a single audio stream and a
* video stream or mutually exclusive video streams, this flag is only set
* to 1 if the file contains a matching <i>Simple Index Object</i> for each
* regular video stream.
*/
const SEEKABLE = 2;
/** @var string */
private $_fileId;
/** @var integer */
private $_fileSize;
/** @var integer */
private $_creationDate;
/** @var integer */
private $_dataPacketsCount;
/** @var integer */
private $_playDuration;
/** @var integer */
private $_sendDuration;
/** @var integer */
private $_preroll;
/** @var integer */
private $_flags;
/** @var integer */
private $_minimumDataPacketSize;
/** @var integer */
private $_maximumDataPacketSize;
/** @var integer */
private $_maximumBitrate;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_fileId = $this->_reader->readGuid();
$this->_fileSize = $this->_reader->readInt64LE();
$this->_creationDate = $this->_reader->readInt64LE();
$this->_dataPacketsCount = $this->_reader->readInt64LE();
$this->_playDuration = $this->_reader->readInt64LE();
$this->_sendDuration = $this->_reader->readInt64LE();
$this->_preroll = $this->_reader->readInt64LE();
$this->_flags = $this->_reader->readUInt32LE();
$this->_minimumDataPacketSize = $this->_reader->readUInt32LE();
$this->_maximumDataPacketSize = $this->_reader->readUInt32LE();
$this->_maximumBitrate = $this->_reader->readUInt32LE();
}
/**
* Returns the file id field.
*
* @return integer
*/
public function getFileId()
{
return $this->_fileId;
}
/**
* Sets the file id field.
*
* @param GUID $fileId The new file id.
*/
public function setFileId($fileId)
{
$this->_fileId = $fileId;
}
/**
* Returns the size, in bytes, of the entire file. The value of this field
* is invalid if the broadcast flag bit in the flags field is set to 1.
*
* @return integer
*/
public function getFileSize()
{
return $this->_fileSize;
}
/**
* Sets the size, in bytes, of the entire file. The value of this field is
* invalid if the broadcast flag bit in the flags field is set to 1.
*
* @param integer $fileSize The size of the entire file.
*/
public function setFileSize($fileSize)
{
$this->_fileSize = $fileSize;
}
/**
* Returns the date and time of the initial creation of the file. The value
* is given as the number of 100-nanosecond intervals since January 1, 1601,
* according to Coordinated Universal Time (Greenwich Mean Time). The value
* of this field may be invalid if the broadcast flag bit in the flags field
* is set to 1.
*
* @return integer
*/
public function getCreationDate()
{
return $this->_creationDate;
}
/**
* Sets the date and time of the initial creation of the file. The value is
* given as the number of 100-nanosecond intervals since January 1, 1601,
* according to Coordinated Universal Time (Greenwich Mean Time). The value
* of this field may be invalid if the broadcast flag bit in the flags field
* is set to 1.
*
* @param integer $creationDate The date and time of the initial creation of
* the file.
*/
public function setCreationDate($creationDate)
{
$this->_creationDate = $creationDate;
}
/**
* Returns the number of Data Packet entries that exist within the
* {@link Zend_Media_Asf_Object_Data Data Object}. The value of this field
* is invalid if the broadcast flag bit in the flags field is set to 1.
*
* @return integer
*/
public function getDataPacketsCount()
{
return $this->_dataPacketsCount;
}
/**
* Sets the number of Data Packet entries that exist within the
* {@link Zend_Media_Asf_Object_Data Data Object}. The value of this field
* is invalid if the broadcast flag bit in the flags field is set to 1.
*
* @param integer $dataPacketsCount The number of Data Packet entries.
*/
public function setDataPacketsCount($dataPacketsCount)
{
$this->_dataPacketsCount = $dataPacketsCount;
}
/**
* Returns the time needed to play the file in 100-nanosecond units. This
* value should include the duration (estimated, if an exact value is
* unavailable) of the the last media object in the presentation. The value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1.
*
* @return integer
*/
public function getPlayDuration()
{
return $this->_playDuration;
}
/**
* Sets the time needed to play the file in 100-nanosecond units. This
* value should include the duration (estimated, if an exact value is
* unavailable) of the the last media object in the presentation. The value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1.
*
* @param integer $playDuration The time needed to play the file.
*/
public function setPlayDuration($playDuration)
{
$this->_playDuration = $playDuration;
}
/**
* Returns the time needed to send the file in 100-nanosecond units. This
* value should include the duration of the last packet in the content. The
* value of this field is invalid if the broadcast flag bit in the flags
* field is set to 1.
*
* @return integer
*/
public function getSendDuration()
{
return $this->_sendDuration;
}
/**
* Sets the time needed to send the file in 100-nanosecond units. This
* value should include the duration of the last packet in the content. The
* value of this field is invalid if the broadcast flag bit in the flags
* field is set to 1.
*
* @param integer $sendDuration The time needed to send the file.
*/
public function setSendDuration($sendDuration)
{
$this->_sendDuration = $sendDuration;
}
/**
* Returns the amount of time to buffer data before starting to play the
* file, in millisecond units. If this value is nonzero, the <i>Play
* Duration</i> field and all of the payload <i>Presentation Time</i> fields
* have been offset by this amount. Therefore, player software must subtract
* the value in the preroll field from the play duration and presentation
* times to calculate their actual values.
*
* @return integer
*/
public function getPreroll()
{
return $this->_preroll;
}
/**
* Sets the amount of time to buffer data before starting to play the file,
* in millisecond units. If this value is nonzero, the <i>Play Duration</i>
* field and all of the payload <i>Presentation Time</i> fields have been
* offset by this amount. Therefore, player software must subtract the value
* in the preroll field from the play duration and presentation times to
* calculate their actual values.
*
* @param integer $preroll The amount of time to buffer data.
*/
public function setPreroll($preroll)
{
$this->_preroll = $preroll;
}
/**
* Checks whether or not the flag is set. Returns <var>true</var> if the
* flag is set, <var>false</var> otherwise.
*
* @param integer $flag The flag to query.
* @return boolean
*/
public function hasFlag($flag)
{
return ($this->_flags & $flag) == $flag;
}
/**
* Returns the flags field.
*
* @return integer
*/
public function getFlags()
{
return $this->_flags;
}
/**
* Sets the flags field.
*
* @param integer $flags The flags field.
*/
public function setFlags($flags)
{
$this->_flags = $flags;
}
/**
* Returns the minimum <i>Data Packet</i> size in bytes. In general, the
* value of this field is invalid if the broadcast flag bit in the flags
* field is set to 1. However, the values for the <i>Minimum Data Packet
* Size</i> and <i>Maximum Data Packet Size</i> fields shall be set to the
* same value, and this value should be set to the packet size, even when
* the broadcast flag in the flags field is set to 1.
*
* @return integer
*/
public function getMinimumDataPacketSize()
{
return $this->_minimumDataPacketSize;
}
/**
* Sets the minimum <i>Data Packet</i> size in bytes. In general, the value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1. However, the values for the <i>Minimum Data Packet Size</i> and
* <i>Maximum Data Packet Size</i> fields shall be set to the same value,
* and this value should be set to the packet size, even when the broadcast
* flag in the flags field is set to 1.
*
* @param integer $minimumDataPacketSize The minimum <i>Data Packet</i> size
* in bytes.
*/
public function setMinimumDataPacketSize($minimumDataPacketSize)
{
$this->_minimumDataPacketSize = $minimumDataPacketSize;
}
/**
* Returns the maximum <i>Data Packet</i> size in bytes. In general, the
* value of this field is invalid if the broadcast flag bit in the flags
* field is set to 1. However, the values for the <i>Minimum Data Packet
* Size</i> and <i>Maximum Data Packet Size</i> fields shall be set to the
* same value, and this value should be set to the packet size, even when
* the broadcast flag in the flags field is set to 1.
*
* @return integer
*/
public function getMaximumDataPacketSize()
{
return $this->_maximumDataPacketSize;
}
/**
* Sets the maximum <i>Data Packet</i> size in bytes. In general, the value
* of this field is invalid if the broadcast flag bit in the flags field is
* set to 1. However, the values for the <i>Minimum Data Packet Size</i> and
* <i>Maximum Data Packet Size</i> fields shall be set to the same value,
* and this value should be set to the packet size, even when the broadcast
* flag in the flags field is set to 1.
*
* @param integer $maximumDataPacketSize The maximum <i>Data Packet</i> size
* in bytes
*/
public function setMaximumDataPacketSize($maximumDataPacketSize)
{
$this->_maximumDataPacketSize = $maximumDataPacketSize;
}
/**
* Returns the maximum instantaneous bit rate in bits per second for the
* entire file. This is equal the sum of the bit rates of the individual
* digital media streams.
*
* @return integer
*/
public function getMaximumBitrate()
{
return $this->_maximumBitrate;
}
/**
* Sets the maximum instantaneous bit rate in bits per second for the
* entire file. This is equal the sum of the bit rates of the individual
* digital media streams.
*
* @param integer $maximumBitrate The maximum instantaneous bit rate in bits
* per second.
*/
public function setMaximumBitrate($maximumBitrate)
{
$this->_maximumBitrate = $maximumBitrate;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$this->setSize(24 /* for header */ + 80);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_fileId)
->writeInt64LE($this->_fileSize)
->writeInt64LE($this->_creationDate)
->writeInt64LE($this->_dataPacketsCount)
->writeInt64LE($this->_playDuration)
->writeInt64LE($this->_sendDuration)
->writeInt64LE($this->_preroll)
->writeUInt32LE($this->_flags)
->writeUInt32LE($this->_minimumDataPacketSize)
->writeUInt32LE($this->_maximumDataPacketSize)
->writeUInt32LE($this->_maximumBitrate);
}
}

View File

@@ -0,0 +1,162 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_GroupMutualExclusion
extends Zend_Media_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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_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;
}
/**
* Sets the nature of the mutual exclusion relationship.
*
* @param string $exclusionType The exclusion type.
*/
public function setExclusionType($exclusionType)
{
$this->_exclusionType = $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;
}
/**
* Sets an array of records. Each record is to consist of the following
* keys.
*
* o streamNumbers -- Specifies the stream numbers for this record. Valid
* values are between 1 and 127.
*
* @param Array $records The array of records
*/
public function setRecords($records)
{
$this->_records = $records;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$recordCount = count($this->_records);
$recordWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $recordCount; $i++) {
$recordWriter
->writeUInt16LE
($streamNumbersCount = count($this->_records[$i]));
for ($j = 0; $j < $streamNumbersCount; $j++) {
$recordWriter->writeUInt16LE
($this->_records[$i][$j]['streamNumbers']);
}
}
$this->setSize(24 /* for header */ + $recordWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_exclusionType)
->writeUInt16LE($recordCount)
->write($recordWriter->toString());
}
}

View File

@@ -0,0 +1,131 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object/Container.php';
/**#@-*/
/**
* The role of the header object is to provide a well-known byte sequence at the
* beginning of ASF files and to contain all the information that is needed to
* properly interpret the information within the data object. The header object
* can optionally contain metadata such as bibliographic information.
*
* Of the three top-level ASF objects, the header object is the only one that
* contains other ASF objects. The header object may include a number of
* standard objects including, but not limited to:
*
* o File Properties Object -- Contains global file attributes.
* o Stream Properties Object -- Defines a digital media stream and its
* characteristics.
* o Header Extension Object -- Allows additional functionality to be added to
* an ASF file while maintaining backward compatibility.
* o Content Description Object -- Contains bibliographic information.
* o Script Command Object -- Contains commands that can be executed on the
* playback timeline.
* o Marker Object -- Provides named jump points within a file.
*
* Note that objects in the header object may appear in any order. To be valid,
* the header object must contain a
* {@link Zend_Media_Asf_Object_FileProperties File Properties Object}, a
* {@link Zend_Media_Asf_Object_HeaderExtension Header Extension Object}, and at
* least one {@link Zend_Media_Asf_Object_StreamProperties Stream Properties
* Object}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Header extends Zend_Media_Asf_Object_Container
{
/** @var integer */
private $_reserved1;
/** @var integer */
private $_reserved2;
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_reader->skip(4);
$this->_reserved1 = $this->_reader->readInt8();
$this->_reserved2 = $this->_reader->readInt8();
$this->constructObjects
(array
(self::FILE_PROPERTIES => 'FileProperties',
self::STREAM_PROPERTIES => 'StreamProperties',
self::HEADER_EXTENSION => 'HeaderExtension',
self::CODEC_LIST => 'CodecList',
self::SCRIPT_COMMAND => 'ScriptCommand',
self::MARKER => 'Marker',
self::BITRATE_MUTUAL_EXCLUSION => 'BitrateMutualExclusion',
self::ERROR_CORRECTION => 'ErrorCorrection',
self::CONTENT_DESCRIPTION => 'ContentDescription',
self::EXTENDED_CONTENT_DESCRIPTION =>
'ExtendedContentDescription',
self::CONTENT_BRANDING => 'ContentBranding',
self::STREAM_BITRATE_PROPERTIES => 'StreamBitrateProperties',
self::CONTENT_ENCRYPTION => 'ContentEncryption',
self::EXTENDED_CONTENT_ENCRYPTION =>
'ExtendedContentEncryption',
self::DIGITAL_SIGNATURE => 'DigitalSignature',
self::PADDING => 'Padding'));
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$objectsWriter = new Zend_Io_StringWriter();
foreach ($this->getObjects() as $objects) {
foreach ($objects as $object) {
$object->write($objectsWriter);
}
}
$this->setSize
(24 /* for header */ + 6 + $objectsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt32LE($this->getObjectCount())
->writeInt8($this->_reserved1)
->writeInt8($this->_reserved2)
->write($objectsWriter->toString());
}
}

View File

@@ -0,0 +1,110 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 zero or more additional extended
* header objects.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_HeaderExtension
extends Zend_Media_Asf_Object_Container
{
/** @var string */
private $_reserved1;
/** @var integer */
private $_reserved2;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_reserved1 = $this->_reader->readGuid();
$this->_reserved2 = $this->_reader->readUInt16LE();
$this->_reader->skip(4);
$this->constructObjects
(array
(self::EXTENDED_STREAM_PROPERTIES => 'ExtendedStreamProperties',
self::ADVANCED_MUTUAL_EXCLUSION => 'AdvancedMutualExclusion',
self::GROUP_MUTUAL_EXCLUSION => 'GroupMutualExclusion',
self::STREAM_PRIORITIZATION => 'StreamPrioritization',
self::BANDWIDTH_SHARING => 'BandwidthSharing',
self::LANGUAGE_LIST => 'LanguageList',
self::METADATA => 'Metadata',
self::METADATA_LIBRARY => 'MetadataLibrary',
self::INDEX_PARAMETERS => 'IndexParameters',
self::MEDIA_OBJECT_INDEX_PARAMETERS =>
'MediaObjectIndexParameters',
self::TIMECODE_INDEX_PARAMETERS => 'TimecodeIndexParameters',
self::COMPATIBILITY => 'Compatibility',
self::ADVANCED_CONTENT_ENCRYPTION =>
'AdvancedContentEncryption',
self::PADDING => 'Padding'));
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$objectsWriter = new Zend_Io_StringWriter();
foreach ($this->getObjects() as $objects) {
foreach ($objects as $object) {
$object->write($objectsWriter);
}
}
$this->setSize
(24 /* for header */ + 22 + $objectsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_reserved1)
->writeUInt16LE($this->_reserved2)
->writeUInt32LE($objectsWriter->getSize())
->write($objectsWriter->toString());
}
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_Header ASF Header}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Index extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_Index Index Object} and how they are being
* indexed. This object shall be present in the
* {@link Zend_Media_Asf_Object_Header Header Object} if there is an
* {@link Zend_Media_Asf_Object_Index Index Object} present in the file.
*
* An Index Specifier is required for each stream that will be indexed by the
* {@link Zend_Media_Asf_Object_Index Index Object}. These specifiers must
* exactly match those in the {@link Zend_Media_Asf_Object_Index Index Object}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_IndexParameters extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Language List Object</i> contains an array of Unicode-based language
* IDs. All other header objects refer to languages through zero-based positions
* in this array.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_LanguageList extends Zend_Media_Asf_Object
{
/** @var Array */
private $_languages = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$languageIdRecordsCount = $this->_reader->readUInt16LE();
for ($i = 0; $i < $languageIdRecordsCount; $i++) {
$languageIdLength = $this->_reader->readInt8();
$languageId = $this->_reader->readString16($languageIdLength);
$this->_languages[] = iconv
('utf-16le', $this->getOption('encoding'), $languageId);
}
}
/**
* Returns the array of language ids.
*
* @return Array
*/
public function getLanguages()
{
return $this->_languages;
}
/**
* Sets the array of language ids.
*
* @param Array $languages The array of language ids.
*/
public function setLanguages($languages)
{
$this->_languages = $languages;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$languageIdRecordsCount = count($this->_languages);
$languageIdRecordsWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $languageIdRecordsCount; $i++) {
$languageIdRecordsWriter
->writeInt8(strlen($languageId = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_languages[$i]) . "\0\0"))
->writeString16($languageId);
}
$this->setSize
(24 /* for header */ + 2 + $languageIdRecordsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($languageIdRecordsCount)
->write($languageIdRecordsWriter->toString());
}
}

View File

@@ -0,0 +1,197 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Marker Object</i> class.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Marker extends Zend_Media_Asf_Object
{
/** @var string */
private $_reserved1;
/** @var integer */
private $_reserved2;
/** @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 Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_reserved1 = $this->_reader->readGuid();
$markersCount = $this->_reader->readUInt32LE();
$this->_reserved2 = $this->_reader->readUInt16LE();
$nameLength = $this->_reader->readUInt16LE();
$this->_name = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($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->readString16($descriptionLength));
$this->_markers[] = $marker;
}
}
/**
* Returns the name of the Marker Object.
*
* @return Array
*/
public function getName()
{
return $this->_name;
}
/**
* Returns the name of the Marker Object.
*
* @param string $name The name.
*/
public function setName($name)
{
$this->_name = $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;
}
/**
* Sets the array of markers. Each entry is to consist 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.
*
* @param Array $markers The array of markers.
*/
public function setMarkers($markers)
{
$this->_markers = $markers;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$name = iconv
($this->getOption('encoding'), 'utf-16le', $this->_name) . "\0\0";
$markersCount = count($this->_markers);
$markersWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $markersCount; $i++) {
$markersWriter
->writeInt64LE($this->_markers[$i]['offset'])
->writeInt64LE($this->_markers[$i]['presentationTime'])
->writeUInt16LE
(12 + ($descriptionLength = strlen($description = iconv
('utf-16le', $this->getOption('encoding'),
$this->_markers[$i]['description']) . "\0\0")))
->writeUInt32LE($this->_markers[$i]['sendTime'])
->writeUInt32LE($this->_markers[$i]['flags'])
->writeUInt32LE($descriptionLength)
->writeString16($description);
}
$this->setSize
(24 /* for header */ + 24 + strlen($name) +
$markersWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_reserved1)
->writeUInt32LE($markersCount)
->writeUInt16LE($this->_reserved2)
->writeUInt16LE(strlen($name))
->writeString16($name)
->write($markersWriter->toString());
}
}

View File

@@ -0,0 +1,186 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_Header ASF Header}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_MediaObjectIndex extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_Header Header Object} if there is a
* {@link Zend_Media_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 Zend_Media_Asf_Object_MediaObjectIndex Media Object Index Object}.
* These specifiers must exactly match those in the
* {@link Zend_Media_Asf_Object_MediaObjectIndex Media Object Index Object}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_MediaObjectIndexParameters
extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,218 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Metadata Object</i> permits authors to store stream-based metadata in
* a file. This object supports the same types of metadata information as the
* <i>Extended Content Description Object</i> except that it also allows a
* stream number to be specified.
*
* @todo Implement better handling of various types of attributes
* according to http://msdn.microsoft.com/en-us/library/aa384495(VS.85).aspx
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Metadata extends Zend_Media_Asf_Object
{
/** @var Array */
private $_descriptionRecords = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$descriptionRecordsCount = $this->_reader->readUInt16LE();
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
$this->_reader->skip(2);
$descriptionRecord =
array('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->readString16($nameLength));
switch ($dataType) {
case 0: // Unicode string
$descriptionRecord['data'] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($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;
default:
break;
}
$this->_descriptionRecords[] = $descriptionRecord;
}
}
/**
* Returns the array of description records. Each record consists of the
* following keys.
*
* o streamNumber -- Specifies the stream number. Valid values are between
* 1 and 127.
*
* o name -- Specifies the name that uniquely identifies the attribute
* being described. Names are case-sensitive.
*
* o data -- Specifies the actual metadata being stored.
*
* @return Array
*/
public function getDescriptionRecords()
{
return $this->_descriptionRecords;
}
/**
* Sets the array of description records. Each record must consist of the
* following keys.
*
* o streamNumber -- Specifies the stream number. Valid values are between
* 1 and 127.
*
* o name -- Specifies the name that uniquely identifies the attribute
* being described. Names are case-sensitive.
*
* o data -- Specifies the actual metadata being stored.
*
* @param Array $descriptionRecords The array of description records.
*/
public function setDescriptionRecords($descriptionRecords)
{
$this->_descriptionRecords = $descriptionRecords;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$descriptionRecordsCount = count($this->_descriptionRecords);
$descriptionRecordsWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
$descriptionRecordsWriter
->writeUInt16LE(0)
->writeUInt16LE($this->_descriptionRecords[$i]['streamNumber'])
->writeUInt16LE(strlen($name = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_descriptionRecords[$i]['name']) . "\0\0"));
if (is_string($this->_descriptionRecords[$i]['data'])) {
/* There is no way to distinguish byte arrays from unicode
* strings and hence the need for a list of fields of type byte
* array */
static $byteArray = array (
''
); // TODO: Add to the list if you encounter one
if (in_array($name, $byteArray)) {
$descriptionRecordsWriter
->writeUInt16LE(1)
->writeUInt32LE
(strlen($this->_descriptionRecords[$i]['data']))
->write($name)
->write($this->_descriptionRecords[$i]['data']);
} else {
$value = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_descriptionRecords[$i]['data']);
$value = ($value ? $value . "\0\0" : '');
$descriptionRecordsWriter
->writeUInt16LE(0)
->writeUInt32LE(strlen($value))
->write($name)
->writeString16($value);
}
} else if (is_bool($this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(2)
->writeUInt32LE(2)
->write($name)
->writeUInt16LE
($this->_descriptionRecords[$i]['data'] ? 1 : 0);
} else if (is_int($this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(3)
->writeUInt32LE(4)
->write($name)
->writeUInt32LE($this->_descriptionRecords[$i]['data']);
} else if (is_float($this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(4)
->writeUInt32LE(8)
->write($name)
->writeInt64LE($this->_descriptionRecords[$i]['data']);
} else {
// Invalid value and there is nothing to be done
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Invalid data type');
}
}
$this->setSize
(24 /* for header */ + 2 + $descriptionRecordsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($descriptionRecordsCount)
->write($descriptionRecordsWriter->toString());
}
}

View File

@@ -0,0 +1,256 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_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.
*
* @todo Implement better handling of various types of attributes
* according to http://msdn.microsoft.com/en-us/library/aa384495(VS.85).aspx
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_MetadataLibrary extends Zend_Media_Asf_Object
{
/** @var Array */
private $_descriptionRecords = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$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->readString16($nameLength));
switch ($dataType) {
case 0: // Unicode string
$descriptionRecord['data'] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($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;
default:
break;
}
$this->_descriptionRecords[] = $descriptionRecord;
}
}
/**
* Returns an array of description records. Each record consists of the
* following keys.
*
* o languageIndex -- Specifies the index into the
* {@link LanguageList Language List Object} 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;
}
/**
* Sets an array of description records. Each record must consist 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 setDescriptionRecords($descriptionRecords)
{
$this->_descriptionRecords = $descriptionRecords;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$descriptionRecordsCount = count($this->_descriptionRecords);
$descriptionRecordsWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $descriptionRecordsCount; $i++) {
$descriptionRecordsWriter
->writeUInt16LE
($this->_descriptionRecords[$i]['languageIndex'])
->writeUInt16LE
($this->_descriptionRecords[$i]['streamNumber'])
->writeUInt16LE(strlen($name = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_descriptionRecords[$i]['name']) . "\0\0"));
if (is_string($this->_descriptionRecords[$i]['data'])) {
$chunks = array();
if (preg_match
("/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{1" .
"2}$/i", $this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(6)
->writeUInt32LE(16)
->write($name)
->writeGuid($this->_descriptionRecords[$i]['data']);
} else {
/* There is no way to distinguish byte arrays from unicode
* strings and hence the need for a list of fields of type
* byte array */
static $byteArray = array (
"W\0M\0/\0L\0y\0r\0i\0c\0s\0_\0S\0y\0n\0c\0h\0r\0o\0n\0i\0s\0e\0d\0\0\0",
"W\0M\0/\0P\0i\0c\0t\0u\0r\0e\0\0\0"
); // TODO: Add to the list if you encounter one
if (in_array($name, $byteArray)) {
$descriptionRecordsWriter
->writeUInt16LE(1)
->writeUInt32LE
(strlen($this->_descriptionRecords[$i]['data']))
->write($name)
->write($this->_descriptionRecords[$i]['data']);
} else {
$value = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_descriptionRecords[$i]['data']);
$value = ($value ? $value . "\0\0" : '');
$descriptionRecordsWriter
->writeUInt16LE(0)
->writeUInt32LE(strlen($value))
->write($name)
->writeString16($value);
}
}
} else if (is_bool($this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(2)
->writeUInt32LE(2)
->write($name)
->writeUInt16LE
($this->_descriptionRecords[$i]['data'] ? 1 : 0);
} else if (is_int($this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(3)
->writeUInt32LE(4)
->write($name)
->writeUInt32LE($this->_descriptionRecords[$i]['data']);
} else if (is_float($this->_descriptionRecords[$i]['data'])) {
$descriptionRecordsWriter
->writeUInt16LE(4)
->writeUInt32LE(8)
->write($name)
->writeInt64LE($this->_descriptionRecords[$i]['data']);
} else {
// Invalid value and there is nothing to be done
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Invalid data type');
}
}
$this->setSize
(24 /* for header */ + 2 + $descriptionRecordsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($descriptionRecordsCount)
->write($descriptionRecordsWriter->toString());
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Padding Object</i> is a dummy object that is used to pad the size of
* the <i>Header Object</i>. This object enables the size of any object stored
* in the <i>Header Object</i> to grow or shrink without having to rewrite the
* entire <i>Data Object</i> and <i>Index Object</i> sections of the ASF file.
* For instance, if entries in the <i>Content Description Object</i> or
* <i>Extended Content Description Object</i> need to be removed or shortened,
* the size of the <i>Padding Object</i> can be increased to compensate for the
* reduction in size of the <i>Content Description Object</i>. The ASF file can
* then be updated by overwriting the previous <i>Header Object</i> with the
* edited <i>Header Object</i> of identical size, without having to move or
* rewrite the data contained in the <i>Data Object</i>.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Padding extends Zend_Media_Asf_Object
{
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
if ($this->getSize() == 0) {
$this->setSize(24);
}
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->write(str_pad('', $this->getSize() - 24 /* header */, "\0"));
}
}

View File

@@ -0,0 +1,183 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_ScriptCommand extends Zend_Media_Asf_Object
{
/** @var string */
private $_reserved;
/** @var Array */
private $_commands = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$this->_reserved = $this->_reader->readGuid();
$commandsCount = $this->_reader->readUInt16LE();
$commandTypesCount = $this->_reader->readUInt16LE();
$commandTypes = array();
for ($i = 0; $i < $commandTypesCount; $i++) {
$commandTypeNameLength = $this->_reader->readUInt16LE();
$commandTypes[] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($commandTypeNameLength * 2));
}
for ($i = 0; $i < $commandsCount; $i++) {
$command = array
('presentationTime' => $this->_reader->readUInt32LE(),
'type' => $commandTypes[$this->_reader->readUInt16LE()]);
$commandNameLength = $this->_reader->readUInt16LE();
$command['name'] = iconv
('utf-16le', $this->getOption('encoding'),
$this->_reader->readString16($commandNameLength * 2));
$this->_commands[] = $command;
}
}
/**
* 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 type -- Specifies the type of this command.
*
* o name -- Specifies the name of this command.
*
* @return Array
*/
public function getCommands()
{
return $this->_commands;
}
/**
* Sets the array of index entries. Each entry is to consist of the
* following keys.
*
* o presentationTime -- Specifies the presentation time of the command,
* in milliseconds.
*
* o type -- Specifies the type of this command.
*
* o name -- Specifies the name of this command.
*
* @param Array $commands The array of index entries.
*/
public function setCommands($commands)
{
$this->_commands = $commands;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$commandTypes = array();
foreach ($this->_commands as $command) {
if (!in_array($command['type'], $commandTypes)) {
$commandTypes[] = $command['type'];
}
}
$commandTypesCount = count($commandTypes);
$commandTypesWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $commandTypesCount; $i++) {
$commandTypesWriter
->writeUInt16LE
(strlen($commandType = iconv
($this->getOption('encoding'), 'utf-16le',
$commandTypes[$i])) / 2)
->write($commandType);
}
$commandsCount = count($this->_commands);
$commandsWriter = new Zend_Io_StringWriter();
for ($i = 0; $i < $commandsCount; $i++) {
$commandsWriter
->writeUInt32LE($this->_commands[$i]['presentationTime'])
->writeUInt16LE
(array_search($this->_commands[$i]['type'], $commandTypes))
->writeUInt16LE
(strlen($command = iconv
($this->getOption('encoding'), 'utf-16le',
$this->_commands[$i]['name'])) / 2)
->write($command);
}
$this->setSize
(24 /* for header */ + 20 + $commandTypesWriter->getSize() +
$commandsWriter->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_reserved)
->writeUInt16LE($commandsCount)
->writeUInt16LE($commandTypesCount)
->write($commandTypesWriter->toString())
->write($commandsWriter->toString());
}
}

View File

@@ -0,0 +1,150 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_SimpleIndex extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,134 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Stream Bitrate Properties Object</i> defines the average bit rate of
* each digital media stream.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_StreamBitrateProperties
extends Zend_Media_Asf_Object
{
/** @var Array */
private $_bitrateRecords = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$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;
}
/**
* Sets 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.
*
* @param Array $bitrateRecords The array of bitrate records.
*/
public function setBitrateRecords($bitrateRecords)
{
$this->_bitrateRecords = $bitrateRecords;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$bitrateRecordsCount = count($this->_bitrateRecords);
$this->setSize
(24 /* for header */ + 2 + $bitrateRecordsCount * 6);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($bitrateRecordsCount);
for ($i = 0; $i < $bitrateRecordsCount; $i++) {
$writer->writeUInt16LE
(($this->_bitrateRecords[$i]['flags'] << 5) |
($this->_bitrateRecords[$i]['streamNumber'] & 0x1f))
->writeUInt32LE
($this->_bitrateRecords[$i]['averageBitrate']);
}
}
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_StreamPrioritization
extends Zend_Media_Asf_Object
{
/** @var Array */
private $_priorityRecords = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader = null, &$options = array())
{
parent::__construct($reader, $options);
if ($reader === null) {
return;
}
$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;
}
/**
* Sets the 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).
*
* @param Array $priorityRecords The array of records.
*/
public function setPriorityRecords($priorityRecords)
{
$this->_priorityRecords = $priorityRecords;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$priorityRecordCount = count($this->_priorityRecords);
$this->setSize
(24 /* for header */ + 2 + $priorityRecordCount * 4);
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeUInt16LE($priorityRecordCount);
for ($i = 0; $i < $priorityRecordCount; $i++) {
$writer->writeUInt16LE($this->_priorityRecords[$i]['streamNumber'])
->writeUInt16LE($this->_priorityRecords[$i]['flags']);
}
}
}

View File

@@ -0,0 +1,534 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Stream Properties Object</i> defines the specific properties and
* characteristics of a digital media stream. This object defines how a digital
* media stream within the <i>Data Object</i> is interpreted, as well as the
* specific format (of elements) of the <i>Data Packet</i> itself.
*
* Whereas every stream in an ASF presentation, including each stream in a
* mutual exclusion relationship, must be represented by a <i>Stream Properties
* Object</i>, in certain cases, this object might be found embedded in the
* <i>Extended Stream Properties Object</i>.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_StreamProperties extends Zend_Media_Asf_Object
{
/**
* Indicates, if set, that the data contained in this stream is encrypted
* and will be unreadable unless there is a way to decrypt the stream.
*/
const ENCRYPTED_CONTENT = 0x8000;
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 string */
private $_streamType;
/** @var string */
private $_errorCorrectionType;
/** @var integer */
private $_timeOffset;
/** @var integer */
private $_flags;
/** @var integer */
private $_reserved;
/** @var Array */
private $_typeSpecificData = array();
/** @var Array */
private $_errorCorrectionData = array();
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_streamType = $this->_reader->readGuid();
$this->_errorCorrectionType = $this->_reader->readGuid();
$this->_timeOffset = $this->_reader->readInt64LE();
$typeSpecificDataLength = $this->_reader->readUInt32LE();
$errorCorrectionDataLength = $this->_reader->readUInt32LE();
$this->_flags = $this->_reader->readUInt16LE();
$this->_reserved = $this->_reader->readUInt32LE();
switch ($this->_streamType) {
case self::AUDIO_MEDIA:
$this->_typeSpecificData = array
('codecId' => $this->_reader->readUInt16LE(),
'numberOfChannels' => $this->_reader->readUInt16LE(),
'samplesPerSecond' => $this->_reader->readUInt32LE(),
'avgNumBytesPerSecond' => $this->_reader->readUInt32LE(),
'blockAlignment' => $this->_reader->readUInt16LE(),
'bitsPerSample' => $this->_reader->readUInt16LE());
$codecSpecificDataSize = $this->_reader->readUInt16LE();
$this->_typeSpecificData['codecSpecificData'] =
$this->_reader->read($codecSpecificDataSize);
break;
case self::VIDEO_MEDIA:
$this->_typeSpecificData = array
('encodedImageWidth' => $this->_reader->readUInt32LE(),
'encodedImageHeight' => $this->_reader->readUInt32LE(),
'reservedFlags' => $this->_reader->readInt8());
$this->_reader->skip(2);
$formatDataSize = $this->_reader->readUInt32LE();
$this->_typeSpecificData = array_merge
($this->_typeSpecificData, array
('imageWidth' => $this->_reader->readUInt32LE(),
'imageHeight' => $this->_reader->readUInt32LE(),
'reserved' => $this->_reader->readUInt16LE(),
'bitsPerPixelCount' => $this->_reader->readUInt16LE(),
'compressionId' => $this->_reader->readUInt32LE(),
'imageSize' => $this->_reader->readUInt32LE(),
'horizontalPixelsPerMeter' =>
$this->_reader->readUInt32LE(),
'verticalPixelsPerMeter' =>
$this->_reader->readUInt32LE(),
'colorsUsedCount' => $this->_reader->readUInt32LE(),
'importantColorsCount' => $this->_reader->readUInt32LE(),
'codecSpecificData' =>
$this->_reader->read($formatDataSize - 38)));
break;
case self::JFIF_MEDIA:
$this->_typeSpecificData = array
('imageWidth' => $this->_reader->readUInt32LE(),
'imageHeight' => $this->_reader->readUInt32LE(),
'reserved' => $this->_reader->readUInt32LE());
break;
case self::DEGRADABLE_JPEG_MEDIA:
$this->_typeSpecificData = array
('imageWidth' => $this->_reader->readUInt32LE(),
'imageHeight' => $this->_reader->readUInt32LE(),
$this->_reader->readUInt16LE(),
$this->_reader->readUInt16LE(),
$this->_reader->readUInt16LE());
$interchangeDataSize = $this->_reader->readUInt16LE();
if ($interchangeDataSize == 0) {
$interchangeDataSize++;
}
$this->_typeSpecificData['interchangeData'] =
$this->_reader->read($interchangeDataSize);
break;
case self::FILE_TRANSFER_MEDIA:
// break intentionally omitted
case self::BINARY_MEDIA:
$this->_typeSpecificData = array
('majorMediaType' => $this->_reader->getGUID(),
'mediaSubtype' => $this->_reader->getGUID(),
'fixedSizeSamples' => $this->_reader->readUInt32LE(),
'temporalCompression' => $this->_reader->readUInt32LE(),
'sampleSize' => $this->_reader->readUInt32LE(),
'formatType' => $this->_reader->getGUID());
$formatDataSize = $this->_reader->readUInt32LE();
$this->_typeSpecificData['formatData'] =
$this->_reader->read($formatDataSize);
break;
case self::COMMAND_MEDIA:
// break intentionally omitted
default:
$this->_reader->skip($typeSpecificDataLength);
break;
}
switch ($this->_errorCorrectionType) {
case self::AUDIO_SPREAD:
$this->_errorCorrectionData = array
('span' => $this->_reader->readInt8(),
'virtualPacketLength' => $this->_reader->readUInt16LE(),
'virtualChunkLength' => $this->_reader->readUInt16LE());
$silenceDataSize = $this->_reader->readUInt16LE();
$this->_errorCorrectionData['silenceData'] =
$this->_reader->read($silenceDataSize);
break;
case self::NO_ERROR_CORRECTION:
// break intentionally omitted
default:
$this->_reader->skip($errorCorrectionDataLength);
break;
}
}
/**
* Returns the number of this stream. 0 is an invalid stream. Valid values
* are between 1 and 127. The numbers assigned to streams in an ASF
* presentation may be any combination of unique values; parsing logic must
* not assume that streams are numbered sequentially.
*
* @return integer
*/
public function getStreamNumber()
{
return $this->_flags & 0x3f;
}
/**
* Returns the number of this stream. 0 is an invalid stream. Valid values
* are between 1 and 127. The numbers assigned to streams in an ASF
* presentation may be any combination of unique values; parsing logic must
* not assume that streams are numbered sequentially.
*
* @param integer $streamNumber The number of this stream.
*/
public function setStreamNumber($streamNumber)
{
if ($streamNumber < 1 || $streamNumber > 127) {
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Invalid argument');
}
$this->_flags = ($this->_flags & 0xffc0) | ($streamNumber & 0x3f);
}
/**
* Returns the type of the stream (for example, audio, video, and so on).
*
* @return string
*/
public function getStreamType()
{
return $this->_streamType;
}
/**
* Sets the type of the stream (for example, audio, video, and so on).
*
* @param integer $streamType The type of the stream.
*/
public function setStreamType($streamType)
{
$this->_streamType = $streamType;
}
/**
* Returns the error correction type used by this digital media stream. For
* streams other than audio, this value should be set to
* NO_ERROR_CORRECTION. For audio streams, this value should be set to
* AUDIO_SPREAD.
*
* @return string
*/
public function getErrorCorrectionType()
{
return $this->_errorCorrectionType;
}
/**
* Sets the error correction type used by this digital media stream. For
* streams other than audio, this value should be set to
* NO_ERROR_CORRECTION. For audio streams, this value should be set to
* AUDIO_SPREAD.
*
* @param integer $errorCorrectionType The error correction type used by
* this digital media stream.
*/
public function setErrorCorrectionType($errorCorrectionType)
{
$this->_errorCorrectionType = $errorCorrectionType;
}
/**
* Returns the presentation time offset of the stream in 100-nanosecond
* units. The value of this field is added to all of the timestamps of the
* samples in the stream. This value shall be equal to the send time of the
* first interleaved packet in the data section. The value of this field is
* typically 0. It is non-zero in the case when an ASF file is edited and it
* is not possible for the editor to change the presentation times and send
* times of ASF packets. Note that if more than one stream is present in an
* ASF file the offset values of all stream properties objects must be
* equal.
*
* @return integer
*/
public function getTimeOffset()
{
return $this->_timeOffset;
}
/**
* Sets the presentation time offset of the stream in 100-nanosecond units.
* The value of this field is added to all of the timestamps of the samples
* in the stream. This value shall be equal to the send time of the first
* interleaved packet in the data section. The value of this field is
* typically 0. It is non-zero in the case when an ASF file is edited and it
* is not possible for the editor to change the presentation times and send
* times of ASF packets. Note that if more than one stream is present in an
* ASF file the offset values of all stream properties objects must be
* equal.
*
* @param integer $timeOffset The presentation time offset of the stream.
*/
public function setTimeOffset($timeOffset)
{
$this->_timeOffset = $timeOffset;
}
/**
* Checks whether or not the flag is set. Returns <var>true</var> if the
* flag is set, <var>false</var> otherwise.
*
* @param integer $flag The flag to query.
* @return boolean
*/
public function hasFlag($flag)
{
return ($this->_flags & $flag) == $flag;
}
/**
* Returns the flags field.
*
* @return integer
*/
public function getFlags()
{
return $this->_flags;
}
/**
* Sets the flags field.
*
* @param integer $flags The flags field.
*/
public function setFlags($flags)
{
$this->_flags = $flags;
}
/**
* Returns type-specific format data. The structure for the <i>Type-Specific
* Data</i> field is determined by the value stored in the <i>Stream
* Type</i> field.
*
* The type-specific data is returned as key-value pairs of an associate
* array.
*
* @return Array
*/
public function getTypeSpecificData()
{
return $this->_typeSpecificData;
}
/**
* Sets type-specific format data. The structure for the <i>Type-Specific
* Data</i> field is determined by the value stored in the <i>Stream Type</i>
* field.
*
* @param Array $typeSpecificData The type-specific data as key-value pairs
* of an associate array.
*/
public function setTypeSpecificData($typeSpecificData)
{
$this->_typeSpecificData = $typeSpecificData;
}
/**
* Returns data specific to the error correction type. The structure for the
* <i>Error Correction Data</i> field is determined by the value stored in
* the <i>Error Correction Type</i> field. For example, an audio data stream
* might need to know how codec chunks were redistributed, or it might need
* a sample of encoded silence.
*
* The error correction type-specific data is returned as key-value pairs of
* an associate array.
*
* @return integer
*/
public function getErrorCorrectionData()
{
return $this->_errorCorrectionData;
}
/**
* Sets data specific to the error correction type. The structure for the
* <i>Error Correction Data</i> field is determined by the value stored in
* the <i>Error Correction Type</i> field. For example, an audio data stream
* might need to know how codec chunks were redistributed, or it might need
* a sample of encoded silence.
*
* @param Array $errorCorrectionData The error correction type-specific data
* as key-value pairs of an associate array.
*/
public function setErrorCorrectionData($errorCorrectionData)
{
$this->_errorCorrectionData = $errorCorrectionData;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Io/StringWriter.php';
$typeSpecificData = new Zend_Io_StringWriter();
switch ($this->_streamType) {
case self::AUDIO_MEDIA:
$typeSpecificData
->writeUInt16LE($this->_typeSpecificData['codecId'])
->writeUInt16LE
($this->_typeSpecificData['numberOfChannels'])
->writeUInt32LE
($this->_typeSpecificData['samplesPerSecond'])
->writeUInt32LE
($this->_typeSpecificData['avgNumBytesPerSecond'])
->writeUInt16LE($this->_typeSpecificData['blockAlignment'])
->writeUInt16LE($this->_typeSpecificData['bitsPerSample'])
->writeUInt16LE
(strlen($this->_typeSpecificData['codecSpecificData']))
->write($this->_typeSpecificData['codecSpecificData']);
break;
case self::VIDEO_MEDIA:
$typeSpecificData
->writeUInt32LE
($this->_typeSpecificData['encodedImageWidth'])
->writeUInt32LE
($this->_typeSpecificData['encodedImageHeight'])
->writeInt8($this->_typeSpecificData['reservedFlags'])
->writeUInt16LE(0) // Reserved
->writeUInt32LE
(38 +
strlen($this->_typeSpecificData['codecSpecificData']))
->writeUInt32LE($this->_typeSpecificData['imageWidth'])
->writeUInt32LE($this->_typeSpecificData['imageHeight'])
->writeUInt16LE($this->_typeSpecificData['reserved'])
->writeUInt16LE
($this->_typeSpecificData['bitsPerPixelCount'])
->writeUInt32LE($this->_typeSpecificData['compressionId'])
->writeUInt32LE($this->_typeSpecificData['imageSize'])
->writeUInt32LE
($this->_typeSpecificData['horizontalPixelsPerMeter'])
->writeUInt32LE
($this->_typeSpecificData['verticalPixelsPerMeter'])
->writeUInt32LE($this->_typeSpecificData['colorsUsedCount'])
->writeUInt32LE
($this->_typeSpecificData['importantColorsCount'])
->write($this->_typeSpecificData['codecSpecificData']);
break;
case self::JFIF_MEDIA:
$typeSpecificData
->writeUInt32LE($this->_typeSpecificData['imageWidth'])
->writeUInt32LE($this->_typeSpecificData['imageHeight'])
->writeUInt32LE(0);
break;
case self::DEGRADABLE_JPEG_MEDIA:
$typeSpecificData
->writeUInt32LE($this->_typeSpecificData['imageWidth'])
->writeUInt32LE($this->_typeSpecificData['imageHeight'])
->writeUInt16LE(0)
->writeUInt16LE(0)
->writeUInt16LE(0);
$interchangeDataSize = strlen
($this->_typeSpecificData['interchangeData']);
if ($interchangeDataSize == 1)
$interchangeDataSize = 0;
$typeSpecificData
->writeUInt16LE($interchangeDataSize)
->write($this->_typeSpecificData['interchangeData']);
break;
case self::FILE_TRANSFER_MEDIA:
// break intentionally omitted
case self::BINARY_MEDIA:
$typeSpecificData
->writeGuid($this->_typeSpecificData['majorMediaType'])
->writeGuid($this->_typeSpecificData['mediaSubtype'])
->writeUInt32LE($this->_typeSpecificData['fixedSizeSamples'])
->writeUInt32LE
($this->_typeSpecificData['temporalCompression'])
->writeUInt32LE($this->_typeSpecificData['sampleSize'])
->writeGuid($this->_typeSpecificData['formatType'])
->writeUInt32LE(strlen($this->_typeSpecificData['formatData']))
->write($this->_typeSpecificData['formatData']);
break;
case self::COMMAND_MEDIA:
// break intentionally omitted
default:
break;
}
$errorCorrectionData = new Zend_Io_StringWriter();
switch ($this->_errorCorrectionType) {
case self::AUDIO_SPREAD:
$errorCorrectionData
->writeInt8($this->_errorCorrectionData['span'])
->writeUInt16LE
($this->_errorCorrectionData['virtualPacketLength'])
->writeUInt16LE
($this->_errorCorrectionData['virtualChunkLength'])
->writeUInt16LE
(strlen($this->_errorCorrectionData['silenceData']))
->write($this->_errorCorrectionData['silenceData']);
break;
case self::NO_ERROR_CORRECTION:
// break intentionally omitted
default:
break;
}
$this->setSize
(24 /* for header */ + 54 + $typeSpecificData->getSize() +
$errorCorrectionData->getSize());
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->writeGuid($this->_streamType)
->writeGuid($this->_errorCorrectionType)
->writeInt64LE($this->_timeOffset)
->writeUInt32LE($typeSpecificData->getSize())
->writeUInt32LE($errorCorrectionData->getSize())
->writeUInt16LE($this->_flags)
->writeUInt32LE($this->_reserved)
->write($typeSpecificData->toString())
->write($errorCorrectionData->toString());
}
}

View File

@@ -0,0 +1,189 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_Header ASF Header}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_TimecodeIndex extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,129 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/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 Zend_Media_Asf_Object_TimecodeIndexParameters Timecode Index
* Parameters Object} must have timecode Payload Extension Systems associated
* with them in the
* {@link Zend_Media_Asf_Object_ExtendedStreamProperties Extended Stream
* Properties Object}. This object shall be present in the
* {@link Zend_Media_Asf_Object_Header Header Object} if there is a
* {@link Zend_Media_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 Zend_Media_Asf_Object_TimecodeIndex Timecode Index Object}. These
* specifiers must exactly match those in the
* {@link Zend_Media_Asf_Object_TimecodeIndex Timecode Index Object}.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_TimecodeIndexParameters
extends Zend_Media_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 Zend_Io_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;
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
require_once 'Zend/Media/Asf/Exception.php';
throw new Zend_Media_Asf_Exception('Operation not supported');
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Asf/Object.php';
/**#@-*/
/**
* The <i>Unknown Object</i> represents objects that are not known to the
* library.
*
* @category Zend
* @package Zend_Media
* @subpackage ASF
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Asf_Object_Unknown extends Zend_Media_Asf_Object
{
/** @var string */
private $_data;
/**
* Constructs the class with given parameters and reads object related data
* from the ASF file.
*
* @param Zend_Io_Reader $reader The reader object.
* @param Array $options The options array.
*/
public function __construct($reader, &$options = array())
{
parent::__construct($reader, $options);
$this->_data = $this->_reader->read
($this->getSize() - 24 /* for header */);
}
/**
* Writes the object data.
*
* @param Zend_Io_Writer $writer The writer object.
* @return void
*/
public function write($writer)
{
$writer->writeGuid($this->getIdentifier())
->writeInt64LE($this->getSize())
->write($this->_data);
}
}