|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | ||||||||
public interface Codec
A Codec is a media processing unit that accepts a Buffer
object as its input, performs some processing on the input data, and then puts the
result in an output Buffer object. It has one input and one output.
Typical examples of codecs include audio decoders, video encoders, and effects.
A codec usually works in one of the following modes:
Buffer and generate
an output Buffer.
This mode is useful when the codec can handle any size of input. A
simple gain codec fits this model: it multiplies each
sample with the gain factor and puts the product in an output Buffer.
Another scenario where this mode is useful is when the codec can only process
data that's in a fixed, pre-determined frame size
and the input Buffer is already packetized accordingly.
One example of such a codec is a GSM audio decoder, which accepts a compressed
GSM audio packet from an RTP depacketizer, decodes the packet, and then puts the result in
an output Buffer.
Buffer.
The codec might consume only part of the input Buffer each time its process
method is called and might not generate an output Buffer during each round of processing.
This mode is useful in stream packetizers, which accept a stream of bytes and divide the stream
into packets (frames) that are used in the next processing phase.
Another scenario where this mode is useful is when two audio processing units that have
incompatible frame sizes need to be chained.
Some restrictions apply to the processing a Codec can perform on its input
and output Buffer objects:
Codec might receive an output Buffer that is not big enough to hold its output data.
In this case, the Codec should allocate a new Buffer for its output data. Codec cannot cache references to Buffer object fields.
It must read all of the parameters from the input and output Buffer objects each time
its process method is called. Codec needs to keep references to a Buffer object's data (for performance reasons),
the Codec must assign other data to the input Buffer object by calling setData
before returning from the process method.
The data assigned can be null, but it is better to assign
some unneeded data to the Buffer, such as input data received earlier.
Such manipulations can be used for in-place processing (where the output of the processing
is put in the same location as input data in order to enhance memory utilization) or for codecs
that need access to more than one frame of data without copying the data (for example, temporal video effects).
| 字段摘要 |
|---|
| 从接口 javax.media.PlugIn 继承的字段 |
|---|
BUFFER_PROCESSED_FAILED, BUFFER_PROCESSED_OK, INPUT_BUFFER_NOT_CONSUMED, OUTPUT_BUFFER_NOT_FILLED, PLUGIN_TERMINATED |
| 方法摘要 | |
|---|---|
Format[] |
getSupportedInputFormats()
Lists all of the input formats that this codec accepts. |
Format[] |
getSupportedOutputFormats(Format input)
Lists the output formats that this codec can generate. |
int |
process(Buffer input,
Buffer output)
Performs the media processing defined by this codec. |
Format |
setInputFormat(Format format)
Sets the format of the data to be input to this codec. |
Format |
setOutputFormat(Format format)
Sets the format for the data this codec outputs. |
| 从接口 javax.media.PlugIn 继承的方法 |
|---|
close, getName, open, reset |
| 从接口 javax.media.Controls 继承的方法 |
|---|
getControl, getControls |
| 方法详细信息 |
|---|
Format[] getSupportedInputFormats()
Formats.Format[] getSupportedOutputFormats(Format input)
input is non-null, this method lists the possible
output formats that can be generated from input data of the specified Format.
If input is null, this method lists
all of the output formats supported by this plug-in.
input - The Format of the data to be used as input to the plug-in.
Formats.Format setInputFormat(Format format)
format - The Format to be set.
Format that was set, which might be the
supported Format that most closely matches the one specified.
Returns null if the specified Format is not supported and
no reasonable match could be found.Format setOutputFormat(Format format)
format - The Format to be set.
Format that was set, which might be the
Format that most closely matched the one specified.
Returns null if the specified Format is not supported and
no reasonable match could be found.
int process(Buffer input,
Buffer output)
input - The Buffer that contains the media data to be processed.output - The Buffer in which to store the processed media data.
BUFFER_PROCESSED_OK if the processing is successful. Other
possible return codes are defined in PlugIn.PlugIn
|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | ||||||||