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 speech encoder configuration interface sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "SpeechEncoderConfigMsgHdlr.h" sl@0: #include "SpeechEncoderConfigMsgs.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: // CSpeechEncoderConfigMsgHdlr::CSpeechEncoderConfigMsgHdlr sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CSpeechEncoderConfigMsgHdlr::CSpeechEncoderConfigMsgHdlr( sl@0: CSpeechEncoderConfig* aSpeechEncoderConfigCI) : sl@0: CMMFObject(KUidSpeechEncoderConfig) sl@0: { sl@0: iSpeechEncoderConfigCI = aSpeechEncoderConfigCI; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CSpeechEncoderConfigMsgHdlr::ConstructL() sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::NewL sl@0: // Two-phased constructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C CSpeechEncoderConfigMsgHdlr* CSpeechEncoderConfigMsgHdlr::NewL( sl@0: TAny* aSpeechEncoderConfigCI) sl@0: { sl@0: CSpeechEncoderConfig* speechEncoderConfigCI = sl@0: (CSpeechEncoderConfig*)aSpeechEncoderConfigCI; sl@0: CSpeechEncoderConfigMsgHdlr* self = sl@0: new (ELeave) CSpeechEncoderConfigMsgHdlr(speechEncoderConfigCI); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: return self; sl@0: } sl@0: sl@0: // Destructor sl@0: EXPORT_C CSpeechEncoderConfigMsgHdlr::~CSpeechEncoderConfigMsgHdlr() sl@0: { sl@0: iSupportedBitrates.Close(); sl@0: delete iDataCopyBuffer; sl@0: delete iSpeechEncoderConfigCI; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::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 CSpeechEncoderConfigMsgHdlr::HandleRequest(TMMFMessage& aMessage) sl@0: { sl@0: // debug panic sl@0: ASSERT(aMessage.Destination().InterfaceId() == KUidSpeechEncoderConfig); 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: // CSpeechEncoderConfigMsgHdlr::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 CSpeechEncoderConfigMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: switch(aMessage.Function()) sl@0: { sl@0: case ESecmGetNumOfSupportedBitrates: sl@0: { sl@0: DoGetNumOfSupportedBitratesL(aMessage); sl@0: break; sl@0: } sl@0: case ESecmGetSupportedBitrates: sl@0: { sl@0: DoGetSupportedBitratesL(aMessage); sl@0: break; sl@0: } sl@0: case ESecmSetBitrate: sl@0: { sl@0: DoSetBitrateL(aMessage); sl@0: break; sl@0: } sl@0: case ESecmGetBitrate: sl@0: { sl@0: DoGetBitrateL(aMessage); sl@0: break; sl@0: } sl@0: case ESecmSetVadMode: sl@0: { sl@0: DoSetVadModeL(aMessage); sl@0: break; sl@0: } sl@0: case ESecmGetVadMode: sl@0: { sl@0: DoGetVadModeL(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: // CSpeechEncoderConfigMsgHdlr::DoGetNumOfSupportedBitratesL sl@0: // Handles the message from the proxy and calls the custom interface. sl@0: // The custom interface returns the data requested and this function sl@0: // writes it back to the proxy. It also creates a buffer and fills sl@0: // it with the bitrate data to be returned in the subsequent call sl@0: // of DoGetSupportedBitratesL(). sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CSpeechEncoderConfigMsgHdlr::DoGetNumOfSupportedBitratesL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: iSupportedBitrates.Reset(); sl@0: TInt status = iSpeechEncoderConfigCI->GetSupportedBitrates( sl@0: iSupportedBitrates); sl@0: CreateBufFromUintArrayL(iSupportedBitrates); sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = iSupportedBitrates.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::CreateBufFromUintArrayL sl@0: // Utility function used to create a buffer a fill it with data from the array sl@0: // passed in. sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CSpeechEncoderConfigMsgHdlr::CreateBufFromUintArrayL(RArray& aArray) sl@0: { sl@0: delete iDataCopyBuffer; sl@0: iDataCopyBuffer = NULL; sl@0: sl@0: iDataCopyBuffer = CBufFlat::NewL(8); sl@0: RBufWriteStream stream; sl@0: stream.Open(*iDataCopyBuffer); sl@0: CleanupClosePushL(stream); sl@0: for (TInt i=0;iPtr(0)); sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::DoSetBitrateL 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 CSpeechEncoderConfigMsgHdlr::DoSetBitrateL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: TInt status = iSpeechEncoderConfigCI->SetBitrate(pckg()); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::DoGetBitrateL sl@0: // Handles the message from the proxy and calls the custom interface. 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 CSpeechEncoderConfigMsgHdlr::DoGetBitrateL(TMMFMessage& aMessage) sl@0: { sl@0: TUint bitrate; sl@0: TInt status = iSpeechEncoderConfigCI->GetBitrate(bitrate); sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = bitrate; sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::DoSetVadModeL 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 CSpeechEncoderConfigMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckg; sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: TInt status = iSpeechEncoderConfigCI->SetVadMode(pckg()); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CSpeechEncoderConfigMsgHdlr::DoGetVadModeL sl@0: // Handles the message from the proxy and calls the custom interface. 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 CSpeechEncoderConfigMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage) sl@0: { sl@0: TBool vadMode; sl@0: TInt status = iSpeechEncoderConfigCI->GetVadMode(vadMode); sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = vadMode; sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: sl@0: sl@0: // End of File