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

AudioPacketizer

public abstract class AudioPacketizer extends AudioCodec
Implements an G723 Packetizer.

Fields Summary
protected byte[]
history
protected int
packetSize
protected int
historyLength
protected int
sample_count
Constructors Summary
Methods Summary
public synchronized intprocess(javax.media.Buffer inputBuffer, javax.media.Buffer outputBuffer)


        int inpLength=inputBuffer.getLength();
        int outLength = packetSize;

        byte[] inpData = (byte[]) inputBuffer.getData();
        byte[] outData = validateByteArraySize(outputBuffer, outLength);


        if (inpLength+historyLength>=packetSize) {
            int copyFromHistory=Math.min(historyLength,packetSize);

            System.arraycopy(history, 0, outData, 0 ,copyFromHistory ) ;

            int remainingBytes=packetSize-copyFromHistory;
            System.arraycopy(inpData, inputBuffer.getOffset(), outData,historyLength,remainingBytes) ;

            historyLength -= copyFromHistory;
            inputBuffer.setOffset( inputBuffer.getOffset() + remainingBytes);
            inputBuffer.setLength( inpLength - remainingBytes);
	    
	    // EP: packetizers will not convert time to RTP
	    // units. This will be done in the RTP session manager and thus
	    // processor will use the media times as is.  
            //outputBuffer.setSequenceNumber(currentSeq++);
            //outputBuffer.setTimeStamp(timestamp);
            //timestamp+=sample_count;

            updateOutput(outputBuffer, outputFormat, outLength, 0);

            return INPUT_BUFFER_NOT_CONSUMED ;
        }

        if (inputBuffer.isEOM() ) { // last packet

            System.arraycopy(history, 0, outData, 0 ,historyLength ) ;
            System.arraycopy(inpData, inputBuffer.getOffset(), outData,historyLength,inpLength) ;

	    // EP: packetizers will not convert time to RTP
	    // units. This will be done in the RTP session manager and thus
	    // processor will use the media times as is. 
            //outputBuffer.setSequenceNumber(currentSeq++);
            //outputBuffer.setTimeStamp(timestamp);
            //timestamp+=sample_count;

            updateOutput(outputBuffer, outputFormat, inpLength + historyLength, 0);

            historyLength=0;

            return BUFFER_PROCESSED_OK;
        }

        //save remainder for next time
        System.arraycopy(inpData, inputBuffer.getOffset(), history, historyLength,inpLength) ;
        historyLength += inpLength;
        return OUTPUT_BUFFER_NOT_FILLED ;
    
public voidreset()

        historyLength=0;