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