javax.media
Class Buffer

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

public class Buffer
extends java.lang.Object

A Buffer is a media-data container that carries media data from one processing stage to the next inside of a Player or Processor. Buffer objects are also used to carry data between a buffer stream and its handler.

A Buffer object maintains information such as the time stamp, length, and Format of the data it carries, as well as any header information 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 for this Buffer.
protected  long duration
          The duration of the data held in this Buffer, in nanoseconds.
static int FLAG_DISCARD
          Indicates that the media data in this Buffer 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 this Buffer will not be dropped even if the frame is behind the presentation schedule.
static int FLAG_NO_SYNC
          Indicates that this Buffer is not to be presented in sync with the scheduled presentation time.
static int FLAG_NO_WAIT
          Indicates that this Buffer will not be waited on even if the frame is ahead of the presentation schedule.
static int FLAG_RELATIVE_TIME
          Indicates that the Buffer carries a time stamp that's in relative time units.
static int FLAG_RTP_MARKER
          This is a marker bit for RTP.
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.
static int FLAG_SYSTEM_TIME
          Indicates that the Buffer carries a time stamp that's relative to the SystemTimeBase.
protected  int flags
          A flag mask that describes the boolean attributes enabled for this Buffer.
protected  Format format
          The Format of the chunk of data in this Buffer.
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, points to the starting point (offset) into the array where the valid data begins.
static long SEQUENCE_UNKNOWN
          The getSequenceNumber method returns this value if the sequence number is not known.
protected  long sequenceNumber
          The sequence number of this Buffer.
static long TIME_UNKNOWN
          The getTimeStamp method return this value if the time stamp of the media is not known.
protected  long timeStamp
          The time stamp of the data held in this Buffer, in nanoseconds.
 
Constructor Summary
Buffer()
           
 
Method Summary
 java.lang.Object clone()
          Clone a buffer.
 void copy(Buffer buffer)
          Copy the attributes from the specified Buffer into this Buffer
 java.lang.Object getData()
          Gets the internal data object that holds the media chunk contained in this Buffer.
 long getDuration()
          Gets the duration of this Buffer.
 int getFlags()
          Gets the mask of the flags set for this Buffer.
 Format getFormat()
          Get the Format of the data in this Buffer.
 java.lang.Object getHeader()
          Gets the header information for the media chunk contained in this Buffer.
 int getLength()
          Gets the length of the valid data in this Buffer if the data is held in an array.
 int getOffset()
          If the media chunk for this Buffer is held in an array, gets the offset into the data array where the valid data begins.
 long getSequenceNumber()
          Gets the sequence number of this Buffer.
 long getTimeStamp()
          Gets the time stamp of this Buffer.
 boolean isDiscard()
          Checks whether or not this Buffer is to be discarded.
 boolean isEOM()
          Checks whether or not this Buffer marks the end of the media stream.
 void setData(java.lang.Object data)
          Sets the internal data object that holds the media chunk.
 void setDiscard(boolean discard)
          Sets the DISCARD flag for this Buffer.
 void setDuration(long duration)
          Sets the duration of this Buffer.
 void setEOM(boolean eom)
          Sets the EOM flag for this Buffer.
 void setFlags(int flags)
          Sets the flag mask for this Buffer.
 void setFormat(Format format)
          Sets the Format of the data in this Buffer.
 void setHeader(java.lang.Object header)
          Sets the header information for the media chunk.
 void setLength(int length)
          Sets the length of the valid data stored in this Buffer if the data is held in an array.
 void setOffset(int offset)
          If the media chunk for this Buffer is held in an array, sets the offset into the array where the valid data begins.
 void setSequenceNumber(long number)
          Sets the sequence number of this Buffer.
 void setTimeStamp(long timeStamp)
          Sets the time stamp of this Buffer.
 
Methods inherited from class java.lang.Object
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, in nanoseconds. The time stamp marks the time when presentation of this Buffer is to begin. If the start time for this Buffer is not known, this time stamp is set to TIME_UNKNOWN.

duration

protected long duration
The duration of the data held in this Buffer, in nanoseconds. The duration specifies how long it will take for this Buffer to be presented when the playback rate is 1.0. If the duration for this Buffer is not known, it is set to TIME_UNKNOWN.

format

protected Format format
The Format of the chunk of data in this Buffer.

flags

protected int flags
A flag mask that describes the boolean attributes enabled for this Buffer. This mask is set to the logical sum of all of the flags that are 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_SYSTEM_TIME, FLAG_FLUSH, FLAG_SYSTEM_MARKER, FLAG_RTP_MARKER

data

protected java.lang.Object data
The object that actually holds the media data chunk for this Buffer. It can be an array type (such as byte[]) or any other type of object. Use instanceOf to determine what type it is.

header

protected java.lang.Object header
Header information (such as RTP header) for this data chunk. It can be of any type. Use instanceOf to determine what type it is.

length

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

offset

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

sequenceNumber

protected long sequenceNumber
The sequence number of this Buffer. The sequence number of adjacent Buffer objects 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 specified.

FLAG_EOM

public static final int FLAG_EOM
Indicates that this Buffer marks the end of media for the data stream. The Buffer might or might not contain valid data to be processed. The length and data attributes need to be examined to determine whether or not this Buffer contains valid data.

FLAG_DISCARD

public static final int FLAG_DISCARD
Indicates that the media data in this Buffer 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 this Buffer will not be dropped even if the frame is behind the presentation schedule.

FLAG_NO_WAIT

public static final int FLAG_NO_WAIT
Indicates that this Buffer will not be waited on even if the frame is ahead of the presentation schedule.

FLAG_NO_SYNC

public static final int FLAG_NO_SYNC
Indicates that this Buffer is not to be presented in sync with the scheduled presentation time. In other words, the Buffer will not be dropped or waited on if it's behind or ahead of schedule.

FLAG_SYSTEM_TIME

public static final int FLAG_SYSTEM_TIME
Indicates that the Buffer carries a time stamp that's relative to the SystemTimeBase. This flag is generally set for data transferred from hardware capture DataSources that uses the system clock.

FLAG_RELATIVE_TIME

public static final int FLAG_RELATIVE_TIME
Indicates that the Buffer carries a time stamp that's in relative time units. This means that individual time stamps are not measured against any indentifiable absolute origin--only the difference between the time stamps of two consecutive buffers carries useful information. (This is the time difference between the two packets.)

FLAG_FLUSH

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

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 this flag.

FLAG_RTP_MARKER

public static final int FLAG_RTP_MARKER
This is a marker bit for RTP. Indicates that the Buffer is the last packet of a video frame.

TIME_UNKNOWN

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

SEQUENCE_UNKNOWN

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

Buffer

public Buffer()
Method Detail

getFormat

public Format getFormat()
Get the Format of the data in this Buffer.

setFormat

public void setFormat(Format format)
Sets the Format of the data in this Buffer.
Parameters:
format - The Format of the data.

getFlags

public int getFlags()
Gets the mask of the flags set for this Buffer. The integer value of the mask is equal to the logical sum of the flags that are 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)
Sets the flag mask for this Buffer. The integer value of the mask is equal to the logical sum of the flags that are 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()
Checks whether or not this Buffer marks the end of the media stream. Even it isEOM returns true, the Buffer might still contain valid data--check the length of the Buffer.

This method provides a convenient alternative to using getFlags to check the EOM flag.

Returns:
true if the EOM flag is enabled, false if it is not.
See Also:
getFlags(), FLAG_EOM

setEOM

public void setEOM(boolean eom)
Sets the EOM flag for this Buffer. If the EOM flag is enabled, this is the last Buffer in the media stream.

This method provides a convenient alternative to using setFlags to enable or disable the EOM flag.

Parameters:
eom - A boolean value that contains the EOM status of the Buffer. Set to true to enable the EOM flag, false to disable the flag.
See Also:
setFlags(int), FLAG_EOM

isDiscard

public boolean isDiscard()
Checks whether or not this Buffer is to be discarded.

This method provides a convenient alternative to using getFlags to check the DISCARD flag.

Returns:
true if the DISCARD flag is enabled, false if it is not.
See Also:
getFlags(), FLAG_DISCARD

setDiscard

public void setDiscard(boolean discard)
Sets the DISCARD flag for this Buffer. If the DISCARD flag is enabled, this Buffer is to be discarded.

This method provides a convenient alternative to using setFlags to enable or disable the DISCARD flag.

Parameters:
discard - A boolean value that contains the DISCARD status of the Buffer. Set to true to enable the EOM flag, false to disable the flag.
See Also:
setFlags(int), FLAG_DISCARD

getData

public java.lang.Object getData()
Gets the internal data object that holds the media chunk contained in this Buffer.
Returns:
The data object that holds the media chunk for this Buffer. It can be an array type (such as byte[]) or any other type of object. Use instanceOf to determine what type it is.
See Also:
data

setData

public void setData(java.lang.Object data)
Sets the internal data object that holds the media chunk.
Parameters:
data - The data object that holds the media data chunk for this Buffer. It can be an array type (such as byte[]) or any other type of object.
See Also:
data

getHeader

public java.lang.Object getHeader()
Gets the header information for the media chunk contained in this Buffer.
Returns:
The object that holds the header information. Use instanceOf to determine what type the header object is.
See Also:
header

setHeader

public void setHeader(java.lang.Object header)
Sets the header information for the media chunk.
Parameters:
header - The header object that holds the media data chunk for this Buffer.
See Also:
header

getLength

public int getLength()
Gets the length of the valid data in this Buffer if the data is held in an array.
Returns:
The length of the valid data in the data array that holds the media chunk for this Buffer.
See Also:
length

setLength

public void setLength(int length)
Sets the length of the valid data stored in this Buffer if the data is held in an array.
Parameters:
length - The length of the valid data in the data array that holds the media chunk for this Buffer.
See Also:
length

getOffset

public int getOffset()
If the media chunk for this Buffer is held in an array, gets the offset into the data array where the valid data begins.

setOffset

public void setOffset(int offset)
If the media chunk for this Buffer is held in an array, sets the offset into the array where the valid data begins.
Parameters:
offset - The starting point for the valid data.
See Also:
offset

getTimeStamp

public long getTimeStamp()
Gets the time stamp of this Buffer.
Returns:
The Buffer time stamp, in nanoseconds.
See Also:
timeStamp

setTimeStamp

public void setTimeStamp(long timeStamp)
Sets the time stamp of this Buffer.
Parameters:
timeStamp - The time stamp for the Buffer, in nanoseconds.
See Also:
timeStamp

getDuration

public long getDuration()
Gets the duration of this Buffer.
Returns:
The Buffer duration, in nanoseconds.
See Also:
duration

setDuration

public void setDuration(long duration)
Sets the duration of this Buffer.
Parameters:
duration - The duration for the Buffer, in nanoseconds.
See Also:
duration

setSequenceNumber

public void setSequenceNumber(long number)
Sets the sequence number of this Buffer. Sequence numbers increase or decrease by 1 for each sequential Buffer, indicating the order in which the data is to be processed. Can be used to identify lost samples of data.
Parameters:
number - The sequence number for the Buffer.
See Also:
sequenceNumber

getSequenceNumber

public long getSequenceNumber()
Gets the sequence number of this Buffer.
Returns:
The sequence number of this Buffer.
See Also:
sequenceNumber

copy

public void copy(Buffer buffer)
Copy the attributes from the specified Buffer into this Buffer
Parameters:
buffer - The input Buffer the copy the attributes from.

clone

public java.lang.Object clone()
Clone a buffer.
Overrides:
clone in class java.lang.Object


Submit a bug or feature
Copyright 1999-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved. See the Specification License for more details.
Sun, Sun Microsystems, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.