public class Datagram extends Object
Modifier and Type | Field and Description |
---|---|
protected byte[] |
data
The datagram's contents, as a generic byte array.
|
protected long |
duration
The datagram duration, in samples.
|
static int |
NUM_HEADER_BYTES |
Modifier | Constructor and Description |
---|---|
|
Datagram(ByteBuffer bb)
Constructor which reads a datagram from a byte buffer.
|
|
Datagram(ByteBuffer bb,
boolean readData)
Constructor which reads a datagram from a byte buffer.
|
protected |
Datagram(long duration)
Constructor for subclasses which want to represent data in a different format.
|
|
Datagram(long setDuration,
byte[] setData)
Constructor from external data.
|
|
Datagram(RandomAccessFile raf)
Constructor which reads a datagram from a random access file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Tests if this datagram is equal to another datagram.
|
byte[] |
getData()
Get the datagram's data field.
|
long |
getDuration()
Get the datagram duration, in samples.
|
int |
getLength()
Get the length, in bytes, of the datagram's data field.
|
void |
setDuration(long setDuration)
Set the new duration.
|
void |
write(DataOutput raf)
Write this datagram to a random access file or data output stream.
|
public static final int NUM_HEADER_BYTES
protected long duration
protected byte[] data
protected Datagram(long duration)
duration
- the datagram duration, in samples. Must be non-negative.IllegalArgumentException
- if duration is negativepublic Datagram(long setDuration, byte[] setData)
setDuration
- the datagram duration, in samples. Must be non-negative.setData
- the datagram.IllegalArgumentException
- if duration is negativeNullPointerException
- if setData is null.public Datagram(RandomAccessFile raf) throws IOException
raf
- the random access file to read the datagram from.IOException
- if there is a problem initialising the datagram from the filepublic Datagram(ByteBuffer bb) throws IOException
bb
- the byte buffer to read the datagram from.IOException
- if the datagram has wrong format or if the datagram cannot be fully readpublic Datagram(ByteBuffer bb, boolean readData) throws IOException
bb
- the byte buffer to read the datagram from.readData
- whether to try and read the actual dataIOException
- if the datagram has wrong format or if the datagram cannot be fully readpublic void setDuration(long setDuration)
setDuration
- the datagram duration, in samples. Must be non-negative.IllegalArgumentException
- if duration is negativepublic void write(DataOutput raf) throws IOException
raf
- the data output to write to.IllegalStateException
- if called when data is null.IOException
- if a write error occurs.public long getDuration()
public int getLength()
IllegalStateException
- if called when data is null.public byte[] getData()
Copyright © 2000–2016 DFKI GmbH. All rights reserved.