~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/StreamBitrateProperties.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: StreamBitrateProperties.php 108 2008-09-05 17:00:05Z svollbehr $
 
36
 */
 
37
 
 
38
/**#@+ @ignore */
 
39
require_once("ASF/Object.php");
 
40
/**#@-*/
 
41
 
 
42
/**
 
43
 * The <i>Stream Bitrate Properties Object</i> defines the average bit rate of
 
44
 * each digital media stream.
 
45
 *
 
46
 * @package    php-reader
 
47
 * @subpackage ASF
 
48
 * @author     Sven Vollbehr <svollbehr@gmail.com>
 
49
 * @copyright  Copyright (c) 2008 The PHP Reader Project Workgroup
 
50
 * @license    http://code.google.com/p/php-reader/wiki/License New BSD License
 
51
 * @version    $Rev: 108 $
 
52
 */
 
53
final class ASF_Object_StreamBitrateProperties extends ASF_Object
 
54
{
 
55
  /** @var Array */
 
56
  private $_bitrateRecords = array();
 
57
  
 
58
  /**
 
59
   * Constructs the class with given parameters and reads object related data
 
60
   * from the ASF file.
 
61
   *
 
62
   * @param Reader $reader  The reader object.
 
63
   * @param Array  $options The options array.
 
64
   */
 
65
  public function __construct($reader, &$options = array())
 
66
  {
 
67
    parent::__construct($reader, $options);
 
68
    
 
69
    $bitrateRecordsCount = $this->_reader->readUInt16LE();
 
70
    for ($i = 0; $i < $bitrateRecordsCount; $i++)
 
71
      $this->_bitrateRecords[] = array
 
72
        ("streamNumber" => ($tmp = $this->_reader->readInt16LE()) & 0x1f,
 
73
         "flags" => $tmp >> 5,
 
74
         "averageBitrate" => $this->_reader->readUInt32LE());
 
75
  }
 
76
  
 
77
  /**
 
78
   * Returns an array of bitrate records. Each record consists of the following
 
79
   * keys.
 
80
   * 
 
81
   *   o streamNumber -- Specifies the number of this stream described by this
 
82
   *     record. 0 is an invalid stream. Valid values are between 1 and 127.
 
83
   * 
 
84
   *   o flags -- These bits are reserved and should be set to 0.
 
85
   * 
 
86
   *   o averageBitrate -- Specifies the average bit rate of the stream in bits
 
87
   *     per second. This value should include an estimate of ASF packet and
 
88
   *     payload overhead associated with this stream.
 
89
   *
 
90
   * @return Array
 
91
   */
 
92
  public function getBitrateRecords() { return $this->_bitrateRecords; }
 
93
}