private int handleAggregationPacket(Buffer input,Buffer output){
  byte[] bufferData=(byte[])input.getData();
  if (aggregationPositon + 1 >= bufferData.length) {
    aggregationPositon=1;
    output.setDiscard(true);
    return BUFFER_PROCESSED_OK;
  }
  int nalu_size=(((bufferData[aggregationPositon] & 0xff) << 8) | (bufferData[aggregationPositon + 1] & 0xff));
  aggregationPositon+=2;
  if (aggregationPositon + nalu_size > bufferData.length) {
    aggregationPositon=1;
    return BUFFER_PROCESSED_FAILED;
  }
  extractNalUnitHeader(aggregationPositon,input);
  if (mNalUnitHeader.isSingleNalUnitPacket()) {
    byte[] data=new byte[nalu_size];
    System.arraycopy(bufferData,aggregationPositon,data,0,nalu_size);
    aggregationPositon+=nalu_size;
    output.setData(data);
    output.setLength(data.length);
    output.setOffset(0);
    output.setTimeStamp(input.getTimeStamp());
    output.setSequenceNumber(input.getSequenceNumber());
    output.setVideoOrientation(input.getVideoOrientation());
    output.setFormat(input.getFormat());
    output.setFlags(input.getFlags());
    return INPUT_BUFFER_NOT_CONSUMED;
  }
 else {
    aggregationPositon=1;
    return BUFFER_PROCESSED_FAILED;
  }
}

private int handleAggregationPacket ( Buffer input , Buffer output ) { byte [ ] bufferData = ( byte [ ] ) input . getData ( ) ; if ( aggregationPositon + 1 >= bufferData . length ) { aggregationPositon = 1 ; output . setDiscard ( true ) ; return BUFFER_PROCESSED_OK ; } int nalu_size = ( ( ( bufferData [ aggregationPositon ] & 0xff ) << 8 ) | ( bufferData [ aggregationPositon + 1 ] & 0xff ) ) ; aggregationPositon += 2 ; if ( aggregationPositon + nalu_size > bufferData . length ) { aggregationPositon = 1 ; return BUFFER_PROCESSED_FAILED ; } extractNalUnitHeader ( aggregationPositon , input ) ; if ( mNalUnitHeader . isSingleNalUnitPacket ( ) ) { byte [ ] data = new byte [ nalu_size ] ; System . arraycopy ( bufferData , aggregationPositon , data , 0 , nalu_size ) ; aggregationPositon += nalu_size ; output . setData ( data ) ; output . setLength ( data . length ) ; output . setOffset ( 0 ) ; output . setTimeStamp ( input . getTimeStamp ( ) ) ; output . setSequenceNumber ( input . getSequenceNumber ( ) ) ; output . setVideoOrientation ( input . getVideoOrientation ( ) ) ; output . setFormat ( input . getFormat ( ) ) ; output . setFlags ( input . getFlags ( ) ) ; return INPUT_BUFFER_NOT_CONSUMED ; } else { aggregationPositon = 1 ; return BUFFER_PROCESSED_FAILED ; } }
handle aggregation nal unit packet
