public abstract class SimpleDecoder<I extends InputBuffer,O extends OutputBuffer,E extends Exception> extends Thread implements Decoder<I,O,E>
Decoders that use their own decode thread.| Modifier and Type | Class and Description |
|---|---|
static interface |
SimpleDecoder.EventListener<E>
Listener for
SimpleDecoder events. |
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Modifier | Constructor and Description |
|---|---|
protected |
SimpleDecoder(I[] inputBuffers,
O[] outputBuffers) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract I |
createInputBuffer()
Creates a new input buffer.
|
protected abstract O |
createOutputBuffer()
Creates a new output buffer.
|
protected abstract E |
decode(I inputBuffer,
O outputBuffer,
boolean reset)
Decodes the
inputBuffer and stores any decoded output in outputBuffer. |
I |
dequeueInputBuffer()
Dequeues the next input buffer to be filled and queued to the decoder.
|
O |
dequeueOutputBuffer()
Dequeues the next output buffer from the decoder.
|
void |
flush()
Flushes input/output buffers that have not been dequeued yet and returns ownership of any
dequeued input buffer to the decoder.
|
void |
queueInputBuffer(I inputBuffer)
Queues an input buffer to the decoder.
|
void |
release()
Releases the decoder.
|
protected void |
releaseOutputBuffer(O outputBuffer)
Releases an output buffer back to the decoder.
|
void |
run() |
protected void |
setInitialInputBufferSize(int size)
Sets the initial size of each input buffer.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected final void setInitialInputBufferSize(int size)
This method should only be called before the decoder is used (i.e. before the first call to
dequeueInputBuffer().
size - The required input buffer size.public final I dequeueInputBuffer() throws E extends Exception
DecoderdequeueInputBuffer in interface Decoder<I extends InputBuffer,O extends OutputBuffer,E extends Exception>E - If a decoder error has occurred.E extends Exceptionpublic final void queueInputBuffer(I inputBuffer) throws E extends Exception
DecoderqueueInputBuffer in interface Decoder<I extends InputBuffer,O extends OutputBuffer,E extends Exception>inputBuffer - The input buffer.E - If a decoder error has occurred.E extends Exceptionpublic final O dequeueOutputBuffer() throws E extends Exception
DecoderdequeueOutputBuffer in interface Decoder<I extends InputBuffer,O extends OutputBuffer,E extends Exception>E - If a decoder error has occurred.E extends Exceptionprotected void releaseOutputBuffer(O outputBuffer)
outputBuffer - The output buffer being released.public final void flush()
Decoderflush in interface Decoder<I extends InputBuffer,O extends OutputBuffer,E extends Exception>public void release()
Decoderrelease in interface Decoder<I extends InputBuffer,O extends OutputBuffer,E extends Exception>protected abstract I createInputBuffer()
protected abstract O createOutputBuffer()
protected abstract E decode(I inputBuffer, O outputBuffer, boolean reset)
inputBuffer and stores any decoded output in outputBuffer.inputBuffer - The buffer to decode.outputBuffer - The output buffer to store decoded data. The flag
Buffer.FLAG_DECODE_ONLY will be set if the same flag is set on inputBuffer,
but the decoder may set/unset the flag if required. If the flag is set after this method
returns, any output should not be presented.reset - True if the decoder must be reset before decoding.