sl@0: /* sl@0: * Copyright (c) 2006 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 SBC encoder interface. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include "SbcEncoderIntfcMsgHdlr.h" sl@0: #include "SbcEncoderIntfcMsgs.h" 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: * CSbcEncoderIntfcMsgHdlr::CSbcEncoderIntfcMsgHdlr sl@0: * C++ default constructor can NOT contain any code, that might leave. sl@0: */ sl@0: CSbcEncoderIntfcMsgHdlr::CSbcEncoderIntfcMsgHdlr( sl@0: CSbcEncoderIntfc* aSbcEncoderIntfcCI) : sl@0: CMMFObject(KUidSbcEncoderIntfc) sl@0: { sl@0: iSbcEncoderIntfcCI = aSbcEncoderIntfcCI; sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::ConstructL sl@0: * Symbian 2nd phase constructor can leave. sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::ConstructL() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::NewL sl@0: * Two-phased constructor. sl@0: */ sl@0: EXPORT_C CSbcEncoderIntfcMsgHdlr* CSbcEncoderIntfcMsgHdlr::NewL( sl@0: TAny* aSbcEncoderIntfcCI) sl@0: { sl@0: CSbcEncoderIntfc* SbcEncoderIntfcCI = sl@0: (CSbcEncoderIntfc*)aSbcEncoderIntfcCI; sl@0: CSbcEncoderIntfcMsgHdlr* self = sl@0: new (ELeave) CSbcEncoderIntfcMsgHdlr(SbcEncoderIntfcCI); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: * Destructor sl@0: */ sl@0: EXPORT_C CSbcEncoderIntfcMsgHdlr::~CSbcEncoderIntfcMsgHdlr() sl@0: { sl@0: delete iDataCopyBuffer; sl@0: delete iSbcEncoderIntfcCI; sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::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 sl@0: * single trap. sl@0: * (other items were commented in a header). sl@0: */ sl@0: EXPORT_C void CSbcEncoderIntfcMsgHdlr::HandleRequest(TMMFMessage& aMessage) sl@0: { sl@0: // debug panic sl@0: ASSERT(aMessage.Destination().InterfaceId() == KUidSbcEncoderIntfc); 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: * CSbcEncoderIntfcMsgHdlr::DoHandleRequestL sl@0: * Determines which custom interface to call. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: switch(aMessage.Function()) sl@0: { sl@0: case ESbceimGetNumOfSupportedSamplingFrequencies: sl@0: { sl@0: DoGetNumOfSupportedSamplingFrequenciesL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetSupportedSamplingFrequencies: sl@0: { sl@0: DoGetSupportedSamplingFrequenciesL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetNumOfSupportedChannelModes: sl@0: { sl@0: DoGetNumOfSupportedChannelModesL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetSupportedChannelModes: sl@0: { sl@0: DoGetSupportedChannelModesL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetNumOfSupportedNumOfSubbands: sl@0: { sl@0: DoGetNumOfSupportedNumOfSubbandsL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetSupportedNumOfSubbands: sl@0: { sl@0: DoGetSupportedNumOfSubbandsL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetNumOfSupportedBlocks: sl@0: { sl@0: DoGetNumOfSupportedBlocksL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetSupportedBlocks: sl@0: { sl@0: DoGetSupportedBlocksL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetNumOfSupportedAllocationMethods: sl@0: { sl@0: DoGetNumOfSupportedAllocationMethodsL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetSupportedAllocationMethods: sl@0: { sl@0: DoGetSupportedAllocationMethodsL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimGetSupportedBitpoolRange: sl@0: { sl@0: DoGetSupportedBitpoolRangeL(aMessage); sl@0: break; sl@0: } sl@0: case ESbceimApplyConfig: sl@0: { sl@0: DoApplyConfigL(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: * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedSamplingFrequenciesL 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 writes sl@0: * it back to the proxy. It also creates a buffer and fills the sampling sl@0: * frequencies data to be returned in the subsequent call to sl@0: * DoGetSupportedSamplingFrequenciesL(). sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedSamplingFrequenciesL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: RArray supSamplingFrequencies; sl@0: CleanupClosePushL(supSamplingFrequencies); sl@0: sl@0: TInt status = iSbcEncoderIntfcCI->GetSupportedSamplingFrequencies( sl@0: supSamplingFrequencies); sl@0: sl@0: // store array in iDataCopyBuffer sl@0: CreateBufFromUintArrayL(supSamplingFrequencies); sl@0: sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = supSamplingFrequencies.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&supSamplingFrequencies); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetSupportedSamplingFrequenciesL sl@0: * Sends the sampling frequency data returned from the custom interface sl@0: * implementation to the client. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetSupportedSamplingFrequenciesL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: SendDataBufferToClientL(aMessage); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedChannelModesL 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 writes sl@0: * it back to the proxy. It also creates a buffer and fills the sampling sl@0: * frequencies data to be returned in the subsequent call to sl@0: * DoGetSupportedChannelModesL(). sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedChannelModesL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: RArray supChannelModes; sl@0: CleanupClosePushL(supChannelModes); sl@0: TInt status = sl@0: iSbcEncoderIntfcCI->GetSupportedChannelModes(supChannelModes); sl@0: sl@0: // store array in iDataCopyBuffer sl@0: CreateBufFromUintArrayL(reinterpret_cast&>(supChannelModes)); sl@0: sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = supChannelModes.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&supChannelModes); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetSupportedChannelModesL sl@0: * Sends the channel modes data returned from the custom interface sl@0: * implementation to the client. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetSupportedChannelModesL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: SendDataBufferToClientL(aMessage); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedBlocksL 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 writes sl@0: * it back to the proxy. It also creates a buffer and fills the supported sl@0: * blocks data to be returned in the subsequent call to sl@0: * DoGetSupportedBlocksL(). sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedBlocksL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: RArray supNumBlocks; sl@0: CleanupClosePushL(supNumBlocks); sl@0: sl@0: TInt status = iSbcEncoderIntfcCI->GetSupportedNumOfBlocks(supNumBlocks); sl@0: sl@0: CreateBufFromUintArrayL(supNumBlocks); sl@0: sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = supNumBlocks.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&supNumBlocks); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetSupportedBlocksL sl@0: * Sends the supported blocks data returned from the custom interface sl@0: * implementation to the client. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetSupportedBlocksL(TMMFMessage& aMessage) sl@0: { sl@0: SendDataBufferToClientL(aMessage); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedNumOfSubbandsL 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 writes sl@0: * it back to the proxy. It also creates a buffer and fills the supported sl@0: * subbands data to be returned in the subsequent call to sl@0: * DoGetSupportedNumOfSubbandsL(). sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedNumOfSubbandsL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: RArray supNumSubbands; sl@0: CleanupClosePushL(supNumSubbands); sl@0: sl@0: TInt status = iSbcEncoderIntfcCI->GetSupportedNumOfSubbands(supNumSubbands); sl@0: sl@0: CreateBufFromUintArrayL(supNumSubbands); sl@0: sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = supNumSubbands.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&supNumSubbands); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetSupportedNumOfSubbandsL sl@0: * Sends the supported subbands data returned from the custom interface sl@0: * implementation to the client. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetSupportedNumOfSubbandsL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: SendDataBufferToClientL(aMessage); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedAllocationMethodsL 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 writes sl@0: * it back to the proxy. It also creates a buffer and fills the supported sl@0: * allocation methods data to be returned in the subsequent call to sl@0: * DoGetSupportedAllocationMethodsL(). sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedAllocationMethodsL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: RArray supAllocMethods; sl@0: CleanupClosePushL(supAllocMethods); sl@0: sl@0: TInt status = sl@0: iSbcEncoderIntfcCI->GetSupportedAllocationMethods(supAllocMethods); sl@0: sl@0: // store array in iDataCopyBuffer sl@0: CreateBufFromUintArrayL(reinterpret_cast&>(supAllocMethods)); sl@0: sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = supAllocMethods.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&supAllocMethods); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetSupportedAllocationMethodsL sl@0: * Sends the supported allocation methods data returned from the custom sl@0: * interface implementation to the client. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetSupportedAllocationMethodsL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: SendDataBufferToClientL(aMessage); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoGetSupportedBitpoolRangeL sl@0: * Handles the message from the proxy and calls the custom interface. sl@0: * The custom interface returns the requested bitpool range and this function sl@0: * writes it back to the proxy. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoGetSupportedBitpoolRangeL( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: TSbcEncoderBitpoolRange bitPoolRange; sl@0: bitPoolRange.iMinSupportedBitpoolSize = 0; sl@0: bitPoolRange.iMaxSupportedBitpoolSize = 0; sl@0: sl@0: TInt status = iSbcEncoderIntfcCI->GetSupportedBitpoolRange( sl@0: bitPoolRange.iMinSupportedBitpoolSize, sl@0: bitPoolRange.iMaxSupportedBitpoolSize); sl@0: sl@0: if (status == KErrNone) sl@0: { sl@0: TPckgBuf pckg; sl@0: pckg() = bitPoolRange; sl@0: aMessage.WriteDataToClientL(pckg); sl@0: } sl@0: sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::DoApplyConfigL sl@0: * Handles the message from the proxy to commit configuration settings and sl@0: * calls the custom interface method. The data passed from the proxy is read sl@0: * from the message and passed to the custom interface. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::DoApplyConfigL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckgBuf; sl@0: aMessage.ReadData1FromClientL(pckgBuf); sl@0: sl@0: iSbcEncoderIntfcCI->SetSamplingFrequency(pckgBuf().iSamplingFrequency); sl@0: iSbcEncoderIntfcCI->SetChannelMode(pckgBuf().iChannelMode); sl@0: iSbcEncoderIntfcCI->SetNumOfSubbands(pckgBuf().iNumOfSubbands); sl@0: iSbcEncoderIntfcCI->SetNumOfBlocks(pckgBuf().iNumOfBlocks); sl@0: iSbcEncoderIntfcCI->SetAllocationMethod(pckgBuf().iAllocationMethod); sl@0: iSbcEncoderIntfcCI->SetBitpoolSize(pckgBuf().iBitpoolSize); sl@0: sl@0: TInt status = iSbcEncoderIntfcCI->ApplyConfig(); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::CreateBufFromUintArrayL sl@0: * Utility function used to create a buffer and fill it with data from the sl@0: * array passed in. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::CreateBufFromUintArrayL(RArray& aArray) sl@0: { sl@0: delete iDataCopyBuffer; sl@0: iDataCopyBuffer = NULL; sl@0: iDataCopyBuffer = CBufFlat::NewL(8); sl@0: sl@0: RBufWriteStream stream; sl@0: stream.Open(*iDataCopyBuffer); sl@0: CleanupClosePushL(stream); sl@0: sl@0: for (TInt i = 0; i < aArray.Count(); i++) sl@0: { sl@0: stream.WriteUint32L(aArray[i]); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&stream); sl@0: } sl@0: sl@0: /** sl@0: * CSbcEncoderIntfcMsgHdlr::SendDataBufferToClientL sl@0: * Sends message with requested configuration data back to the client. sl@0: * (other items were commented in a header). sl@0: */ sl@0: void CSbcEncoderIntfcMsgHdlr::SendDataBufferToClientL(TMMFMessage& aMessage) sl@0: { sl@0: if (!iDataCopyBuffer) sl@0: { sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: sl@0: aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0)); sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: sl@0: // ========================== OTHER EXPORTED FUNCTIONS ========================= sl@0: sl@0: // End of File