PageRenderTime 31ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/Zend/Media/Asf/Object/SimpleIndex.php

http://php-reader.googlecode.com/
PHP | 150 lines | 43 code | 12 blank | 95 comment | 1 complexity | 89ab149208b7895fbe114b9e2a237968 MD5 | raw file
  1<?php
  2/**
  3 * Zend Framework
  4 *
  5 * LICENSE
  6 *
  7 * This source file is subject to the new BSD license that is bundled
  8 * with this package in the file LICENSE.txt.
  9 * It is also available through the world-wide-web at this URL:
 10 * http://framework.zend.com/license/new-bsd
 11 * If you did not receive a copy of the license and are unable to
 12 * obtain it through the world-wide-web, please send an email
 13 * to license@zend.com so we can send you a copy immediately.
 14 *
 15 * @category   Zend
 16 * @package    Zend_Media
 17 * @subpackage ASF
 18 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 
 19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 20 * @version    $Id: SimpleIndex.php 177 2010-03-09 13:13:34Z svollbehr $
 21 */
 22
 23/**#@+ @ignore */
 24require_once 'Zend/Media/Asf/Object.php';
 25/**#@-*/
 26
 27/**
 28 * For each video stream in an ASF file, there should be one instance of the
 29 * <i>Simple Index Object</i>. Additionally, the instances of the <i>Simple
 30 * Index Object</i> shall be ordered by stream number.
 31 *
 32 * Index entries in the <i>Simple Index Object</i> are in terms of
 33 * <i>Presentation Times</i>. The corresponding <i>Packet Number</i> field
 34 * values (of the <i>Index Entry</i>, see below) indicate the packet number of
 35 * the ASF <i>Data Packet</i> with the closest past key frame. Note that for
 36 * video streams that contain both key frames and non-key frames, the <i>Packet
 37 * Number</i> field will always point to the closest past key frame.
 38 *
 39 * @category   Zend
 40 * @package    Zend_Media
 41 * @subpackage ASF
 42 * @author     Sven Vollbehr <sven@vollbehr.eu>
 43 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 
 44 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 45 * @version    $Id: SimpleIndex.php 177 2010-03-09 13:13:34Z svollbehr $
 46 */
 47final class Zend_Media_Asf_Object_SimpleIndex extends Zend_Media_Asf_Object
 48{
 49    /** @var string */
 50    private $_fileId;
 51
 52    /** @var integer */
 53    private $_indexEntryTimeInterval;
 54
 55    /** @var integer */
 56    private $_maximumPacketCount;
 57
 58    /** @var Array */
 59    private $_indexEntries = array();
 60
 61    /**
 62     * Constructs the class with given parameters and reads object related data
 63     * from the ASF file.
 64     *
 65     * @param Zend_Io_Reader $reader  The reader object.
 66     * @param Array          $options The options array.
 67     */
 68    public function __construct($reader, &$options = array())
 69    {
 70        parent::__construct($reader, $options);
 71
 72        $this->_fileId = $this->_reader->readGuid();
 73        $this->_indexEntryTimeInterval = $this->_reader->readInt64LE();
 74        $this->_maximumPacketCount = $this->_reader->readUInt32LE();
 75        $indexEntriesCount = $this->_reader->readUInt32LE();
 76        for ($i = 0; $i < $indexEntriesCount; $i++) {
 77            $this->_indexEntries[] = array
 78                ('packetNumber' => $this->_reader->readUInt32LE(),
 79                 'packetCount' => $this->_reader->readUInt16LE());
 80        }
 81    }
 82
 83    /**
 84     * Returns the unique identifier for this ASF file. The value of this field
 85     * should be changed every time the file is modified in any way. The value
 86     * of this field may be set to 0 or set to be identical to the value of the
 87     * <i>File ID</i> field of the <i>Data Object</i> and the <i>Header
 88     * Object</i>.
 89     *
 90     * @return string
 91     */
 92    public function getFileId() 
 93    {
 94        return $this->_fileId; 
 95    }
 96
 97    /**
 98     * Returns the time interval between each index entry in 100-nanosecond units.
 99     * The most common value is 10000000, to indicate that the index entries are
100     * in 1-second intervals, though other values can be used as well.
101     *
102     * @return integer
103     */
104    public function getIndexEntryTimeInterval()
105    {
106        return $this->_indexEntryTimeInterval;
107    }
108
109    /**
110     * Returns the maximum <i>Packet Count</i> value of all <i>Index Entries</i>.
111     *
112     * @return integer
113     */
114    public function getMaximumPacketCount() 
115    {
116        return $this->_maximumPacketCount; 
117    }
118
119    /**
120     * Returns an array of index entries. Each entry consists of the following
121     * keys.
122     *
123     *   o packetNumber -- Specifies the number of the Data Packet associated
124     *     with this index entry. Note that for video streams that contain both
125     *     key frames and non-key frames, this field will always point to the
126     *     closest key frame prior to the time interval.
127     *
128     *   o packetCount -- Specifies the number of <i>Data Packets</i> to send at
129     *     this index entry. If a video key frame has been fragmented into two
130     *     Data Packets, the value of this field will be equal to 2.
131     *
132     * @return Array
133     */
134    public function getIndexEntries() 
135    {
136        return $this->_indexEntries; 
137    }
138
139    /**
140     * Writes the object data.
141     *
142     * @param Zend_Io_Writer $writer The writer object.
143     * @return void
144     */
145    public function write($writer)
146    {
147        require_once 'Zend/Media/Asf/Exception.php';
148        throw new Zend_Media_Asf_Exception('Operation not supported');
149    }
150}