jlibrtp
Class StaticProcs

java.lang.Object
  extended by jlibrtp.StaticProcs

public class StaticProcs
extends java.lang.Object

Generic functions for converting between unsigned integers and byte[]s.

Author:
Arne Kepp

Constructor Summary
StaticProcs()
           
 
Method Summary
static java.lang.String bitsOfByte(byte aByte)
          Get the bits of a byte
static java.lang.String bitsOfBytes(byte[] bytes)
           
static byte byteOfHex(byte[] hex)
          Get the hex representation of a byte
static int bytesToUIntInt(byte[] bytes, int index)
          Combines two bytes (most significant bit first) into a 16 bit unsigned integer.
static long bytesToUIntLong(byte[] bytes, int index)
          Combines four bytes (most significant bit first) into a 32 bit unsigned integer.
static java.lang.String hexOfByte(byte aByte)
          Get the hex representation of a byte
static void printBits(byte aByte)
          Print the bits of a byte to standard out.
static byte[] uIntIntToByteWord(int i)
          Converts an integer into an array of bytes.
static byte[] uIntLongToByteWord(long j)
          Converts an unsigned 32 bit integer, stored in a long, into an array of bytes.
static long undoNtpMess(long ntpTs1, long ntpTs2)
          Recreates a UNIX timestamp based on the NTP representation used in RTCP SR packets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticProcs

public StaticProcs()
Method Detail

uIntIntToByteWord

public static byte[] uIntIntToByteWord(int i)
Converts an integer into an array of bytes. Primarily used for 16 bit unsigned integers, ignore the first two octets.

Parameters:
i - a 16 bit unsigned integer in an int
Returns:
byte[2] representing the integer as unsigned, most significant bit first.

uIntLongToByteWord

public static byte[] uIntLongToByteWord(long j)
Converts an unsigned 32 bit integer, stored in a long, into an array of bytes.

Parameters:
j - a long
Returns:
byte[4] representing the unsigned integer, most significant bit first.

bytesToUIntInt

public static int bytesToUIntInt(byte[] bytes,
                                 int index)
Combines two bytes (most significant bit first) into a 16 bit unsigned integer.

Parameters:
index - of most significant byte
Returns:
int with the 16 bit unsigned integer

bytesToUIntLong

public static long bytesToUIntLong(byte[] bytes,
                                   int index)
Combines four bytes (most significant bit first) into a 32 bit unsigned integer.

Parameters:
bytes -
index - of most significant byte
Returns:
long with the 32 bit unsigned integer

undoNtpMess

public static long undoNtpMess(long ntpTs1,
                               long ntpTs2)
Recreates a UNIX timestamp based on the NTP representation used in RTCP SR packets

Parameters:
ntpTs1 - from RTCP SR packet
ntpTs2 - from RTCP SR packet
Returns:
the UNIX timestamp

bitsOfByte

public static java.lang.String bitsOfByte(byte aByte)
Get the bits of a byte

Parameters:
aByte - the byte you wish to convert
Returns:
a String of 1's and 0's

hexOfByte

public static java.lang.String hexOfByte(byte aByte)
Get the hex representation of a byte

Parameters:
aByte - the byte you wish to convert
Returns:
a String of two chars 0-1,A-F

byteOfHex

public static byte byteOfHex(byte[] hex)
Get the hex representation of a byte

Parameters:
hex - 4 bytes the byte you wish to convert
Returns:
a String of two chars 0-1,A-F

printBits

public static void printBits(byte aByte)
Print the bits of a byte to standard out. For debugging.

Parameters:
aByte - the byte you wish to print out.

bitsOfBytes

public static java.lang.String bitsOfBytes(byte[] bytes)