javax.media
Class Buffer

java.lang.Object
  |
  +--javax.media.Buffer

public class Buffer
extends java.lang.Object

This is a media container that carries media data between the different processing stages inside a Player/Processor as well as between a buffer stream and its handler. The Buffer object contains additional information such as time stamp, length and format of the data and any additional header that might be required to process the media data.

Since:
JMF 2.0
See Also:
PlugIn, PushBufferStream, PullBufferStream

Field Summary
protected  java.lang.Object data
          The object that actually holds the media data chunk.
static int FLAG_DISCARD
          Indicates that this media data should be ignored.
static int FLAG_EOM
          Indicates that this buffer marks the end of media for the data stream.
static int FLAG_FLUSH
          This is a marker bit used by the system.
static int FLAG_KEY_FRAME
          Indicates that this buffer starts with a key frame.
static int FLAG_NO_DROP
          Indicates that the buffer in consideration will not be dropped even when the frame is behind the presentation schedule.
static int FLAG_NO_SYNC
          Indicates that the buffer in consideration is not to be presented in sync.
static int FLAG_NO_WAIT
          Indicates that the buffer in consideration will not be waited on even when the frame is ahead of the presentation schedule.
static int FLAG_RELATIVE_TIME
          Indicates that the buffer carries a timestamp that's in relative time units.
static int FLAG_RTP_MARKER
          This is a marker bit used in case of RTP to signify the end of a video frame.
static int FLAG_SID
          Indicates that this buffer contains only SID (silence information description) frames.
static int FLAG_SILENCE
          Indicates that this buffer contains only silence frames.
static int FLAG_SYSTEM_MARKER
          This is a marker bit used by the system.
protected  int flags
          The flag mask set on this buffer to describe some boolean attributes of this buffer.
protected  Format format
          The format of this data chunk.
protected  java.lang.Object header
          Header information (such as RTP header) for this data chunk.
protected  int length
          For array data type, states how many samples are valid in the array.
protected  int offset
          For array data type, this points to the starting offset into the array where the valid data begins.
static long SEQUENCE_UNKNOWN
          The getSequenceNumber method will return this if the sequence number is not known.
protected  long sequenceNumber
          The sequence number of this buffer.
static long TIME_UNKNOWN
          The getTimeStamp method will return this if the time stamp of the media is not known.
protected  long timeStamp
          The time stamp of the data held in this buffer.
 
Constructor Summary
Buffer()
           
 
Method Summary
 java.lang.Object getData()
          Returns the internal data object which holds the media chunk.
 int getFlags()
          Return the mask of flags set for this buffer object.
 Format getFormat()
          Returns the data format.
 java.lang.Object getHeader()
          Returns the header information for the media chunk.
 int getLength()
          Returns the length of the valid data if the data is an array.
 int getOffset()
          Returns the starting offset of the valid data in the array.
 long getSequenceNumber()
          Returns the sequence number of this media chunk.
 long getTimeStamp()
          Returns the time stamp of this particular chunk of media data.
 boolean isDiscard()
          Returns true if this buffer is to be discarded.
 boolean isEOM()
          Returns true if this buffer marks the end of media.
 void setData(java.lang.Object data)
          Sets the internal data object which holds the media chunk.
 void setDiscard(boolean discard)
          Mark/Unmark this buffer as Discard.
 void setEOM(boolean eom)
          Mark/Unmark this buffer as EOM.
 void setFlags(int flags)
          Set the flag mask for this buffer object.
 void setFormat(Format format)
          Sets the data format.
 void setHeader(java.lang.Object header)
          Sets the header information for the media chunk.
 void setLength(int length)
          For array data, sets the length of valid data stored in the array.
 void setOffset(int offset)
          For array data, sets the starting offset of the valid data.
 void setSequenceNumber(long number)
          Sets the sequence number of this media chunk.
 void setTimeStamp(long timeStamp)
          Sets the time stamp of this particular chunk of media data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeStamp

protected long timeStamp
The time stamp of the data held in this buffer. It marks the start time when this buffer is to be presented. This unit is in nanoseconds. It is set to be TIME_UNKNOWN if the time stamp for this buffer is not known.

format

protected Format format
The format of this data chunk.

flags

protected int flags
The flag mask set on this buffer to describe some boolean attributes of this buffer. It is set to be the logical OR of the boolean attributes that are turned on for this buffer. See all the valid flags that can be set on this buffer.

data

protected java.lang.Object data
The object that actually holds the media data chunk. It can be an array type (such as byte[]) or any other type of object. Use instanceOf to find out which.

header

protected java.lang.Object header
Header information (such as RTP header) for this data chunk. Can be of any type. Use instanceOf to find out which.

length

protected int length
For array data type, states how many samples are valid in the array. (The array might be larger than the real media length).

offset

protected int offset
For array data type, this points to the starting offset into the array where the valid data begins.

sequenceNumber

protected long sequenceNumber
The sequence number of this buffer. Sequence number of adjacent buffers in a sequence should differ by 1: positive 1 if the media is playing forward; negative 1 if the media is played in reverse. If the sequence number is not known, SEQUENCE_UNKNOWN is used.

FLAG_EOM

public static final int FLAG_EOM
Indicates that this buffer marks the end of media for the data stream. This buffer may or may not contain valid data to be processed. The length and data attributes need to be examined to check for valid data contained in this buffer.

FLAG_DISCARD

public static final int FLAG_DISCARD
Indicates that this media data should be ignored.

FLAG_SILENCE

public static final int FLAG_SILENCE
Indicates that this buffer contains only silence frames.

FLAG_SID

public static final int FLAG_SID
Indicates that this buffer contains only SID (silence information description) frames.

FLAG_KEY_FRAME

public static final int FLAG_KEY_FRAME
Indicates that this buffer starts with a key frame.

FLAG_NO_DROP

public static final int FLAG_NO_DROP
Indicates that the buffer in consideration will not be dropped even when the frame is behind the presentation schedule.

FLAG_NO_WAIT

public static final int FLAG_NO_WAIT
Indicates that the buffer in consideration will not be waited on even when the frame is ahead of the presentation schedule.

FLAG_NO_SYNC

public static final int FLAG_NO_SYNC
Indicates that the buffer in consideration is not to be presented in sync. with the scheduled presentation time. i.e. the buffer will not be dropped or waited on if it's behind or ahead of schedule.

FLAG_RELATIVE_TIME

public static final int FLAG_RELATIVE_TIME
Indicates that the buffer carries a timestamp that's in relative time units. i.e., timestamps taken as individuals are not measured in any indentifiable absolute origin. Only the difference between the time stamps of 2 consecutive buffers carries informative info -- it will indicate the time difference between the two packets. This flag is set generally when buffers are transferred in and out of a processor.

FLAG_FLUSH

public static final int FLAG_FLUSH
This is a marker bit used by the system. When this is set, it marks a zero-length buffer generated by the system to flush the data path. Do not attempt to use or overwrite it.

FLAG_SYSTEM_MARKER

public static final int FLAG_SYSTEM_MARKER
This is a marker bit used by the system. Do not attempt to use or overwrite it.

FLAG_RTP_MARKER

public static final int FLAG_RTP_MARKER
This is a marker bit used in case of RTP to signify the end of a video frame. i.e. the last packet of the video frame.

TIME_UNKNOWN

public static final long TIME_UNKNOWN
The getTimeStamp method will return this if the time stamp of the media is not known.

SEQUENCE_UNKNOWN

public static final long SEQUENCE_UNKNOWN
The getSequenceNumber method will return this if the sequence number is not known.
Constructor Detail

Buffer

public Buffer()
Method Detail

getFormat

public Format getFormat()
Returns the data format.

setFormat

public void setFormat(Format format)
Sets the data format.
Parameters:
format - the format of the data

getFlags

public int getFlags()
Return the mask of flags set for this buffer object. The integer value of the mask is equal to the logical sum of the flags set.
See Also:
FLAG_EOM, FLAG_DISCARD, FLAG_SILENCE, FLAG_SID, FLAG_KEY_FRAME, FLAG_NO_DROP, FLAG_NO_WAIT, FLAG_NO_SYNC, FLAG_RELATIVE_TIME, FLAG_FLUSH, FLAG_SYSTEM_MARKER, FLAG_RTP_MARKER

setFlags

public void setFlags(int flags)
Set the flag mask for this buffer object. The integer value of the mask is equal to the logical sum of the flags set.
See Also:
FLAG_EOM, FLAG_DISCARD, FLAG_SILENCE, FLAG_SID, FLAG_KEY_FRAME, FLAG_NO_DROP, FLAG_NO_WAIT, FLAG_NO_SYNC, FLAG_RELATIVE_TIME, FLAG_FLUSH, FLAG_SYSTEM_MARKER, FLAG_RTP_MARKER

isEOM

public boolean isEOM()
Returns true if this buffer marks the end of media. Notice that it could still contain valid data. Check the length of the buffer. This is a convenient function to getFlags which returns the logical sum of the flags set.
See Also:
getFlags(), FLAG_EOM

setEOM

public void setEOM(boolean eom)
Mark/Unmark this buffer as EOM. This is a convenient function to setFlags which returns the logical sum of the flags set.
See Also:
setFlags(int), FLAG_EOM

isDiscard

public boolean isDiscard()
Returns true if this buffer is to be discarded. This is a convenient function to getFlags which returns the logical sum of the flags set.
See Also:
getFlags(), FLAG_DISCARD

setDiscard

public void setDiscard(boolean discard)
Mark/Unmark this buffer as Discard. This is a convenient function to setFlags which returns the logical sum of the flags set.
See Also:
setFlags(int), FLAG_DISCARD

getData

public java.lang.Object getData()
Returns the internal data object which holds the media chunk.
See Also:
data

setData

public void setData(java.lang.Object data)
Sets the internal data object which holds the media chunk.
See Also:
data

getHeader

public java.lang.Object getHeader()
Returns the header information for the media chunk.
See Also:
header

setHeader

public void setHeader(java.lang.Object header)
Sets the header information for the media chunk.
See Also:
header

getLength

public int getLength()
Returns the length of the valid data if the data is an array.
See Also:
length

setLength

public void setLength(int length)
For array data, sets the length of valid data stored in the array.
Parameters:
length - length of the valid data.
See Also:
length

getOffset

public int getOffset()
Returns the starting offset of the valid data in the array.

setOffset

public void setOffset(int offset)
For array data, sets the starting offset of the valid data.
Parameters:
offset - starting offset of the valid data stored in the array.
See Also:
offset

getTimeStamp

public long getTimeStamp()
Returns the time stamp of this particular chunk of media data.
See Also:
timeStamp

setTimeStamp

public void setTimeStamp(long timeStamp)
Sets the time stamp of this particular chunk of media data.
Parameters:
timeStamp - the time stamp.
See Also:
timeStamp

setSequenceNumber

public void setSequenceNumber(long number)
Sets the sequence number of this media chunk. Sequence numbers should increase or decrease by 1 for each sample, indicating the order in which the data is to be processed. Could be used to indicate lost samples of data.
See Also:
sequenceNumber

getSequenceNumber

public long getSequenceNumber()
Returns the sequence number of this media chunk.
See Also:
sequenceNumber