javax.media
类 Buffer

java.lang.Object
  继承者 javax.media.Buffer
直接已知子类:
ExtBuffer

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.

从以下版本开始:
JMF 2.0
另请参见:
PlugIn, PushBufferStream, PullBufferStream

字段摘要
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_BUF_OVERFLOWN
          Indicates that some buffer queue in the data flow path from where this buffer comes from is overflown.
static int FLAG_BUF_UNDERFLOWN
          Indicates that some buffer queue in the data flow path from where this buffer comes from is underflown.
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_LIVE_DATA
          Indicates that the data is arriving from a live (real-time) source.
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_RTP_TIME
          Indicates that the Buffer carries a time stamp that's in RTP (NTP) time units.
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.
 
构造方法摘要
Buffer()
           
 
方法摘要
 java.lang.Object clone()
          Clone a buffer.
 void copy(Buffer buffer)
          Copy the attributes from the specified Buffer into this Buffer
 void copy(Buffer buffer, boolean swapData)
          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.
 
从类 java.lang.Object 继承的方法
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

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.

另请参见:
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_RTP_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.

另请参见:
常量字段值

FLAG_RTP_TIME

public static final int FLAG_RTP_TIME
Indicates that the Buffer carries a time stamp that's in RTP (NTP) time units.

另请参见:
常量字段值

FLAG_BUF_OVERFLOWN

public static final int FLAG_BUF_OVERFLOWN
Indicates that some buffer queue in the data flow path from where this buffer comes from is overflown. When such condition occurs, the processing element should attempt to speed up the procesing of this buffer object to reduce the overflow.

另请参见:
常量字段值

FLAG_BUF_UNDERFLOWN

public static final int FLAG_BUF_UNDERFLOWN
Indicates that some buffer queue in the data flow path from where this buffer comes from is underflown. When such condition occurs, the processing element should attempt to speed up the procesing of this buffer object to reduce the underflow.

另请参见:
常量字段值

FLAG_LIVE_DATA

public static final int FLAG_LIVE_DATA
Indicates that the data is arriving from a live (real-time) source.

另请参见:
常量字段值

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.

另请参见:
常量字段值
构造方法详细信息

Buffer

public Buffer()
方法详细信息

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.

参数:
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.

另请参见:
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.

另请参见:
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.

返回:
true if the EOM flag is enabled, false if it is not.
另请参见:
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.

参数:
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.
另请参见:
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.

返回:
true if the DISCARD flag is enabled, false if it is not.
另请参见:
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.

参数:
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.
另请参见:
setFlags(int), FLAG_DISCARD

getData

public java.lang.Object getData()
Gets the internal data object that holds the media chunk contained in this Buffer.

返回:
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.
另请参见:
data

setData

public void setData(java.lang.Object data)
Sets the internal data object that holds the media chunk.

参数:
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.
另请参见:
data

getHeader

public java.lang.Object getHeader()
Gets the header information for the media chunk contained in this Buffer.

返回:
The object that holds the header information. Use instanceOf to determine what type the header object is.
另请参见:
header

setHeader

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

参数:
header - The header object that holds the media data chunk for this Buffer.
另请参见:
header

getLength

public int getLength()
Gets the length of the valid data in this Buffer if the data is held in an array.

返回:
The length of the valid data in the data array that holds the media chunk for this Buffer.
另请参见:
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.

参数:
length - The length of the valid data in the data array that holds the media chunk for this Buffer.
另请参见:
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.

参数:
offset - The starting point for the valid data.
另请参见:
offset

getTimeStamp

public long getTimeStamp()
Gets the time stamp of this Buffer.

返回:
The Buffer time stamp, in nanoseconds.
另请参见:
timeStamp

setTimeStamp

public void setTimeStamp(long timeStamp)
Sets the time stamp of this Buffer.

参数:
timeStamp - The time stamp for the Buffer, in nanoseconds.
另请参见:
timeStamp

getDuration

public long getDuration()
Gets the duration of this Buffer.

返回:
The Buffer duration, in nanoseconds.
另请参见:
duration

setDuration

public void setDuration(long duration)
Sets the duration of this Buffer.

参数:
duration - The duration for the Buffer, in nanoseconds.
另请参见:
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.

参数:
number - The sequence number for the Buffer.
另请参见:
sequenceNumber

getSequenceNumber

public long getSequenceNumber()
Gets the sequence number of this Buffer.

返回:
The sequence number of this Buffer.
另请参见:
sequenceNumber

copy

public void copy(Buffer buffer)
Copy the attributes from the specified Buffer into this Buffer

参数:
buffer - The input Buffer the copy the attributes from.

copy

public void copy(Buffer buffer,
                 boolean swapData)
Copy the attributes from the specified Buffer into this Buffer. If swapData is true, the data values are swapped between the buffers, otherwise the data value is copied.

参数:
buffer - The input Buffer the copy the attributes from.
swapData - Specifies whether the data objects are to be swapped.

clone

public java.lang.Object clone()
Clone a buffer.

覆盖:
java.lang.Object 中的 clone