|
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 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
24 #include <openmax/il/common/omxilutil.h> |
|
25 |
|
26 #include "log.h" |
|
27 #include "omxilmicsourceapb0port.h" |
|
28 #include "omxilmicsourceprocessingfunction.h" |
|
29 |
|
30 _LIT8(KMimeTypeAudioPcm, "audio/pcm"); |
|
31 |
|
32 COmxILMicSourceAPB0Port* |
|
33 COmxILMicSourceAPB0Port::NewL( |
|
34 const TOmxILCommonPortData& aCommonPortData, |
|
35 const RArray<OMX_AUDIO_CODINGTYPE>& aSupportedAudioFormats, |
|
36 const OMX_AUDIO_PARAM_PCMMODETYPE& aParamAudioPcm, |
|
37 const OMX_AUDIO_CONFIG_VOLUMETYPE& aConfigAudioVolume, |
|
38 const OMX_AUDIO_CONFIG_MUTETYPE& aConfigAudioMute, |
|
39 COmxILMicSourceProcessingFunction& aProcessingFunction) |
|
40 { |
|
41 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::NewL")); |
|
42 |
|
43 COmxILMicSourceAPB0Port* self = |
|
44 new (ELeave)COmxILMicSourceAPB0Port(aParamAudioPcm, |
|
45 aConfigAudioVolume, |
|
46 aConfigAudioMute, |
|
47 aProcessingFunction); |
|
48 |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(aCommonPortData, aSupportedAudioFormats); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 |
|
54 } |
|
55 |
|
56 |
|
57 void |
|
58 COmxILMicSourceAPB0Port::ConstructL(const TOmxILCommonPortData& aCommonPortData, const RArray<OMX_AUDIO_CODINGTYPE>& aSupportedAudioFormats) |
|
59 { |
|
60 // base |
|
61 COmxILAudioPort::ConstructL(aCommonPortData, aSupportedAudioFormats); |
|
62 |
|
63 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::ConstructL")); |
|
64 OMX_PARAM_PORTDEFINITIONTYPE& paramPortDefinition=GetParamPortDefinition(); |
|
65 // We have to finish with iParamPortDefinition |
|
66 paramPortDefinition.eDomain = OMX_PortDomainAudio; |
|
67 paramPortDefinition.format.audio.pNativeRender = 0; |
|
68 |
|
69 iMimeTypeBuf.CreateL(KMimeTypeAudioPcm(), KMimeTypeAudioPcm().Length() + 1); |
|
70 |
|
71 TUint8* pTUint2 = const_cast<TUint8*>(iMimeTypeBuf.PtrZ()); |
|
72 paramPortDefinition.format.audio.cMIMEType = reinterpret_cast<OMX_STRING>(pTUint2); |
|
73 |
|
74 paramPortDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE; |
|
75 paramPortDefinition.format.audio.eEncoding = OMX_AUDIO_CodingPCM; |
|
76 |
|
77 iConfigAudioVolume.bLinear = OMX_FALSE; |
|
78 } |
|
79 |
|
80 |
|
81 COmxILMicSourceAPB0Port::COmxILMicSourceAPB0Port( |
|
82 const OMX_AUDIO_PARAM_PCMMODETYPE& aParamAudioPcm, |
|
83 const OMX_AUDIO_CONFIG_VOLUMETYPE& aConfigAudioVolume, |
|
84 const OMX_AUDIO_CONFIG_MUTETYPE& aConfigAudioMute, |
|
85 COmxILMicSourceProcessingFunction& aProcessingFunction) |
|
86 : |
|
87 iParamAudioPcm(aParamAudioPcm), |
|
88 iConfigAudioVolume(aConfigAudioVolume), |
|
89 iConfigAudioMute(aConfigAudioMute), |
|
90 iProcessingFunction(aProcessingFunction) |
|
91 { |
|
92 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::COmxILMicSourceAPB0Port")); |
|
93 } |
|
94 |
|
95 |
|
96 COmxILMicSourceAPB0Port::~COmxILMicSourceAPB0Port() |
|
97 { |
|
98 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::~COmxILMicSourceAPB0Port")); |
|
99 |
|
100 iMimeTypeBuf.Close(); |
|
101 } |
|
102 |
|
103 |
|
104 OMX_ERRORTYPE |
|
105 COmxILMicSourceAPB0Port::SetFormatInPortDefinition( |
|
106 const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition, |
|
107 TBool& aUpdateProcessingFunction) |
|
108 { |
|
109 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::SetFormatInPortDefinition")); |
|
110 |
|
111 // There's no point on chaging the cMIMEType type of this port |
|
112 // Same thing for pNativeRender and eEncoding |
|
113 GetParamPortDefinition().format.audio.bFlagErrorConcealment = |
|
114 aPortDefinition.format.audio.bFlagErrorConcealment; |
|
115 |
|
116 // Error concealment not currently needed at the processing function |
|
117 aUpdateProcessingFunction = EFalse; |
|
118 |
|
119 return OMX_ErrorNone; |
|
120 } |
|
121 |
|
122 |
|
123 TBool |
|
124 COmxILMicSourceAPB0Port::IsTunnelledPortCompatible( |
|
125 const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition) const |
|
126 { |
|
127 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::IsTunnelledPortCompatible")); |
|
128 |
|
129 // First, the easy checks... |
|
130 if(aPortDefinition.eDomain != GetParamPortDefinition().eDomain) |
|
131 { |
|
132 return EFalse; |
|
133 } |
|
134 |
|
135 if(aPortDefinition.format.audio.eEncoding != OMX_AUDIO_CodingPCM) |
|
136 { |
|
137 return EFalse; |
|
138 } |
|
139 |
|
140 TBool retValue(EFalse); |
|
141 RBuf8 tunnelMimeTypeBuf; |
|
142 TInt err = tunnelMimeTypeBuf.Create(KMimeTypeAudioPcm().Length() + 1); |
|
143 if(err == KErrNone) |
|
144 { |
|
145 |
|
146 tunnelMimeTypeBuf = |
|
147 const_cast<const TUint8*>( |
|
148 reinterpret_cast<TUint8*>(aPortDefinition.format.audio.cMIMEType)); |
|
149 |
|
150 if (iMimeTypeBuf == tunnelMimeTypeBuf) |
|
151 { |
|
152 retValue = ETrue; |
|
153 } |
|
154 |
|
155 tunnelMimeTypeBuf.Close(); |
|
156 } |
|
157 |
|
158 return retValue; |
|
159 } |
|
160 |
|
161 |
|
162 OMX_ERRORTYPE |
|
163 COmxILMicSourceAPB0Port::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const |
|
164 { |
|
165 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::GetLocalOmxParamIndexes")); |
|
166 |
|
167 // Always collect local indexes from parent |
|
168 OMX_ERRORTYPE omxRetValue = |
|
169 COmxILAudioPort::GetLocalOmxParamIndexes(aIndexArray); |
|
170 |
|
171 if (OMX_ErrorNone != omxRetValue) |
|
172 { |
|
173 return omxRetValue; |
|
174 } |
|
175 |
|
176 TInt err = aIndexArray.InsertInOrder(OMX_IndexParamAudioPcm); |
|
177 |
|
178 // Note that index duplication is OK. |
|
179 if (KErrNone != err && KErrAlreadyExists != err) |
|
180 { |
|
181 return OMX_ErrorInsufficientResources; |
|
182 } |
|
183 |
|
184 return OMX_ErrorNone; |
|
185 |
|
186 } |
|
187 |
|
188 OMX_ERRORTYPE |
|
189 COmxILMicSourceAPB0Port::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const |
|
190 { |
|
191 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::GetLocalOmxConfigIndexes")); |
|
192 |
|
193 // Always collect local indexes from parent |
|
194 OMX_ERRORTYPE omxRetValue = |
|
195 COmxILAudioPort::GetLocalOmxConfigIndexes(aIndexArray); |
|
196 |
|
197 if (OMX_ErrorNone != omxRetValue) |
|
198 { |
|
199 return omxRetValue; |
|
200 } |
|
201 |
|
202 TInt err = aIndexArray.InsertInOrder(OMX_IndexConfigAudioVolume); |
|
203 |
|
204 // Note that index duplication is OK. |
|
205 if (KErrNone == err || KErrAlreadyExists == err) |
|
206 { |
|
207 err = aIndexArray.InsertInOrder(OMX_IndexConfigAudioMute); |
|
208 } |
|
209 |
|
210 if (KErrNone != err && KErrAlreadyExists != err) |
|
211 { |
|
212 return OMX_ErrorInsufficientResources; |
|
213 } |
|
214 |
|
215 return OMX_ErrorNone; |
|
216 |
|
217 } |
|
218 |
|
219 |
|
220 OMX_ERRORTYPE |
|
221 COmxILMicSourceAPB0Port::GetParameter(OMX_INDEXTYPE aParamIndex, |
|
222 TAny* apComponentParameterStructure) const |
|
223 { |
|
224 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::GetParameter")); |
|
225 |
|
226 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
227 switch(aParamIndex) |
|
228 { |
|
229 case OMX_IndexParamAudioPcm: |
|
230 { |
|
231 if (OMX_ErrorNone != |
|
232 (omxRetValue = |
|
233 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
234 apComponentParameterStructure, |
|
235 sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)))) |
|
236 { |
|
237 return omxRetValue; |
|
238 } |
|
239 |
|
240 OMX_AUDIO_PARAM_PCMMODETYPE* pPcmMode |
|
241 = static_cast<OMX_AUDIO_PARAM_PCMMODETYPE*>( |
|
242 apComponentParameterStructure); |
|
243 |
|
244 *pPcmMode = iParamAudioPcm; |
|
245 } |
|
246 break; |
|
247 |
|
248 default: |
|
249 { |
|
250 // Try the parent's indexes |
|
251 return COmxILAudioPort::GetParameter(aParamIndex, |
|
252 apComponentParameterStructure); |
|
253 } |
|
254 }; |
|
255 |
|
256 return OMX_ErrorNone; |
|
257 |
|
258 } |
|
259 |
|
260 |
|
261 OMX_ERRORTYPE |
|
262 COmxILMicSourceAPB0Port::SetParameter(OMX_INDEXTYPE aParamIndex, |
|
263 const TAny* apComponentParameterStructure, |
|
264 TBool& aUpdateProcessingFunction) |
|
265 { |
|
266 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::SetParameter")); |
|
267 |
|
268 aUpdateProcessingFunction = EFalse; |
|
269 |
|
270 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
271 switch(aParamIndex) |
|
272 { |
|
273 case OMX_IndexParamAudioPcm: |
|
274 { |
|
275 if (OMX_ErrorNone != |
|
276 (omxRetValue = |
|
277 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
278 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
279 sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)))) |
|
280 { |
|
281 return omxRetValue; |
|
282 } |
|
283 |
|
284 const OMX_AUDIO_PARAM_PCMMODETYPE* pPcmMode |
|
285 = static_cast<const OMX_AUDIO_PARAM_PCMMODETYPE*>( |
|
286 apComponentParameterStructure); |
|
287 |
|
288 // Set the new default values |
|
289 if (iParamAudioPcm.eNumData != pPcmMode->eNumData || |
|
290 iParamAudioPcm.eEndian != pPcmMode->eEndian || |
|
291 iParamAudioPcm.bInterleaved != pPcmMode->bInterleaved || |
|
292 iParamAudioPcm.nBitPerSample != pPcmMode->nBitPerSample || |
|
293 iParamAudioPcm.nSamplingRate != pPcmMode->nSamplingRate || |
|
294 iParamAudioPcm.ePCMMode != pPcmMode->ePCMMode) |
|
295 { |
|
296 iParamAudioPcm.eNumData = pPcmMode->eNumData; |
|
297 iParamAudioPcm.eEndian = pPcmMode->eEndian; |
|
298 iParamAudioPcm.bInterleaved = pPcmMode->bInterleaved; |
|
299 iParamAudioPcm.nBitPerSample = pPcmMode->nBitPerSample; |
|
300 iParamAudioPcm.nSamplingRate = pPcmMode->nSamplingRate; |
|
301 iParamAudioPcm.ePCMMode = pPcmMode->ePCMMode; |
|
302 // This is an indication to the PortManager that the processing |
|
303 // function needs to get updated |
|
304 aUpdateProcessingFunction = ETrue; |
|
305 } |
|
306 |
|
307 if(iParamAudioPcm.nChannels != pPcmMode->nChannels) |
|
308 { |
|
309 iParamAudioPcm.nChannels = pPcmMode->nChannels; |
|
310 aUpdateProcessingFunction = ETrue; |
|
311 |
|
312 //Only change channel mappings when the number of channels has been changed. |
|
313 for (TInt i=0; i<OMX_AUDIO_MAXCHANNELS; i++) |
|
314 { |
|
315 |
|
316 if (iParamAudioPcm.eChannelMapping[i] != pPcmMode->eChannelMapping[i]) |
|
317 { |
|
318 iParamAudioPcm.eChannelMapping[i] = pPcmMode->eChannelMapping[i]; |
|
319 } |
|
320 } |
|
321 } |
|
322 } |
|
323 break; |
|
324 default: |
|
325 { |
|
326 // Try the parent's indexes |
|
327 return COmxILAudioPort::SetParameter(aParamIndex, |
|
328 apComponentParameterStructure, |
|
329 aUpdateProcessingFunction); |
|
330 } |
|
331 }; |
|
332 |
|
333 return OMX_ErrorNone; |
|
334 |
|
335 } |
|
336 |
|
337 |
|
338 OMX_ERRORTYPE |
|
339 COmxILMicSourceAPB0Port::GetConfig(OMX_INDEXTYPE aConfigIndex, |
|
340 TAny* apComponentConfigStructure) const |
|
341 { |
|
342 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::GetConfig")); |
|
343 |
|
344 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
345 switch(aConfigIndex) |
|
346 { |
|
347 case OMX_IndexConfigAudioVolume: |
|
348 { |
|
349 if (OMX_ErrorNone != |
|
350 (omxRetValue = |
|
351 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
352 apComponentConfigStructure, |
|
353 sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE)))) |
|
354 { |
|
355 return omxRetValue; |
|
356 } |
|
357 |
|
358 OMX_AUDIO_CONFIG_VOLUMETYPE* pConfigVolume |
|
359 = static_cast<OMX_AUDIO_CONFIG_VOLUMETYPE*>( |
|
360 apComponentConfigStructure); |
|
361 |
|
362 *pConfigVolume = iConfigAudioVolume; |
|
363 } |
|
364 break; |
|
365 |
|
366 case OMX_IndexConfigAudioMute: |
|
367 { |
|
368 if (OMX_ErrorNone != |
|
369 (omxRetValue = |
|
370 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
371 apComponentConfigStructure, |
|
372 sizeof(OMX_AUDIO_CONFIG_MUTETYPE)))) |
|
373 { |
|
374 return omxRetValue; |
|
375 } |
|
376 |
|
377 OMX_AUDIO_CONFIG_MUTETYPE* pConfigMute |
|
378 = static_cast<OMX_AUDIO_CONFIG_MUTETYPE*>( |
|
379 apComponentConfigStructure); |
|
380 |
|
381 *pConfigMute = iConfigAudioMute; |
|
382 } |
|
383 break; |
|
384 |
|
385 default: |
|
386 { |
|
387 // There's no need to try the parent indexes as we know there isn't any |
|
388 // other config in the parent audio classes |
|
389 return OMX_ErrorUnsupportedIndex; |
|
390 } |
|
391 }; |
|
392 |
|
393 return OMX_ErrorNone; |
|
394 |
|
395 } |
|
396 |
|
397 OMX_ERRORTYPE |
|
398 COmxILMicSourceAPB0Port::SetConfig(OMX_INDEXTYPE aConfigIndex, |
|
399 const TAny* apComponentConfigStructure, |
|
400 TBool& aUpdateProcessingFunction) |
|
401 { |
|
402 DEBUG_PRINTF(_L8("COmxILMicSourceAPB0Port::SetConfig")); |
|
403 |
|
404 aUpdateProcessingFunction = EFalse; |
|
405 |
|
406 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
407 switch(aConfigIndex) |
|
408 { |
|
409 case OMX_IndexConfigAudioVolume: |
|
410 { |
|
411 if (OMX_ErrorNone != |
|
412 (omxRetValue = |
|
413 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
414 const_cast<OMX_PTR>(apComponentConfigStructure), |
|
415 sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE)))) |
|
416 { |
|
417 return omxRetValue; |
|
418 } |
|
419 |
|
420 const OMX_AUDIO_CONFIG_VOLUMETYPE* pConfigVolume |
|
421 = static_cast<const OMX_AUDIO_CONFIG_VOLUMETYPE*>( |
|
422 apComponentConfigStructure); |
|
423 |
|
424 // Set the new default values |
|
425 if (iConfigAudioVolume.bLinear != pConfigVolume->bLinear || |
|
426 iConfigAudioVolume.sVolume.nValue != pConfigVolume->sVolume.nValue || |
|
427 iConfigAudioVolume.sVolume.nMin != pConfigVolume->sVolume.nMin || |
|
428 iConfigAudioVolume.sVolume.nMax != pConfigVolume->sVolume.nMax) |
|
429 { |
|
430 iConfigAudioVolume.bLinear = pConfigVolume->bLinear; |
|
431 iConfigAudioVolume.sVolume.nValue = pConfigVolume->sVolume.nValue; |
|
432 iConfigAudioVolume.sVolume.nMin = pConfigVolume->sVolume.nMin; |
|
433 iConfigAudioVolume.sVolume.nMax = pConfigVolume->sVolume.nMax; |
|
434 // This is an indication to the PortManager that the processing |
|
435 // function needs to get updated |
|
436 aUpdateProcessingFunction = ETrue; |
|
437 } |
|
438 |
|
439 } |
|
440 break; |
|
441 case OMX_IndexConfigAudioMute: |
|
442 { |
|
443 if (OMX_ErrorNone != |
|
444 (omxRetValue = |
|
445 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
446 const_cast<OMX_PTR>(apComponentConfigStructure), |
|
447 sizeof(OMX_AUDIO_CONFIG_MUTETYPE)))) |
|
448 { |
|
449 return omxRetValue; |
|
450 } |
|
451 |
|
452 const OMX_AUDIO_CONFIG_MUTETYPE* pConfigMute |
|
453 = static_cast<const OMX_AUDIO_CONFIG_MUTETYPE*>( |
|
454 apComponentConfigStructure); |
|
455 |
|
456 if (iConfigAudioMute.bMute != pConfigMute->bMute) |
|
457 { |
|
458 iConfigAudioMute.bMute = pConfigMute->bMute; |
|
459 // This is an indication to the PortManager that the processing |
|
460 // function needs to get updated |
|
461 aUpdateProcessingFunction = ETrue; |
|
462 } |
|
463 |
|
464 } |
|
465 break; |
|
466 default: |
|
467 { |
|
468 // There's no need to try the parent indexes as we know there isn't any |
|
469 // other config in the parent audio classes |
|
470 return OMX_ErrorUnsupportedIndex; |
|
471 } |
|
472 }; |
|
473 |
|
474 return OMX_ErrorNone; |
|
475 } |
|
476 |
|
477 OMX_ERRORTYPE |
|
478 COmxILMicSourceAPB0Port::DoBufferAllocation(OMX_U32 aSizeBytes, |
|
479 OMX_U8*& apPortSpecificBuffer, |
|
480 OMX_PTR& /* apPortPrivate */, |
|
481 OMX_PTR& /* apPlatformPrivate */, |
|
482 OMX_PTR /* apAppPrivate */) |
|
483 { |
|
484 //Simply delegate the call down to processing function class. |
|
485 return iProcessingFunction.DoBufferAllocation(aSizeBytes, |
|
486 apPortSpecificBuffer, |
|
487 GetParamPortDefinition()); |
|
488 } |
|
489 |
|
490 void COmxILMicSourceAPB0Port::DoBufferDeallocation(OMX_PTR apPortSpecificBuffer, |
|
491 OMX_PTR apPortPrivate, |
|
492 OMX_PTR /*apPlatformPrivate*/, |
|
493 OMX_PTR /* apAppPrivate */) |
|
494 { |
|
495 //Simply delegate the call down to processing function class. |
|
496 iProcessingFunction.DoBufferDeallocation(apPortSpecificBuffer, apPortPrivate); |
|
497 } |
|
498 |
|
499 OMX_ERRORTYPE |
|
500 COmxILMicSourceAPB0Port::DoBufferWrapping(OMX_U32 aSizeBytes, |
|
501 OMX_U8* apBuffer, |
|
502 OMX_PTR& apPortPrivate, |
|
503 OMX_PTR& /*apPlatformPrivate*/, |
|
504 OMX_PTR /* apAppPrivate */ ) |
|
505 { |
|
506 if(aSizeBytes > GetParamPortDefinition().nBufferSize) |
|
507 { |
|
508 //Make sure the sharing buffers is smaller than the native buffers |
|
509 GetParamPortDefinition().nBufferSize = aSizeBytes; |
|
510 } |
|
511 |
|
512 return iProcessingFunction.DoBufferWrapping(aSizeBytes, |
|
513 apBuffer, |
|
514 apPortPrivate, |
|
515 GetParamPortDefinition()); |
|
516 } |
|
517 |
|
518 void COmxILMicSourceAPB0Port::DoBufferUnwrapping(OMX_PTR apPortSpecificBuffer, |
|
519 OMX_PTR apPortPrivate, |
|
520 OMX_PTR /*apPlatformPrivate*/, |
|
521 OMX_PTR /* apAppPrivate */) |
|
522 { |
|
523 //Simply delegate the call down to processing function class. |
|
524 iProcessingFunction.DoBufferUnwrapping(apPortSpecificBuffer, apPortPrivate); |
|
525 } |
|
526 |