Package com.wowza.wms.amf
Class AMFPacket
- Object
- 
- com.wowza.wms.amf.AMFPacket
 
- 
 public class AMFPacket extends ObjectAMFPacket: data container for data being transferred to and from the server from the Flash client. AMFPacket is also used to store data read/written to/from an flv file. 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddData(byte[] data, int offset, int size)Add data to the packetintaddDataEx(byte[] srcData, int srcOffset, int destOffset, int srcBytes)Add data to the packetstatic intcalcTotalPacketSize(int packetSize, int headerSize, int chunkSize, int amfNumber, boolean isLongTimecode)Calculate the total packet size for given packet parametersAMFPacketclone()AMFPacketclone(boolean doCopy)booleancontainsExtraDataKey(String key)Return true if extra data contains the keystatic AMFPacketdeserializePacket(byte[] buffer)java.util.Map<String,IAMFPacketExtraData>extraDataClone()Deep copy the extra data and return as a Mapstatic java.util.Map<String,IAMFPacketExtraData>extraDataClone(java.util.Map<String,IAMFPacketExtraData> extraData)longgetAbsTimecode()Get absolute timecode (milliseconds)byte[]getData()Get data as byte[]java.nio.ByteBuffergetDataBuffer()Get data as ByteBufferIAMFPacketExtraDatagetExtraData(String key)Get extra data valuejava.util.Set<String>getExtraDataKeys()Get a set of the extra data keysintgetFirstByte()Get first byte of data (used to peek into packet)ObjectgetLock()Get lock (mostly used for extra data access)intgetMissing()Get the number of bytes remaining unfilled in the packetintgetSecondByte()Get second byte of data (used to peek into packet)longgetSeq()Get packet sequence number.intgetSize()Get packet sizeintgetSrc()Get stream id (0 if not stream data)longgetTimecode()Get timecode (milliseconds) relative to the previous packet.intgetType()Get content type IVHost.CONTENTTYPE_*booleanisAudio()Is this an audio packet IVHost.CONTENTTYPE_AUDIObooleanisExtraData()Returns true if this packet contains any extra databooleanisVideo()Is this an audio packet IVHost.CONTENTTYPE_VIDEOStringprettyPrint()voidputAllExtraData(java.util.Map<String,IAMFPacketExtraData> entries)Add extra data key value pairsIAMFPacketExtraDataputExtraData(String key, IAMFPacketExtraData value)Add extra data valuebyte[]serializePacket()voidsetAbsTimecode(long absTimecode)Set absolute timecode (milliseconds)voidsetDataBuffer(byte[] data)Set the data buffer to a byte arrayvoidsetDataBuffer(java.nio.ByteBuffer data)Set the data for this packetvoidsetSeq(long seq)Set packet sequence.voidsetSize(int size)Set packet sizevoidsetSrc(int src)Set stream id (0 if not stream data)voidsetTimecode(long timecode)Set timecode (milliseconds) relative,voidsetTimecodes(long timecode, long absTimecode)Set both relative and absolute timecode in one call (milliseconds)voidsetType(int type)Set content type IVHost.CONTENTTYPE_*StringtoString()Return object as formatted stringvoidtruncatePacket(int newSize)
 
- 
- 
- 
Constructor Detail- 
AMFPacketpublic AMFPacket() Create new empty packet
 - 
AMFPacketpublic AMFPacket(int type, int src, int size)Create new packet with given values- Parameters:
- type- packet content type: IVHost.CONTENTTYPE_*
- src- stream id
- size- packet size (bytes)
 
 - 
AMFPacketpublic AMFPacket(int type, int src, byte[] data)Create new packet with given values- Parameters:
- type- packet content type: IVHost.CONTENTTYPE_*
- src- stream id
- data- data buffer
 
 
- 
 - 
Method Detail- 
clonepublic AMFPacket clone() - Overrides:
- clonein class- Object
 
 - 
clonepublic AMFPacket clone(boolean doCopy) 
 - 
getSizepublic int getSize() Get packet size- Returns:
- packet size
 
 - 
setSizepublic void setSize(int size) Set packet size- Parameters:
- size- packet size
 
 - 
truncatePacketpublic void truncatePacket(int newSize) 
 - 
getMissingpublic int getMissing() Get the number of bytes remaining unfilled in the packet- Returns:
- number of bytes unfilled in packet
 
 - 
setDataBufferpublic void setDataBuffer(java.nio.ByteBuffer data) Set the data for this packet- Parameters:
- data- byte buffer that holds packet data
 
 - 
setDataBufferpublic void setDataBuffer(byte[] data) Set the data buffer to a byte array- Parameters:
- data- data buffer byte array
 
 - 
addDatapublic int addData(byte[] data, int offset, int size)Add data to the packet- Parameters:
- data- byte buffer with data
- offset- offset in byte buffer
- size- size of data
- Returns:
- number of bytes unfilled in packet
 
 - 
getTypepublic int getType() Get content type IVHost.CONTENTTYPE_*- Returns:
- content type
 
 - 
setTypepublic void setType(int type) Set content type IVHost.CONTENTTYPE_*- Parameters:
- type- content type
 
 - 
getSrcpublic int getSrc() Get stream id (0 if not stream data)- Returns:
- stream id
 
 - 
setSrcpublic void setSrc(int src) Set stream id (0 if not stream data)- Parameters:
- src- stream id
 
 - 
toStringpublic String toString() Return object as formatted string- Overrides:
- toStringin class- Object
 
 - 
getTimecodepublic long getTimecode() Get timecode (milliseconds) relative to the previous packet.- Returns:
- timecode (milliseconds)
 
 - 
setTimecodespublic void setTimecodes(long timecode, long absTimecode)Set both relative and absolute timecode in one call (milliseconds)Note this time is relative to the previous packet. - Parameters:
- timecode- relative timecode (milliseconds)
- absTimecode- absolute timecode (milliseconds)
 
 - 
setTimecodepublic void setTimecode(long timecode) Set timecode (milliseconds) relative,Note this time is relative to the previous packet. - Parameters:
- timecode- timecode (milliseconds)
 
 - 
getAbsTimecodepublic long getAbsTimecode() Get absolute timecode (milliseconds)- Returns:
- absolute timecode
 
 - 
setAbsTimecodepublic void setAbsTimecode(long absTimecode) Set absolute timecode (milliseconds)- Parameters:
- absTimecode- absolute timecode
 
 - 
getSeqpublic long getSeq() Get packet sequence number. Used for live streams to keep track of packet ordering.- Returns:
- packet sequence
 
 - 
setSeqpublic void setSeq(long seq) Set packet sequence. Used for live streams to keep track of packet ordering.- Parameters:
- seq- packet sequence
 
 - 
isAudiopublic boolean isAudio() Is this an audio packet IVHost.CONTENTTYPE_AUDIO- Returns:
- true if audio packet
 
 - 
isVideopublic boolean isVideo() Is this an audio packet IVHost.CONTENTTYPE_VIDEO- Returns:
- true if video packet
 
 - 
getDataBufferpublic java.nio.ByteBuffer getDataBuffer() Get data as ByteBuffer- Returns:
- data as ByteBuffer
 
 - 
getDatapublic byte[] getData() Get data as byte[]- Returns:
- data as byte[] null if no data
 
 - 
getFirstBytepublic int getFirstByte() Get first byte of data (used to peek into packet)- Returns:
- first byte of data in packet
 
 - 
getSecondBytepublic int getSecondByte() Get second byte of data (used to peek into packet)- Returns:
- second byte of data in packet
 
 - 
calcTotalPacketSizepublic static int calcTotalPacketSize(int packetSize, int headerSize, int chunkSize, int amfNumber, boolean isLongTimecode)Calculate the total packet size for given packet parameters- Parameters:
- packetSize- data size
- headerSize- header size
- chunkSize- chunk size
- amfNumber- amf number
- isLongTimecode- is long timecode
- Returns:
- total bytes
 
 - 
addDataExpublic int addDataEx(byte[] srcData, int srcOffset, int destOffset, int srcBytes)Add data to the packet- Parameters:
- srcData- - source byte buffer with data
- srcOffset- - start copying from source buffer at this offset
- destOffset- - copy into destination buffer from this offset
- srcBytes- - size of data to copy
- Returns:
- number of bytes unfilled in packet
 
 - 
serializePacketpublic byte[] serializePacket() 
 - 
deserializePacketpublic static AMFPacket deserializePacket(byte[] buffer) 
 - 
getLockpublic Object getLock() Get lock (mostly used for extra data access)- Returns:
- lock
 
 - 
putExtraDatapublic IAMFPacketExtraData putExtraData(String key, IAMFPacketExtraData value) Add extra data value- Parameters:
- key- key
- value- extra data
- Returns:
- extra data currently at that key
 
 - 
putAllExtraDatapublic void putAllExtraData(java.util.Map<String,IAMFPacketExtraData> entries) Add extra data key value pairs- Parameters:
- entries- extra data key value pairs
 
 - 
getExtraDatapublic IAMFPacketExtraData getExtraData(String key) Get extra data value- Parameters:
- key- key
- Returns:
- extra data value
 
 - 
getExtraDataKeyspublic java.util.Set<String> getExtraDataKeys() Get a set of the extra data keys- Returns:
- extra data keys
 
 - 
containsExtraDataKeypublic boolean containsExtraDataKey(String key) Return true if extra data contains the key- Parameters:
- key- key
- Returns:
- true if extra data contains the key
 
 - 
isExtraDatapublic boolean isExtraData() Returns true if this packet contains any extra data- Returns:
- true if this packet contains any extra data
 
 - 
extraDataClonepublic static java.util.Map<String,IAMFPacketExtraData> extraDataClone(java.util.Map<String,IAMFPacketExtraData> extraData) 
 - 
extraDataClonepublic java.util.Map<String,IAMFPacketExtraData> extraDataClone() Deep copy the extra data and return as a Map- Returns:
- deep copy of extra data
 
 - 
prettyPrintpublic String prettyPrint() 
 
- 
 
-