AMFReader

The rtMedia for WordPress, BuddyPress and bbPress AMFReader class.

Defined (1)

The class is defined in the following location(s).

/lib/getid3/module.audio-video.flv.php  
  1. class AMFReader { 
  2. public $stream; 
  3.  
  4. public function __construct(&$stream) { 
  5. $this->stream =& $stream; 
  6.  
  7. public function readData() { 
  8. $value = null; 
  9.  
  10. $type = $this->stream->readByte(); 
  11. switch ($type) { 
  12.  
  13. // Double 
  14. case 0: 
  15. $value = $this->readDouble(); 
  16. break; 
  17.  
  18. // Boolean 
  19. case 1: 
  20. $value = $this->readBoolean(); 
  21. break; 
  22.  
  23. // String 
  24. case 2: 
  25. $value = $this->readString(); 
  26. break; 
  27.  
  28. // Object 
  29. case 3: 
  30. $value = $this->readObject(); 
  31. break; 
  32.  
  33. // null 
  34. case 6: 
  35. return null; 
  36. break; 
  37.  
  38. // Mixed array 
  39. case 8: 
  40. $value = $this->readMixedArray(); 
  41. break; 
  42.  
  43. // Array 
  44. case 10: 
  45. $value = $this->readArray(); 
  46. break; 
  47.  
  48. // Date 
  49. case 11: 
  50. $value = $this->readDate(); 
  51. break; 
  52.  
  53. // Long string 
  54. case 13: 
  55. $value = $this->readLongString(); 
  56. break; 
  57.  
  58. // XML (handled as string) 
  59. case 15: 
  60. $value = $this->readXML(); 
  61. break; 
  62.  
  63. // Typed object (handled as object) 
  64. case 16: 
  65. $value = $this->readTypedObject(); 
  66. break; 
  67.  
  68. // Long string 
  69. default: 
  70. $value = '(unknown or unsupported data type)'; 
  71. break; 
  72.  
  73. return $value; 
  74.  
  75. public function readDouble() { 
  76. return $this->stream->readDouble(); 
  77.  
  78. public function readBoolean() { 
  79. return $this->stream->readByte() == 1; 
  80.  
  81. public function readString() { 
  82. return $this->stream->readUTF(); 
  83.  
  84. public function readObject() { 
  85. // Get highest numerical index - ignored 
  86. // $highestIndex = $this->stream->readLong(); 
  87.  
  88. $data = array(); 
  89.  
  90. while ($key = $this->stream->readUTF()) { 
  91. $data[$key] = $this->readData(); 
  92. // Mixed array record ends with empty string (0x00 0x00) and 0x09 
  93. if (($key == '') && ($this->stream->peekByte() == 0x09)) { 
  94. // Consume byte 
  95. $this->stream->readByte(); 
  96. return $data; 
  97.  
  98. public function readMixedArray() { 
  99. // Get highest numerical index - ignored 
  100. $highestIndex = $this->stream->readLong(); 
  101.  
  102. $data = array(); 
  103.  
  104. while ($key = $this->stream->readUTF()) { 
  105. if (is_numeric($key)) { 
  106. $key = (float) $key; 
  107. $data[$key] = $this->readData(); 
  108. // Mixed array record ends with empty string (0x00 0x00) and 0x09 
  109. if (($key == '') && ($this->stream->peekByte() == 0x09)) { 
  110. // Consume byte 
  111. $this->stream->readByte(); 
  112.  
  113. return $data; 
  114.  
  115. public function readArray() { 
  116. $length = $this->stream->readLong(); 
  117. $data = array(); 
  118.  
  119. for ($i = 0; $i < $length; $i++) { 
  120. $data[] = $this->readData(); 
  121. return $data; 
  122.  
  123. public function readDate() { 
  124. $timestamp = $this->stream->readDouble(); 
  125. $timezone = $this->stream->readInt(); 
  126. return $timestamp; 
  127.  
  128. public function readLongString() { 
  129. return $this->stream->readLongUTF(); 
  130.  
  131. public function readXML() { 
  132. return $this->stream->readLongUTF(); 
  133.  
  134. public function readTypedObject() { 
  135. $className = $this->stream->readUTF(); 
  136. return $this->readObject();