|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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).
Fields inherited from interface javax.media.PlugIn |
BUFFER_PROCESSED_FAILED,
BUFFER_PROCESSED_OK,
INPUT_BUFFER_NOT_CONSUMED,
OUTPUT_BUFFER_NOT_FILLED,
PLUGIN_TERMINATED |
Method Summary | |
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. |
Methods inherited from interface javax.media.PlugIn |
close,
getName,
open,
reset |
Methods inherited from interface javax.media.Controls |
getControl,
getControls |
Method Detail |
public Format[] getSupportedInputFormats()
Formats
.public 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
.public 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.public 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.public 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |