~keith-hughitt/helioviewer.org/2.0

« back to all changes in this revision

Viewing changes to api/lib/phpvideotoolkit/adapters/ffmpeg-php/php-reader/src/ASF/Object/SimpleIndex.php

  • Committer: Keith Hughitt
  • Date: 2010-03-24 11:14:04 UTC
  • Revision ID: hughitt1@io-20100324111404-tjat3xqy09nqvwik
Helioviewer.orgĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * PHP Reader Library
 
4
 *
 
5
 * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
 
6
 *
 
7
 * Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions are met:
 
9
 *
 
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.
 
18
 *
 
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.
 
30
 *
 
31
 * @package    php-reader
 
32
 * @subpackage ASF
 
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 $
 
36
 */
 
37
 
 
38
/**#@+ @ignore */
 
39
require_once("ASF/Object.php");
 
40
/**#@-*/
 
41
 
 
42
/**
 
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.
 
46
 * 
 
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.
 
53
 *
 
54
 * @package    php-reader
 
55
 * @subpackage ASF
 
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 $
 
60
 */
 
61
final class ASF_Object_SimpleIndex extends ASF_Object
 
62
{
 
63
  /** @var string */
 
64
  private $_fileId;
 
65
 
 
66
  /** @var integer */
 
67
  private $_indexEntryTimeInterval;
 
68
 
 
69
  /** @var integer */
 
70
  private $_maximumPacketCount;
 
71
 
 
72
  /** @var Array */
 
73
  private $_indexEntries = array();
 
74
  
 
75
  /**
 
76
   * Constructs the class with given parameters and reads object related data
 
77
   * from the ASF file.
 
78
   *
 
79
   * @param Reader $reader  The reader object.
 
80
   * @param Array  $options The options array.
 
81
   */
 
82
  public function __construct($reader, &$options = array())
 
83
  {
 
84
    parent::__construct($reader, $options);
 
85
    
 
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());
 
94
    }
 
95
  }
 
96
 
 
97
  /**
 
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
 
102
   * Object</i>.
 
103
   *
 
104
   * @return string
 
105
   */
 
106
  public function getFileId() { return $this->_fileId; }
 
107
 
 
108
  /**
 
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.
 
112
   *
 
113
   * @return integer
 
114
   */
 
115
  public function getIndexEntryTimeInterval()
 
116
  {
 
117
    return $this->_indexEntryTimeInterval;
 
118
  }
 
119
 
 
120
  /**
 
121
   * Returns the maximum <i>Packet Count</i> value of all <i>Index Entries</i>.
 
122
   *
 
123
   * @return integer
 
124
   */
 
125
  public function getMaximumPacketCount() { return $this->_maximumPacketCount; }
 
126
 
 
127
  /**
 
128
   * Returns an array of index entries. Each entry consists of the following
 
129
   * keys.
 
130
   * 
 
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.
 
135
   * 
 
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.
 
139
   *
 
140
   * @return Array
 
141
   */
 
142
  public function getIndexEntries() { return $this->_indexEntries; }
 
143
}