PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Zend/Media/Iso14496/Box/Stss.php

http://php-reader.googlecode.com/
PHP | 123 lines | 34 code | 8 blank | 81 comment | 2 complexity | e949bb2a00376193d491e80876c5e0ce 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 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 25 * POSSIBILITY OF SUCH DAMAGE.
 26 *
 27 * @category   Zend
 28 * @package    Zend_Media
 29 * @subpackage ISO14496
 30 * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) 
 31 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 32 * @version    $Id: Stss.php 177 2010-03-09 13:13:34Z svollbehr $
 33 */
 34
 35/**#@+ @ignore */
 36require_once 'Zend/Media/Iso14496/FullBox.php';
 37/**#@-*/
 38
 39/**
 40 * The <i>Sync Sample Box</i> provides a compact marking of the random access
 41 * points within the stream. The table is arranged in strictly increasing order
 42 * of sample number. If the sync sample box is not present, every sample is a
 43 * random access point.
 44 *
 45 * @category   Zend
 46 * @package    Zend_Media
 47 * @subpackage ISO14496
 48 * @author     Sven Vollbehr <sven@vollbehr.eu>
 49 * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) 
 50 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 51 * @version    $Id: Stss.php 177 2010-03-09 13:13:34Z svollbehr $
 52 */
 53final class Zend_Media_Iso14496_Box_Stss extends Zend_Media_Iso14496_FullBox
 54{
 55    /** @var Array */
 56    private $_syncSampleTable = array();
 57
 58    /**
 59     * Constructs the class with given parameters and reads box related data
 60     * from the ISO Base Media file.
 61     *
 62     * @param Zend_Io_Reader $reader  The reader object.
 63     * @param Array          $options The options array.
 64     */
 65    public function __construct($reader, &$options = array())
 66    {
 67        parent::__construct($reader, $options);
 68
 69        $entryCount = $this->_reader->readUInt32BE();
 70        for ($i = 1; $i <= $entryCount; $i++) {
 71            $this->_syncSampleTable[$i] = $this->_reader->readUInt32BE();
 72        }
 73    }
 74
 75    /**
 76     * Returns an array of values. Each entry has the entry number as its index
 77     * and an integer that gives the numbers of the samples that are random
 78     * access points in the stream as its value.
 79     *
 80     * @return Array
 81     */
 82    public function getSyncSampleTable()
 83    {
 84        return $this->_syncSampleTable;
 85    }
 86
 87    /**
 88     * Sets an array of values. Each entry has the entry number as its index
 89     * and an integer that gives the numbers of the samples that are random
 90     * access points in the stream as its value.
 91     *
 92     * @param Array $syncSampleTable The array of values.
 93     */
 94    public function setSyncSampleTable($syncSampleTable)
 95    {
 96        $this->_syncSampleTable = $syncSampleTable;
 97    }
 98
 99    /**
100     * Returns the box heap size in bytes.
101     *
102     * @return integer
103     */
104    public function getHeapSize()
105    {
106        return parent::getHeapSize() + 4 + count($this->_syncSampleTable) * 4;
107    }
108
109    /**
110     * Writes the box data.
111     *
112     * @param Zend_Io_Writer $writer The writer object.
113     * @return void
114     */
115    protected function _writeData($writer)
116    {
117        parent::_writeData($writer);
118        $writer->writeUInt32BE($entryCount = count($this->_syncSampleTable));
119        for ($i = 1; $i <= $entryCount; $i++) {
120            $writer->writeUInt32BE($this->_syncSampleTable[$i]);
121        }
122    }
123}