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

http://php-reader.googlecode.com/ · PHP · 133 lines · 32 code · 8 blank · 93 comment · 1 complexity · b986a9d6fa5617e4bd12da941e5a8d17 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: MediaObjectIndexParameters.php 177 2010-03-09 13:13:34Z svollbehr $
  21. */
  22. /**#@+ @ignore */
  23. require_once 'Zend/Media/Asf/Object.php';
  24. /**#@-*/
  25. /**
  26. * The <i>Media Object Index Parameters Object</i> supplies information about
  27. * those streams that actually indexed (there must be at least one stream in an
  28. * index) by media objects. This object shall be present in the
  29. * {@link Zend_Media_Asf_Object_Header Header Object} if there is a
  30. * {@link Zend_Media_Asf_Object_MediaObjectIndex Media Object Index Object}
  31. * present in the file.
  32. *
  33. * An Index Specifier is required for each stream that will be indexed by the
  34. * {@link Zend_Media_Asf_Object_MediaObjectIndex Media Object Index Object}.
  35. * These specifiers must exactly match those in the
  36. * {@link Zend_Media_Asf_Object_MediaObjectIndex Media Object Index Object}.
  37. *
  38. * @category Zend
  39. * @package Zend_Media
  40. * @subpackage ASF
  41. * @author Sven Vollbehr <sven@vollbehr.eu>
  42. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. * @version $Id: MediaObjectIndexParameters.php 177 2010-03-09 13:13:34Z svollbehr $
  45. */
  46. final class Zend_Media_Asf_Object_MediaObjectIndexParameters
  47. extends Zend_Media_Asf_Object
  48. {
  49. /** @var string */
  50. private $_indexEntryCountInterval;
  51. /** @var Array */
  52. private $_indexSpecifiers = array();
  53. /**
  54. * Constructs the class with given parameters and reads object related data
  55. * from the ASF file.
  56. *
  57. * @param Zend_Io_Reader $reader The reader object.
  58. * @param Array $options The options array.
  59. */
  60. public function __construct($reader, &$options = array())
  61. {
  62. parent::__construct($reader, $options);
  63. $this->_indexEntryCountInterval = $this->_reader->readUInt32LE();
  64. $indexSpecifiersCount = $this->_reader->readUInt16LE();
  65. for ($i = 0; $i < $indexSpecifiersCount; $i++) {
  66. $this->_indexSpecifiers[] = array
  67. ('streamNumber' => $this->_reader->readUInt16LE(),
  68. 'indexType' => $this->_reader->readUInt16LE());
  69. }
  70. }
  71. /**
  72. * Returns the interval between each index entry by the number of media
  73. * objects. This value cannot be 0.
  74. *
  75. * @return integer
  76. */
  77. public function getIndexEntryCountInterval()
  78. {
  79. return $this->_indexEntryCountInterval;
  80. }
  81. /**
  82. * Returns an array of index entries. Each entry consists of the following
  83. * keys.
  84. *
  85. * o streamNumber -- Specifies the stream number that the Index Specifiers
  86. * refer to. Valid values are between 1 and 127.
  87. *
  88. * o indexType -- Specifies the type of index. Values are defined as
  89. * follows:
  90. * 1 = Nearest Past Data Packet,
  91. * 2 = Nearest Past Media Object,
  92. * 3 = Nearest Past Cleanpoint,
  93. * 0xff = Frame Number Offset.
  94. * For a video stream, the Nearest Past Media Object and Nearest Past
  95. * Data Packet indexes point to the closest data packet containing an
  96. * entire video frame or first fragment of a video frame; Nearest Past
  97. * Cleanpoint indexes point to the closest data packet containing an
  98. * entire video frame (or first fragment of a video frame) that is a key
  99. * frame; and Frame Number Offset indicates how many more frames need to
  100. * be read for the given stream, starting with the first frame in the
  101. * packet pointed to by the index entry, in order to get to the
  102. * requested frame. Nearest Past Media Object is the most common value.
  103. * Because ASF payloads do not contain the full frame number, there is
  104. * often a Frame Number Offset index alongside one of the other types of
  105. * indexes to allow the user to identify the exact frame being seeked
  106. * to.
  107. *
  108. * @return Array
  109. */
  110. public function getIndexSpecifiers()
  111. {
  112. return $this->_indexSpecifiers;
  113. }
  114. /**
  115. * Writes the object data.
  116. *
  117. * @param Zend_Io_Writer $writer The writer object.
  118. * @return void
  119. */
  120. public function write($writer)
  121. {
  122. require_once 'Zend/Media/Asf/Exception.php';
  123. throw new Zend_Media_Asf_Exception('Operation not supported');
  124. }
  125. }