www.pudn.com > Full-Duplex_Audio_Example.rar > fullduplexexappui.cpp
/*
* =============================================================================
* Name : FullDuplexExAppUi.cpp
* Part of : FullDuplexEx
* Description : Application Framework | AppUI class implementation
* Version :
*
* Copyright © 2007 Nokia. All rights reserved.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia. All rights are reserved. Copying, including
* reproducing, storing, adapting or translating, any
* or all of this material requires the prior written consent of
* Nokia. This material also contains confidential
* information which may not be disclosed to others without the
* prior written consent of Nokia.
* =============================================================================
*/
// INCLUDE FILES
#include "FullDuplexExAppUi.h"
#include "FullDuplexExContainer.h"
#include "FullDuplexEngine.h"
#include
#include "FullDuplexEx.hrh"
#include
// ================= MEMBER FUNCTIONS =======================
// ----------------------------------------------------------
// CFullDuplexExAppUi::ConstructL()
// 2nd phase constructor
// ----------------------------------------------------------
void CFullDuplexExAppUi::ConstructL()
{
BaseConstructL(EAknEnableSkin);
iAppContainer = CFullDuplexExContainer::NewL(ClientRect());
iAppContainer->SetMopParent(this);
AddToStackL(iAppContainer);
iFDEng = 0;
RestartEngineL();
}
// ----------------------------------------------------
// CFullDuplexExAppUi::~CFullDuplexExAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CFullDuplexExAppUi::~CFullDuplexExAppUi()
{
delete iFDEng;
if (iAppContainer)
{
RemoveFromStack(iAppContainer);
delete iAppContainer;
}
}
void CFullDuplexExAppUi::RestartEngineL(TInt aCodec)
{
if(iFDEng)
{
iFDEng->Stop();
delete iFDEng;
}
iCurrentCodec = aCodec;
TFourCC fourCC;
switch(iCurrentCodec)
{
case EFullDuplexExCodecAMR:
default:
fourCC = TFourCC(' ', 'A', 'M', 'R');
break;
case EFullDuplexExCodecG711:
fourCC = TFourCC('G', '7', '1', '1');
break;
case EFullDuplexExCodecG729:
fourCC = TFourCC('G', '7', '2', '9');
break;
case EFullDuplexExCodeciLBC:
fourCC = TFourCC('I', 'L', 'B', 'C');
break;
}
iAppContainer->SetCodec(fourCC);
iFDEng = CFullDuplexEngine::NewL(iAppContainer, fourCC);
}
// ----------------------------------------------------
// CFullDuplexExAppUi::HandleCommandL
// Menu command handling
// ----------------------------------------------------
//
void CFullDuplexExAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyExit:
case EEikCmdExit:
{
iFDEng->Stop();
Exit();
break;
}
case EFullDuplexExCmdInit:
{
iFDEng->Initialize();
break;
}
case EFullDuplexExCmdStart:
{
iFDEng->StartL();
break;
}
case EFullDuplexExCmdStop:
{
iFDEng->Stop();
break;
}
case EFullDuplexExCodecAMR:
case EFullDuplexExCodecG711:
case EFullDuplexExCodecG729:
case EFullDuplexExCodeciLBC:
{
RestartEngineL(aCommand);
break;
}
default:
break;
}
}
// ----------------------------------------------------
// CFullDuplexExAppUi::DynInitMenuPaneL
// Dynamically initialises a menu pane.
// ----------------------------------------------------
//
void CFullDuplexExAppUi::DynInitMenuPaneL(TInt aResourceId,
CEikMenuPane* aMenuPane)
{
if ( aResourceId == R_FULLDUPLEXEX_MENU )
{
aMenuPane->SetItemDimmed( EFullDuplexExCmdStart, ETrue );
aMenuPane->SetItemDimmed( EFullDuplexExCmdStop, ETrue );
aMenuPane->SetItemDimmed( EFullDuplexExCmdInit, ETrue );
switch (iFDEng->State())
{
case CFullDuplexEngineBase::ENotReady:
// do nothing
break;
case CFullDuplexEngineBase::EReady:
aMenuPane->SetItemDimmed( EFullDuplexExCmdStart, EFalse );
break;
case CFullDuplexEngineBase::EPlaying:
aMenuPane->SetItemDimmed( EFullDuplexExCmdStop, EFalse );
break;
case CFullDuplexEngineBase::ERestartNeeded:
aMenuPane->SetItemDimmed( EFullDuplexExCmdInit, EFalse );
break;
default:
break;
}
}
}
// End of File