// -----------------------------------------------------------------------------
// CG711PayloadFormatRead::FillSinkBuffer
// Fill SinkBuffer.
// -----------------------------------------------------------------------------
//
void CG711PayloadFormatRead::FillSinkBufferL()
{
    DP_G711_READ( "CG711PayloadFormatRead::FillSinkBuffer()" );

    CMMFDataBuffer* curFrameBuffer = NULL;
    if ( EBufferOne == iCurrentBuffer )
    {
        curFrameBuffer = iFrameBufferOne;
    }
    else
    {
        curFrameBuffer = iFrameBufferTwo;
    }

    TDes8& curFrameData( curFrameBuffer->Data() );
    curFrameData.SetLength( KVoIPHeaderLength );

    // Put next frame decoded from RTP payload to the framebuffer
    iBufferToReadExists = GetNextFrame( curFrameData );

    // G.711 Gwc expects 2 bytes for dtx-decision
    if ( iCnFrame )
    {
        DP_G711_READ( "CG711PayloadFormatRead::FillSinkBufferL add dtx-header" );

        curFrameData[0] = KVoIPCNFrame;
        curFrameData[1] = 0;
    }
    else
    {
        DP_G711_READ( "CG711PayloadFormatRead::FillSinkBufferL add voice-header" );

        curFrameData[0] = KVoIPAudioFrame;
        curFrameData[1] = 0;
    }

    curFrameBuffer->SetFrameNumber( iRecvHeader.iTimestamp + ( ( iFrameIndex - 1 )
                                    * TUint( iCInfo.iHwFrameTime * KDefaultSampleRateInkHz ) ) );

    DP_G711_READ2( "CG711PayloadFormatRead::FillSinkBuffer - FRAMENUM: %u",
                   curFrameBuffer->FrameNumber() );

    const TInt dataLen( ( iCInfo.iHwFrameTime * KBitsPerByte )
                        + KVoIPHeaderLength );
    curFrameData.SetLength( dataLen );
    curFrameBuffer->SetStatus( EFull );

    DP_G711_READ2( "CG711PayloadFormatRead: Filled framebuffer with buf. size: %d",
                   curFrameBuffer->BufferSize() );

    iStateMachine->ChangeState( EEmptyDataToSink );

    DP_G711_READ( "CG711PayloadFormatRead::FillSinkBuffer - DONE" );
}
/** Verify CMMFBuffer buffer stats
 * Use case: N/A
 * @test Req. under test REQ172.7.25
 */
TVerdict CTestStep_MMF_BASECL_U_0006::DoTestStepL( void )
	 {
	 TVerdict verdict = EPass;
	 CMMFDataBuffer* descriptorBuffer = CMMFDataBuffer::NewL(); //create descriptor buffer

	 //check that the buffer is initially available
	 if (descriptorBuffer->Status() != EAvailable) verdict = EFail;

	 //check we can write to the status - onlt try one option assume if one does the others do -since this
	 //is an enumeration this is a reasonable assumption
	 descriptorBuffer->SetStatus(EFull);
	 if (descriptorBuffer->Status() != EFull) verdict = EFail;

	 delete descriptorBuffer;
	 return verdict;
	 }