os/mm/devsoundextensions/mmfcustominterfaces/WmaDecoderIntfc/WmaDecoderIntfcMsgHdlr/src/WmaDecoderIntfcMsgHdlr.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Message handler for WMA 10 Pro decoder custom interface.
21 #include "WmaDecoderIntfcMsgs.h"
22 #include "WmaDecoderIntfcMsgHdlr.h"
23 //#include "WmaDecoderIntfc.h"
25 // EXTERNAL DATA STRUCTURES
27 // EXTERNAL FUNCTION PROTOTYPES
33 // LOCAL CONSTANTS AND MACROS
35 // MODULE DATA STRUCTURES
37 // LOCAL FUNCTION PROTOTYPES
39 // FORWARD DECLARATIONS
41 // ============================= LOCAL FUNCTIONS ===============================
43 // ============================ MEMBER FUNCTIONS ===============================
45 //------------------------------------------------------------------------------
46 // CWmaDecoderIntfcMsgHdlr::CWmaDecoderIntfcMsgHdlr
47 // C++ default constructor can NOT contain any code, that might leave.
48 //------------------------------------------------------------------------------
49 CWmaDecoderIntfcMsgHdlr::CWmaDecoderIntfcMsgHdlr(
50 CWmaDecoderIntfc* aWmaDecoderConfigCI) :
51 CMMFObject(KUidWmaDecoderIntfc)
53 iWmaDecoderIntfcCI = aWmaDecoderConfigCI;
56 //------------------------------------------------------------------------------
57 // CWmaDecoderIntfcMsgHdlr::ConstructL
58 // Symbian 2nd phase constructor can leave.
59 //------------------------------------------------------------------------------
60 void CWmaDecoderIntfcMsgHdlr::ConstructL()
64 //------------------------------------------------------------------------------
65 // WmaDecoderIntfcMsgHdlr::NewL
66 // Two-phased constructor.
67 //------------------------------------------------------------------------------
68 EXPORT_C CWmaDecoderIntfcMsgHdlr* CWmaDecoderIntfcMsgHdlr::NewL(
69 TAny* aWmaDecoderConfigCI)
71 CWmaDecoderIntfc* WmaDecoderConfigCI =
72 (CWmaDecoderIntfc*)aWmaDecoderConfigCI;
73 CWmaDecoderIntfcMsgHdlr* self =
74 new (ELeave) CWmaDecoderIntfcMsgHdlr(WmaDecoderConfigCI);
75 CleanupStack::PushL( self );
77 CleanupStack::Pop( self );
82 //------------------------------------------------------------------------------
84 //------------------------------------------------------------------------------
85 EXPORT_C CWmaDecoderIntfcMsgHdlr::~CWmaDecoderIntfcMsgHdlr()
87 iSupportedFormats.Close();
88 iSupportedTools.Close();
89 iControllableTools.Close();
91 delete iDataCopyBuffer;
92 delete iWmaDecoderIntfcCI;
95 //------------------------------------------------------------------------------
96 // CWmaDecoderIntfcMsgHdlr::HandleRequest
97 // Handles the messages from the proxy.
98 //------------------------------------------------------------------------------
99 EXPORT_C void CWmaDecoderIntfcMsgHdlr::HandleRequest(
100 TMMFMessage& aMessage)
102 ASSERT(aMessage.Destination().InterfaceId() == KUidWmaDecoderIntfc);
104 TRAPD(error, DoHandleRequestL(aMessage));
108 aMessage.Complete(error);
112 //------------------------------------------------------------------------------
113 // CWmaDecoderIntfcMsgHdlr::DoHandleRequestL
114 // Determines which custom interface to call.
115 //------------------------------------------------------------------------------
116 void CWmaDecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
118 switch(aMessage.Function())
120 case EWmaGetSupportedFormats:
122 DoGetSupportedFormatsL(aMessage);
125 case EWmaGetSupportedTools:
127 DoGetSupportedToolsL(aMessage);
130 case EWmaGetSupportedMaxChannels:
132 DoGetSupportedMaxChannelsL(aMessage);
135 case EWmaGetSupportedMaxBitrate:
137 DoGetSupportedMaxBitrateL(aMessage);
140 case EWmaGetSupportedMaxSampleRate:
142 DoGetSupportedMaxSampleRateL(aMessage);
145 case EWmaGetControllableTools:
147 DoGetControllableToolsL(aMessage);
155 case EWmaApplyConfig:
157 DoApplyConfigL(aMessage);
160 case EWmaGetNumOfSupportedFormats:
162 DoGetNumOfSupportedFormatsL(aMessage);
165 case EWmaGetNumOfSupportedTools:
167 DoGetNumOfSupportedToolsL(aMessage);
170 case EWmaGetNumOfControllableTools:
172 DoGetNumOfControllableToolsL(aMessage);
178 aMessage.Complete(KErrNotSupported);
184 //------------------------------------------------------------------------------
185 // CWmaDecoderIntfcMsgHdlr::DoGetSupportedFormatsL
186 // Get supported formats.
187 //------------------------------------------------------------------------------
188 void CWmaDecoderIntfcMsgHdlr::DoGetSupportedFormatsL(TMMFMessage& aMessage)
190 if (!iDataCopyBuffer)
192 User::Leave(KErrNotReady);
194 aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0));
195 aMessage.Complete(KErrNone);
198 //------------------------------------------------------------------------------
199 // CWmaDecoderIntfcMsgHdlr::DoGetSupportedToolsL
200 // Get supported tools.
201 //------------------------------------------------------------------------------
202 void CWmaDecoderIntfcMsgHdlr::DoGetSupportedToolsL(TMMFMessage& aMessage)
204 if (!iDataCopyBuffer)
206 User::Leave(KErrNotReady);
208 aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0));
209 aMessage.Complete(KErrNone);
212 //------------------------------------------------------------------------------
213 // CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxChannelsL
214 // Get max number of channels.
215 //------------------------------------------------------------------------------
216 void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxChannelsL(TMMFMessage& aMessage)
218 TUint maxChannels = 0;
219 TInt status = iWmaDecoderIntfcCI->GetSupportedMaxChannelsIn(maxChannels);
221 TPckgBuf<TUint> pckg;
222 pckg() = maxChannels;
223 aMessage.WriteDataToClientL(pckg);
225 aMessage.Complete(status);
228 //------------------------------------------------------------------------------
229 // CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxBitrateL
230 // Get supported max bit rates.
231 //------------------------------------------------------------------------------
232 void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxBitrateL(TMMFMessage& aMessage)
234 TUint maxBitrate = 0;
235 TInt status = iWmaDecoderIntfcCI->GetSupportedMaxBitrate(maxBitrate);
237 TPckgBuf<TUint> pckg;
239 aMessage.WriteDataToClientL(pckg);
241 aMessage.Complete(status);
244 //------------------------------------------------------------------------------
245 // CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxSampleRateL
246 // Get supported max sample rate.
247 //------------------------------------------------------------------------------
248 void CWmaDecoderIntfcMsgHdlr::DoGetSupportedMaxSampleRateL(TMMFMessage& aMessage)
250 TUint maxSamplerate = 0;
251 TInt status = iWmaDecoderIntfcCI->GetSupportedMaxSampleRate(maxSamplerate);
253 TPckgBuf<TUint> pckg;
254 pckg() = maxSamplerate;
255 aMessage.WriteDataToClientL(pckg);
257 aMessage.Complete(status);
261 //------------------------------------------------------------------------------
262 // CWmaDecoderIntfcMsgHdlr::DoGetControllableToolsL
263 // Get supported controllable tools.
264 //------------------------------------------------------------------------------
265 void CWmaDecoderIntfcMsgHdlr::DoGetControllableToolsL(TMMFMessage& aMessage)
267 if (!iDataCopyBuffer)
269 User::Leave(KErrNotReady);
271 aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0));
272 aMessage.Complete(KErrNone);
275 //------------------------------------------------------------------------------
276 // CWmaDecoderIntfcMsgHdlr::DoGetAllL
277 // Get all configure parameters.
278 //------------------------------------------------------------------------------
279 void CWmaDecoderIntfcMsgHdlr::DoGetAllL(TMMFMessage& aMessage)
281 TPckgBuf<TAllParams> pckg;
282 CWmaDecoderIntfc::TFormat format;
283 TInt status = iWmaDecoderIntfcCI->GetFormat(format);
284 pckg().iCurrentFormat = format;
285 pckg().iCurrentFormatStatus = status;
287 TUint bitsPerSample = 0;
288 status = iWmaDecoderIntfcCI->GetBitsPerSampleIn(bitsPerSample);
289 pckg().iCurrentBitsPerSample = bitsPerSample;
290 pckg().iCurrentBitsPerSampleStatus = status;
292 TUint numOfChannels = 0;
293 status = iWmaDecoderIntfcCI->GetNumOfChannelsIn(numOfChannels);
294 pckg().iCurrentNumChannelsIn = numOfChannels;
295 pckg().iCurrentNumChannelsInStatus = status;
297 TUint samplesPerSec = 0;
298 status = iWmaDecoderIntfcCI->GetSamplesPerSec (samplesPerSec);
299 pckg().iCurrentSamplesPerSec = samplesPerSec;
300 pckg().iCurrentSamplesPerSecStatus = status;
302 TUint avgBytesPerSec = 0;
303 status = iWmaDecoderIntfcCI->GetAvgBytesPerSec (avgBytesPerSec);
304 pckg().iCurrentAvgBytesPerSec = avgBytesPerSec;
305 pckg().iCurrentAvgBytesPerSecStatus = status;
307 TUint blockAlign = 0;
308 status = iWmaDecoderIntfcCI->GetBlockAlign (blockAlign) ;
309 pckg().iCurrentBlockAlign = blockAlign;
310 pckg().iCurrentBlockAlignStatus = status;
312 TUint encodeOpts = 0;
313 status = iWmaDecoderIntfcCI->GetEncodeOptions (encodeOpts);
314 pckg().iCurrentEncodeOptions = encodeOpts;
315 pckg().iCurrentEncodeOptionsStatus = status;
317 TUint encodeOpts1 = 0;
318 status = iWmaDecoderIntfcCI->GetEncodeOptions1 (encodeOpts1);
319 pckg().iCurrentEncodeOptions1 = encodeOpts1;
320 pckg().iCurrentEncodeOptions1Status = status;
322 TUint encodeOpts2 = 0;
323 status = iWmaDecoderIntfcCI->GetEncodeOptions2(encodeOpts2);
324 pckg().iCurrentEncodeOptions2 = encodeOpts2;
325 pckg().iCurrentEncodeOptions2Status = status;
327 TUint channelMask = 0;
328 status = iWmaDecoderIntfcCI->GetChannelMaskIn (channelMask);
329 pckg().iCurrentChannelMask = channelMask;
330 pckg().iCurrentChannelMaskStatus = status;
332 CWmaDecoderIntfc::TTool tool = CWmaDecoderIntfc::EToolOutput32Bit;
334 status = iWmaDecoderIntfcCI->GetTool(tool, able);
335 pckg().iCurrentToolOutPut32Bit = able;
336 pckg().iCurrentToolOutPut32BitStatus = status;
338 tool = CWmaDecoderIntfc::EDownMixToStereo;
339 status = iWmaDecoderIntfcCI->GetTool(tool, able);
340 pckg().iCurrentToolDownMixToStereo = able;
341 pckg().iCurrentToolDownMixToStereoStatus = status;
343 tool = CWmaDecoderIntfc::ELostDataConcealment;
344 status = iWmaDecoderIntfcCI->GetTool(tool, able);
345 pckg().iCurrentToolLostDataConcealment = able;
346 pckg().iCurrentToolLostDataConcealmentStatus = status;
348 aMessage.WriteDataToClientL(pckg);
350 aMessage.Complete(KErrNone);
354 //------------------------------------------------------------------------------
355 // CWmaDecoderIntfcMsgHdlr::DoApplyConfigL
356 // Handles the message from the proxy and calls the custom interface method
357 // to commit configuration settings to the decoder.
358 //------------------------------------------------------------------------------
359 void CWmaDecoderIntfcMsgHdlr::DoApplyConfigL(TMMFMessage& aMessage)
361 TInt status = KErrNone;
362 TPckgBuf<TWmaDecoderConfig> pckgBuf;
364 aMessage.ReadData1FromClientL(pckgBuf);
366 iWmaDecoderIntfcCI->SetFormat(pckgBuf().iFormat);
367 iWmaDecoderIntfcCI->SetBitsPerSampleIn(pckgBuf().iBitsPerSample);
368 iWmaDecoderIntfcCI->SetNumChannelsIn(pckgBuf().iNumChannelsIn);
369 iWmaDecoderIntfcCI->SetSamplesPerSec(pckgBuf().iSamplesPerSec);
370 iWmaDecoderIntfcCI->SetAvgBytesPerSec(pckgBuf().iAvgBytesPerSec);
371 iWmaDecoderIntfcCI->SetBlockAlign(pckgBuf().iBlockAlign);
372 iWmaDecoderIntfcCI->SetEncodeOptions(pckgBuf().iEncodeOptions);
373 iWmaDecoderIntfcCI->SetEncodeOptions1(pckgBuf().iEncodeOptions1);
374 iWmaDecoderIntfcCI->SetEncodeOptions2(pckgBuf().iEncodeOptions2);
375 iWmaDecoderIntfcCI->SetChannelMaskIn(pckgBuf().iChannelMask);
377 TBool able = pckgBuf().iToolOutPut32Bit;
380 iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::EToolOutput32Bit);
384 iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::EToolOutput32Bit);
387 able = pckgBuf().iToolDownMixToStereo;
390 iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::EDownMixToStereo);
394 iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::EDownMixToStereo);
397 able = pckgBuf().iToolLostDataConcealment;
400 iWmaDecoderIntfcCI->EnableTool(CWmaDecoderIntfc::ELostDataConcealment);
404 iWmaDecoderIntfcCI->DisableTool(CWmaDecoderIntfc::ELostDataConcealment);
407 status = iWmaDecoderIntfcCI->ApplyConfig();
408 aMessage.Complete(status);
411 //------------------------------------------------------------------------------
412 // CWmaDecoderIntfcMsgHdlr::CreateBufFromUintArrayL
413 // Utility function used to create a buffer and fill it with data from the
415 //------------------------------------------------------------------------------
416 void CWmaDecoderIntfcMsgHdlr::CreateBufFromUintArrayL(RArray<TUint>& aArray)
418 delete iDataCopyBuffer;
419 iDataCopyBuffer = NULL;
420 iDataCopyBuffer = CBufFlat::NewL(8);
422 RBufWriteStream stream;
423 stream.Open(*iDataCopyBuffer);
424 CleanupClosePushL(stream);
426 for (TInt i = 0; i < aArray.Count(); i++)
428 stream.WriteUint32L(aArray[i]);
431 CleanupStack::PopAndDestroy(&stream);
434 // ---------------------------------------------------------
435 // CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedFormatsL
437 // ---------------------------------------------------------
439 void CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedFormatsL(TMMFMessage& aMessage)
441 iSupportedFormats.Reset();
442 TInt status = iWmaDecoderIntfcCI->GetSupportedFormats(iSupportedFormats);
444 CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(iSupportedFormats));
445 TPckgBuf<TUint> pckg;
446 pckg() = iSupportedFormats.Count();
447 aMessage.WriteDataToClientL(pckg);
449 aMessage.Complete(status);
452 // ---------------------------------------------------------
453 // CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedToolsL(
454 // ---------------------------------------------------------
456 void CWmaDecoderIntfcMsgHdlr::DoGetNumOfSupportedToolsL(TMMFMessage& aMessage)
458 iSupportedTools.Reset();
459 TInt status = iWmaDecoderIntfcCI->GetSupportedTools(iSupportedTools);
460 CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(iSupportedTools));
462 TPckgBuf<TUint> pckg;
463 pckg() = iSupportedTools.Count();
464 aMessage.WriteDataToClientL(pckg);
465 aMessage.Complete(status);
468 // ---------------------------------------------------------
469 // CWmaDecoderIntfcMsgHdlr::DoGetNumOfControllableToolsL
470 // ---------------------------------------------------------
472 void CWmaDecoderIntfcMsgHdlr::DoGetNumOfControllableToolsL(TMMFMessage& aMessage)
474 iControllableTools.Reset();
475 TInt status = iWmaDecoderIntfcCI->GetControllableTools(iControllableTools);
476 CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(iControllableTools));
477 TPckgBuf<TUint> pckg;
478 pckg() = iControllableTools.Count();
479 aMessage.WriteDataToClientL(pckg);
480 aMessage.Complete(status);