5
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
10
* - Redistributions of source code must retain the above copyright notice,
11
* this list of conditions and the following disclaimer.
12
* - Redistributions in binary form must reproduce the above copyright notice,
13
* this list of conditions and the following disclaimer in the documentation
14
* and/or other materials provided with the distribution.
15
* - Neither the name of the project workgroup nor the names of its
16
* contributors may be used to endorse or promote products derived from this
17
* software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
* POSSIBILITY OF SUCH DAMAGE.
33
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
34
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
35
* @version $Id: SimpleIndex.php 108 2008-09-05 17:00:05Z svollbehr $
39
require_once("ASF/Object.php");
43
* For each video stream in an ASF file, there should be one instance of the
44
* <i>Simple Index Object</i>. Additionally, the instances of the <i>Simple
45
* Index Object</i> shall be ordered by stream number.
47
* Index entries in the <i>Simple Index Object</i> are in terms of
48
* <i>Presentation Times</i>. The corresponding <i>Packet Number</i> field
49
* values (of the <i>Index Entry</i>, see below) indicate the packet number of
50
* the ASF <i>Data Packet</i> with the closest past key frame. Note that for
51
* video streams that contain both key frames and non-key frames, the <i>Packet
52
* Number</i> field will always point to the closest past key frame.
56
* @author Sven Vollbehr <svollbehr@gmail.com>
57
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
58
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
59
* @version $Rev: 108 $
61
final class ASF_Object_SimpleIndex extends ASF_Object
67
private $_indexEntryTimeInterval;
70
private $_maximumPacketCount;
73
private $_indexEntries = array();
76
* Constructs the class with given parameters and reads object related data
79
* @param Reader $reader The reader object.
80
* @param Array $options The options array.
82
public function __construct($reader, &$options = array())
84
parent::__construct($reader, $options);
86
$this->_fileId = $this->_reader->readGUID();
87
$this->_indexEntryTimeInterval = $this->_reader->readInt64LE();
88
$this->_maximumPacketCount = $this->_reader->readUInt32LE();
89
$indexEntriesCount = $this->_reader->readUInt32LE();
90
for ($i = 0; $i < $indexEntriesCount; $i++) {
91
$this->_indexEntries[] = array
92
("packetNumber" => $this->_reader->readUInt32LE(),
93
"packetCount" => $this->_reader->readUInt16LE());
98
* Returns the unique identifier for this ASF file. The value of this field
99
* should be changed every time the file is modified in any way. The value of
100
* this field may be set to 0 or set to be identical to the value of the
101
* <i>File ID</i> field of the <i>Data Object</i> and the <i>Header
106
public function getFileId() { return $this->_fileId; }
109
* Returns the time interval between each index entry in 100-nanosecond units.
110
* The most common value is 10000000, to indicate that the index entries are
111
* in 1-second intervals, though other values can be used as well.
115
public function getIndexEntryTimeInterval()
117
return $this->_indexEntryTimeInterval;
121
* Returns the maximum <i>Packet Count</i> value of all <i>Index Entries</i>.
125
public function getMaximumPacketCount() { return $this->_maximumPacketCount; }
128
* Returns an array of index entries. Each entry consists of the following
131
* o packetNumber -- Specifies the number of the Data Packet associated
132
* with this index entry. Note that for video streams that contain both
133
* key frames and non-key frames, this field will always point to the
134
* closest key frame prior to the time interval.
136
* o packetCount -- Specifies the number of <i>Data Packets</i> to send at
137
* this index entry. If a video key frame has been fragmented into two
138
* Data Packets, the value of this field will be equal to 2.
142
public function getIndexEntries() { return $this->_indexEntries; }