Class 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int EXT_HEADER_SIZE
      The size of the extension header as defined by RFC 3550.
      static int FIXED_HEADER_SIZE
      The size of the fixed part of the RTP header as defined by RFC 3550.
      static int SEQUENCE_NUMBER_MASK
      The bitmask for the RTP sequence number field.
      static long TIMESTAMP_MASK
      The bitmask for the RTP timestamp field.
    • Constructor Summary

      Constructors 
      Constructor Description
      RawPacket()
      Initializes a new empty RawPacket instance.
      RawPacket​(byte[] buffer, int offset, int length)
      Initializes a new RawPacket instance with a specific byte array buffer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addExtension​(byte id, byte[] data)
      Adds the given buffer as a header extension of this packet according the rules specified in RFC 5285.
      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.
      RawPacket.HeaderExtension addExtension​(byte id, int len)
      Adds an RTP header extension with a given ID and a given length to this packet.
      void append​(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.
      byte extractSsrcAudioLevel​(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 packet
      int getCsrcCount()
      Returns the number of CSRC identifiers currently included in this packet.
      static int getCsrcCount​(byte[] buffer, int offset, int length)
      Returns the number of CSRC identifiers currently included in this packet.
      boolean getExtensionBit()
      Returns true if the extension bit of this packet has been set and false otherwise.
      static boolean getExtensionBit​(byte[] buffer, int offset, int length)
      Returns true if the extension bit of this packet has been set and false otherwise.
      int getExtensionLength()
      Returns the length of the extensions currently added to this packet.
      static int getExtensionLength​(byte[] buffer, int offset, int length)
      Returns the length of the extensions currently added to this packet.
      int getFlags()
      Gets the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket.
      RawPacket.HeaderExtension getHeaderExtension​(byte id)  
      RawPacket.HeaderExtensions getHeaderExtensions()  
      int getHeaderExtensionType()
      Return the define by profile part of the extension header.
      int getHeaderLength()
      Get RTP header length from a RTP packet
      static int getHeaderLength​(byte[] buffer, int offset, int length)
      Get RTP header length from a RTP packet
      int getLength()
      Get the length of this packet's data
      int getOffset()
      Get the start offset of this packet's data inside storing buffer
      int getOriginalSequenceNumber()
      Gets the OSN value of an RTX packet.
      int getPaddingSize()
      Get RTP padding size from a RTP packet
      static int getPaddingSize​(byte[] buf, int off, int len)
      Get RTP padding size from a RTP packet
      byte[] getPayload()
      Get the RTP payload (bytes) of this RTP packet.
      int getPayloadLength()
      Get RTP payload length from a RTP packet
      int getPayloadLength​(boolean removePadding)
      Get RTP payload length from a RTP packet
      static int getPayloadLength​(byte[] buffer, int offset, int length)
      Get RTP payload length from a RTP packet
      static int getPayloadLength​(byte[] buffer, int offset, int length, boolean removePadding)
      Get RTP payload length from a RTP packet
      int getPayloadOffset()
      Get the RTP payload offset of an RTP packet.
      static int getPayloadOffset​(byte[] buffer, int offset, int length)
      Get the RTP payload offset of an RTP packet.
      byte getPayloadType()
      Get RTP payload type from a RTP packet
      static int getPayloadType​(byte[] buf, int off, int len)
      Get RTP payload type from a RTP packet
      static int getPayloadType​(RawPacket pkt)
      Get RTP payload type from a RTP packet
      int getRTCPPacketType()
      Gets the packet type of this RTCP packet.
      long getRTCPSSRC()
      Get RTCP SSRC from a RTCP packet
      static long getRTCPSSRC​(byte[] buf, int off, int len)
      Get RTCP SSRC from a RTCP packet
      static long getRTCPSSRC​(org.jitsi.utils.ByteArrayBuffer baf)
      Get RTCP SSRC from a RTCP packet
      int getSequenceNumber()
      Get RTP sequence number from a RTP packet
      static int getSequenceNumber​(byte[] buffer, int offset, int length)
      Get RTP sequence number from a RTP packet
      static int getSequenceNumber​(org.jitsi.utils.ByteArrayBuffer baf)
      Gets the RTP sequence number from a RTP packet.
      int getSRTCPIndex​(int authTagLen)
      Get SRTCP sequence number from a SRTCP packet
      static int getSRTCPIndex​(org.jitsi.utils.ByteArrayBuffer baf, int authTagLen)
      Get SRTCP sequence number from a SRTCP packet
      int getSSRC()
      Get RTP SSRC from a RTP packet
      static int getSSRC​(byte[] buffer, int offset, int length)
      Get RTP SSRC from a RTP packet
      static int getSSRC​(org.jitsi.utils.ByteArrayBuffer baf)
      Get RTP SSRC from a RTP packet
      long getSSRCAsLong()
      Returns a long representation of the SSRC of this RTP packet.
      static long getSSRCAsLong​(byte[] buffer, int offset, int length)
      Returns a long representation of the SSRC of this RTP packet.
      long getTimestamp()
      Returns the timestamp for this RTP RawPacket.
      static long getTimestamp​(byte[] buf, int off, int len)
      Gets the RTP timestamp for an RTP buffer.
      static long getTimestamp​(org.jitsi.utils.ByteArrayBuffer baf)
      Gets the RTP timestamp for an RTP buffer.
      int getVersion()
      Gets the value of the "version" field of an RTP packet.
      static int getVersion​(byte[] buffer, int offset, int length)
      Gets the value of the "version" field of an RTP packet.
      static int getVersion​(org.jitsi.utils.ByteArrayBuffer baf)
      Gets the value of the "version" field of an RTP packet.
      void grow​(int howMuch)
      Grows the internal buffer of this RawPacket.
      boolean isInvalid()
      Perform checks on the packet represented by this instance and return true if it is found to be invalid.
      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.
      boolean isPacketMarked()
      Test whether the RTP Marker bit is set
      static boolean isPacketMarked​(byte[] buffer, int offset, int length)
      Test whether the RTP Marker bit is set
      static boolean isPacketMarked​(org.jitsi.utils.ByteArrayBuffer baf)
      Test whether the RTP Marker bit is set
      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).
      boolean isSkipStats()
      Whether to skip packet statistics.
      byte readByte​(int off)
      Read a byte from this packet at specified offset
      int readInt​(int off)
      Read a integer from this packet at specified offset
      byte[] readRegion​(int off, int len)
      Read a byte region from specified offset with specified length
      void readRegionToBuff​(int off, int len, byte[] outBuff)
      Read a byte region from specified offset with specified length in given buffer
      int readUint16AsInt​(int off)
      Read an unsigned short at specified offset as a int
      long readUint32AsLong​(int off)
      Read a 32-bit unsigned integer from this packet at the specified offset.
      void removeExtension()
      Removes the extension from the packet and its header.
      void setBuffer​(byte[] buffer)  
      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.
      void setFlags​(int flags)
      Sets the bitmap/flag mask that specifies the set of boolean attributes enabled for this RawPacket.
      void setLength​(int length)  
      void setMarker​(boolean marker)
      Sets or resets the marker bit of this packet according to the marker parameter.
      void setOffset​(int offset)  
      void setOriginalSequenceNumber​(int sequenceNumber)
      Sets the OSN value of an RTX packet.
      boolean setPaddingSize​(int len)
      Sets the padding length for this RTP packet.
      void setPayloadType​(byte payload)
      Sets the payload type of this packet.
      static void setSequenceNumber​(byte[] buffer, int offset, int seq)
      Set sequence number for an RTP buffer
      void setSequenceNumber​(int seq)
      Set the RTP sequence number of an RTP packet
      static void setSequenceNumber​(org.jitsi.utils.ByteArrayBuffer baf, int dstSeqNum)
      Sets the sequence number of an RTP packet.
      void setSkipStats​(boolean skipStats)
      Changes the skipStats flag.
      void setSSRC​(int ssrc)
      Set the SSRC of this packet
      static void setTimestamp​(byte[] buf, int off, int len, long ts)
      Set the RTP timestamp for an RTP buffer.
      void setTimestamp​(long timestamp)
      Set the timestamp value of the RTP Packet
      static void setTimestamp​(org.jitsi.utils.ByteArrayBuffer baf, long ts)
      Sets the RTP timestamp of an RTP packet.
      boolean setVersion()
      Sets the RTP version in this RTP packet.
      void shrink​(int len)
      Shrink the buffer of this packet by specified length
      String toString()
      void writeByte​(int off, byte b)
      Write a byte to this packet at specified offset
      void writeInt​(int off, int data)
      Set an integer at specified offset in network order.
      void writeShort​(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 instance
        offset - the offset in buffer at which the actual data to be represented by the new instance starts
        length - 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 using getHeaderExtensions(), or while manipulating the state of this RawPacket.
        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 using getHeaderExtensions(), or while manipulating the state of this RawPacket.
        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 using getHeaderExtensions(), or while manipulating the state of this RawPacket.
        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:
        append in interface org.jitsi.utils.ByteArrayBuffer
        Parameters:
        data - byte array to append
        len - 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:
        getBuffer in interface org.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.
      • 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:
        getLength in interface org.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:
        getOffset in interface org.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 - the ByteArrayBuffer that 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 - the ByteArrayBuffer that 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 the ByteArrayBuffer that 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 a long representation of the SSRC of this RTP packet.
        Returns:
        a long representation of the SSRC of this RTP packet.
      • getSSRCAsLong

        public static long getSSRCAsLong​(byte[] buffer,
                                         int offset,
                                         int length)
        Returns a long representation of the SSRC of this RTP packet.
        Returns:
        a long representation 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 - the ByteArrayBuffer that contains the RTP packet.
        Returns:
        the timestamp in the RTP buffer.
      • grow

        public void grow​(int howMuch)
        Grows the internal buffer of this RawPacket. 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:
        grow in interface org.jitsi.utils.ByteArrayBuffer
        Parameters:
        howMuch - the number of bytes by which this RawPacket is 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:
        isInvalid in interface org.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 read
        len - 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:
        readRegionToBuff in interface org.jitsi.utils.ByteArrayBuffer
        Parameters:
        off - start offset of the region to be read
        len - length of the region to be read
        outBuff - 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:
        setLength in interface org.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:
        setOffset in interface org.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:
        shrink in interface org.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 byte
        b - 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 buffer
        data - 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 RawPacket with the given ID, or null if the packet doesn't have one. WARNING: This method should not be used while iterating over the extensions with getHeaderExtensions(), because it uses the same iterator.