1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "omxildummyaudiodecilif.h" |
|
17 #include "iltestuids.hrh" |
|
18 #include "omxilspecversion.h" |
|
19 #include "tilstructtypes.h" |
|
20 #include "tomxilstruct.h" |
|
21 #include "milcomponentportif.h" |
|
22 #include <ecom/implementationproxy.h> |
|
23 #include <a3f/audioformatuids.h> |
|
24 |
|
25 |
|
26 // _________________________________________________________________________________ |
|
27 |
|
28 const TImplementationProxy ImplementationTable[] = |
|
29 { |
|
30 IMPLEMENTATION_PROXY_ENTRY(KUidOmxILDummyAudioDecMILIFPlugin , COmxILDummyAudioDecILIF::NewL) |
|
31 }; |
|
32 |
|
33 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
34 { |
|
35 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
36 |
|
37 return ImplementationTable; |
|
38 }; |
|
39 // _________________________________________________________________________________ |
|
40 |
|
41 |
|
42 const TUint KMonoChannel = 1; |
|
43 const TUint KStereoChannel = 2; |
|
44 const TInt KPcm16BitsPerSample = 16; |
|
45 |
|
46 |
|
47 COmxILDummyAudioDecILIF* COmxILDummyAudioDecILIF::NewL() |
|
48 { |
|
49 COmxILDummyAudioDecILIF* self = new (ELeave) COmxILDummyAudioDecILIF; |
|
50 return self; |
|
51 } |
|
52 |
|
53 COmxILDummyAudioDecILIF::COmxILDummyAudioDecILIF() |
|
54 { |
|
55 } |
|
56 |
|
57 COmxILDummyAudioDecILIF::~COmxILDummyAudioDecILIF() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 |
|
63 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
64 |
|
65 Mandatory params across all standard components |
|
66 =============================================== |
|
67 OMX_IndexParamPortDefinition OMX_PARAM_PORTDEFINITIONTYPE (KUidTPortDefinitionType, TPortDefinitionType) |
|
68 OMX_IndexParamAudioInit |
|
69 OMX_IndexParamCompBufferSupplier |
|
70 |
|
71 Mandatory params across all audio standard components |
|
72 ===================================================== |
|
73 OMX_IndexParamAudioPortFormat OMX_AUDIO_PARAM_PORTFORMATTYPE (KUidTAudioPortFormatType, TAudioPortFormatType) |
|
74 |
|
75 Component role: audio_decoder.aac |
|
76 ================================= |
|
77 - APB+0: Accepts encoded audio |
|
78 OMX_IndexParamAudioAac OMX_AUDIO_PARAM_AACPROFILETYPE (KUidTPortAACProfileType, TPortAACProfileType) |
|
79 - APB+1: Emits decoded audio |
|
80 OMX_IndexParamAudioPcm OMX_AUDIO_PARAM_PCMMODETYPE (KUidTPortPCMType, TPortPCMType) |
|
81 |
|
82 Component role: audio_renderer.pcm |
|
83 ================================== |
|
84 - APB+0: Accepts audio for rendering: |
|
85 (OMX_IndexParamAudioPcm, OMX_AUDIO_PARAM_PCMMODETYPE) (KUidTPortPCMType, TPortPCMType) |
|
86 (OMX_IndexConfigAudioVolume, OMX_AUDIO_CONFIG_VOLUMETYPE) (KUidTPortVolumeType, TPortVolumeType) |
|
87 (OMX_IndexConfigAudioMute, OMX_AUDIO_CONFIG_MUTETYPE) (KUidTPortMuteType, TPortMuteType) |
|
88 |
|
89 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
90 |
|
91 TInt COmxILDummyAudioDecILIF::SetConfig(const TILStruct& aConfig, |
|
92 const MILComponentPortIf* aComponentPort) |
|
93 { |
|
94 |
|
95 TInt portIndex = 0xFF; // Initialize to invalid port index |
|
96 if (aComponentPort) |
|
97 { |
|
98 portIndex = aComponentPort->PortIndex(); |
|
99 } |
|
100 else |
|
101 { |
|
102 // All parameters and configs are targetted to the port. |
|
103 return KErrArgument; |
|
104 } |
|
105 |
|
106 TInt error = KErrNone; |
|
107 |
|
108 switch (aConfig.Uid().iUid) |
|
109 { |
|
110 case KUidOMXILStructType: |
|
111 { |
|
112 const TOMXILStructParam* omxILStructParam = static_cast<const TOMXILStructParam*> (&aConfig); |
|
113 switch (omxILStructParam->Index()) |
|
114 { |
|
115 case OMX_IndexParamPortDefinition: |
|
116 { |
|
117 OMX_PARAM_PORTDEFINITIONTYPE* config = reinterpret_cast<OMX_PARAM_PORTDEFINITIONTYPE*>( |
|
118 const_cast<TOMXILStructParam*>(omxILStructParam)->Param()); |
|
119 ASSERT(config); |
|
120 config->nPortIndex = portIndex; |
|
121 config->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
|
122 error = OmxSetParameter(OMX_IndexParamPortDefinition, config); |
|
123 break; |
|
124 } |
|
125 default: |
|
126 { |
|
127 error = KErrNotSupported; |
|
128 } |
|
129 } |
|
130 break; |
|
131 } |
|
132 |
|
133 case KUidMMFTTaskConfig: |
|
134 { |
|
135 const TTaskConfig* config = TILTaskConfig::GetStructure(aConfig); |
|
136 ASSERT(config); |
|
137 |
|
138 TInt sampleRate = config->iRate; |
|
139 TInt channels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel; |
|
140 TBool interleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse; |
|
141 |
|
142 TUid format; |
|
143 error = GetComponentIfRole(format); |
|
144 if (error != KErrNone) |
|
145 { |
|
146 break; |
|
147 } |
|
148 |
|
149 if (format == KUidFormatOGG) |
|
150 { |
|
151 if (aComponentPort->PortDirection()== EDirOutput) |
|
152 { |
|
153 // Set Output Port (PCM16) |
|
154 OMX_AUDIO_PARAM_PCMMODETYPE pcm; |
|
155 pcm.nVersion = KOMXILSpecVersion; |
|
156 pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE); |
|
157 pcm.nPortIndex = portIndex; |
|
158 pcm.nSamplingRate = sampleRate; |
|
159 pcm.ePCMMode = OMX_AUDIO_PCMModeLinear; |
|
160 pcm.eNumData = OMX_NumericalDataSigned; |
|
161 pcm.nBitPerSample = KPcm16BitsPerSample; |
|
162 pcm.nChannels = channels; |
|
163 pcm.bInterleaved = (OMX_BOOL)interleaved; |
|
164 |
|
165 error = OmxSetParameter(OMX_IndexParamAudioPcm, &pcm); |
|
166 } |
|
167 else if (aComponentPort->PortDirection() == EDirInput) |
|
168 { |
|
169 // Set Input Port (Vorbis) |
|
170 OMX_AUDIO_PARAM_VORBISTYPE vorbis; |
|
171 vorbis.nVersion = KOMXILSpecVersion; |
|
172 vorbis.nSize = sizeof(OMX_AUDIO_PARAM_VORBISTYPE); |
|
173 vorbis.nPortIndex = portIndex; |
|
174 |
|
175 error = OmxSetParameter(OMX_IndexParamAudioVorbis, &vorbis); |
|
176 } |
|
177 } |
|
178 else if (format == KUidFormatPCM16) |
|
179 { |
|
180 if (aComponentPort->PortDirection()== EDirInput) |
|
181 { |
|
182 // Set Input Port (PCM16) |
|
183 OMX_AUDIO_PARAM_PCMMODETYPE pcm; |
|
184 pcm.nVersion = KOMXILSpecVersion; |
|
185 pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE); |
|
186 pcm.nPortIndex = portIndex; |
|
187 pcm.nSamplingRate = sampleRate; |
|
188 pcm.ePCMMode = OMX_AUDIO_PCMModeLinear; |
|
189 pcm.eNumData = OMX_NumericalDataSigned; |
|
190 pcm.nBitPerSample = KPcm16BitsPerSample; |
|
191 pcm.nChannels = channels; |
|
192 pcm.bInterleaved = (OMX_BOOL)interleaved; |
|
193 |
|
194 error = OmxSetParameter(OMX_IndexParamAudioPcm, &pcm); |
|
195 } |
|
196 else |
|
197 { |
|
198 error = KErrNotSupported; |
|
199 } |
|
200 } |
|
201 else |
|
202 { |
|
203 error = KErrNotSupported; |
|
204 } |
|
205 break; |
|
206 } |
|
207 case KUidTPortDefinitionType: |
|
208 { |
|
209 OMX_PARAM_PORTDEFINITIONTYPE* config = const_cast<OMX_PARAM_PORTDEFINITIONTYPE*>( |
|
210 TILPortDefinition::GetStructure(aConfig)); |
|
211 ASSERT(config); |
|
212 config->nVersion = KOMXILSpecVersion; |
|
213 config->nSize = sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE); |
|
214 config->nPortIndex = portIndex; |
|
215 error = OmxSetParameter(OMX_IndexParamPortDefinition, config); |
|
216 break; |
|
217 } |
|
218 case KUidTAudioPortFormatType: |
|
219 { |
|
220 OMX_AUDIO_PARAM_PORTFORMATTYPE* config = const_cast<OMX_AUDIO_PARAM_PORTFORMATTYPE*>( |
|
221 TILAudioPortFormat::GetStructure(aConfig)); |
|
222 ASSERT(config); |
|
223 config->nVersion = KOMXILSpecVersion; |
|
224 config->nSize = sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE); |
|
225 config->nPortIndex = portIndex; |
|
226 error = OmxSetParameter(OMX_IndexParamAudioPortFormat, config); |
|
227 break; |
|
228 } |
|
229 case KUidTPortPCMModeType: |
|
230 { |
|
231 OMX_AUDIO_PARAM_PCMMODETYPE* config = const_cast<OMX_AUDIO_PARAM_PCMMODETYPE*>( |
|
232 TILPortPCMMode::GetStructure(aConfig)); |
|
233 ASSERT(config); |
|
234 config->nVersion = KOMXILSpecVersion; |
|
235 config->nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE); |
|
236 config->nPortIndex = portIndex; |
|
237 error = OmxSetParameter(OMX_IndexParamAudioPcm, config); |
|
238 break; |
|
239 } |
|
240 case KUidTPortAACProfileType: |
|
241 { |
|
242 OMX_AUDIO_PARAM_AACPROFILETYPE* config = const_cast<OMX_AUDIO_PARAM_AACPROFILETYPE*>( |
|
243 TILPortAACProfile::GetStructure(aConfig)); |
|
244 ASSERT(config); |
|
245 config->nVersion = KOMXILSpecVersion; |
|
246 config->nSize = sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE); |
|
247 config->nPortIndex = portIndex; |
|
248 error = OmxSetParameter(OMX_IndexParamAudioAac, config); |
|
249 break; |
|
250 } |
|
251 case KUidTPortVorbisType: |
|
252 { |
|
253 OMX_AUDIO_PARAM_VORBISTYPE* config = const_cast<OMX_AUDIO_PARAM_VORBISTYPE*>( |
|
254 TILPortVorbis::GetStructure(aConfig)); |
|
255 ASSERT(config); |
|
256 config->nVersion = KOMXILSpecVersion; |
|
257 config->nSize = sizeof(OMX_AUDIO_PARAM_VORBISTYPE); |
|
258 config->nPortIndex = portIndex; |
|
259 error = OmxSetParameter(OMX_IndexParamAudioVorbis, config); |
|
260 break; |
|
261 } |
|
262 case KUidTPortVolumeType: |
|
263 { |
|
264 OMX_AUDIO_CONFIG_VOLUMETYPE* config = const_cast<OMX_AUDIO_CONFIG_VOLUMETYPE*>( |
|
265 TILPortVolume::GetStructure(aConfig)); |
|
266 ASSERT(config); |
|
267 config->nVersion = KOMXILSpecVersion; |
|
268 config->nSize = sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE); |
|
269 config->nPortIndex = portIndex; |
|
270 error = OmxSetConfig(OMX_IndexConfigAudioVolume, config); |
|
271 break; |
|
272 } |
|
273 case KUidTPortMuteType: |
|
274 { |
|
275 OMX_AUDIO_CONFIG_MUTETYPE* config = const_cast<OMX_AUDIO_CONFIG_MUTETYPE*>( |
|
276 TILPortMute::GetStructure(aConfig)); |
|
277 ASSERT(config); |
|
278 config->nVersion = KOMXILSpecVersion; |
|
279 config->nSize = sizeof(OMX_AUDIO_CONFIG_MUTETYPE); |
|
280 config->nPortIndex = portIndex; |
|
281 error = OmxSetConfig(OMX_IndexConfigAudioMute, config); |
|
282 break; |
|
283 } |
|
284 default: |
|
285 { |
|
286 error = KErrNotSupported; |
|
287 } |
|
288 } |
|
289 return error; |
|
290 } |
|
291 |
|
292 |
|
293 TInt COmxILDummyAudioDecILIF::GetConfig(TILStruct& aConfig, |
|
294 const MILComponentPortIf* aComponentPort) const |
|
295 { |
|
296 TInt portIndex = 0xFF; // Initialize to invalid port index |
|
297 if (aComponentPort) |
|
298 { |
|
299 portIndex = aComponentPort->PortIndex(); |
|
300 } |
|
301 else |
|
302 { |
|
303 // All parameters and configs are targetted to the port. |
|
304 return KErrArgument; |
|
305 } |
|
306 |
|
307 TInt error = KErrNone; |
|
308 |
|
309 switch (aConfig.Uid().iUid) |
|
310 { |
|
311 case KUidOMXILStructType: |
|
312 { |
|
313 TOMXILStructParam* omxILStructParam = static_cast<TOMXILStructParam*> (&aConfig); |
|
314 switch (omxILStructParam->Index()) |
|
315 { |
|
316 case OMX_IndexParamPortDefinition: |
|
317 { |
|
318 OMX_PARAM_PORTDEFINITIONTYPE* config = reinterpret_cast<OMX_PARAM_PORTDEFINITIONTYPE*>(omxILStructParam->Param()); |
|
319 ASSERT(config); |
|
320 config->nVersion = KOMXILSpecVersion; |
|
321 config->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
|
322 config->nPortIndex = portIndex; |
|
323 error = OmxGetParameter(OMX_IndexParamPortDefinition, config); |
|
324 break; |
|
325 } |
|
326 default: |
|
327 { |
|
328 error = KErrNotSupported; |
|
329 } |
|
330 } |
|
331 break; |
|
332 } |
|
333 |
|
334 case KUidTPortDefinitionType: |
|
335 { |
|
336 OMX_PARAM_PORTDEFINITIONTYPE* config = TILPortDefinition::GetStructure(aConfig); |
|
337 ASSERT(config); |
|
338 config->nVersion = KOMXILSpecVersion; |
|
339 config->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
|
340 config->nPortIndex = portIndex; |
|
341 error = OmxGetParameter(OMX_IndexParamPortDefinition, config); |
|
342 break; |
|
343 } |
|
344 case KUidTAudioPortFormatType: |
|
345 { |
|
346 OMX_AUDIO_PARAM_PORTFORMATTYPE* config = TILAudioPortFormat::GetStructure(aConfig); |
|
347 ASSERT(config); |
|
348 config->nVersion = KOMXILSpecVersion; |
|
349 config->nSize = sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE); |
|
350 config->nPortIndex = portIndex; |
|
351 error = OmxGetParameter(OMX_IndexParamAudioPortFormat, config); |
|
352 break; |
|
353 } |
|
354 case KUidTPortPCMModeType: |
|
355 { |
|
356 OMX_AUDIO_PARAM_PCMMODETYPE* config = TILPortPCMMode::GetStructure(aConfig); |
|
357 ASSERT(config); |
|
358 config->nVersion = KOMXILSpecVersion; |
|
359 config->nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE); |
|
360 config->nPortIndex = portIndex; |
|
361 error = OmxGetParameter(OMX_IndexParamAudioPcm, config); |
|
362 break; |
|
363 } |
|
364 case KUidTPortAACProfileType: |
|
365 { |
|
366 OMX_AUDIO_PARAM_AACPROFILETYPE* config = TILPortAACProfile::GetStructure(aConfig); |
|
367 ASSERT(config); |
|
368 config->nVersion = KOMXILSpecVersion; |
|
369 config->nSize = sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE); |
|
370 config->nPortIndex = portIndex; |
|
371 error = OmxGetParameter(OMX_IndexParamAudioAac, config); |
|
372 break; |
|
373 } |
|
374 case KUidTPortVorbisType: |
|
375 { |
|
376 OMX_AUDIO_PARAM_VORBISTYPE* config = TILPortVorbis::GetStructure(aConfig); |
|
377 ASSERT(config); |
|
378 config->nVersion = KOMXILSpecVersion; |
|
379 config->nSize = sizeof(OMX_AUDIO_PARAM_VORBISTYPE); |
|
380 config->nPortIndex = portIndex; |
|
381 error = OmxGetParameter(OMX_IndexParamAudioVorbis, config); |
|
382 break; |
|
383 } |
|
384 case KUidTPortVolumeType: |
|
385 { |
|
386 OMX_AUDIO_CONFIG_VOLUMETYPE* config = TILPortVolume::GetStructure(aConfig); |
|
387 ASSERT(config); |
|
388 config->nVersion = KOMXILSpecVersion; |
|
389 config->nSize = sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE); |
|
390 config->nPortIndex = portIndex; |
|
391 error = OmxGetConfig(OMX_IndexConfigAudioVolume, config); |
|
392 break; |
|
393 } |
|
394 case KUidTPortMuteType: |
|
395 { |
|
396 OMX_AUDIO_CONFIG_MUTETYPE* config = TILPortMute::GetStructure(aConfig); |
|
397 ASSERT(config); |
|
398 config->nVersion = KOMXILSpecVersion; |
|
399 config->nSize = sizeof(OMX_AUDIO_CONFIG_MUTETYPE); |
|
400 config->nPortIndex = portIndex; |
|
401 error = OmxGetConfig(OMX_IndexConfigAudioMute, config); |
|
402 break; |
|
403 } |
|
404 default: |
|
405 { |
|
406 error = KErrNotSupported; |
|
407 } |
|
408 } |
|
409 |
|
410 return error; |
|
411 } |
|
412 |
|
413 TInt COmxILDummyAudioDecILIF::SetExtConfig(const TDesC8& aParameterName, |
|
414 const TILStruct& aConfig, |
|
415 const MILComponentPortIf* aComponentPort) |
|
416 { |
|
417 TInt portIndex = 0xFF; // Initialize to invalid port index |
|
418 if (aComponentPort) |
|
419 { |
|
420 portIndex = aComponentPort->PortIndex(); |
|
421 } |
|
422 else |
|
423 { |
|
424 // All parameters and configs are targetted to the port. |
|
425 return KErrArgument; |
|
426 } |
|
427 |
|
428 OMX_INDEXTYPE indexType; |
|
429 TInt error = KErrNone; |
|
430 error = OmxGetExtensionIndex(aParameterName, &indexType); |
|
431 |
|
432 if (error == KErrNone) |
|
433 { |
|
434 switch (aConfig.Uid().iUid) |
|
435 { |
|
436 case KUidTPortDefinitionType: |
|
437 { |
|
438 OMX_PARAM_PORTDEFINITIONTYPE* config = const_cast<OMX_PARAM_PORTDEFINITIONTYPE*>(TILPortDefinition::GetStructure(aConfig)); |
|
439 ASSERT(config); |
|
440 config->nVersion = KOMXILSpecVersion; |
|
441 config->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
|
442 config->nPortIndex = portIndex; |
|
443 error = OmxSetParameter(OMX_IndexParamPortDefinition, config); |
|
444 break; |
|
445 } |
|
446 default: |
|
447 { |
|
448 error = KErrNotSupported; |
|
449 } |
|
450 } |
|
451 } |
|
452 |
|
453 |
|
454 return error; |
|
455 } |
|
456 |
|
457 TInt COmxILDummyAudioDecILIF::GetExtConfig(const TDesC8& aParameterName, |
|
458 TILStruct& aConfig, |
|
459 const MILComponentPortIf* aComponentPort) const |
|
460 { |
|
461 TInt portIndex = 0xFF; // Initialize to invalid port index |
|
462 if (aComponentPort) |
|
463 { |
|
464 portIndex = aComponentPort->PortIndex(); |
|
465 } |
|
466 else |
|
467 { |
|
468 // All parameters and configs are targetted to the port. |
|
469 return KErrArgument; |
|
470 } |
|
471 |
|
472 OMX_INDEXTYPE indexType; |
|
473 |
|
474 TInt error = KErrNone; |
|
475 error = OmxGetExtensionIndex(aParameterName, &indexType); |
|
476 |
|
477 if (error == KErrNone) |
|
478 { |
|
479 switch (aConfig.Uid().iUid) |
|
480 { |
|
481 case KUidTPortDefinitionType: |
|
482 { |
|
483 OMX_PARAM_PORTDEFINITIONTYPE* config = TILPortDefinition::GetStructure(aConfig); |
|
484 ASSERT(config); |
|
485 config->nVersion = KOMXILSpecVersion; |
|
486 config->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); |
|
487 config->nPortIndex = portIndex; |
|
488 error = OmxGetParameter(indexType, config); |
|
489 break; |
|
490 } |
|
491 default: |
|
492 { |
|
493 error = KErrNotSupported; |
|
494 } |
|
495 } |
|
496 } |
|
497 return error; |
|
498 } |
|
499 |
|
500 TInt COmxILDummyAudioDecILIF::SetComponentIfRole(const TUid& aComponentRole) |
|
501 { |
|
502 if ((aComponentRole == KUidFormatAAC) || |
|
503 (aComponentRole == KUidFormatOGG) || |
|
504 (aComponentRole == KUidFormatPCM16)) |
|
505 { |
|
506 return (COmxILDummyBaseILIF::SetComponentIfRole(aComponentRole)); |
|
507 } |
|
508 else |
|
509 { |
|
510 return KErrNotSupported; |
|
511 } |
|
512 } |
|