net.java.sip.communicator.impl.neomedia.codec.audio
Class Utils
java.lang.Object
net.java.sip.communicator.impl.neomedia.codec.audio.Utils
public class Utils
- extends Object
- Author:
- Damian Minkov
|
Constructor Summary |
Utils()
|
|
Method Summary |
static short[] |
byteToShortArray(byte[] byteArray,
int offset,
int length,
boolean little)
Converts a byte array into a short array. |
static void |
shortArrToByteArr(short[] in,
byte[] res,
boolean little)
The result array must be twice as the input one. |
static byte[] |
shortToBytes(short v,
boolean little)
Get a pair of bytes representing a short value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Utils
public Utils()
byteToShortArray
public static short[] byteToShortArray(byte[] byteArray,
int offset,
int length,
boolean little)
throws ArrayIndexOutOfBoundsException
- Converts a byte array into a short array. Since a byte is 8-bits,
and a short is 16-bits, the returned short array will be half in
length than the byte array. If the length of the byte array is odd,
the length of the short array will be
(byteArray.length - 1)/2, i.e., the last byte is
discarded.
- Parameters:
byteArray - a byte arrayoffset - which byte to start fromlength - how many bytes to convertlittle - specifies whether the result should be using little endian
order or not.
- Returns:
- a short array, or
null if byteArray is of zero
length
- Throws:
ArrayIndexOutOfBoundsException
shortArrToByteArr
public static void shortArrToByteArr(short[] in,
byte[] res,
boolean little)
- The result array must be twice as the input one. Since a byte is 8-bits,
and a short is 16-bits.
- Parameters:
in - the short[] array that we'll be transforming.res - the byte[] arrays where we'll be setting the converted short
values.little - specifies whether the result should be using little endian
order or not.
shortToBytes
public static byte[] shortToBytes(short v,
boolean little)
- Get a pair of bytes representing a short value.
- Parameters:
v - the short value to convert.little - specifies whether the result should be using little endian
order or no.
- Returns:
- a byte[] array containing the result.
SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.