<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-// also https://github.com/JamesHeinrich/getID3 //
+// available at https://github.com/JamesHeinrich/getID3 //
+// or https://www.getid3.org //
+// or http://getid3.sourceforge.net //
+// see readme.txt for more details //
+/////////////////////////////////////////////////////////////////
+// //
+// module.audio-video.flv.php //
+// module for analyzing Shockwave Flash Video files //
+// dependencies: NONE //
+// //
+/////////////////////////////////////////////////////////////////
// //
// FLV module by Seth Kaufman <sethØwhirl-i-gig*com> //
// //
// * version 0.1 (26 June 2005) //
// //
-// //
// * version 0.1.1 (15 July 2005) //
// minor modifications by James Heinrich <info@getid3.org> //
// //
// handle GETID3_FLV_VIDEO_VP6FLV_ALPHA //
// improved AVCSequenceParameterSetReader::readData() //
// by Xander Schouwerwou <schouwerwouØgmail*com> //
-// //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.flv.php //
-// module for analyzing Shockwave Flash Video files //
-// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
define('H264_PROFILE_HIGH444', 144);
define('H264_PROFILE_HIGH444_PREDICTIVE', 244);
-class getid3_flv extends getid3_handler {
-
+class getid3_flv extends getid3_handler
+{
const magic = 'FLV';
- public $max_frames = 100000; // break out of the loop if too many frames have been scanned; only scan this many if meta frame does not contain useful duration
-
+ /**
+ * Break out of the loop if too many frames have been scanned; only scan this
+ * many if meta frame does not contain useful duration.
+ *
+ * @var int
+ */
+ public $max_frames = 100000;
+
+ /**
+ * @return bool
+ */
public function Analyze() {
$info = &$this->getid3->info;
return true;
}
-
+ /**
+ * @param int $id
+ *
+ * @return string|false
+ */
public static function audioFormatLookup($id) {
static $lookup = array(
0 => 'Linear PCM, platform endian',
return (isset($lookup[$id]) ? $lookup[$id] : false);
}
+ /**
+ * @param int $id
+ *
+ * @return int|false
+ */
public static function audioRateLookup($id) {
static $lookup = array(
0 => 5500,
return (isset($lookup[$id]) ? $lookup[$id] : false);
}
+ /**
+ * @param int $id
+ *
+ * @return int|false
+ */
public static function audioBitDepthLookup($id) {
static $lookup = array(
0 => 8,
return (isset($lookup[$id]) ? $lookup[$id] : false);
}
+ /**
+ * @param int $id
+ *
+ * @return string|false
+ */
public static function videoCodecLookup($id) {
static $lookup = array(
GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
}
}
-class AMFStream {
+class AMFStream
+{
+ /**
+ * @var string
+ */
public $bytes;
+
+ /**
+ * @var int
+ */
public $pos;
+ /**
+ * @param string $bytes
+ */
public function __construct(&$bytes) {
$this->bytes =& $bytes;
$this->pos = 0;
}
- public function readByte() {
- return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
+ /**
+ * @return int
+ */
+ public function readByte() { // 8-bit
+ return ord(substr($this->bytes, $this->pos++, 1));
}
- public function readInt() {
+ /**
+ * @return int
+ */
+ public function readInt() { // 16-bit
return ($this->readByte() << 8) + $this->readByte();
}
- public function readLong() {
+ /**
+ * @return int
+ */
+ public function readLong() { // 32-bit
return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
}
+ /**
+ * @return float|false
+ */
public function readDouble() {
return getid3_lib::BigEndian2Float($this->read(8));
}
+ /**
+ * @return string
+ */
public function readUTF() {
$length = $this->readInt();
return $this->read($length);
}
+ /**
+ * @return string
+ */
public function readLongUTF() {
$length = $this->readLong();
return $this->read($length);
}
+ /**
+ * @param int $length
+ *
+ * @return string
+ */
public function read($length) {
$val = substr($this->bytes, $this->pos, $length);
$this->pos += $length;
return $val;
}
+ /**
+ * @return int
+ */
public function peekByte() {
$pos = $this->pos;
$val = $this->readByte();
return $val;
}
+ /**
+ * @return int
+ */
public function peekInt() {
$pos = $this->pos;
$val = $this->readInt();
return $val;
}
+ /**
+ * @return int
+ */
public function peekLong() {
$pos = $this->pos;
$val = $this->readLong();
return $val;
}
+ /**
+ * @return float|false
+ */
public function peekDouble() {
$pos = $this->pos;
$val = $this->readDouble();
return $val;
}
+ /**
+ * @return string
+ */
public function peekUTF() {
$pos = $this->pos;
$val = $this->readUTF();
return $val;
}
+ /**
+ * @return string
+ */
public function peekLongUTF() {
$pos = $this->pos;
$val = $this->readLongUTF();
}
}
-class AMFReader {
+class AMFReader
+{
+ /**
+ * @var AMFStream
+ */
public $stream;
- public function __construct(&$stream) {
- $this->stream =& $stream;
+ /**
+ * @param AMFStream $stream
+ */
+ public function __construct(AMFStream $stream) {
+ $this->stream = $stream;
}
+ /**
+ * @return mixed
+ */
public function readData() {
$value = null;
return $value;
}
+ /**
+ * @return float|false
+ */
public function readDouble() {
return $this->stream->readDouble();
}
+ /**
+ * @return bool
+ */
public function readBoolean() {
return $this->stream->readByte() == 1;
}
+ /**
+ * @return string
+ */
public function readString() {
return $this->stream->readUTF();
}
+ /**
+ * @return array
+ */
public function readObject() {
// Get highest numerical index - ignored
// $highestIndex = $this->stream->readLong();
$data = array();
+ $key = null;
while ($key = $this->stream->readUTF()) {
$data[$key] = $this->readData();
return $data;
}
+ /**
+ * @return array
+ */
public function readMixedArray() {
// Get highest numerical index - ignored
$highestIndex = $this->stream->readLong();
$data = array();
+ $key = null;
while ($key = $this->stream->readUTF()) {
if (is_numeric($key)) {
- $key = (float) $key;
+ $key = (int) $key;
}
$data[$key] = $this->readData();
}
return $data;
}
+ /**
+ * @return array
+ */
public function readArray() {
$length = $this->stream->readLong();
$data = array();
return $data;
}
+ /**
+ * @return float|false
+ */
public function readDate() {
$timestamp = $this->stream->readDouble();
$timezone = $this->stream->readInt();
return $timestamp;
}
+ /**
+ * @return string
+ */
public function readLongString() {
return $this->stream->readLongUTF();
}
+ /**
+ * @return string
+ */
public function readXML() {
return $this->stream->readLongUTF();
}
+ /**
+ * @return array
+ */
public function readTypedObject() {
$className = $this->stream->readUTF();
return $this->readObject();
}
}
-class AVCSequenceParameterSetReader {
+class AVCSequenceParameterSetReader
+{
+ /**
+ * @var string
+ */
public $sps;
public $start = 0;
public $currentBytes = 0;
public $currentBits = 0;
+
+ /**
+ * @var int
+ */
public $width;
+
+ /**
+ * @var int
+ */
public $height;
+ /**
+ * @param string $sps
+ */
public function __construct($sps) {
$this->sps = $sps;
}
}
}
+ /**
+ * @param int $bits
+ */
public function skipBits($bits) {
$newBits = $this->currentBits + $bits;
$this->currentBytes += (int)floor($newBits / 8);
$this->currentBits = $newBits % 8;
}
+ /**
+ * @return int
+ */
public function getBit() {
$result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01;
$this->skipBits(1);
return $result;
}
+ /**
+ * @param int $bits
+ *
+ * @return int
+ */
public function getBits($bits) {
$result = 0;
for ($i = 0; $i < $bits; $i++) {
return $result;
}
+ /**
+ * @return int
+ */
public function expGolombUe() {
$significantBits = 0;
$bit = $this->getBit();
return (1 << $significantBits) + $this->getBits($significantBits) - 1;
}
+ /**
+ * @return int
+ */
public function expGolombSe() {
$result = $this->expGolombUe();
if (($result & 0x01) == 0) {
}
}
+ /**
+ * @return int
+ */
public function getWidth() {
return $this->width;
}
+ /**
+ * @return int
+ */
public function getHeight() {
return $this->height;
}