ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
AMFStream.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
9 // available at http://getid3.sourceforge.net //
10 // or http://www.getid3.org //
11 // //
12 // AMFStream //
13 // by Seth Kaufman <seth@whirl-i-gig.com> //
14 // //
16 // //
17 // dependencies: None //
18 // ///
20 
29 class AMFStream
30 {
31  public $bytes;
32  public $pos;
33 
38  public function __construct(&$bytes)
39  {
40  $this->bytes = & $bytes;
41  $this->pos = 0;
42  }
43 
48  public function readByte()
49  {
50  return Helper::BigEndian2Int(substr($this->bytes,
51  $this->pos++, 1));
52  }
53 
58  public function readInt()
59  {
60  return ($this->readByte() << 8) + $this->readByte();
61  }
62 
67  public function readLong()
68  {
69  return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
70  }
71 
76  public function readDouble()
77  {
78  return Helper::BigEndian2Float($this->read(8));
79  }
80 
85  public function readUTF()
86  {
87  $length = $this->readInt();
88 
89  return $this->read($length);
90  }
91 
96  public function readLongUTF()
97  {
98  $length = $this->readLong();
99 
100  return $this->read($length);
101  }
102 
108  public function read($length)
109  {
110  $val = substr($this->bytes, $this->pos, $length);
111  $this->pos += $length;
112 
113  return $val;
114  }
115 
120  public function peekByte()
121  {
122  $pos = $this->pos;
123  $val = $this->readByte();
124  $this->pos = $pos;
125 
126  return $val;
127  }
128 
133  public function peekInt()
134  {
135  $pos = $this->pos;
136  $val = $this->readInt();
137  $this->pos = $pos;
138 
139  return $val;
140  }
141 
146  public function peekLong()
147  {
148  $pos = $this->pos;
149  $val = $this->readLong();
150  $this->pos = $pos;
151 
152  return $val;
153  }
154 
159  public function peekDouble()
160  {
161  $pos = $this->pos;
162  $val = $this->readDouble();
163  $this->pos = $pos;
164 
165  return $val;
166  }
167 
172  public function peekUTF()
173  {
174  $pos = $this->pos;
175  $val = $this->readUTF();
176  $this->pos = $pos;
177 
178  return $val;
179  }
180 
185  public function peekLongUTF()
186  {
187  $pos = $this->pos;
188  $val = $this->readLongUTF();
189  $this->pos = $pos;
190 
191  return $val;
192  }
193 }
static BigEndian2Float($byteword)
ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic.
Definition: Helper.php:290
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: Helper.php:374
GetId3() by James Heinrich info@getid3.org //.
Definition: AMFStream.php:29