FileDocCategorySizeDatePackage
Many2one.javaAPI DocJMF 2.1.1e2473Mon May 12 12:21:02 BST 2003com.ibm.media.codec.audio

Many2one

public class Many2one extends BasicCodec
SimpleCodec is a codec that accepts a chunk of data of any size and generate output data, It buffers samples internally if necessary.

Fields Summary
int
counter
boolean
flagEOM
Format
af
Constructors Summary
Methods Summary
public java.lang.StringgetName()

	return "many frames to one converter";
    
public javax.media.Format[]getSupportedInputFormats()


        
	Format fmt [] = new Format[1];
	fmt[0] = af;
	return fmt;
    
public javax.media.Format[]getSupportedOutputFormats(javax.media.Format in)

	Format fmt [] = new Format[1];
	fmt[0] = af;
	return fmt;
    
public intprocess(javax.media.Buffer inputBuffer, javax.media.Buffer outputBuffer)
process the media from the input buffer to the output buffer



	// System.out.println("in  " + inputBuffer.getLength() );
	// System.out.println("out " + outputBuffer.getLength() );

	if (flagEOM) {
	    outputBuffer.setLength(0);
	    outputBuffer.setEOM(true);

	    flagEOM=false;
	    return BUFFER_PROCESSED_OK;
	}

	if (outputBuffer.isDiscard()) {
	    outputBuffer.setLength(0);
	    outputBuffer.setOffset(0);
	}


	if (inputBuffer.isEOM()) {
	    // 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 ) {
		flagEOM=true;
		return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED ;
	    } else {
		// in case we have nothing in the output, we are done
		outputBuffer.setLength(0);
		outputBuffer.setEOM(true);
		return BUFFER_PROCESSED_OK;
	    }
	}




	if (outputBuffer.getData()==null)
	    outputBuffer.setData(new byte[10000]);


	System.arraycopy(inputBuffer.getData(),inputBuffer.getOffset(),
			 outputBuffer.getData(),outputBuffer.getLength(),
			 inputBuffer.getLength() );

	outputBuffer.setLength(outputBuffer.getLength() + inputBuffer.getLength() );


	if ( (++counter) == 5 ) {
	    counter=0;
	    outputBuffer.setFormat(af );
	    return BUFFER_PROCESSED_OK;

	}


	return BUFFER_PROCESSED_OK | OUTPUT_BUFFER_NOT_FILLED ;