|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Message handler for SBC encoder interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <SbcEncoderIntfc.h> |
|
22 #include "SbcEncoderIntfcMsgHdlr.h" |
|
23 #include "SbcEncoderIntfcMsgs.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 |
|
35 // MODULE DATA STRUCTURES |
|
36 |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 |
|
41 // ============================= LOCAL FUNCTIONS =============================== |
|
42 |
|
43 // ============================ MEMBER FUNCTIONS =============================== |
|
44 |
|
45 /** |
|
46 * CSbcEncoderIntfcMsgHdlr::CSbcEncoderIntfcMsgHdlr |
|
47 * C++ default constructor can NOT contain any code, that might leave. |
|
48 */ |
|
49 CSbcEncoderIntfcMsgHdlr::CSbcEncoderIntfcMsgHdlr( |
|
50 CSbcEncoderIntfc* aSbcEncoderIntfcCI) : |
|
51 CMMFObject(KUidSbcEncoderIntfc) |
|
52 { |
|
53 iSbcEncoderIntfcCI = aSbcEncoderIntfcCI; |
|
54 } |
|
55 |
|
56 /** |
|
57 * CSbcEncoderIntfcMsgHdlr::ConstructL |
|
58 * Symbian 2nd phase constructor can leave. |
|
59 */ |
|
60 void CSbcEncoderIntfcMsgHdlr::ConstructL() |
|
61 { |
|
62 } |
|
63 |
|
64 /** |
|
65 * CSbcEncoderIntfcMsgHdlr::NewL |
|
66 * Two-phased constructor. |
|
67 */ |
|
68 EXPORT_C CSbcEncoderIntfcMsgHdlr* CSbcEncoderIntfcMsgHdlr::NewL( |
|
69 TAny* aSbcEncoderIntfcCI) |
|
70 { |
|
71 CSbcEncoderIntfc* SbcEncoderIntfcCI = |
|
72 (CSbcEncoderIntfc*)aSbcEncoderIntfcCI; |
|
73 CSbcEncoderIntfcMsgHdlr* self = |
|
74 new (ELeave) CSbcEncoderIntfcMsgHdlr(SbcEncoderIntfcCI); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 */ |
|
84 EXPORT_C CSbcEncoderIntfcMsgHdlr::~CSbcEncoderIntfcMsgHdlr() |
|
85 { |
|
86 delete iDataCopyBuffer; |
|
87 delete iSbcEncoderIntfcCI; |
|
88 } |
|
89 |
|
90 /** |
|
91 * CSbcEncoderIntfcMsgHdlr::HandleRequest |
|
92 * Handles the messages from the proxy. |
|
93 * Calls a subfunction which determines which custom interface to call. |
|
94 * A subfunction is used to contain multiple leaving functions for a |
|
95 * single trap. |
|
96 * (other items were commented in a header). |
|
97 */ |
|
98 EXPORT_C void CSbcEncoderIntfcMsgHdlr::HandleRequest(TMMFMessage& aMessage) |
|
99 { |
|
100 // debug panic |
|
101 ASSERT(aMessage.Destination().InterfaceId() == KUidSbcEncoderIntfc); |
|
102 TRAPD(error, DoHandleRequestL(aMessage)); |
|
103 if(error) |
|
104 { |
|
105 aMessage.Complete(error); |
|
106 } |
|
107 } |
|
108 |
|
109 /** |
|
110 * CSbcEncoderIntfcMsgHdlr::DoHandleRequestL |
|
111 * Determines which custom interface to call. |
|
112 * (other items were commented in a header). |
|
113 */ |
|
114 void CSbcEncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage) |
|
115 { |
|
116 switch(aMessage.Function()) |
|
117 { |
|
118 case ESbceimGetNumOfSupportedSamplingFrequencies: |
|
119 { |
|
120 DoGetNumOfSupportedSamplingFrequenciesL(aMessage); |
|
121 break; |
|
122 } |
|
123 case ESbceimGetSupportedSamplingFrequencies: |
|
124 { |
|
125 DoGetSupportedSamplingFrequenciesL(aMessage); |
|
126 break; |
|
127 } |
|
128 case ESbceimGetNumOfSupportedChannelModes: |
|
129 { |
|
130 DoGetNumOfSupportedChannelModesL(aMessage); |
|
131 break; |
|
132 } |
|
133 case ESbceimGetSupportedChannelModes: |
|
134 { |
|
135 DoGetSupportedChannelModesL(aMessage); |
|
136 break; |
|
137 } |
|
138 case ESbceimGetNumOfSupportedNumOfSubbands: |
|
139 { |
|
140 DoGetNumOfSupportedNumOfSubbandsL(aMessage); |
|
141 break; |
|
142 } |
|
143 case ESbceimGetSupportedNumOfSubbands: |
|
144 { |
|
145 DoGetSupportedNumOfSubbandsL(aMessage); |
|
146 break; |
|
147 } |
|
148 case ESbceimGetNumOfSupportedBlocks: |
|
149 { |
|
150 DoGetNumOfSupportedBlocksL(aMessage); |
|
151 break; |
|
152 } |
|
153 case ESbceimGetSupportedBlocks: |
|
154 { |
|
155 DoGetSupportedBlocksL(aMessage); |
|
156 break; |
|
157 } |
|
158 case ESbceimGetNumOfSupportedAllocationMethods: |
|
159 { |
|
160 DoGetNumOfSupportedAllocationMethodsL(aMessage); |
|
161 break; |
|
162 } |
|
163 case ESbceimGetSupportedAllocationMethods: |
|
164 { |
|
165 DoGetSupportedAllocationMethodsL(aMessage); |
|
166 break; |
|
167 } |
|
168 case ESbceimGetSupportedBitpoolRange: |
|
169 { |
|
170 DoGetSupportedBitpoolRangeL(aMessage); |
|
171 break; |
|
172 } |
|
173 case ESbceimApplyConfig: |
|
174 { |
|
175 DoApplyConfigL(aMessage); |
|
176 break; |
|
177 } |
|
178 default: |
|
179 { |
|
180 aMessage.Complete(KErrNotSupported); |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 /** |
|
186 * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedSamplingFrequenciesL |
|
187 * Handles the message from the proxy and calls the custom interface. |
|
188 * The custom interface returns the data requested and this function writes |
|
189 * it back to the proxy. It also creates a buffer and fills the sampling |
|
190 * frequencies data to be returned in the subsequent call to |
|
191 * DoGetSupportedSamplingFrequenciesL(). |
|
192 * (other items were commented in a header). |
|
193 */ |
|
194 void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedSamplingFrequenciesL( |
|
195 TMMFMessage& aMessage) |
|
196 { |
|
197 RArray<TUint> supSamplingFrequencies; |
|
198 CleanupClosePushL(supSamplingFrequencies); |
|
199 |
|
200 TInt status = iSbcEncoderIntfcCI->GetSupportedSamplingFrequencies( |
|
201 supSamplingFrequencies); |
|
202 |
|
203 // store array in iDataCopyBuffer |
|
204 CreateBufFromUintArrayL(supSamplingFrequencies); |
|
205 |
|
206 if (status == KErrNone) |
|
207 { |
|
208 TPckgBuf<TUint> pckg; |
|
209 pckg() = supSamplingFrequencies.Count(); |
|
210 aMessage.WriteDataToClientL(pckg); |
|
211 } |
|
212 |
|
213 CleanupStack::PopAndDestroy(&supSamplingFrequencies); |
|
214 aMessage.Complete(status); |
|
215 } |
|
216 |
|
217 /** |
|
218 * CSbcEncoderIntfcMsgHdlr::DoGetSupportedSamplingFrequenciesL |
|
219 * Sends the sampling frequency data returned from the custom interface |
|
220 * implementation to the client. |
|
221 * (other items were commented in a header). |
|
222 */ |
|
223 void CSbcEncoderIntfcMsgHdlr::DoGetSupportedSamplingFrequenciesL( |
|
224 TMMFMessage& aMessage) |
|
225 { |
|
226 SendDataBufferToClientL(aMessage); |
|
227 } |
|
228 |
|
229 /** |
|
230 * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedChannelModesL |
|
231 * Handles the message from the proxy and calls the custom interface. |
|
232 * The custom interface returns the data requested and this function writes |
|
233 * it back to the proxy. It also creates a buffer and fills the sampling |
|
234 * frequencies data to be returned in the subsequent call to |
|
235 * DoGetSupportedChannelModesL(). |
|
236 * (other items were commented in a header). |
|
237 */ |
|
238 void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedChannelModesL( |
|
239 TMMFMessage& aMessage) |
|
240 { |
|
241 RArray<CSbcEncoderIntfc::TSbcChannelMode> supChannelModes; |
|
242 CleanupClosePushL(supChannelModes); |
|
243 TInt status = |
|
244 iSbcEncoderIntfcCI->GetSupportedChannelModes(supChannelModes); |
|
245 |
|
246 // store array in iDataCopyBuffer |
|
247 CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(supChannelModes)); |
|
248 |
|
249 if (status == KErrNone) |
|
250 { |
|
251 TPckgBuf<TUint> pckg; |
|
252 pckg() = supChannelModes.Count(); |
|
253 aMessage.WriteDataToClientL(pckg); |
|
254 } |
|
255 |
|
256 CleanupStack::PopAndDestroy(&supChannelModes); |
|
257 aMessage.Complete(status); |
|
258 } |
|
259 |
|
260 /** |
|
261 * CSbcEncoderIntfcMsgHdlr::DoGetSupportedChannelModesL |
|
262 * Sends the channel modes data returned from the custom interface |
|
263 * implementation to the client. |
|
264 * (other items were commented in a header). |
|
265 */ |
|
266 void CSbcEncoderIntfcMsgHdlr::DoGetSupportedChannelModesL( |
|
267 TMMFMessage& aMessage) |
|
268 { |
|
269 SendDataBufferToClientL(aMessage); |
|
270 } |
|
271 |
|
272 /** |
|
273 * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedBlocksL |
|
274 * Handles the message from the proxy and calls the custom interface. |
|
275 * The custom interface returns the data requested and this function writes |
|
276 * it back to the proxy. It also creates a buffer and fills the supported |
|
277 * blocks data to be returned in the subsequent call to |
|
278 * DoGetSupportedBlocksL(). |
|
279 * (other items were commented in a header). |
|
280 */ |
|
281 void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedBlocksL( |
|
282 TMMFMessage& aMessage) |
|
283 { |
|
284 RArray<TUint> supNumBlocks; |
|
285 CleanupClosePushL(supNumBlocks); |
|
286 |
|
287 TInt status = iSbcEncoderIntfcCI->GetSupportedNumOfBlocks(supNumBlocks); |
|
288 |
|
289 CreateBufFromUintArrayL(supNumBlocks); |
|
290 |
|
291 if (status == KErrNone) |
|
292 { |
|
293 TPckgBuf<TUint> pckg; |
|
294 pckg() = supNumBlocks.Count(); |
|
295 aMessage.WriteDataToClientL(pckg); |
|
296 } |
|
297 |
|
298 CleanupStack::PopAndDestroy(&supNumBlocks); |
|
299 aMessage.Complete(status); |
|
300 } |
|
301 |
|
302 /** |
|
303 * CSbcEncoderIntfcMsgHdlr::DoGetSupportedBlocksL |
|
304 * Sends the supported blocks data returned from the custom interface |
|
305 * implementation to the client. |
|
306 * (other items were commented in a header). |
|
307 */ |
|
308 void CSbcEncoderIntfcMsgHdlr::DoGetSupportedBlocksL(TMMFMessage& aMessage) |
|
309 { |
|
310 SendDataBufferToClientL(aMessage); |
|
311 } |
|
312 |
|
313 /** |
|
314 * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedNumOfSubbandsL |
|
315 * Handles the message from the proxy and calls the custom interface. |
|
316 * The custom interface returns the data requested and this function writes |
|
317 * it back to the proxy. It also creates a buffer and fills the supported |
|
318 * subbands data to be returned in the subsequent call to |
|
319 * DoGetSupportedNumOfSubbandsL(). |
|
320 * (other items were commented in a header). |
|
321 */ |
|
322 void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedNumOfSubbandsL( |
|
323 TMMFMessage& aMessage) |
|
324 { |
|
325 RArray<TUint> supNumSubbands; |
|
326 CleanupClosePushL(supNumSubbands); |
|
327 |
|
328 TInt status = iSbcEncoderIntfcCI->GetSupportedNumOfSubbands(supNumSubbands); |
|
329 |
|
330 CreateBufFromUintArrayL(supNumSubbands); |
|
331 |
|
332 if (status == KErrNone) |
|
333 { |
|
334 TPckgBuf<TUint> pckg; |
|
335 pckg() = supNumSubbands.Count(); |
|
336 aMessage.WriteDataToClientL(pckg); |
|
337 } |
|
338 |
|
339 CleanupStack::PopAndDestroy(&supNumSubbands); |
|
340 aMessage.Complete(status); |
|
341 } |
|
342 |
|
343 /** |
|
344 * CSbcEncoderIntfcMsgHdlr::DoGetSupportedNumOfSubbandsL |
|
345 * Sends the supported subbands data returned from the custom interface |
|
346 * implementation to the client. |
|
347 * (other items were commented in a header). |
|
348 */ |
|
349 void CSbcEncoderIntfcMsgHdlr::DoGetSupportedNumOfSubbandsL( |
|
350 TMMFMessage& aMessage) |
|
351 { |
|
352 SendDataBufferToClientL(aMessage); |
|
353 } |
|
354 |
|
355 /** |
|
356 * CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedAllocationMethodsL |
|
357 * Handles the message from the proxy and calls the custom interface. |
|
358 * The custom interface returns the data requested and this function writes |
|
359 * it back to the proxy. It also creates a buffer and fills the supported |
|
360 * allocation methods data to be returned in the subsequent call to |
|
361 * DoGetSupportedAllocationMethodsL(). |
|
362 * (other items were commented in a header). |
|
363 */ |
|
364 void CSbcEncoderIntfcMsgHdlr::DoGetNumOfSupportedAllocationMethodsL( |
|
365 TMMFMessage& aMessage) |
|
366 { |
|
367 RArray<CSbcEncoderIntfc::TSbcAllocationMethod> supAllocMethods; |
|
368 CleanupClosePushL(supAllocMethods); |
|
369 |
|
370 TInt status = |
|
371 iSbcEncoderIntfcCI->GetSupportedAllocationMethods(supAllocMethods); |
|
372 |
|
373 // store array in iDataCopyBuffer |
|
374 CreateBufFromUintArrayL(reinterpret_cast<RArray<TUint>&>(supAllocMethods)); |
|
375 |
|
376 if (status == KErrNone) |
|
377 { |
|
378 TPckgBuf<TUint> pckg; |
|
379 pckg() = supAllocMethods.Count(); |
|
380 aMessage.WriteDataToClientL(pckg); |
|
381 } |
|
382 |
|
383 CleanupStack::PopAndDestroy(&supAllocMethods); |
|
384 aMessage.Complete(status); |
|
385 } |
|
386 |
|
387 /** |
|
388 * CSbcEncoderIntfcMsgHdlr::DoGetSupportedAllocationMethodsL |
|
389 * Sends the supported allocation methods data returned from the custom |
|
390 * interface implementation to the client. |
|
391 * (other items were commented in a header). |
|
392 */ |
|
393 void CSbcEncoderIntfcMsgHdlr::DoGetSupportedAllocationMethodsL( |
|
394 TMMFMessage& aMessage) |
|
395 { |
|
396 SendDataBufferToClientL(aMessage); |
|
397 } |
|
398 |
|
399 /** |
|
400 * CSbcEncoderIntfcMsgHdlr::DoGetSupportedBitpoolRangeL |
|
401 * Handles the message from the proxy and calls the custom interface. |
|
402 * The custom interface returns the requested bitpool range and this function |
|
403 * writes it back to the proxy. |
|
404 * (other items were commented in a header). |
|
405 */ |
|
406 void CSbcEncoderIntfcMsgHdlr::DoGetSupportedBitpoolRangeL( |
|
407 TMMFMessage& aMessage) |
|
408 { |
|
409 TSbcEncoderBitpoolRange bitPoolRange; |
|
410 bitPoolRange.iMinSupportedBitpoolSize = 0; |
|
411 bitPoolRange.iMaxSupportedBitpoolSize = 0; |
|
412 |
|
413 TInt status = iSbcEncoderIntfcCI->GetSupportedBitpoolRange( |
|
414 bitPoolRange.iMinSupportedBitpoolSize, |
|
415 bitPoolRange.iMaxSupportedBitpoolSize); |
|
416 |
|
417 if (status == KErrNone) |
|
418 { |
|
419 TPckgBuf<TSbcEncoderBitpoolRange> pckg; |
|
420 pckg() = bitPoolRange; |
|
421 aMessage.WriteDataToClientL(pckg); |
|
422 } |
|
423 |
|
424 aMessage.Complete(status); |
|
425 } |
|
426 |
|
427 /** |
|
428 * CSbcEncoderIntfcMsgHdlr::DoApplyConfigL |
|
429 * Handles the message from the proxy to commit configuration settings and |
|
430 * calls the custom interface method. The data passed from the proxy is read |
|
431 * from the message and passed to the custom interface. |
|
432 * (other items were commented in a header). |
|
433 */ |
|
434 void CSbcEncoderIntfcMsgHdlr::DoApplyConfigL(TMMFMessage& aMessage) |
|
435 { |
|
436 TPckgBuf<TSbcEncoderConfig> pckgBuf; |
|
437 aMessage.ReadData1FromClientL(pckgBuf); |
|
438 |
|
439 iSbcEncoderIntfcCI->SetSamplingFrequency(pckgBuf().iSamplingFrequency); |
|
440 iSbcEncoderIntfcCI->SetChannelMode(pckgBuf().iChannelMode); |
|
441 iSbcEncoderIntfcCI->SetNumOfSubbands(pckgBuf().iNumOfSubbands); |
|
442 iSbcEncoderIntfcCI->SetNumOfBlocks(pckgBuf().iNumOfBlocks); |
|
443 iSbcEncoderIntfcCI->SetAllocationMethod(pckgBuf().iAllocationMethod); |
|
444 iSbcEncoderIntfcCI->SetBitpoolSize(pckgBuf().iBitpoolSize); |
|
445 |
|
446 TInt status = iSbcEncoderIntfcCI->ApplyConfig(); |
|
447 aMessage.Complete(status); |
|
448 } |
|
449 |
|
450 /** |
|
451 * CSbcEncoderIntfcMsgHdlr::CreateBufFromUintArrayL |
|
452 * Utility function used to create a buffer and fill it with data from the |
|
453 * array passed in. |
|
454 * (other items were commented in a header). |
|
455 */ |
|
456 void CSbcEncoderIntfcMsgHdlr::CreateBufFromUintArrayL(RArray<TUint>& aArray) |
|
457 { |
|
458 delete iDataCopyBuffer; |
|
459 iDataCopyBuffer = NULL; |
|
460 iDataCopyBuffer = CBufFlat::NewL(8); |
|
461 |
|
462 RBufWriteStream stream; |
|
463 stream.Open(*iDataCopyBuffer); |
|
464 CleanupClosePushL(stream); |
|
465 |
|
466 for (TInt i = 0; i < aArray.Count(); i++) |
|
467 { |
|
468 stream.WriteUint32L(aArray[i]); |
|
469 } |
|
470 |
|
471 CleanupStack::PopAndDestroy(&stream); |
|
472 } |
|
473 |
|
474 /** |
|
475 * CSbcEncoderIntfcMsgHdlr::SendDataBufferToClientL |
|
476 * Sends message with requested configuration data back to the client. |
|
477 * (other items were commented in a header). |
|
478 */ |
|
479 void CSbcEncoderIntfcMsgHdlr::SendDataBufferToClientL(TMMFMessage& aMessage) |
|
480 { |
|
481 if (!iDataCopyBuffer) |
|
482 { |
|
483 User::Leave(KErrNotReady); |
|
484 } |
|
485 |
|
486 aMessage.WriteDataToClientL(iDataCopyBuffer->Ptr(0)); |
|
487 aMessage.Complete(KErrNone); |
|
488 } |
|
489 |
|
490 |
|
491 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
492 |
|
493 // End of File |