sl@0: /* sl@0: * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Message handler for G711 decoder interface sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "G711DecoderIntfcMsgHdlr.h" sl@0: #include "G711DecoderIntfcMsgs.h" sl@0: #include sl@0: sl@0: // EXTERNAL DATA STRUCTURES sl@0: sl@0: // EXTERNAL FUNCTION PROTOTYPES sl@0: sl@0: // CONSTANTS sl@0: sl@0: // MACROS sl@0: sl@0: // LOCAL CONSTANTS AND MACROS sl@0: sl@0: // MODULE DATA STRUCTURES sl@0: sl@0: // LOCAL FUNCTION PROTOTYPES sl@0: sl@0: // FORWARD DECLARATIONS sl@0: sl@0: // ============================= LOCAL FUNCTIONS =============================== sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr( sl@0: CG711DecoderIntfc* aG711DecoderIntfcCI) : sl@0: CMMFObject(KUidG711DecoderIntfc) sl@0: { sl@0: iG711DecoderIntfcCI = aG711DecoderIntfcCI; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CG711DecoderIntfcMsgHdlr::ConstructL() sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::NewL sl@0: // Two-phased constructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C CG711DecoderIntfcMsgHdlr* CG711DecoderIntfcMsgHdlr::NewL( sl@0: TAny* aG711DecoderIntfcCI) sl@0: { sl@0: CG711DecoderIntfc* errorConcealmentIntfcCI = sl@0: (CG711DecoderIntfc*)aG711DecoderIntfcCI; sl@0: CG711DecoderIntfcMsgHdlr* self = sl@0: new (ELeave) CG711DecoderIntfcMsgHdlr(errorConcealmentIntfcCI); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: sl@0: return self; sl@0: } sl@0: sl@0: // Destructor sl@0: EXPORT_C CG711DecoderIntfcMsgHdlr::~CG711DecoderIntfcMsgHdlr() sl@0: { sl@0: delete iG711DecoderIntfcCI; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::HandleRequest sl@0: // Handles the messages from the proxy. sl@0: // Calls a subfunction which determines which custom interface to call. sl@0: // A subfunction is used to contain multiple leaving functions for a single sl@0: // trap. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C void CG711DecoderIntfcMsgHdlr::HandleRequest( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: ASSERT(aMessage.Destination().InterfaceId() == KUidG711DecoderIntfc); sl@0: TRAPD(error,DoHandleRequestL(aMessage)); sl@0: if(error) sl@0: { sl@0: aMessage.Complete(error); sl@0: } sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::DoHandleRequestL sl@0: // Determines which custom interface to call. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CG711DecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: switch(aMessage.Function()) sl@0: { sl@0: case EG711dimSetDecoderMode: sl@0: { sl@0: DoSetDecoderModeL(aMessage); sl@0: break; sl@0: } sl@0: case EG711dimSetCng: sl@0: { sl@0: DoSetCngL(aMessage); sl@0: break; sl@0: } sl@0: case EG711dimGetCng: sl@0: { sl@0: DoGetCngL(aMessage); sl@0: break; sl@0: } sl@0: case EG711dimSetPlc: sl@0: { sl@0: DoSetPlcL(aMessage); sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: aMessage.Complete(KErrNotSupported); sl@0: } sl@0: } sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL sl@0: // Handles the message from the proxy and calls the custom interface method. sl@0: // The data passed from the proxy is read from the message and passed to sl@0: // the custom interface. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckgBuf; sl@0: aMessage.ReadData1FromClientL(pckgBuf); sl@0: TInt status = iG711DecoderIntfcCI->SetDecoderMode(pckgBuf()); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::DoSetCngL sl@0: // Handles the message from the proxy and calls the custom interface method. sl@0: // The data passed from the proxy is read from the message and passed to sl@0: // the custom interface. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CG711DecoderIntfcMsgHdlr::DoSetCngL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckgBuf; sl@0: aMessage.ReadData1FromClientL(pckgBuf); sl@0: TInt status = iG711DecoderIntfcCI->SetCng(pckgBuf()); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::DoGetCngL sl@0: // Handles the message from the proxy and calls the custom interface method. sl@0: // The custom interface returns the data requested and this function sl@0: // writes it back to the proxy. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CG711DecoderIntfcMsgHdlr::DoGetCngL(TMMFMessage& aMessage) sl@0: { sl@0: TBool cng; sl@0: TInt status = iG711DecoderIntfcCI->GetCng(cng); sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckgBuf; sl@0: pckgBuf() = cng; sl@0: aMessage.WriteDataToClientL(pckgBuf); sl@0: } sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CG711DecoderIntfcMsgHdlr::DoSetPlcL sl@0: // Handles the message from the proxy and calls the custom interface method. sl@0: // The data passed from the proxy is read from the message and passed to sl@0: // the custom interface. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CG711DecoderIntfcMsgHdlr::DoSetPlcL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckgBuf; sl@0: aMessage.ReadData1FromClientL(pckgBuf); sl@0: TInt status = iG711DecoderIntfcCI->SetPlc(pckgBuf()); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: sl@0: sl@0: // End of File