Package org.jitsi.service.neomedia
Class RawPacket
- java.lang.Object
-
- org.jitsi.service.neomedia.RawPacket
-
- All Implemented Interfaces:
org.jitsi.utils.ByteArrayBuffer
- Direct Known Subclasses:
DtmfRawPacket,FlexFec03Packet,ZrtpRawPacket
public class RawPacket extends Object implements org.jitsi.utils.ByteArrayBuffer
When using TransformConnector, a RTP/RTCP packet is represented using RawPacket. RawPacket stores the buffer holding the RTP/RTCP packet, as well as the inner offset and length of RTP/RTCP packet data. After transformation, data is also store in RawPacket objects, either the original RawPacket (in place transformation), or a newly created RawPacket. Besides packet info storage, RawPacket also provides some other operations such as readInt() to ease the development process. FIXME This class needs to be split/merged into RTPHeader, RTCPHeader, ByteBufferUtils, etc.- Author:
- Werner Dittmann (Werner.Dittmann@t-online.de), Bing SU (nova.su@gmail.com), Emil Ivov, Damian Minkov, Boris Grozev, Lyubomir Marinov, George Politis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRawPacket.HeaderExtensionRepresents an RTP header extension with the RFC5285 one-byte header:classRawPacket.HeaderExtensionsImplements an iterator over the RTP header extensions of aRawPacket.
-
Field Summary
Fields Modifier and Type Field Description static intEXT_HEADER_SIZEThe size of the extension header as defined by RFC 3550.static intFIXED_HEADER_SIZEThe size of the fixed part of the RTP header as defined by RFC 3550.static intSEQUENCE_NUMBER_MASKThe bitmask for the RTP sequence number field.static longTIMESTAMP_MASKThe bitmask for the RTP timestamp field.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtension(byte id, byte[] data)Adds the given buffer as a header extension of this packet according the rules specified in RFC 5285.voidaddExtension(byte id, byte[] data, int len)Adds the given buffer as a header extension of this packet according the rules specified in RFC 5285.RawPacket.HeaderExtensionaddExtension(byte id, int len)Adds an RTP header extension with a given ID and a given length to this packet.voidappend(byte[] data, int len)Append a byte array to the end of the packet.long[]extractCsrcAudioLevels(byte csrcExtID)Returns a map binding CSRC IDs to audio levels as reported by the remote party that sent this packet.long[]extractCsrcList()Returns the list of CSRC IDs, currently encapsulated in this packet.byteextractSsrcAudioLevel(byte ssrcExtID)Extracts the source audio level reported by the remote party which sent this packet and carried in this packet.byte[]getBuffer()Get buffer containing the content of this packetintgetCsrcCount()Returns the number of CSRC identifiers currently included in this packet.static intgetCsrcCount(byte[] buffer, int offset, int length)Returns the number of CSRC identifiers currently included in this packet.booleangetExtensionBit()Returns true if the extension bit of this packet has been set and false otherwise.static booleangetExtensionBit(byte[] buffer, int offset, int length)Returns true if the extension bit of this packet has been set and false otherwise.intgetExtensionLength()Returns the length of the extensions currently added to this packet.static intgetExtensionLength(byte[] buffer, int offset, int length)Returns the length of the extensions currently added to this packet.intgetFlags()Gets the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket.RawPacket.HeaderExtensiongetHeaderExtension(byte id)RawPacket.HeaderExtensionsgetHeaderExtensions()intgetHeaderExtensionType()Return the define by profile part of the extension header.intgetHeaderLength()Get RTP header length from a RTP packetstatic intgetHeaderLength(byte[] buffer, int offset, int length)Get RTP header length from a RTP packetintgetLength()Get the length of this packet's dataintgetOffset()Get the start offset of this packet's data inside storing bufferintgetOriginalSequenceNumber()Gets the OSN value of an RTX packet.intgetPaddingSize()Get RTP padding size from a RTP packetstatic intgetPaddingSize(byte[] buf, int off, int len)Get RTP padding size from a RTP packetbyte[]getPayload()Get the RTP payload (bytes) of this RTP packet.intgetPayloadLength()Get RTP payload length from a RTP packetintgetPayloadLength(boolean removePadding)Get RTP payload length from a RTP packetstatic intgetPayloadLength(byte[] buffer, int offset, int length)Get RTP payload length from a RTP packetstatic intgetPayloadLength(byte[] buffer, int offset, int length, boolean removePadding)Get RTP payload length from a RTP packetintgetPayloadOffset()Get the RTP payload offset of an RTP packet.static intgetPayloadOffset(byte[] buffer, int offset, int length)Get the RTP payload offset of an RTP packet.bytegetPayloadType()Get RTP payload type from a RTP packetstatic intgetPayloadType(byte[] buf, int off, int len)Get RTP payload type from a RTP packetstatic intgetPayloadType(RawPacket pkt)Get RTP payload type from a RTP packetintgetRTCPPacketType()Gets the packet type of this RTCP packet.longgetRTCPSSRC()Get RTCP SSRC from a RTCP packetstatic longgetRTCPSSRC(byte[] buf, int off, int len)Get RTCP SSRC from a RTCP packetstatic longgetRTCPSSRC(org.jitsi.utils.ByteArrayBuffer baf)Get RTCP SSRC from a RTCP packetintgetSequenceNumber()Get RTP sequence number from a RTP packetstatic intgetSequenceNumber(byte[] buffer, int offset, int length)Get RTP sequence number from a RTP packetstatic intgetSequenceNumber(org.jitsi.utils.ByteArrayBuffer baf)Gets the RTP sequence number from a RTP packet.intgetSRTCPIndex(int authTagLen)Get SRTCP sequence number from a SRTCP packetstatic intgetSRTCPIndex(org.jitsi.utils.ByteArrayBuffer baf, int authTagLen)Get SRTCP sequence number from a SRTCP packetintgetSSRC()Get RTP SSRC from a RTP packetstatic intgetSSRC(byte[] buffer, int offset, int length)Get RTP SSRC from a RTP packetstatic intgetSSRC(org.jitsi.utils.ByteArrayBuffer baf)Get RTP SSRC from a RTP packetlonggetSSRCAsLong()Returns alongrepresentation of the SSRC of this RTP packet.static longgetSSRCAsLong(byte[] buffer, int offset, int length)Returns alongrepresentation of the SSRC of this RTP packet.longgetTimestamp()Returns the timestamp for this RTP RawPacket.static longgetTimestamp(byte[] buf, int off, int len)Gets the RTP timestamp for an RTP buffer.static longgetTimestamp(org.jitsi.utils.ByteArrayBuffer baf)Gets the RTP timestamp for an RTP buffer.intgetVersion()Gets the value of the "version" field of an RTP packet.static intgetVersion(byte[] buffer, int offset, int length)Gets the value of the "version" field of an RTP packet.static intgetVersion(org.jitsi.utils.ByteArrayBuffer baf)Gets the value of the "version" field of an RTP packet.voidgrow(int howMuch)Grows the internal buffer of thisRawPacket.booleanisInvalid()Perform checks on the packet represented by this instance and return true if it is found to be invalid.static booleanisInvalid(byte[] buffer, int offset, int length)Perform checks on the packet represented by this instance and return true if it is found to be invalid.booleanisPacketMarked()Test whether the RTP Marker bit is setstatic booleanisPacketMarked(byte[] buffer, int offset, int length)Test whether the RTP Marker bit is setstatic booleanisPacketMarked(org.jitsi.utils.ByteArrayBuffer baf)Test whether the RTP Marker bit is setstatic booleanisRtpRtcp(byte[] buf, int off, int len)Checks whether the RTP/RTCP header is valid or not (note that a valid header does not necessarily imply a valid packet).booleanisSkipStats()Whether to skip packet statistics.bytereadByte(int off)Read a byte from this packet at specified offsetintreadInt(int off)Read a integer from this packet at specified offsetbyte[]readRegion(int off, int len)Read a byte region from specified offset with specified lengthvoidreadRegionToBuff(int off, int len, byte[] outBuff)Read a byte region from specified offset with specified length in given bufferintreadUint16AsInt(int off)Read an unsigned short at specified offset as a intlongreadUint32AsLong(int off)Read a 32-bit unsigned integer from this packet at the specified offset.voidremoveExtension()Removes the extension from the packet and its header.voidsetBuffer(byte[] buffer)voidsetCsrcList(long[] newCsrcList)Replaces the existing CSRC list (even if empty) with newCsrcList and updates the CC (CSRC count) field of this RawPacket accordingly.voidsetFlags(int flags)Sets the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket.voidsetLength(int length)voidsetMarker(boolean marker)Sets or resets the marker bit of this packet according to the marker parameter.voidsetOffset(int offset)voidsetOriginalSequenceNumber(int sequenceNumber)Sets the OSN value of an RTX packet.booleansetPaddingSize(int len)Sets the padding length for this RTP packet.voidsetPayloadType(byte payload)Sets the payload type of this packet.static voidsetSequenceNumber(byte[] buffer, int offset, int seq)Set sequence number for an RTP buffervoidsetSequenceNumber(int seq)Set the RTP sequence number of an RTP packetstatic voidsetSequenceNumber(org.jitsi.utils.ByteArrayBuffer baf, int dstSeqNum)Sets the sequence number of an RTP packet.voidsetSkipStats(boolean skipStats)Changes the skipStats flag.voidsetSSRC(int ssrc)Set the SSRC of this packetstatic voidsetTimestamp(byte[] buf, int off, int len, long ts)Set the RTP timestamp for an RTP buffer.voidsetTimestamp(long timestamp)Set the timestamp value of the RTP Packetstatic voidsetTimestamp(org.jitsi.utils.ByteArrayBuffer baf, long ts)Sets the RTP timestamp of an RTP packet.booleansetVersion()Sets the RTP version in this RTP packet.voidshrink(int len)Shrink the buffer of this packet by specified lengthStringtoString()voidwriteByte(int off, byte b)Write a byte to this packet at specified offsetvoidwriteInt(int off, int data)Set an integer at specified offset in network order.voidwriteShort(int off, short val)Write a short to this packet at the specified offset.
-
-
-
Field Detail
-
EXT_HEADER_SIZE
public static final int EXT_HEADER_SIZE
The size of the extension header as defined by RFC 3550.- See Also:
- Constant Field Values
-
FIXED_HEADER_SIZE
public static final int FIXED_HEADER_SIZE
The size of the fixed part of the RTP header as defined by RFC 3550.- See Also:
- Constant Field Values
-
SEQUENCE_NUMBER_MASK
public static final int SEQUENCE_NUMBER_MASK
The bitmask for the RTP sequence number field.- See Also:
- Constant Field Values
-
TIMESTAMP_MASK
public static final long TIMESTAMP_MASK
The bitmask for the RTP timestamp field.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RawPacket
public RawPacket()
Initializes a new empty RawPacket instance.
-
RawPacket
public RawPacket(byte[] buffer, int offset, int length)Initializes a new RawPacket instance with a specific byte array buffer.- Parameters:
buffer- the byte array to be the buffer of the new instanceoffset- the offset in buffer at which the actual data to be represented by the new instance startslength- the number of bytes in buffer which constitute the actual data to be represented by the new instance
-
-
Method Detail
-
getVersion
public static int getVersion(org.jitsi.utils.ByteArrayBuffer baf)
Gets the value of the "version" field of an RTP packet.- Returns:
- the value of the RTP "version" field.
-
getVersion
public static int getVersion(byte[] buffer, int offset, int length)Gets the value of the "version" field of an RTP packet.- Returns:
- the value of the RTP "version" field.
-
isPacketMarked
public static boolean isPacketMarked(org.jitsi.utils.ByteArrayBuffer baf)
Test whether the RTP Marker bit is set- Returns:
- true if the RTP Marker bit is set, false otherwise.
-
isPacketMarked
public static boolean isPacketMarked(byte[] buffer, int offset, int length)Test whether the RTP Marker bit is set- Returns:
- true if the RTP Marker bit is set, false otherwise.
-
isInvalid
public static boolean isInvalid(byte[] buffer, int offset, int length)Perform checks on the packet represented by this instance and return true if it is found to be invalid. A return value of false does not necessarily mean that the packet is valid.- Returns:
- true if the RTP/RTCP packet represented by this instance is found to be invalid, false otherwise.
-
getRTCPSSRC
public static long getRTCPSSRC(org.jitsi.utils.ByteArrayBuffer baf)
Get RTCP SSRC from a RTCP packet- Returns:
- RTP SSRC from source RTP packet in a
long.
-
getRTCPSSRC
public static long getRTCPSSRC(byte[] buf, int off, int len)Get RTCP SSRC from a RTCP packet- Returns:
- RTP SSRC from source RTP packet
-
isRtpRtcp
public static boolean isRtpRtcp(byte[] buf, int off, int len)Checks whether the RTP/RTCP header is valid or not (note that a valid header does not necessarily imply a valid packet). It does so by checking the RTP/RTCP header version and makes sure the buffer is at least 8 bytes long for RTCP and 12 bytes long for RTP.- Parameters:
buf- the byte buffer that contains the RTCP header.off- the offset in the byte buffer where the RTCP header starts.len- the number of bytes in buffer which constitute the actual data.- Returns:
- true if the RTP/RTCP packet is valid, false otherwise.
-
addExtension
public void addExtension(byte id, byte[] data)Adds the given buffer as a header extension of this packet according the rules specified in RFC 5285. Note that this method does not replace extensions so if you add the same buffer twice it would be added as a separate extension. This method MUST NOT be called while iterating over the extensions usinggetHeaderExtensions(), or while manipulating the state of thisRawPacket.- Parameters:
id- the ID with which to add the extension.data- the buffer containing the extension data.
-
addExtension
public void addExtension(byte id, byte[] data, int len)Adds the given buffer as a header extension of this packet according the rules specified in RFC 5285. Note that this method does not replace extensions so if you add the same buffer twice it would be added as a separate extension. This method MUST NOT be called while iterating over the extensions usinggetHeaderExtensions(), or while manipulating the state of thisRawPacket.- Parameters:
id- the ID with which to add the extension.data- the buffer containing the extension data.len- the length of the extension.
-
addExtension
public RawPacket.HeaderExtension addExtension(byte id, int len)
Adds an RTP header extension with a given ID and a given length to this packet. The contents of the extension are not set to anything, and the caller of this method is responsible for filling them in. This method MUST NOT be called while iterating over the extensions usinggetHeaderExtensions(), or while manipulating the state of thisRawPacket.- Parameters:
id- the ID of the extension to add.len- the length in bytes of the extension to add.- Returns:
- the header extension which was added.
-
append
public void append(byte[] data, int len)Append a byte array to the end of the packet. This may change the data buffer of this packet.- Specified by:
appendin interfaceorg.jitsi.utils.ByteArrayBuffer- Parameters:
data- byte array to appendlen- the number of bytes to append
-
extractCsrcAudioLevels
public long[] extractCsrcAudioLevels(byte csrcExtID)
Returns a map binding CSRC IDs to audio levels as reported by the remote party that sent this packet.- Parameters:
csrcExtID- the ID of the extension that's transporting csrc audio levels in the session that this RawPacket belongs to.- Returns:
- an array representing a map binding CSRC IDs to audio levels as reported by the remote party that sent this packet. The entries of the map are contained in consecutive elements of the returned array where elements at even indices stand for CSRC IDs and elements at odd indices stand for the associated audio levels
-
extractCsrcList
public long[] extractCsrcList()
Returns the list of CSRC IDs, currently encapsulated in this packet.- Returns:
- an array containing the list of CSRC IDs, currently encapsulated in this packet.
-
extractSsrcAudioLevel
public byte extractSsrcAudioLevel(byte ssrcExtID)
Extracts the source audio level reported by the remote party which sent this packet and carried in this packet.- Parameters:
ssrcExtID- the ID of the extension that's transporting ssrc audio levels in the session that this RawPacket belongs to- Returns:
- the source audio level reported by the remote party which sent this packet and carried in this packet or a negative value if this packet contains no extension such as the specified by ssrcExtID
-
getBuffer
public byte[] getBuffer()
Get buffer containing the content of this packet- Specified by:
getBufferin interfaceorg.jitsi.utils.ByteArrayBuffer- Returns:
- buffer containing the content of this packet
-
getCsrcCount
public int getCsrcCount()
Returns the number of CSRC identifiers currently included in this packet.- Returns:
- the CSRC count for this RawPacket.
-
getCsrcCount
public static int getCsrcCount(byte[] buffer, int offset, int length)Returns the number of CSRC identifiers currently included in this packet.- Returns:
- the CSRC count for this RawPacket.
-
getExtensionBit
public boolean getExtensionBit()
Returns true if the extension bit of this packet has been set and false otherwise.- Returns:
- true if the extension bit of this packet has been set and false otherwise.
-
getExtensionBit
public static boolean getExtensionBit(byte[] buffer, int offset, int length)Returns true if the extension bit of this packet has been set and false otherwise.- Returns:
- true if the extension bit of this packet has been set and false otherwise.
-
getExtensionLength
public int getExtensionLength()
Returns the length of the extensions currently added to this packet.- Returns:
- the length of the extensions currently added to this packet.
-
getHeaderExtensions
public RawPacket.HeaderExtensions getHeaderExtensions()
- Returns:
- the iterator over this
RawPacket's RTP header extensions.
-
getExtensionLength
public static int getExtensionLength(byte[] buffer, int offset, int length)Returns the length of the extensions currently added to this packet.- Returns:
- the length of the extensions currently added to this packet.
-
getFlags
public int getFlags()
Gets the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket.- Returns:
- the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket
-
getHeaderExtensionType
public int getHeaderExtensionType()
Return the define by profile part of the extension header.- Returns:
- the starting two bytes of extension header.
-
getHeaderLength
public int getHeaderLength()
Get RTP header length from a RTP packet- Returns:
- RTP header length from source RTP packet
-
getHeaderLength
public static int getHeaderLength(byte[] buffer, int offset, int length)Get RTP header length from a RTP packet- Returns:
- RTP header length from source RTP packet
-
getLength
public int getLength()
Get the length of this packet's data- Specified by:
getLengthin interfaceorg.jitsi.utils.ByteArrayBuffer- Returns:
- length of this packet's data
-
getOffset
public int getOffset()
Get the start offset of this packet's data inside storing buffer- Specified by:
getOffsetin interfaceorg.jitsi.utils.ByteArrayBuffer- Returns:
- start offset of this packet's data inside storing buffer
-
getVersion
public int getVersion()
Gets the value of the "version" field of an RTP packet.- Returns:
- the value of the RTP "version" field.
-
getPaddingSize
public int getPaddingSize()
Get RTP padding size from a RTP packet- Returns:
- RTP padding size from source RTP packet
-
getPaddingSize
public static int getPaddingSize(byte[] buf, int off, int len)Get RTP padding size from a RTP packet- Returns:
- RTP padding size from source RTP packet
-
getPayload
public byte[] getPayload()
Get the RTP payload (bytes) of this RTP packet.- Returns:
- an array of bytes which represents the RTP payload of this RTP packet
-
getPayloadLength
public int getPayloadLength(boolean removePadding)
Get RTP payload length from a RTP packet- Returns:
- RTP payload length from source RTP packet
-
getPayloadLength
public int getPayloadLength()
Get RTP payload length from a RTP packet- Returns:
- RTP payload length from source RTP packet
-
getPayloadLength
public static int getPayloadLength(byte[] buffer, int offset, int length)Get RTP payload length from a RTP packet- Returns:
- RTP payload length from source RTP packet
-
getPayloadLength
public static int getPayloadLength(byte[] buffer, int offset, int length, boolean removePadding)Get RTP payload length from a RTP packet- Returns:
- RTP payload length from source RTP packet
-
getPayloadOffset
public int getPayloadOffset()
Get the RTP payload offset of an RTP packet.- Returns:
- the RTP payload offset of an RTP packet.
-
getPayloadOffset
public static int getPayloadOffset(byte[] buffer, int offset, int length)Get the RTP payload offset of an RTP packet.- Returns:
- the RTP payload offset of an RTP packet.
-
getPayloadType
public byte getPayloadType()
Get RTP payload type from a RTP packet- Returns:
- RTP payload type of source RTP packet
-
getPayloadType
public static int getPayloadType(byte[] buf, int off, int len)Get RTP payload type from a RTP packet- Returns:
- RTP payload type of source RTP packet, or -1 in case of an error.
-
getPayloadType
public static int getPayloadType(RawPacket pkt)
Get RTP payload type from a RTP packet- Returns:
- RTP payload type of source RTP packet, or -1 in case of an error.
-
getRTCPSSRC
public long getRTCPSSRC()
Get RTCP SSRC from a RTCP packet- Returns:
- RTP SSRC from source RTP packet
-
getRTCPPacketType
public int getRTCPPacketType()
Gets the packet type of this RTCP packet.- Returns:
- the packet type of this RTCP packet.
-
getSequenceNumber
public int getSequenceNumber()
Get RTP sequence number from a RTP packet- Returns:
- RTP sequence num from source packet
-
getSequenceNumber
public static int getSequenceNumber(byte[] buffer, int offset, int length)Get RTP sequence number from a RTP packet- Returns:
- RTP sequence num from source packet
-
getSequenceNumber
public static int getSequenceNumber(org.jitsi.utils.ByteArrayBuffer baf)
Gets the RTP sequence number from a RTP packet.- Parameters:
baf- theByteArrayBufferthat contains the RTP packet.- Returns:
- the RTP sequence number from a RTP packet.
-
setSequenceNumber
public static void setSequenceNumber(byte[] buffer, int offset, int seq)Set sequence number for an RTP buffer
-
setSequenceNumber
public static void setSequenceNumber(org.jitsi.utils.ByteArrayBuffer baf, int dstSeqNum)Sets the sequence number of an RTP packet.- Parameters:
baf- theByteArrayBufferthat contains the RTP packet.dstSeqNum- the sequence number to set in the RTP packet.
-
setTimestamp
public static void setTimestamp(byte[] buf, int off, int len, long ts)Set the RTP timestamp for an RTP buffer.- Parameters:
buf- the byte array that holds the RTP packet.off- the offset in buffer at which the actual RTP data begins.len- the number of bytes in buffer which constitute the actual RTP data.ts- the timestamp to set in the RTP buffer.
-
setTimestamp
public static void setTimestamp(org.jitsi.utils.ByteArrayBuffer baf, long ts)Sets the RTP timestamp of an RTP packet. param baaf theByteArrayBufferthat contains the RTP packet.- Parameters:
ts- the timestamp to set in the RTP packet.
-
getSRTCPIndex
public int getSRTCPIndex(int authTagLen)
Get SRTCP sequence number from a SRTCP packet- Parameters:
authTagLen- authentication tag length- Returns:
- SRTCP sequence num from source packet
-
getSRTCPIndex
public static int getSRTCPIndex(org.jitsi.utils.ByteArrayBuffer baf, int authTagLen)Get SRTCP sequence number from a SRTCP packet- Parameters:
authTagLen- authentication tag length- Returns:
- SRTCP sequence num from source packet
-
getSSRC
public int getSSRC()
Get RTP SSRC from a RTP packet- Returns:
- RTP SSRC from source RTP packet
-
getSSRC
public static int getSSRC(byte[] buffer, int offset, int length)Get RTP SSRC from a RTP packet- Returns:
- RTP SSRC from source RTP packet
-
getSSRC
public static int getSSRC(org.jitsi.utils.ByteArrayBuffer baf)
Get RTP SSRC from a RTP packet
-
getSSRCAsLong
public long getSSRCAsLong()
Returns alongrepresentation of the SSRC of this RTP packet.- Returns:
- a
longrepresentation of the SSRC of this RTP packet.
-
getSSRCAsLong
public static long getSSRCAsLong(byte[] buffer, int offset, int length)Returns alongrepresentation of the SSRC of this RTP packet.- Returns:
- a
longrepresentation of the SSRC of this RTP packet.
-
getTimestamp
public long getTimestamp()
Returns the timestamp for this RTP RawPacket.- Returns:
- the timestamp for this RTP RawPacket.
-
getTimestamp
public static long getTimestamp(byte[] buf, int off, int len)Gets the RTP timestamp for an RTP buffer.- Parameters:
buf- the byte array that holds the RTP packet.off- the offset in buffer at which the actual RTP data begins.len- the number of bytes in buffer which constitute the actual RTP data.- Returns:
- the timestamp in the RTP buffer.
-
getTimestamp
public static long getTimestamp(org.jitsi.utils.ByteArrayBuffer baf)
Gets the RTP timestamp for an RTP buffer.- Parameters:
baf- theByteArrayBufferthat contains the RTP packet.- Returns:
- the timestamp in the RTP buffer.
-
grow
public void grow(int howMuch)
Grows the internal buffer of thisRawPacket. This will change the data buffer of this packet but not the length of the valid data. Use this to grow the internal buffer to avoid buffer re-allocations when appending data.- Specified by:
growin interfaceorg.jitsi.utils.ByteArrayBuffer- Parameters:
howMuch- the number of bytes by which thisRawPacketis to grow
-
isInvalid
public boolean isInvalid()
Perform checks on the packet represented by this instance and return true if it is found to be invalid. A return value of false does not necessarily mean that the packet is valid.- Specified by:
isInvalidin interfaceorg.jitsi.utils.ByteArrayBuffer- Returns:
- true if the RTP/RTCP packet represented by this instance is found to be invalid, false otherwise.
-
isPacketMarked
public boolean isPacketMarked()
Test whether the RTP Marker bit is set- Returns:
- whether the RTP Marker bit is set
-
readByte
public byte readByte(int off)
Read a byte from this packet at specified offset- Parameters:
off- start offset of the byte- Returns:
- byte at offset
-
readInt
public int readInt(int off)
Read a integer from this packet at specified offset- Parameters:
off- start offset of the integer to be read- Returns:
- the integer to be read
-
readUint32AsLong
public long readUint32AsLong(int off)
Read a 32-bit unsigned integer from this packet at the specified offset.- Parameters:
off- start offset of the integer to be read.- Returns:
- the integer to be read
-
readRegion
public byte[] readRegion(int off, int len)Read a byte region from specified offset with specified length- Parameters:
off- start offset of the region to be readlen- length of the region to be read- Returns:
- byte array of [offset, offset + length)
-
readRegionToBuff
public void readRegionToBuff(int off, int len, byte[] outBuff)Read a byte region from specified offset with specified length in given buffer- Specified by:
readRegionToBuffin interfaceorg.jitsi.utils.ByteArrayBuffer- Parameters:
off- start offset of the region to be readlen- length of the region to be readoutBuff- output buffer
-
writeShort
public void writeShort(int off, short val)Write a short to this packet at the specified offset.
-
readUint16AsInt
public int readUint16AsInt(int off)
Read an unsigned short at specified offset as a int- Parameters:
off- start offset of the unsigned short- Returns:
- the int value of the unsigned short at offset
-
removeExtension
public void removeExtension()
Removes the extension from the packet and its header.
-
setBuffer
public void setBuffer(byte[] buffer)
- Parameters:
buffer- the buffer to set
-
setCsrcList
public void setCsrcList(long[] newCsrcList)
Replaces the existing CSRC list (even if empty) with newCsrcList and updates the CC (CSRC count) field of this RawPacket accordingly.- Parameters:
newCsrcList- the list of CSRC identifiers that we'd like to set for this RawPacket.
-
setFlags
public void setFlags(int flags)
Sets the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket.- Parameters:
flags- the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket
-
setLength
public void setLength(int length)
- Specified by:
setLengthin interfaceorg.jitsi.utils.ByteArrayBuffer- Parameters:
length- the length to set
-
setMarker
public void setMarker(boolean marker)
Sets or resets the marker bit of this packet according to the marker parameter.- Parameters:
marker- true if we are to raise the marker bit and false otherwise.
-
setOffset
public void setOffset(int offset)
- Specified by:
setOffsetin interfaceorg.jitsi.utils.ByteArrayBuffer- Parameters:
offset- the offset to set
-
setPayloadType
public void setPayloadType(byte payload)
Sets the payload type of this packet.- Parameters:
payload- the RTP payload type describing the content of this packet.
-
setSequenceNumber
public void setSequenceNumber(int seq)
Set the RTP sequence number of an RTP packet- Parameters:
seq- the sequence number to set (only the least-significant 16bits are used)
-
setSSRC
public void setSSRC(int ssrc)
Set the SSRC of this packet- Parameters:
ssrc- SSRC to set
-
setTimestamp
public void setTimestamp(long timestamp)
Set the timestamp value of the RTP Packet- Parameters:
timestamp- : the RTP Timestamp
-
shrink
public void shrink(int len)
Shrink the buffer of this packet by specified length- Specified by:
shrinkin interfaceorg.jitsi.utils.ByteArrayBuffer- Parameters:
len- length to shrink
-
writeByte
public void writeByte(int off, byte b)Write a byte to this packet at specified offset- Parameters:
off- start offset of the byteb- byte to write
-
writeInt
public void writeInt(int off, int data)Set an integer at specified offset in network order.- Parameters:
off- Offset into the bufferdata- The integer to store in the packet
-
getOriginalSequenceNumber
public int getOriginalSequenceNumber()
Gets the OSN value of an RTX packet.- Returns:
- the OSN value of an RTX packet.
-
setOriginalSequenceNumber
public void setOriginalSequenceNumber(int sequenceNumber)
Sets the OSN value of an RTX packet.- Parameters:
sequenceNumber- the new OSN value of this RTX packet.
-
setPaddingSize
public boolean setPaddingSize(int len)
Sets the padding length for this RTP packet.- Parameters:
len- the padding length.- Returns:
- the number of bytes that were written, or -1 in case of an error.
-
setVersion
public boolean setVersion()
Sets the RTP version in this RTP packet.- Returns:
- the number of bytes that were written, or -1 in case of an error.
-
isSkipStats
public boolean isSkipStats()
Whether to skip packet statistics.- Returns:
- returns true if we want to skip stats for this packet.
-
setSkipStats
public void setSkipStats(boolean skipStats)
Changes the skipStats flag.- Parameters:
skipStats- the new value.
-
getHeaderExtension
public RawPacket.HeaderExtension getHeaderExtension(byte id)
- Parameters:
id-- Returns:
- the header extension of this
RawPacketwith the given ID, or null if the packet doesn't have one. WARNING: This method should not be used while iterating over the extensions withgetHeaderExtensions(), because it uses the same iterator.
-
-