mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,127 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVHeader
|
||||
{
|
||||
|
||||
public static const MIN_FILE_HEADER_BYTE_COUNT:int = 9;
|
||||
|
||||
private var _hasVideoTags:Boolean = true;
|
||||
|
||||
private var _hasAudioTags:Boolean = true;
|
||||
|
||||
private var offset:uint;
|
||||
|
||||
public function FLVHeader(param1:IDataInput = null)
|
||||
{
|
||||
super();
|
||||
if(param1 != null)
|
||||
{
|
||||
readHeader(param1);
|
||||
readRest(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function get hasAudioTags() : Boolean
|
||||
{
|
||||
return _hasAudioTags;
|
||||
}
|
||||
|
||||
public function set hasAudioTags(param1:Boolean) : void
|
||||
{
|
||||
_hasAudioTags = param1;
|
||||
}
|
||||
|
||||
public function get hasVideoTags() : Boolean
|
||||
{
|
||||
return _hasVideoTags;
|
||||
}
|
||||
|
||||
public function set hasVideoTags(param1:Boolean) : void
|
||||
{
|
||||
_hasVideoTags = param1;
|
||||
}
|
||||
|
||||
public function write(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeByte(70);
|
||||
param1.writeByte(76);
|
||||
param1.writeByte(86);
|
||||
param1.writeByte(1);
|
||||
var _loc3_:uint = 0;
|
||||
if(_hasAudioTags)
|
||||
{
|
||||
_loc3_ |= 4;
|
||||
}
|
||||
if(_hasVideoTags)
|
||||
{
|
||||
_loc3_ |= 1;
|
||||
}
|
||||
param1.writeByte(_loc3_);
|
||||
var _loc2_:uint = 9;
|
||||
param1.writeUnsignedInt(_loc2_);
|
||||
var _loc4_:uint = 0;
|
||||
param1.writeUnsignedInt(_loc4_);
|
||||
}
|
||||
|
||||
internal function readHeader(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 9)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short");
|
||||
}
|
||||
if(param1.readByte() != 70)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[0] not \'F\'");
|
||||
}
|
||||
if(param1.readByte() != 76)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[1] not \'L\'");
|
||||
}
|
||||
if(param1.readByte() != 86)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Signature[2] not \'V\'");
|
||||
}
|
||||
if(param1.readByte() != 1)
|
||||
{
|
||||
throw new Error("FLVHeader readHeader() Version not 0x01");
|
||||
}
|
||||
var _loc2_:int = param1.readByte();
|
||||
_hasAudioTags = _loc2_ & 4 ? true : false;
|
||||
_hasVideoTags = _loc2_ & 1 ? true : false;
|
||||
offset = param1.readUnsignedInt();
|
||||
if(offset < 9)
|
||||
{
|
||||
throw new Error("FLVHeader() offset smaller than minimum");
|
||||
}
|
||||
}
|
||||
|
||||
internal function readRest(param1:IDataInput) : void
|
||||
{
|
||||
var _loc2_:ByteArray = null;
|
||||
if(offset > 9)
|
||||
{
|
||||
if(offset - 9 < param1.bytesAvailable - 4)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short for nonstandard offset");
|
||||
}
|
||||
_loc2_ = new ByteArray();
|
||||
param1.readBytes(_loc2_,0,offset - 9);
|
||||
}
|
||||
if(param1.bytesAvailable < 4)
|
||||
{
|
||||
throw new Error("FLVHeader() input too short for previousTagSize0");
|
||||
}
|
||||
param1.readUnsignedInt();
|
||||
}
|
||||
|
||||
internal function get restBytesNeeded() : int
|
||||
{
|
||||
return 4 + (offset - 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVParser
|
||||
{
|
||||
|
||||
private var state:String;
|
||||
|
||||
private var savedBytes:ByteArray;
|
||||
|
||||
private var currentTag:FLVTag = null;
|
||||
|
||||
private var flvHeader:FLVHeader;
|
||||
|
||||
public function FLVParser(param1:Boolean)
|
||||
{
|
||||
super();
|
||||
savedBytes = new ByteArray();
|
||||
if(param1)
|
||||
{
|
||||
state = "fileHeader";
|
||||
}
|
||||
else
|
||||
{
|
||||
state = "type";
|
||||
}
|
||||
}
|
||||
|
||||
public function flush(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeBytes(savedBytes);
|
||||
}
|
||||
|
||||
public function parse(param1:IDataInput, param2:Boolean, param3:Function) : void
|
||||
{
|
||||
var _loc5_:IDataInput = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Boolean = true;
|
||||
while(_loc4_)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case "fileHeader":
|
||||
_loc5_ = byteSource(param1,9);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
flvHeader = new FLVHeader();
|
||||
flvHeader.readHeader(_loc5_);
|
||||
state = "fileHeaderRest";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "fileHeaderRest":
|
||||
_loc5_ = byteSource(param1,flvHeader.restBytesNeeded);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
flvHeader.readRest(_loc5_);
|
||||
state = "type";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "type":
|
||||
_loc5_ = byteSource(param1,1);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
switch(_loc6_ = _loc5_.readByte())
|
||||
{
|
||||
case 8:
|
||||
case 40:
|
||||
currentTag = new FLVTagAudio(_loc6_);
|
||||
break;
|
||||
case 9:
|
||||
case 41:
|
||||
currentTag = new FLVTagVideo(_loc6_);
|
||||
break;
|
||||
case 18:
|
||||
case 50:
|
||||
currentTag = new FLVTagScriptDataObject(_loc6_);
|
||||
break;
|
||||
default:
|
||||
currentTag = new FLVTag(_loc6_);
|
||||
}
|
||||
state = "header";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
_loc5_ = byteSource(param1,11 - 1);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
currentTag.readRemainingHeader(_loc5_);
|
||||
if(currentTag.dataSize)
|
||||
{
|
||||
state = "data";
|
||||
}
|
||||
else
|
||||
{
|
||||
state = "prevTag";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "data":
|
||||
_loc5_ = byteSource(param1,currentTag.dataSize);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
currentTag.readData(_loc5_);
|
||||
state = "prevTag";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
case "prevTag":
|
||||
_loc5_ = byteSource(param1,4);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
currentTag.readPrevTag(_loc5_);
|
||||
state = "type";
|
||||
_loc4_ = param3(currentTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("FLVParser state machine in unknown state");
|
||||
}
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
param1.readBytes(savedBytes,savedBytes.length);
|
||||
}
|
||||
}
|
||||
|
||||
private function byteSource(param1:IDataInput, param2:int) : IDataInput
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(savedBytes.bytesAvailable + param1.bytesAvailable < param2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(savedBytes.bytesAvailable)
|
||||
{
|
||||
_loc3_ = param2 - savedBytes.bytesAvailable;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
param1.readBytes(savedBytes,savedBytes.length,_loc3_);
|
||||
}
|
||||
return savedBytes;
|
||||
}
|
||||
savedBytes.length = 0;
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
internal class FLVParserState
|
||||
{
|
||||
|
||||
internal static const FILE_HEADER:String = "fileHeader";
|
||||
|
||||
internal static const FILE_HEADER_REST:String = "fileHeaderRest";
|
||||
|
||||
internal static const TYPE:String = "type";
|
||||
|
||||
internal static const HEADER:String = "header";
|
||||
|
||||
internal static const DATA:String = "data";
|
||||
|
||||
internal static const PREV_TAG:String = "prevTag";
|
||||
|
||||
public function FLVParserState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
import flash.utils.IDataOutput;
|
||||
|
||||
public class FLVTag
|
||||
{
|
||||
|
||||
public static const TAG_TYPE_AUDIO:int = 8;
|
||||
|
||||
public static const TAG_TYPE_VIDEO:int = 9;
|
||||
|
||||
public static const TAG_TYPE_SCRIPTDATAOBJECT:int = 18;
|
||||
|
||||
public static const TAG_FLAG_ENCRYPTED:int = 32;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_AUDIO:int = 40;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_VIDEO:int = 41;
|
||||
|
||||
public static const TAG_TYPE_ENCRYPTED_SCRIPTDATAOBJECT:int = 50;
|
||||
|
||||
internal static const TAG_HEADER_BYTE_COUNT:int = 11;
|
||||
|
||||
internal static const PREV_TAG_BYTE_COUNT:int = 4;
|
||||
|
||||
protected var bytes:ByteArray = null;
|
||||
|
||||
public function FLVTag(param1:int)
|
||||
{
|
||||
super();
|
||||
bytes = new ByteArray();
|
||||
bytes.length = 11;
|
||||
bytes[0] = param1;
|
||||
}
|
||||
|
||||
public function read(param1:IDataInput) : void
|
||||
{
|
||||
readType(param1);
|
||||
readRemainingHeader(param1);
|
||||
readData(param1);
|
||||
readPrevTag(param1);
|
||||
}
|
||||
|
||||
public function readType(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 1)
|
||||
{
|
||||
throw new Error("FLVTag.readType() input too short");
|
||||
}
|
||||
param1.readBytes(bytes,0,1);
|
||||
}
|
||||
|
||||
public function readRemaining(param1:IDataInput) : void
|
||||
{
|
||||
readRemainingHeader(param1);
|
||||
readData(param1);
|
||||
readPrevTag(param1);
|
||||
}
|
||||
|
||||
public function readRemainingHeader(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 10)
|
||||
{
|
||||
throw new Error("FLVTag.readHeader() input too short");
|
||||
}
|
||||
param1.readBytes(bytes,1,11 - 1);
|
||||
}
|
||||
|
||||
public function readData(param1:IDataInput) : void
|
||||
{
|
||||
if(dataSize > 0)
|
||||
{
|
||||
if(param1.bytesAvailable < dataSize)
|
||||
{
|
||||
throw new Error("FLVTag().readData input shorter than dataSize");
|
||||
}
|
||||
param1.readBytes(bytes,11,dataSize);
|
||||
}
|
||||
}
|
||||
|
||||
public function readPrevTag(param1:IDataInput) : void
|
||||
{
|
||||
if(param1.bytesAvailable < 4)
|
||||
{
|
||||
throw new Error("FLVTag.readPrevTag() input too short");
|
||||
}
|
||||
param1.readUnsignedInt();
|
||||
}
|
||||
|
||||
public function write(param1:IDataOutput) : void
|
||||
{
|
||||
param1.writeBytes(bytes,0,11 + dataSize);
|
||||
param1.writeUnsignedInt(11 + dataSize);
|
||||
}
|
||||
|
||||
public function get tagType() : uint
|
||||
{
|
||||
return bytes[0];
|
||||
}
|
||||
|
||||
public function set tagType(param1:uint) : void
|
||||
{
|
||||
bytes[0] = param1;
|
||||
}
|
||||
|
||||
public function get isEncrpted() : Boolean
|
||||
{
|
||||
return bytes[0] & 0x20 ? true : false;
|
||||
}
|
||||
|
||||
public function get dataSize() : uint
|
||||
{
|
||||
return bytes[1] << 16 | bytes[2] << 8 | bytes[3];
|
||||
}
|
||||
|
||||
public function set dataSize(param1:uint) : void
|
||||
{
|
||||
bytes[1] = param1 >> 16 & 0xFF;
|
||||
bytes[2] = param1 >> 8 & 0xFF;
|
||||
bytes[3] = param1 & 0xFF;
|
||||
bytes.length = 11 + param1;
|
||||
}
|
||||
|
||||
public function get timestamp() : uint
|
||||
{
|
||||
return bytes[7] << 24 | bytes[4] << 16 | bytes[5] << 8 | bytes[6];
|
||||
}
|
||||
|
||||
public function set timestamp(param1:uint) : void
|
||||
{
|
||||
bytes[7] = param1 >> 24 & 0xFF;
|
||||
bytes[4] = param1 >> 16 & 0xFF;
|
||||
bytes[5] = param1 >> 8 & 0xFF;
|
||||
bytes[6] = param1 & 0xFF;
|
||||
}
|
||||
|
||||
public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
_loc1_.writeBytes(bytes,11,dataSize);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set data(param1:ByteArray) : void
|
||||
{
|
||||
bytes.length = 11 + param1.length;
|
||||
bytes.position = 11;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class FLVTagAudio extends FLVTag
|
||||
{
|
||||
|
||||
public static const SOUND_FORMAT_LINEAR:int = 0;
|
||||
|
||||
public static const SOUND_FORMAT_ADPCM:int = 1;
|
||||
|
||||
public static const SOUND_FORMAT_MP3:int = 2;
|
||||
|
||||
public static const SOUND_FORMAT_LINEAR_LE:int = 3;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER_16K:int = 4;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER_8K:int = 5;
|
||||
|
||||
public static const SOUND_FORMAT_NELLYMOSER:int = 6;
|
||||
|
||||
public static const SOUND_FORMAT_G711A:int = 7;
|
||||
|
||||
public static const SOUND_FORMAT_G711U:int = 8;
|
||||
|
||||
public static const SOUND_FORMAT_AAC:int = 10;
|
||||
|
||||
public static const SOUND_FORMAT_SPEEX:int = 11;
|
||||
|
||||
public static const SOUND_FORMAT_MP3_8K:int = 14;
|
||||
|
||||
public static const SOUND_FORMAT_DEVICE_SPECIFIC:int = 15;
|
||||
|
||||
public static const SOUND_RATE_5K:Number = 5512.5;
|
||||
|
||||
public static const SOUND_RATE_11K:Number = 11025;
|
||||
|
||||
public static const SOUND_RATE_22K:Number = 22050;
|
||||
|
||||
public static const SOUND_RATE_44K:Number = 44100;
|
||||
|
||||
public static const SOUND_SIZE_8BITS:int = 8;
|
||||
|
||||
public static const SOUND_SIZE_16BITS:int = 16;
|
||||
|
||||
public static const SOUND_CHANNELS_MONO:int = 1;
|
||||
|
||||
public static const SOUND_CHANNELS_STEREO:int = 2;
|
||||
|
||||
public function FLVTagAudio(param1:int = 8)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get soundFormatByte() : int
|
||||
{
|
||||
return bytes[11 + 0];
|
||||
}
|
||||
|
||||
public function set soundFormatByte(param1:int) : void
|
||||
{
|
||||
bytes[11 + 0] = param1;
|
||||
}
|
||||
|
||||
public function get soundFormat() : int
|
||||
{
|
||||
return bytes[11 + 0] >> 4 & 0x0F;
|
||||
}
|
||||
|
||||
public function set soundFormat(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 11 + 0;
|
||||
var _loc3_:int = bytes[_loc2_] & 0x0F;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
bytes[11 + 0] |= param1 << 4 & 0xF0;
|
||||
if(param1 == 10)
|
||||
{
|
||||
soundRate = 44100;
|
||||
soundChannels = 2;
|
||||
isAACSequenceHeader = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function get soundRate() : Number
|
||||
{
|
||||
switch(bytes[11 + 0] >> 2 & 3)
|
||||
{
|
||||
case 0:
|
||||
return 5512.5;
|
||||
case 1:
|
||||
return 11025;
|
||||
case 2:
|
||||
return 22050;
|
||||
case 3:
|
||||
return 44100;
|
||||
default:
|
||||
throw new Error("get soundRate() a two-bit number wasn\'t 0, 1, 2, or 3. impossible.");
|
||||
}
|
||||
}
|
||||
|
||||
public function set soundRate(param1:Number) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
switch(param1)
|
||||
{
|
||||
case 5512.5:
|
||||
_loc2_ = 0;
|
||||
break;
|
||||
case 11025:
|
||||
_loc2_ = 1;
|
||||
break;
|
||||
case 22050:
|
||||
_loc2_ = 2;
|
||||
break;
|
||||
case 44100:
|
||||
_loc2_ = 3;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundRate valid values 5512.5, 11025, 22050, 44100");
|
||||
}
|
||||
var _loc3_:Number = 11 + 0;
|
||||
var _loc4_:int = bytes[_loc3_] & 0xF3;
|
||||
bytes[_loc3_] = _loc4_;
|
||||
bytes[11 + 0] |= _loc2_ << 2;
|
||||
}
|
||||
|
||||
public function get soundSize() : int
|
||||
{
|
||||
if(bytes[11 + 0] >> 1 & 1)
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function set soundSize(param1:int) : void
|
||||
{
|
||||
switch(param1 - 8)
|
||||
{
|
||||
case 0:
|
||||
var _loc2_:* = 11 + 0;
|
||||
var _loc3_:* = bytes[_loc2_] & 0xFD;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
break;
|
||||
case 8:
|
||||
_loc3_ = 11 + 0;
|
||||
_loc2_ = bytes[_loc3_] | 2;
|
||||
bytes[_loc3_] = _loc2_;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundSize valid values 8, 16");
|
||||
}
|
||||
}
|
||||
|
||||
public function get soundChannels() : int
|
||||
{
|
||||
if(bytes[11 + 0] & 1)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function set soundChannels(param1:int) : void
|
||||
{
|
||||
switch(param1 - 1)
|
||||
{
|
||||
case 0:
|
||||
var _loc2_:* = 11 + 0;
|
||||
var _loc3_:* = bytes[_loc2_] & 0xFE;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
break;
|
||||
case 1:
|
||||
_loc3_ = 11 + 0;
|
||||
_loc2_ = bytes[_loc3_] | 1;
|
||||
bytes[_loc3_] = _loc2_;
|
||||
break;
|
||||
default:
|
||||
throw new Error("set soundChannels valid values 1, 2");
|
||||
}
|
||||
}
|
||||
|
||||
public function get isAACSequenceHeader() : Boolean
|
||||
{
|
||||
if(soundFormat != 10)
|
||||
{
|
||||
throw new Error("get isAACSequenceHeader not valid if soundFormat != SOUND_FORMAT_AAC");
|
||||
}
|
||||
if(bytes[11 + 1] == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function set isAACSequenceHeader(param1:Boolean) : void
|
||||
{
|
||||
if(soundFormat != 10)
|
||||
{
|
||||
throw new Error("set isAACSequenceHeader not valid if soundFormat != SOUND_FORMAT_AAC");
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
bytes[11 + 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes[11 + 1] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get isCodecConfiguration() : Boolean
|
||||
{
|
||||
switch(soundFormat - 10)
|
||||
{
|
||||
case 0:
|
||||
if(isAACSequenceHeader)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(soundFormat == 10)
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 2,dataSize - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 1,dataSize - 1);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function set data(param1:ByteArray) : void
|
||||
{
|
||||
if(soundFormat == 10)
|
||||
{
|
||||
bytes.length = 11 + param1.length + 2;
|
||||
bytes.position = 11 + 2;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.length = 11 + param1.length + 1;
|
||||
bytes.position = 11 + 1;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
public class FLVTagScriptDataObject extends FLVTag
|
||||
{
|
||||
|
||||
public function FLVTagScriptDataObject(param1:int = 18)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get objects() : Array
|
||||
{
|
||||
var _loc1_:Array = [];
|
||||
bytes.position = 11;
|
||||
while(bytes.bytesAvailable)
|
||||
{
|
||||
_loc1_.push(bytes.readObject());
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set objects(param1:Array) : void
|
||||
{
|
||||
bytes.objectEncoding = 0;
|
||||
bytes.length = 11;
|
||||
bytes.position = 11;
|
||||
for each(var _loc2_:Object in param1)
|
||||
{
|
||||
bytes.writeObject(_loc2_);
|
||||
}
|
||||
dataSize = bytes.length - 11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package org.osmf.net.httpstreaming.flv
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class FLVTagVideo extends FLVTag
|
||||
{
|
||||
|
||||
public static const FRAME_TYPE_KEYFRAME:int = 1;
|
||||
|
||||
public static const FRAME_TYPE_INTER:int = 2;
|
||||
|
||||
public static const FRAME_TYPE_DISPOSABLE_INTER:int = 3;
|
||||
|
||||
public static const FRAME_TYPE_GENERATED_KEYFRAME:int = 4;
|
||||
|
||||
public static const FRAME_TYPE_INFO:int = 5;
|
||||
|
||||
public static const CODEC_ID_JPEG:int = 1;
|
||||
|
||||
public static const CODEC_ID_SORENSON:int = 2;
|
||||
|
||||
public static const CODEC_ID_SCREEN:int = 3;
|
||||
|
||||
public static const CODEC_ID_VP6:int = 4;
|
||||
|
||||
public static const CODEC_ID_VP6_ALPHA:int = 5;
|
||||
|
||||
public static const CODEC_ID_SCREEN_V2:int = 6;
|
||||
|
||||
public static const CODEC_ID_AVC:int = 7;
|
||||
|
||||
public static const AVC_PACKET_TYPE_SEQUENCE_HEADER:int = 0;
|
||||
|
||||
public static const AVC_PACKET_TYPE_NALU:int = 1;
|
||||
|
||||
public static const AVC_PACKET_TYPE_END_OF_SEQUENCE:int = 2;
|
||||
|
||||
public static const INFO_PACKET_SEEK_START:int = 0;
|
||||
|
||||
public static const INFO_PACKET_SEEK_END:int = 1;
|
||||
|
||||
public function FLVTagVideo(param1:int = 9)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
public function get frameType() : int
|
||||
{
|
||||
return bytes[11 + 0] >> 4 & 0x0F;
|
||||
}
|
||||
|
||||
public function set frameType(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 11 + 0;
|
||||
var _loc3_:int = bytes[_loc2_] & 0x0F;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
bytes[11 + 0] |= (param1 & 0x0F) << 4;
|
||||
}
|
||||
|
||||
public function get codecID() : int
|
||||
{
|
||||
return bytes[11 + 0] & 0x0F;
|
||||
}
|
||||
|
||||
public function set codecID(param1:int) : void
|
||||
{
|
||||
var _loc2_:Number = 11 + 0;
|
||||
var _loc3_:int = bytes[_loc2_] & 0xF0;
|
||||
bytes[_loc2_] = _loc3_;
|
||||
bytes[11 + 0] |= param1 & 0x0F;
|
||||
}
|
||||
|
||||
public function get infoPacketValue() : int
|
||||
{
|
||||
if(frameType != 5)
|
||||
{
|
||||
throw new Error("get infoPacketValue() not permitted unless frameType is FRAME_TYPE_INFO");
|
||||
}
|
||||
return bytes[11 + 1];
|
||||
}
|
||||
|
||||
public function set infoPacketValue(param1:int) : void
|
||||
{
|
||||
if(frameType != 5)
|
||||
{
|
||||
throw new Error("get infoPacketValue() not permitted unless frameType is FRAME_TYPE_INFO");
|
||||
}
|
||||
bytes[11 + 1] = param1;
|
||||
bytes.length = 11 + 2;
|
||||
dataSize = 2;
|
||||
}
|
||||
|
||||
public function get avcPacketType() : int
|
||||
{
|
||||
if(codecID != 7)
|
||||
{
|
||||
throw new Error("get avcPacketType() not permitted unless codecID is CODEC_ID_AVC");
|
||||
}
|
||||
return bytes[11 + 1];
|
||||
}
|
||||
|
||||
public function set avcPacketType(param1:int) : void
|
||||
{
|
||||
if(codecID != 7)
|
||||
{
|
||||
throw new Error("set avcPacketType() not permitted unless codecID is CODEC_ID_AVC");
|
||||
}
|
||||
bytes[11 + 1] = param1;
|
||||
if(avcPacketType != 1)
|
||||
{
|
||||
bytes[11 + 2] = 0;
|
||||
bytes[11 + 3] = 0;
|
||||
bytes[11 + 4] = 0;
|
||||
bytes.length = 11 + 5;
|
||||
dataSize = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public function get avcCompositionTimeOffset() : int
|
||||
{
|
||||
if(codecID != 7 || avcPacketType != 1)
|
||||
{
|
||||
throw new Error("get avcCompositionTimeOffset() not permitted unless codecID is CODEC_ID_AVC and avcPacketType is AVC NALU");
|
||||
}
|
||||
var _loc1_:int = bytes[11 + 2] << 16;
|
||||
_loc1_ |= bytes[11 + 3] << 8;
|
||||
_loc1_ |= bytes[11 + 4];
|
||||
if(_loc1_ & 0x800000)
|
||||
{
|
||||
_loc1_ |= 4278190080;
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function set avcCompositionTimeOffset(param1:int) : void
|
||||
{
|
||||
if(codecID != 7 || avcPacketType != 1)
|
||||
{
|
||||
throw new Error("set avcCompositionTimeOffset() not permitted unless codecID is CODEC_ID_AVC and avcPacketType is AVC NALU");
|
||||
}
|
||||
bytes[11 + 2] = param1 >> 16 & 0xFF;
|
||||
bytes[11 + 3] = param1 >> 8 & 0xFF;
|
||||
bytes[11 + 4] = param1 & 0xFF;
|
||||
}
|
||||
|
||||
override public function get data() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
if(codecID == 7)
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 5,dataSize - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.writeBytes(bytes,11 + 1,dataSize - 1);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function set data(param1:ByteArray) : void
|
||||
{
|
||||
if(codecID == 7)
|
||||
{
|
||||
bytes.length = 11 + param1.length + 5;
|
||||
bytes.position = 11 + 5;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes.length = 11 + param1.length + 1;
|
||||
bytes.position = 11 + 1;
|
||||
bytes.writeBytes(param1,0,param1.length);
|
||||
dataSize = param1.length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user