PageRenderTime 28ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://php-reader.googlecode.com/
PHP | 233 lines | 75 code | 20 blank | 138 comment | 0 complexity | 9fe69cb7cabe82e5573de5c005daca5f 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: Infe.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>Item Information Entry Box</i> contains the entry information.
 41 *
 42 * @category   Zend
 43 * @package    Zend_Media
 44 * @subpackage ISO14496
 45 * @author     Sven Vollbehr <sven@vollbehr.eu>
 46 * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) 
 47 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 48 * @version    $Id: Infe.php 177 2010-03-09 13:13:34Z svollbehr $
 49 */
 50final class Zend_Media_Iso14496_Box_Infe extends Zend_Media_Iso14496_FullBox
 51{
 52    /** @var integer */
 53    private $_itemId;
 54
 55    /** @var integer */
 56    private $_itemProtectionIndex;
 57
 58    /** @var string */
 59    private $_itemName;
 60
 61    /** @var string */
 62    private $_contentType;
 63
 64    /** @var string */
 65    private $_contentEncoding;
 66
 67    /**
 68     * Constructs the class with given parameters and reads box related data
 69     * from the ISO Base Media file.
 70     *
 71     * @param Zend_Io_Reader $reader  The reader object.
 72     * @param Array          $options The options array.
 73     */
 74    public function __construct($reader, &$options = array())
 75    {
 76        parent::__construct($reader, $options);
 77
 78        $this->_itemId = $this->_reader->readUInt16BE();
 79        $this->_itemProtectionIndex = $this->_reader->readUInt16BE();
 80        list($this->_itemName, $this->_contentType, $this->_contentEncoding) =
 81            preg_split
 82                ("/\\x00/", $this->_reader->read
 83                 ($this->getOffset() + $this->getSize() -
 84                  $this->_reader->getOffset()));
 85    }
 86
 87    /**
 88     * Returns the item identifier. The value is either 0 for the primary
 89     * resource (e.g. the XML contained in an
 90     * {@link Zend_Media_Iso14496_Box_Xml XML Box}) or the ID of the item for
 91     * which the following information is defined.
 92     *
 93     * @return integer
 94     */
 95    public function getItemId()
 96    {
 97        return $this->_itemId;
 98    }
 99
100    /**
101     * Sets the item identifier. The value must be either 0 for the primary
102     * resource (e.g. the XML contained in an
103     * {@link Zend_Media_Iso14496_Box_Xml XML Box}) or the ID of the item for
104     * which the following information is defined.
105     *
106     * @param integer $itemId The item identifier.
107     */
108    public function setItemId($itemId)
109    {
110        $this->_itemId = $itemId;
111    }
112
113    /**
114     * Returns the item protection index. The value is either 0 for an
115     * unprotected item, or the one-based index into the
116     * {@link Zend_Media_Iso14496_Box_Ipro Item Protection Box} defining the
117     * protection applied to this item (the first box in the item protection box
118     * has the index 1).
119     *
120     * @return integer
121     */
122    public function getItemProtectionIndex()
123    {
124        return $this->_itemProtectionIndex;
125    }
126
127    /**
128     * Sets the item protection index. The value must be either 0 for an
129     * unprotected item, or the one-based index into the
130     * {@link Zend_Media_Iso14496_Box_Ipro Item Protection Box} defining the
131     * protection applied to this item (the first box in the item protection box
132     * has the index 1).
133     *
134     * @param integer $itemProtectionIndex The index.
135     */
136    public function setItemProtectionIndex($itemProtectionIndex)
137    {
138        $this->_itemProtectionIndex = $itemProtectionIndex;
139    }
140
141    /**
142     * Returns the symbolic name of the item.
143     *
144     * @return string
145     */
146    public function getItemName()
147    {
148        return $this->_itemName;
149    }
150
151    /**
152     * Sets the symbolic name of the item.
153     *
154     * @param string $itemName The item name.
155     */
156    public function setItemName($itemName)
157    {
158        $this->_itemName = $itemName;
159    }
160
161    /**
162     * Returns the MIME type for the item.
163     *
164     * @return string
165     */
166    public function getContentType()
167    {
168        return $this->_contentType;
169    }
170
171    /**
172     * Sets the MIME type for the item.
173     *
174     * @param string $contentType The content type.
175     */
176    public function setContentType($contentType)
177    {
178        $this->_contentType = $contentType;
179    }
180
181    /**
182     * Returns the optional content encoding type as defined for
183     * Content-Encoding for HTTP /1.1. Some possible values are <i>gzip</i>,
184     * <i>compress</i> and <i>deflate</i>. An empty string indicates no content
185     * encoding.
186     *
187     * @return string
188     */
189    public function getContentEncoding()
190    {
191        return $this->_contentEncoding;
192    }
193
194    /**
195     * Sets the optional content encoding type as defined for
196     * Content-Encoding for HTTP /1.1. Some possible values are <i>gzip</i>,
197     * <i>compress</i> and <i>deflate</i>. An empty string indicates no content
198     * encoding.
199     *
200     * @param string $contentEncoding The content encoding.
201     */
202    public function setContentEncoding($contentEncoding)
203    {
204        $this->_contentEncoding = $contentEncoding;
205    }
206
207    /**
208     * Returns the box heap size in bytes.
209     *
210     * @return integer
211     */
212    public function getHeapSize()
213    {
214        return parent::getHeapSize() + 7 + strlen($this->_itemName) +
215            strlen($this->_contentType) + strlen($this->_contentEncoding);
216    }
217
218    /**
219     * Writes the box data.
220     *
221     * @param Zend_Io_Writer $writer The writer object.
222     * @return void
223     */
224    protected function _writeData($writer)
225    {
226        parent::_writeData($writer);
227        $writer->writeUInt16BE($this->_itemId)
228               ->writeUInt16BE($this->_itemProtectionIndex)
229               ->writeString8($this->_itemName, 1)
230               ->writeString8($this->_contentType, 1)
231               ->writeString8($this->_contentEncoding, 1);
232    }
233}