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 WMA 10 Pro decoder custom interface. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "WmaDecoderIntfcMsgs.h" sl@0: #include "WmaDecoderIntfcMsgHdlr.h" sl@0: //#include "WmaDecoderIntfc.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: // CWmaDecoderIntfcMsgHdlr::CWmaDecoderIntfcMsgHdlr sl@0: // C++ default constructor can NOT contain any code, that might leave. sl@0: //------------------------------------------------------------------------------ sl@0: CWmaDecoderIntfcMsgHdlr::CWmaDecoderIntfcMsgHdlr( sl@0: CWmaDecoderIntfc* aWmaDecoderConfigCI) : sl@0: CMMFObject(KUidWmaDecoderIntfc) sl@0: { sl@0: iWmaDecoderIntfcCI = aWmaDecoderConfigCI; sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::ConstructL() sl@0: { sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // WmaDecoderIntfcMsgHdlr::NewL sl@0: // Two-phased constructor. sl@0: //------------------------------------------------------------------------------ sl@0: EXPORT_C CWmaDecoderIntfcMsgHdlr* CWmaDecoderIntfcMsgHdlr::NewL( sl@0: TAny* aWmaDecoderConfigCI) sl@0: { sl@0: CWmaDecoderIntfc* WmaDecoderConfigCI = sl@0: (CWmaDecoderIntfc*)aWmaDecoderConfigCI; sl@0: CWmaDecoderIntfcMsgHdlr* self = sl@0: new (ELeave) CWmaDecoderIntfcMsgHdlr(WmaDecoderConfigCI); 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: //------------------------------------------------------------------------------ sl@0: // Destructor sl@0: //------------------------------------------------------------------------------ sl@0: EXPORT_C CWmaDecoderIntfcMsgHdlr::~CWmaDecoderIntfcMsgHdlr() sl@0: { sl@0: iSupportedFormats.Close(); sl@0: iSupportedTools.Close(); sl@0: iControllableTools.Close(); sl@0: sl@0: delete iDataCopyBuffer; sl@0: delete iWmaDecoderIntfcCI; sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::HandleRequest sl@0: // Handles the messages from the proxy. sl@0: //------------------------------------------------------------------------------ sl@0: EXPORT_C void CWmaDecoderIntfcMsgHdlr::HandleRequest( sl@0: TMMFMessage& aMessage) sl@0: { sl@0: ASSERT(aMessage.Destination().InterfaceId() == KUidWmaDecoderIntfc); sl@0: sl@0: TRAPD(error, DoHandleRequestL(aMessage)); sl@0: sl@0: if(error) sl@0: { sl@0: aMessage.Complete(error); sl@0: } sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoHandleRequestL sl@0: // Determines which custom interface to call. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: switch(aMessage.Function()) sl@0: { sl@0: case EWmaGetSupportedFormats: sl@0: { sl@0: DoGetSupportedFormatsL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetSupportedTools: sl@0: { sl@0: DoGetSupportedToolsL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetSupportedMaxChannels: sl@0: { sl@0: DoGetSupportedMaxChannelsL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetSupportedMaxBitrate: sl@0: { sl@0: DoGetSupportedMaxBitrateL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetSupportedMaxSampleRate: sl@0: { sl@0: DoGetSupportedMaxSampleRateL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetControllableTools: sl@0: { sl@0: DoGetControllableToolsL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetAllMsg: sl@0: { sl@0: DoGetAllL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaApplyConfig: sl@0: { sl@0: DoApplyConfigL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetNumOfSupportedFormats: sl@0: { sl@0: DoGetNumOfSupportedFormatsL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetNumOfSupportedTools: sl@0: { sl@0: DoGetNumOfSupportedToolsL(aMessage); sl@0: break; sl@0: } sl@0: case EWmaGetNumOfControllableTools: sl@0: { sl@0: DoGetNumOfControllableToolsL(aMessage); sl@0: break; sl@0: } sl@0: sl@0: default: sl@0: { sl@0: aMessage.Complete(KErrNotSupported); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetSupportedFormatsL sl@0: // Get supported formats. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetSupportedFormatsL(TMMFMessage& aMessage) sl@0: { sl@0: if (!iDataCopyBuffer) sl@0: { sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0)); sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetSupportedToolsL sl@0: // Get supported tools. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetSupportedToolsL(TMMFMessage& aMessage) sl@0: { sl@0: if (!iDataCopyBuffer) sl@0: { sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0)); sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxChannelsL sl@0: // Get max number of channels. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxChannelsL(TMMFMessage& aMessage) sl@0: { sl@0: TUint maxChannels = 0; sl@0: TInt status = iWmaDecoderIntfcCI->GetSupportedMaxChannelsIn(maxChannels); sl@0: sl@0: TPckgBuf pckg; sl@0: pckg() = maxChannels; sl@0: aMessage.WriteDataToClientL(pckg); sl@0: sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxBitrateL sl@0: // Get supported max bit rates. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxBitrateL(TMMFMessage& aMessage) sl@0: { sl@0: TUint maxBitrate = 0; sl@0: TInt status = iWmaDecoderIntfcCI->GetSupportedMaxBitrate(maxBitrate); sl@0: sl@0: TPckgBuf pckg; sl@0: pckg() = maxBitrate; sl@0: aMessage.WriteDataToClientL(pckg); sl@0: sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxSampleRateL sl@0: // Get supported max sample rate. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxSampleRateL(TMMFMessage& aMessage) sl@0: { sl@0: TUint maxSamplerate = 0; sl@0: TInt status = iWmaDecoderIntfcCI->GetSupportedMaxSampleRate(maxSamplerate); sl@0: sl@0: TPckgBuf pckg; sl@0: pckg() = maxSamplerate; sl@0: aMessage.WriteDataToClientL(pckg); sl@0: sl@0: aMessage.Complete(status); sl@0: sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetControllableToolsL sl@0: // Get supported controllable tools. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetControllableToolsL(TMMFMessage& aMessage) sl@0: { sl@0: if (!iDataCopyBuffer) sl@0: { sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0)); sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetAllL sl@0: // Get all configure parameters. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetAllL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckg; sl@0: CWmaDecoderIntfc::TFormat format; sl@0: TInt status = iWmaDecoderIntfcCI->GetFormat(format); sl@0: pckg().iCurrentFormat = format; sl@0: pckg().iCurrentFormatStatus = status; sl@0: sl@0: TUint bitsPerSample = 0; sl@0: status = iWmaDecoderIntfcCI->GetBitsPerSampleIn(bitsPerSample); sl@0: pckg().iCurrentBitsPerSample = bitsPerSample; sl@0: pckg().iCurrentBitsPerSampleStatus = status; sl@0: sl@0: TUint numOfChannels = 0; sl@0: status = iWmaDecoderIntfcCI->GetNumOfChannelsIn(numOfChannels); sl@0: pckg().iCurrentNumChannelsIn = numOfChannels; sl@0: pckg().iCurrentNumChannelsInStatus = status; sl@0: sl@0: TUint samplesPerSec = 0; sl@0: status = iWmaDecoderIntfcCI->GetSamplesPerSec (samplesPerSec); sl@0: pckg().iCurrentSamplesPerSec = samplesPerSec; sl@0: pckg().iCurrentSamplesPerSecStatus = status; sl@0: sl@0: TUint avgBytesPerSec = 0; sl@0: status = iWmaDecoderIntfcCI->GetAvgBytesPerSec (avgBytesPerSec); sl@0: pckg().iCurrentAvgBytesPerSec = avgBytesPerSec; sl@0: pckg().iCurrentAvgBytesPerSecStatus = status; sl@0: sl@0: TUint blockAlign = 0; sl@0: status = iWmaDecoderIntfcCI->GetBlockAlign (blockAlign) ; sl@0: pckg().iCurrentBlockAlign = blockAlign; sl@0: pckg().iCurrentBlockAlignStatus = status; sl@0: sl@0: TUint encodeOpts = 0; sl@0: status = iWmaDecoderIntfcCI->GetEncodeOptions (encodeOpts); sl@0: pckg().iCurrentEncodeOptions = encodeOpts; sl@0: pckg().iCurrentEncodeOptionsStatus = status; sl@0: sl@0: TUint encodeOpts1 = 0; sl@0: status = iWmaDecoderIntfcCI->GetEncodeOptions1 (encodeOpts1); sl@0: pckg().iCurrentEncodeOptions1 = encodeOpts1; sl@0: pckg().iCurrentEncodeOptions1Status = status; sl@0: sl@0: TUint encodeOpts2 = 0; sl@0: status = iWmaDecoderIntfcCI->GetEncodeOptions2(encodeOpts2); sl@0: pckg().iCurrentEncodeOptions2 = encodeOpts2; sl@0: pckg().iCurrentEncodeOptions2Status = status; sl@0: sl@0: TUint channelMask = 0; sl@0: status = iWmaDecoderIntfcCI->GetChannelMaskIn (channelMask); sl@0: pckg().iCurrentChannelMask = channelMask; sl@0: pckg().iCurrentChannelMaskStatus = status; sl@0: sl@0: CWmaDecoderIntfc::TTool tool = CWmaDecoderIntfc::EToolOutput32Bit; sl@0: TBool able = EFalse; sl@0: status = iWmaDecoderIntfcCI->GetTool(tool, able); sl@0: pckg().iCurrentToolOutPut32Bit = able; sl@0: pckg().iCurrentToolOutPut32BitStatus = status; sl@0: sl@0: tool = CWmaDecoderIntfc::EDownMixToStereo; sl@0: status = iWmaDecoderIntfcCI->GetTool(tool, able); sl@0: pckg().iCurrentToolDownMixToStereo = able; sl@0: pckg().iCurrentToolDownMixToStereoStatus = status; sl@0: sl@0: tool = CWmaDecoderIntfc::ELostDataConcealment; sl@0: status = iWmaDecoderIntfcCI->GetTool(tool, able); sl@0: pckg().iCurrentToolLostDataConcealment = able; sl@0: pckg().iCurrentToolLostDataConcealmentStatus = status; sl@0: sl@0: aMessage.WriteDataToClientL(pckg); sl@0: sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::DoApplyConfigL sl@0: // Handles the message from the proxy and calls the custom interface method sl@0: // to commit configuration settings to the decoder. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::DoApplyConfigL(TMMFMessage& aMessage) sl@0: { sl@0: TInt status = KErrNone; sl@0: TPckgBuf pckgBuf; sl@0: sl@0: aMessage.ReadData1FromClientL(pckgBuf); sl@0: sl@0: iWmaDecoderIntfcCI->SetFormat(pckgBuf().iFormat); sl@0: iWmaDecoderIntfcCI->SetBitsPerSampleIn(pckgBuf().iBitsPerSample); sl@0: iWmaDecoderIntfcCI->SetNumChannelsIn(pckgBuf().iNumChannelsIn); sl@0: iWmaDecoderIntfcCI->SetSamplesPerSec(pckgBuf().iSamplesPerSec); sl@0: iWmaDecoderIntfcCI->SetAvgBytesPerSec(pckgBuf().iAvgBytesPerSec); sl@0: iWmaDecoderIntfcCI->SetBlockAlign(pckgBuf().iBlockAlign); sl@0: iWmaDecoderIntfcCI->SetEncodeOptions(pckgBuf().iEncodeOptions); sl@0: iWmaDecoderIntfcCI->SetEncodeOptions1(pckgBuf().iEncodeOptions1); sl@0: iWmaDecoderIntfcCI->SetEncodeOptions2(pckgBuf().iEncodeOptions2); sl@0: iWmaDecoderIntfcCI->SetChannelMaskIn(pckgBuf().iChannelMask); sl@0: sl@0: TBool able = pckgBuf().iToolOutPut32Bit; sl@0: if (able) sl@0: { sl@0: iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::EToolOutput32Bit); sl@0: } sl@0: else sl@0: { sl@0: iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::EToolOutput32Bit); sl@0: } sl@0: sl@0: able = pckgBuf().iToolDownMixToStereo; sl@0: if (able) sl@0: { sl@0: iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::EDownMixToStereo); sl@0: } sl@0: else sl@0: { sl@0: iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::EDownMixToStereo); sl@0: } sl@0: sl@0: able = pckgBuf().iToolLostDataConcealment; sl@0: if (able) sl@0: { sl@0: iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::ELostDataConcealment); sl@0: } sl@0: else sl@0: { sl@0: iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::ELostDataConcealment); sl@0: } sl@0: sl@0: status = iWmaDecoderIntfcCI->ApplyConfig(); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: // CWmaDecoderIntfcMsgHdlr::CreateBufFromUintArrayL sl@0: // Utility function used to create a buffer and fill it with data from the sl@0: // array passed in. sl@0: //------------------------------------------------------------------------------ sl@0: void CWmaDecoderIntfcMsgHdlr::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: // CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedFormatsL sl@0: // sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedFormatsL(TMMFMessage& aMessage) sl@0: { sl@0: iSupportedFormats.Reset(); sl@0: TInt status = iWmaDecoderIntfcCI->GetSupportedFormats(iSupportedFormats); sl@0: sl@0: CreateBufFromUintArrayL(reinterpret_cast&>(iSupportedFormats)); sl@0: TPckgBuf pckg; sl@0: pckg() = iSupportedFormats.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedToolsL( sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedToolsL(TMMFMessage& aMessage) sl@0: { sl@0: iSupportedTools.Reset(); sl@0: TInt status = iWmaDecoderIntfcCI->GetSupportedTools(iSupportedTools); sl@0: CreateBufFromUintArrayL(reinterpret_cast&>(iSupportedTools)); sl@0: sl@0: TPckgBuf pckg; sl@0: pckg() = iSupportedTools.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CWmaDecoderIntfcMsgHdlr::DoGetNumOfControllableToolsL sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CWmaDecoderIntfcMsgHdlr::DoGetNumOfControllableToolsL(TMMFMessage& aMessage) sl@0: { sl@0: iControllableTools.Reset(); sl@0: TInt status = iWmaDecoderIntfcCI->GetControllableTools(iControllableTools); sl@0: CreateBufFromUintArrayL(reinterpret_cast&>(iControllableTools)); sl@0: TPckgBuf pckg; sl@0: pckg() = iControllableTools.Count(); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: aMessage.Complete(status); sl@0: } sl@0: sl@0: sl@0: sl@0: // End of File