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(javax.media.Buffer inputBuffer, javax.media.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(javax.media.Format format)

	return true;
    
protected booleancheckInputBuffer(javax.media.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 javax.media.FormatgetInputFormat()

	return inputFormat;
    
protected javax.media.FormatgetOutputFormat()

	return outputFormat;
    
public javax.media.Format[]getSupportedInputFormats()

	return inputFormats;
    
protected booleanisEOM(javax.media.Buffer inputBuffer)

	return inputBuffer.isEOM();
    
public voidopen()

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

	return 0;
    
protected voidpropagateEOM(javax.media.Buffer outputBuffer)

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

    
public javax.media.FormatsetInputFormat(javax.media.Format input)


        
	inputFormat = input;
	return input;
    
public javax.media.FormatsetOutputFormat(javax.media.Format output)

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

	outputBuffer.setFormat(format);
	outputBuffer.setLength(length);
	outputBuffer.setOffset(offset);
    
protected javax.media.format.RGBFormatupdateRGBFormat(javax.media.format.VideoFormat newFormat, javax.media.format.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;