public class RTPUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<? super java.lang.Integer> |
sequenceNumberComparator
A
Comparator implementation for unsigned 16-bit Integer s. |
Constructor and Description |
---|
RTPUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
applySequenceNumberDelta(int startingSequenceNumber,
int delta)
Apply a delta to a given sequence number and return the result (taking
rollover into account)
|
static int |
as16Bits(int value)
Returns the given integer masked to 16 bits
|
static long |
as32Bits(long value)
Returns the given integer masked to 32 bits
|
static int |
getSequenceNumberDelta(int a,
int b)
Returns the delta between two RTP sequence numbers, taking into account
rollover.
|
static boolean |
isNewerTimestampThan(long a,
long b)
Returns whether or not the first given timestamp is newer than the second
|
static boolean |
isOlderSequenceNumberThan(int seqNumOne,
int seqNumTwo)
Returns whether or not seqNumOne is 'older' than seqNumTwo, taking
rollover into account
|
static int |
readInt(byte[] buf,
int off)
Read an integer from a buffer at a specified offset.
|
static int |
readInt16AsInt(byte[] buf,
int off)
Read a signed short at a specified offset as an int.
|
static int |
readUint16AsInt(byte[] buf,
int off)
Read an unsigned short at a specified offset as an int.
|
static int |
readUint24AsInt(byte[] buf,
int off)
Read an unsigned short at specified offset as a int
|
static long |
readUint32AsLong(byte[] buf,
int off)
Reads a 32-bit unsigned integer from the given buffer at the given
offset and returns its
long representation. |
static long |
rtpTimestampDiff(long a,
long b)
Returns the difference between two RTP timestamps.
|
static int |
subtractNumber(int a,
int b)
Returns result of the subtraction of one RTP sequence number from another
(modulo 2^16).
|
static java.lang.String |
toHexString(byte[] buf)
Return a string containing the hex string version of the given bytes
|
static java.lang.String |
toHexString(byte[] buf,
int off,
int len)
Return a string containing the hex string version of the given byte
|
static int |
writeInt(byte[] buf,
int off,
int data)
Set an integer at specified offset in network order.
|
static int |
writeShort(byte[] buf,
int off,
short data)
Set an integer at specified offset in network order.
|
static int |
writeUint24(byte[] buf,
int off,
int data)
Writes the least significant 24 bits from the given integer into the
given byte array at the given offset.
|
public static final java.util.Comparator<? super java.lang.Integer> sequenceNumberComparator
Comparator
implementation for unsigned 16-bit Integer
s.
Compares a
and b
inside the [0, 2^16] ring;
a
is considered smaller than b
if it takes a smaller
number to reach from a
to b
than the other way round.
IMPORTANT: This is a valid Comparator
implementation only when
used for subsets of [0, 2^16) which don't span more than 2^15 elements.
E.g. it works for: [0, 2^15-1] and ([50000, 2^16) u [0, 10000])
Doesn't work for: [0, 2^15] and ([0, 2^15-1] u {2^16-1}) and [0, 2^16)public static int getSequenceNumberDelta(int a, int b)
public static boolean isOlderSequenceNumberThan(int seqNumOne, int seqNumTwo)
seqNumOne
- seqNumTwo
- public static int subtractNumber(int a, int b)
public static int applySequenceNumberDelta(int startingSequenceNumber, int delta)
startingSequenceNumber
- the starting sequence numberdelta
- the delta to be appliedpublic static int writeInt(byte[] buf, int off, int data)
off
- Offset into the bufferdata
- The integer to store in the packetpublic static int writeUint24(byte[] buf, int off, int data)
buf
- the buffer into which to write.off
- the offset at which to write.data
- the integer to write.public static int writeShort(byte[] buf, int off, short data)
off
- Offset into the bufferdata
- The integer to store in the packetpublic static int readInt(byte[] buf, int off)
buf
- the buffer.off
- start offset of the integer to be read.public static long readUint32AsLong(byte[] buf, int off)
long
representation.buf
- the buffer.off
- start offset of the integer to be read.public static int readUint16AsInt(byte[] buf, int off)
buf
- the buffer from which to read.off
- start offset of the unsigned shortpublic static int readInt16AsInt(byte[] buf, int off)
buf
- the buffer from which to read.off
- start offset of the unsigned shortpublic static int readUint24AsInt(byte[] buf, int off)
buf
- off
- start offset of the unsigned shortpublic static int as16Bits(int value)
value
- the integer to maskpublic static long as32Bits(long value)
value
- the integer to maskpublic static long rtpTimestampDiff(long a, long b)
public static boolean isNewerTimestampThan(long a, long b)
a
- b
- public static java.lang.String toHexString(byte[] buf)
buf
- public static java.lang.String toHexString(byte[] buf, int off, int len)
buf
- off
- len
-
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.