FileDocCategorySizeDatePackage
BasicCodec.javaAPI DocJMF 2.1.1e3586Mon May 12 12:20:48 BST 2003com.sun.media

BasicCodec

public abstract class BasicCodec extends BasicPlugIn implements Codec

Fields Summary
private static final boolean
DEBUG
protected Format
inputFormat
protected Format
outputFormat
protected boolean
opened
protected Format[]
inputFormats
protected Format[]
outputFormats
protected boolean
pendingEOM
Constructors Summary
Methods Summary
protected intcheckEOM(Buffer inputBuffer, Buffer outputBuffer)


        processAtEOM(inputBuffer,outputBuffer); // process tail of input

        // this is a little tricky since we have to output two frames now:
        // one to close former session, another to signle EOM
        if (outputBuffer.getLength() > 0 ) {
	    pendingEOM=true;
	    return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED ;
        } else {
	    // in case we have nothing in the output, we are done
	    propagateEOM(outputBuffer);
	    return BUFFER_PROCESSED_OK;
        }
    
protected booleancheckFormat(Format format)

	return true;
    
protected booleancheckInputBuffer(Buffer inputBuffer)

	boolean fError= !isEOM(inputBuffer) &&
	                (inputBuffer == null || inputBuffer.getFormat() == null ||
			 !checkFormat(inputBuffer.getFormat()) );

	if (DEBUG)
	    if (fError)
		System.out.println(getClass().getName()+" : [error] checkInputBuffer");

	return !fError;

    
public voidclose()

	opened = false;
    
protected intgetArrayElementSize(java.lang.Class type)

	if (type == Format.intArray)
	    return 4;
	else if (type == Format.shortArray)
	    return 2;
	else if (type == Format.byteArray)
	    return 1;
	else
	    return 0;
    
protected FormatgetInputFormat()

	return inputFormat;
    
protected FormatgetOutputFormat()

	return outputFormat;
    
public Format[]getSupportedInputFormats()

	return inputFormats;
    
protected booleanisEOM(Buffer inputBuffer)

	return inputBuffer.isEOM();
    
public voidopen()

	opened = true;
    
protected intprocessAtEOM(Buffer inputBuffer, Buffer outputBuffer)

	return 0;
    
protected voidpropagateEOM(Buffer outputBuffer)

	updateOutput(outputBuffer, getOutputFormat(), 0, 0);
	outputBuffer.setEOM(true);
    
public voidreset()

    
public FormatsetInputFormat(Format input)


        
	inputFormat = input;
	return input;
    
public FormatsetOutputFormat(Format output)

	outputFormat = output;
	return output;
    
protected voidupdateOutput(Buffer outputBuffer, Format format, int length, int offset)

	outputBuffer.setFormat(format);
	outputBuffer.setLength(length);
	outputBuffer.setOffset(offset);
    
protected RGBFormatupdateRGBFormat(VideoFormat newFormat, RGBFormat outputFormat)

	Dimension size = newFormat.getSize();
	RGBFormat oldFormat = (RGBFormat) outputFormat;
	int lineStride = size.width * oldFormat.getPixelStride();
	RGBFormat newRGB = new RGBFormat(size,
					 lineStride * size.height,
					 oldFormat.getDataType(),
					 newFormat.getFrameRate(),
					 oldFormat.getBitsPerPixel(),
					 oldFormat.getRedMask(),
					 oldFormat.getGreenMask(),
					 oldFormat.getBlueMask(),
					 oldFormat.getPixelStride(),
					 lineStride,
					 oldFormat.getFlipped(),
					 oldFormat.getEndian()
					 );
	return newRGB;