os/mm/devsoundextensions/mmfcustominterfaces/WmaDecoderIntfc/WmaDecoderIntfcMsgHdlr/src/WmaDecoderIntfcMsgHdlr.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/mmfcustominterfaces/WmaDecoderIntfc/WmaDecoderIntfcMsgHdlr/src/WmaDecoderIntfcMsgHdlr.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,485 @@
1.4 +/*
1.5 +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: Message handler for WMA 10 Pro decoder custom interface.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include "WmaDecoderIntfcMsgs.h"
1.25 +#include "WmaDecoderIntfcMsgHdlr.h"
1.26 +//#include "WmaDecoderIntfc.h"
1.27 +
1.28 +// EXTERNAL DATA STRUCTURES
1.29 +
1.30 +// EXTERNAL FUNCTION PROTOTYPES
1.31 +
1.32 +// CONSTANTS
1.33 +
1.34 +// MACROS
1.35 +
1.36 +// LOCAL CONSTANTS AND MACROS
1.37 +
1.38 +// MODULE DATA STRUCTURES
1.39 +
1.40 +// LOCAL FUNCTION PROTOTYPES
1.41 +
1.42 +// FORWARD DECLARATIONS
1.43 +
1.44 +// ============================= LOCAL FUNCTIONS ===============================
1.45 +
1.46 +// ============================ MEMBER FUNCTIONS ===============================
1.47 +
1.48 +//------------------------------------------------------------------------------
1.49 +// CWmaDecoderIntfcMsgHdlr::CWmaDecoderIntfcMsgHdlr
1.50 +// C++ default constructor can NOT contain any code, that might leave.
1.51 +//------------------------------------------------------------------------------
1.52 +CWmaDecoderIntfcMsgHdlr::CWmaDecoderIntfcMsgHdlr(
1.53 + CWmaDecoderIntfc* aWmaDecoderConfigCI) :
1.54 + CMMFObject(KUidWmaDecoderIntfc)
1.55 + {
1.56 + iWmaDecoderIntfcCI = aWmaDecoderConfigCI;
1.57 + }
1.58 +
1.59 +//------------------------------------------------------------------------------
1.60 +// CWmaDecoderIntfcMsgHdlr::ConstructL
1.61 +// Symbian 2nd phase constructor can leave.
1.62 +//------------------------------------------------------------------------------
1.63 +void CWmaDecoderIntfcMsgHdlr::ConstructL()
1.64 + {
1.65 + }
1.66 +
1.67 +//------------------------------------------------------------------------------
1.68 +// WmaDecoderIntfcMsgHdlr::NewL
1.69 +// Two-phased constructor.
1.70 +//------------------------------------------------------------------------------
1.71 +EXPORT_C CWmaDecoderIntfcMsgHdlr* CWmaDecoderIntfcMsgHdlr::NewL(
1.72 + TAny* aWmaDecoderConfigCI)
1.73 + {
1.74 + CWmaDecoderIntfc* WmaDecoderConfigCI =
1.75 + (CWmaDecoderIntfc*)aWmaDecoderConfigCI;
1.76 + CWmaDecoderIntfcMsgHdlr* self =
1.77 + new (ELeave) CWmaDecoderIntfcMsgHdlr(WmaDecoderConfigCI);
1.78 + CleanupStack::PushL( self );
1.79 + self->ConstructL();
1.80 + CleanupStack::Pop( self );
1.81 +
1.82 + return self;
1.83 + }
1.84 +
1.85 +//------------------------------------------------------------------------------
1.86 +// Destructor
1.87 +//------------------------------------------------------------------------------
1.88 +EXPORT_C CWmaDecoderIntfcMsgHdlr::~CWmaDecoderIntfcMsgHdlr()
1.89 + {
1.90 + iSupportedFormats.Close();
1.91 + iSupportedTools.Close();
1.92 + iControllableTools.Close();
1.93 +
1.94 + delete iDataCopyBuffer;
1.95 + delete iWmaDecoderIntfcCI;
1.96 + }
1.97 +
1.98 +//------------------------------------------------------------------------------
1.99 +// CWmaDecoderIntfcMsgHdlr::HandleRequest
1.100 +// Handles the messages from the proxy.
1.101 +//------------------------------------------------------------------------------
1.102 +EXPORT_C void CWmaDecoderIntfcMsgHdlr::HandleRequest(
1.103 + TMMFMessage& aMessage)
1.104 + {
1.105 + ASSERT(aMessage.Destination().InterfaceId() == KUidWmaDecoderIntfc);
1.106 +
1.107 + TRAPD(error, DoHandleRequestL(aMessage));
1.108 +
1.109 + if(error)
1.110 + {
1.111 + aMessage.Complete(error);
1.112 + }
1.113 + }
1.114 +
1.115 +//------------------------------------------------------------------------------
1.116 +// CWmaDecoderIntfcMsgHdlr::DoHandleRequestL
1.117 +// Determines which custom interface to call.
1.118 +//------------------------------------------------------------------------------
1.119 +void CWmaDecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
1.120 + {
1.121 + switch(aMessage.Function())
1.122 + {
1.123 + case EWmaGetSupportedFormats:
1.124 + {
1.125 + DoGetSupportedFormatsL(aMessage);
1.126 + break;
1.127 + }
1.128 + case EWmaGetSupportedTools:
1.129 + {
1.130 + DoGetSupportedToolsL(aMessage);
1.131 + break;
1.132 + }
1.133 + case EWmaGetSupportedMaxChannels:
1.134 + {
1.135 + DoGetSupportedMaxChannelsL(aMessage);
1.136 + break;
1.137 + }
1.138 + case EWmaGetSupportedMaxBitrate:
1.139 + {
1.140 + DoGetSupportedMaxBitrateL(aMessage);
1.141 + break;
1.142 + }
1.143 + case EWmaGetSupportedMaxSampleRate:
1.144 + {
1.145 + DoGetSupportedMaxSampleRateL(aMessage);
1.146 + break;
1.147 + }
1.148 + case EWmaGetControllableTools:
1.149 + {
1.150 + DoGetControllableToolsL(aMessage);
1.151 + break;
1.152 + }
1.153 + case EWmaGetAllMsg:
1.154 + {
1.155 + DoGetAllL(aMessage);
1.156 + break;
1.157 + }
1.158 + case EWmaApplyConfig:
1.159 + {
1.160 + DoApplyConfigL(aMessage);
1.161 + break;
1.162 + }
1.163 + case EWmaGetNumOfSupportedFormats:
1.164 + {
1.165 + DoGetNumOfSupportedFormatsL(aMessage);
1.166 + break;
1.167 + }
1.168 + case EWmaGetNumOfSupportedTools:
1.169 + {
1.170 + DoGetNumOfSupportedToolsL(aMessage);
1.171 + break;
1.172 + }
1.173 + case EWmaGetNumOfControllableTools:
1.174 + {
1.175 + DoGetNumOfControllableToolsL(aMessage);
1.176 + break;
1.177 + }
1.178 +
1.179 + default:
1.180 + {
1.181 + aMessage.Complete(KErrNotSupported);
1.182 + break;
1.183 + }
1.184 + }
1.185 + }
1.186 +
1.187 +//------------------------------------------------------------------------------
1.188 +// CWmaDecoderIntfcMsgHdlr::DoGetSupportedFormatsL
1.189 +// Get supported formats.
1.190 +//------------------------------------------------------------------------------
1.191 +void CWmaDecoderIntfcMsgHdlr::DoGetSupportedFormatsL(TMMFMessage& aMessage)
1.192 + {
1.193 + if (!iDataCopyBuffer)
1.194 + {
1.195 + User::Leave(KErrNotReady);
1.196 + }
1.197 + aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0));
1.198 + aMessage.Complete(KErrNone);
1.199 + }
1.200 +
1.201 +//------------------------------------------------------------------------------
1.202 +// CWmaDecoderIntfcMsgHdlr::DoGetSupportedToolsL
1.203 +// Get supported tools.
1.204 +//------------------------------------------------------------------------------
1.205 +void CWmaDecoderIntfcMsgHdlr::DoGetSupportedToolsL(TMMFMessage& aMessage)
1.206 + {
1.207 + if (!iDataCopyBuffer)
1.208 + {
1.209 + User::Leave(KErrNotReady);
1.210 + }
1.211 + aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0));
1.212 + aMessage.Complete(KErrNone);
1.213 + }
1.214 +
1.215 +//------------------------------------------------------------------------------
1.216 +// CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxChannelsL
1.217 +// Get max number of channels.
1.218 +//------------------------------------------------------------------------------
1.219 +void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxChannelsL(TMMFMessage& aMessage)
1.220 + {
1.221 + TUint maxChannels = 0;
1.222 + TInt status = iWmaDecoderIntfcCI->GetSupportedMaxChannelsIn(maxChannels);
1.223 +
1.224 + TPckgBuf<TUint> pckg;
1.225 + pckg() = maxChannels;
1.226 + aMessage.WriteDataToClientL(pckg);
1.227 +
1.228 + aMessage.Complete(status);
1.229 + }
1.230 +
1.231 +//------------------------------------------------------------------------------
1.232 +// CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxBitrateL
1.233 +// Get supported max bit rates.
1.234 +//------------------------------------------------------------------------------
1.235 +void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxBitrateL(TMMFMessage& aMessage)
1.236 + {
1.237 + TUint maxBitrate = 0;
1.238 + TInt status = iWmaDecoderIntfcCI->GetSupportedMaxBitrate(maxBitrate);
1.239 +
1.240 + TPckgBuf<TUint> pckg;
1.241 + pckg() = maxBitrate;
1.242 + aMessage.WriteDataToClientL(pckg);
1.243 +
1.244 + aMessage.Complete(status);
1.245 + }
1.246 +
1.247 +//------------------------------------------------------------------------------
1.248 +// CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxSampleRateL
1.249 +// Get supported max sample rate.
1.250 +//------------------------------------------------------------------------------
1.251 +void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxSampleRateL(TMMFMessage& aMessage)
1.252 + {
1.253 + TUint maxSamplerate = 0;
1.254 + TInt status = iWmaDecoderIntfcCI->GetSupportedMaxSampleRate(maxSamplerate);
1.255 +
1.256 + TPckgBuf<TUint> pckg;
1.257 + pckg() = maxSamplerate;
1.258 + aMessage.WriteDataToClientL(pckg);
1.259 +
1.260 + aMessage.Complete(status);
1.261 +
1.262 + }
1.263 +
1.264 +//------------------------------------------------------------------------------
1.265 +// CWmaDecoderIntfcMsgHdlr::DoGetControllableToolsL
1.266 +// Get supported controllable tools.
1.267 +//------------------------------------------------------------------------------
1.268 +void CWmaDecoderIntfcMsgHdlr::DoGetControllableToolsL(TMMFMessage& aMessage)
1.269 + {
1.270 + if (!iDataCopyBuffer)
1.271 + {
1.272 + User::Leave(KErrNotReady);
1.273 + }
1.274 + aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0));
1.275 + aMessage.Complete(KErrNone);
1.276 + }
1.277 +
1.278 +//------------------------------------------------------------------------------
1.279 +// CWmaDecoderIntfcMsgHdlr::DoGetAllL
1.280 +// Get all configure parameters.
1.281 +//------------------------------------------------------------------------------
1.282 +void CWmaDecoderIntfcMsgHdlr::DoGetAllL(TMMFMessage& aMessage)
1.283 + {
1.284 + TPckgBuf<TAllParams> pckg;
1.285 + CWmaDecoderIntfc::TFormat format;
1.286 + TInt status = iWmaDecoderIntfcCI->GetFormat(format);
1.287 + pckg().iCurrentFormat = format;
1.288 + pckg().iCurrentFormatStatus = status;
1.289 +
1.290 + TUint bitsPerSample = 0;
1.291 + status = iWmaDecoderIntfcCI->GetBitsPerSampleIn(bitsPerSample);
1.292 + pckg().iCurrentBitsPerSample = bitsPerSample;
1.293 + pckg().iCurrentBitsPerSampleStatus = status;
1.294 +
1.295 + TUint numOfChannels = 0;
1.296 + status = iWmaDecoderIntfcCI->GetNumOfChannelsIn(numOfChannels);
1.297 + pckg().iCurrentNumChannelsIn = numOfChannels;
1.298 + pckg().iCurrentNumChannelsInStatus = status;
1.299 +
1.300 + TUint samplesPerSec = 0;
1.301 + status = iWmaDecoderIntfcCI->GetSamplesPerSec (samplesPerSec);
1.302 + pckg().iCurrentSamplesPerSec = samplesPerSec;
1.303 + pckg().iCurrentSamplesPerSecStatus = status;
1.304 +
1.305 + TUint avgBytesPerSec = 0;
1.306 + status = iWmaDecoderIntfcCI->GetAvgBytesPerSec (avgBytesPerSec);
1.307 + pckg().iCurrentAvgBytesPerSec = avgBytesPerSec;
1.308 + pckg().iCurrentAvgBytesPerSecStatus = status;
1.309 +
1.310 + TUint blockAlign = 0;
1.311 + status = iWmaDecoderIntfcCI->GetBlockAlign (blockAlign) ;
1.312 + pckg().iCurrentBlockAlign = blockAlign;
1.313 + pckg().iCurrentBlockAlignStatus = status;
1.314 +
1.315 + TUint encodeOpts = 0;
1.316 + status = iWmaDecoderIntfcCI->GetEncodeOptions (encodeOpts);
1.317 + pckg().iCurrentEncodeOptions = encodeOpts;
1.318 + pckg().iCurrentEncodeOptionsStatus = status;
1.319 +
1.320 + TUint encodeOpts1 = 0;
1.321 + status = iWmaDecoderIntfcCI->GetEncodeOptions1 (encodeOpts1);
1.322 + pckg().iCurrentEncodeOptions1 = encodeOpts1;
1.323 + pckg().iCurrentEncodeOptions1Status = status;
1.324 +
1.325 + TUint encodeOpts2 = 0;
1.326 + status = iWmaDecoderIntfcCI->GetEncodeOptions2(encodeOpts2);
1.327 + pckg().iCurrentEncodeOptions2 = encodeOpts2;
1.328 + pckg().iCurrentEncodeOptions2Status = status;
1.329 +
1.330 + TUint channelMask = 0;
1.331 + status = iWmaDecoderIntfcCI->GetChannelMaskIn (channelMask);
1.332 + pckg().iCurrentChannelMask = channelMask;
1.333 + pckg().iCurrentChannelMaskStatus = status;
1.334 +
1.335 + CWmaDecoderIntfc::TTool tool = CWmaDecoderIntfc::EToolOutput32Bit;
1.336 + TBool able = EFalse;
1.337 + status = iWmaDecoderIntfcCI->GetTool(tool, able);
1.338 + pckg().iCurrentToolOutPut32Bit = able;
1.339 + pckg().iCurrentToolOutPut32BitStatus = status;
1.340 +
1.341 + tool = CWmaDecoderIntfc::EDownMixToStereo;
1.342 + status = iWmaDecoderIntfcCI->GetTool(tool, able);
1.343 + pckg().iCurrentToolDownMixToStereo = able;
1.344 + pckg().iCurrentToolDownMixToStereoStatus = status;
1.345 +
1.346 + tool = CWmaDecoderIntfc::ELostDataConcealment;
1.347 + status = iWmaDecoderIntfcCI->GetTool(tool, able);
1.348 + pckg().iCurrentToolLostDataConcealment = able;
1.349 + pckg().iCurrentToolLostDataConcealmentStatus = status;
1.350 +
1.351 + aMessage.WriteDataToClientL(pckg);
1.352 +
1.353 + aMessage.Complete(KErrNone);
1.354 + }
1.355 +
1.356 +
1.357 +//------------------------------------------------------------------------------
1.358 +// CWmaDecoderIntfcMsgHdlr::DoApplyConfigL
1.359 +// Handles the message from the proxy and calls the custom interface method
1.360 +// to commit configuration settings to the decoder.
1.361 +//------------------------------------------------------------------------------
1.362 +void CWmaDecoderIntfcMsgHdlr::DoApplyConfigL(TMMFMessage& aMessage)
1.363 + {
1.364 + TInt status = KErrNone;
1.365 + TPckgBuf<TWmaDecoderConfig> pckgBuf;
1.366 +
1.367 + aMessage.ReadData1FromClientL(pckgBuf);
1.368 +
1.369 + iWmaDecoderIntfcCI->SetFormat(pckgBuf().iFormat);
1.370 + iWmaDecoderIntfcCI->SetBitsPerSampleIn(pckgBuf().iBitsPerSample);
1.371 + iWmaDecoderIntfcCI->SetNumChannelsIn(pckgBuf().iNumChannelsIn);
1.372 + iWmaDecoderIntfcCI->SetSamplesPerSec(pckgBuf().iSamplesPerSec);
1.373 + iWmaDecoderIntfcCI->SetAvgBytesPerSec(pckgBuf().iAvgBytesPerSec);
1.374 + iWmaDecoderIntfcCI->SetBlockAlign(pckgBuf().iBlockAlign);
1.375 + iWmaDecoderIntfcCI->SetEncodeOptions(pckgBuf().iEncodeOptions);
1.376 + iWmaDecoderIntfcCI->SetEncodeOptions1(pckgBuf().iEncodeOptions1);
1.377 + iWmaDecoderIntfcCI->SetEncodeOptions2(pckgBuf().iEncodeOptions2);
1.378 + iWmaDecoderIntfcCI->SetChannelMaskIn(pckgBuf().iChannelMask);
1.379 +
1.380 + TBool able = pckgBuf().iToolOutPut32Bit;
1.381 + if (able)
1.382 + {
1.383 + iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::EToolOutput32Bit);
1.384 + }
1.385 + else
1.386 + {
1.387 + iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::EToolOutput32Bit);
1.388 + }
1.389 +
1.390 + able = pckgBuf().iToolDownMixToStereo;
1.391 + if (able)
1.392 + {
1.393 + iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::EDownMixToStereo);
1.394 + }
1.395 + else
1.396 + {
1.397 + iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::EDownMixToStereo);
1.398 + }
1.399 +
1.400 + able = pckgBuf().iToolLostDataConcealment;
1.401 + if (able)
1.402 + {
1.403 + iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::ELostDataConcealment);
1.404 + }
1.405 + else
1.406 + {
1.407 + iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::ELostDataConcealment);
1.408 + }
1.409 +
1.410 + status = iWmaDecoderIntfcCI->ApplyConfig();
1.411 + aMessage.Complete(status);
1.412 + }
1.413 +
1.414 +//------------------------------------------------------------------------------
1.415 +// CWmaDecoderIntfcMsgHdlr::CreateBufFromUintArrayL
1.416 +// Utility function used to create a buffer and fill it with data from the
1.417 +// array passed in.
1.418 +//------------------------------------------------------------------------------
1.419 +void CWmaDecoderIntfcMsgHdlr::CreateBufFromUintArrayL(RArray<TUint>& aArray)
1.420 + {
1.421 + delete iDataCopyBuffer;
1.422 + iDataCopyBuffer = NULL;
1.423 + iDataCopyBuffer = CBufFlat::NewL(8);
1.424 +
1.425 + RBufWriteStream stream;
1.426 + stream.Open(*iDataCopyBuffer);
1.427 + CleanupClosePushL(stream);
1.428 +
1.429 + for (TInt i = 0; i < aArray.Count(); i++)
1.430 + {
1.431 + stream.WriteUint32L(aArray[i]);
1.432 + }
1.433 +
1.434 + CleanupStack::PopAndDestroy(&stream);
1.435 + }
1.436 +
1.437 +// ---------------------------------------------------------
1.438 +// CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedFormatsL
1.439 +//
1.440 +// ---------------------------------------------------------
1.441 +//
1.442 +void CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedFormatsL(TMMFMessage& aMessage)
1.443 + {
1.444 + iSupportedFormats.Reset();
1.445 + TInt status = iWmaDecoderIntfcCI->GetSupportedFormats(iSupportedFormats);
1.446 +
1.447 + CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(iSupportedFormats));
1.448 + TPckgBuf<TUint> pckg;
1.449 + pckg() = iSupportedFormats.Count();
1.450 + aMessage.WriteDataToClientL(pckg);
1.451 +
1.452 + aMessage.Complete(status);
1.453 + }
1.454 +
1.455 +// ---------------------------------------------------------
1.456 +// CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedToolsL(
1.457 +// ---------------------------------------------------------
1.458 +//
1.459 +void CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedToolsL(TMMFMessage& aMessage)
1.460 + {
1.461 + iSupportedTools.Reset();
1.462 + TInt status = iWmaDecoderIntfcCI->GetSupportedTools(iSupportedTools);
1.463 + CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(iSupportedTools));
1.464 +
1.465 + TPckgBuf<TUint> pckg;
1.466 + pckg() = iSupportedTools.Count();
1.467 + aMessage.WriteDataToClientL(pckg);
1.468 + aMessage.Complete(status);
1.469 + }
1.470 +
1.471 +// ---------------------------------------------------------
1.472 +// CWmaDecoderIntfcMsgHdlr::DoGetNumOfControllableToolsL
1.473 +// ---------------------------------------------------------
1.474 +//
1.475 +void CWmaDecoderIntfcMsgHdlr::DoGetNumOfControllableToolsL(TMMFMessage& aMessage)
1.476 + {
1.477 + iControllableTools.Reset();
1.478 + TInt status = iWmaDecoderIntfcCI->GetControllableTools(iControllableTools);
1.479 + CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(iControllableTools));
1.480 + TPckgBuf<TUint> pckg;
1.481 + pckg() = iControllableTools.Count();
1.482 + aMessage.WriteDataToClientL(pckg);
1.483 + aMessage.Complete(status);
1.484 + }
1.485 +
1.486 +
1.487 +
1.488 +// End of File