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