1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
21 @internalComponent |
21 @internalComponent |
22 */ |
22 */ |
23 |
23 |
24 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
24 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
25 #include <openmax/il/common/omxilutil.h> |
25 #include <openmax/il/common/omxilutil.h> |
|
26 #include <openmax/il/shai/OMX_Symbian_ExtensionNames.h> |
26 #include "log.h" |
27 #include "log.h" |
27 #include "omxilpcmrendererapb0port.h" |
28 #include "omxilpcmrendererapb0port.h" |
28 #include "omxilpcmrendererconst.h" |
29 #include "omxilpcmrendererconst.h" |
29 |
30 #include "omxilpcmrendererprocessingfunction.h" |
30 |
31 |
31 COmxILPcmRendererAPB0Port* |
32 |
32 COmxILPcmRendererAPB0Port::NewL( |
33 COmxILPcmRendererAPB0Port* COmxILPcmRendererAPB0Port::NewL( |
33 const TOmxILCommonPortData& aCommonPortData, |
34 const TOmxILCommonPortData& aCommonPortData, |
34 const RArray<OMX_AUDIO_CODINGTYPE>& aSupportedAudioFormats, |
35 const RArray<OMX_AUDIO_CODINGTYPE>& aSupportedAudioFormats, |
35 const OMX_AUDIO_PARAM_PCMMODETYPE& aParamAudioPcm, |
36 const OMX_AUDIO_PARAM_PCMMODETYPE& aParamAudioPcm, |
36 const OMX_AUDIO_CONFIG_VOLUMETYPE& aConfigAudioVolume, |
37 const OMX_AUDIO_CONFIG_VOLUMETYPE& aConfigAudioVolume, |
37 const OMX_AUDIO_CONFIG_MUTETYPE& aConfigAudioMute) |
38 const OMX_AUDIO_CONFIG_MUTETYPE& aConfigAudioMute, |
|
39 COmxILPcmRendererProcessingFunction& aProcessingFunction) |
38 { |
40 { |
39 DEBUG_PRINTF(_L8("COmxILPcmRendererAPB0Port::NewL")); |
41 DEBUG_PRINTF(_L8("COmxILPcmRendererAPB0Port::NewL")); |
40 |
42 |
41 COmxILPcmRendererAPB0Port* self = new (ELeave)COmxILPcmRendererAPB0Port( |
43 COmxILPcmRendererAPB0Port* self = new (ELeave)COmxILPcmRendererAPB0Port( |
42 aParamAudioPcm, |
44 aParamAudioPcm, |
43 aConfigAudioVolume, |
45 aConfigAudioVolume, |
44 aConfigAudioMute); |
46 aConfigAudioMute, |
|
47 aProcessingFunction); |
45 |
48 |
46 CleanupStack::PushL(self); |
49 CleanupStack::PushL(self); |
47 self->ConstructL(aCommonPortData, aSupportedAudioFormats); |
50 self->ConstructL(aCommonPortData, aSupportedAudioFormats); |
48 CleanupStack::Pop(self); |
51 CleanupStack::Pop(self); |
49 return self; |
52 return self; |
67 paramPortDefinition.format.audio.cMIMEType = reinterpret_cast<OMX_STRING>(pTUint2); |
70 paramPortDefinition.format.audio.cMIMEType = reinterpret_cast<OMX_STRING>(pTUint2); |
68 |
71 |
69 paramPortDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE; |
72 paramPortDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE; |
70 paramPortDefinition.format.audio.eEncoding = OMX_AUDIO_CodingPCM; |
73 paramPortDefinition.format.audio.eEncoding = OMX_AUDIO_CodingPCM; |
71 |
74 |
72 // Init iParamVolumeRamp here... |
75 // Init iConfigVolumeRamp here... |
73 iConfigVolumeRamp.nSize = sizeof(OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP); |
76 iConfigVolumeRamp.nSize = sizeof(OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE); |
74 iConfigVolumeRamp.nVersion = TOmxILSpecVersion(); |
77 iConfigVolumeRamp.nVersion = TOmxILSpecVersion(); |
75 iConfigVolumeRamp.nPortIndex = paramPortDefinition.nPortIndex; |
78 iConfigVolumeRamp.nPortIndex = paramPortDefinition.nPortIndex; |
76 iConfigVolumeRamp.nRampDuration = 0; |
79 iConfigVolumeRamp.nChannel = 0; |
|
80 iConfigVolumeRamp.bLinear = OMX_FALSE; |
|
81 iConfigVolumeRamp.sStartVolume.nValue = 0; |
|
82 iConfigVolumeRamp.sStartVolume.nMin = 0; |
|
83 iConfigVolumeRamp.sStartVolume.nMax = 0; |
|
84 iConfigVolumeRamp.sEndVolume.nValue = 0; |
|
85 iConfigVolumeRamp.sEndVolume.nMin = 0; |
|
86 iConfigVolumeRamp.sEndVolume.nMax = 0; |
|
87 iConfigVolumeRamp.nRampDuration = 0; |
|
88 iConfigVolumeRamp.bRampTerminate = OMX_FALSE; |
|
89 iConfigVolumeRamp.sCurrentVolume.nValue = 0; |
|
90 iConfigVolumeRamp.sCurrentVolume.nMin = 0; |
|
91 iConfigVolumeRamp.sCurrentVolume.nMax = 0; |
|
92 iConfigVolumeRamp.nRampCurrentTime = 0; |
|
93 iConfigVolumeRamp.nRampMinDuration = 0; |
|
94 iConfigVolumeRamp.nRampMaxDuration = 0; |
|
95 iConfigVolumeRamp.nVolumeStep = 0; |
77 } |
96 } |
78 |
97 |
79 |
98 |
80 COmxILPcmRendererAPB0Port::COmxILPcmRendererAPB0Port( |
99 COmxILPcmRendererAPB0Port::COmxILPcmRendererAPB0Port( |
81 const OMX_AUDIO_PARAM_PCMMODETYPE& aParamAudioPcm, |
100 const OMX_AUDIO_PARAM_PCMMODETYPE& aParamAudioPcm, |
82 const OMX_AUDIO_CONFIG_VOLUMETYPE& aConfigAudioVolume, |
101 const OMX_AUDIO_CONFIG_VOLUMETYPE& aConfigAudioVolume, |
83 const OMX_AUDIO_CONFIG_MUTETYPE& aConfigAudioMute) |
102 const OMX_AUDIO_CONFIG_MUTETYPE& aConfigAudioMute, |
|
103 COmxILPcmRendererProcessingFunction& aProcessingFunction) |
84 : |
104 : |
85 iParamAudioPcm(aParamAudioPcm), |
105 iParamAudioPcm(aParamAudioPcm), |
86 iConfigAudioVolume(aConfigAudioVolume), |
106 iConfigAudioVolume(aConfigAudioVolume), |
87 iConfigAudioMute(aConfigAudioMute) |
107 iConfigAudioMute(aConfigAudioMute), |
|
108 iProcessingFunction(aProcessingFunction) |
88 { |
109 { |
89 DEBUG_PRINTF(_L8("COmxILPcmRendererAPB0Port::COmxILPcmRendererAPB0Port")); |
110 DEBUG_PRINTF(_L8("COmxILPcmRendererAPB0Port::COmxILPcmRendererAPB0Port")); |
90 } |
111 } |
91 |
112 |
92 |
113 |
198 } |
219 } |
199 |
220 |
200 TInt err = aIndexArray.InsertInOrder(OMX_IndexConfigAudioVolume); |
221 TInt err = aIndexArray.InsertInOrder(OMX_IndexConfigAudioVolume); |
201 |
222 |
202 // Note that index duplication is OK. |
223 // Note that index duplication is OK. |
203 if (KErrNone == err || KErrAlreadyExists == err) |
|
204 { |
|
205 err = aIndexArray.InsertInOrder(OMX_IndexConfigAudioMute); |
|
206 |
|
207 if (KErrNone == err || KErrAlreadyExists == err) |
|
208 { |
|
209 err = aIndexArray.InsertInOrder( |
|
210 OMX_SymbianIndexConfigAudioPcmVolumeRamp); |
|
211 } |
|
212 |
|
213 } |
|
214 |
|
215 if (KErrNone != err && KErrAlreadyExists != err) |
224 if (KErrNone != err && KErrAlreadyExists != err) |
216 { |
225 { |
|
226 return OMX_ErrorInsufficientResources; |
|
227 } |
|
228 |
|
229 err = aIndexArray.InsertInOrder(OMX_IndexConfigAudioMute); |
|
230 |
|
231 if (KErrNone != err && KErrAlreadyExists != err) |
|
232 { |
|
233 return OMX_ErrorInsufficientResources; |
|
234 } |
|
235 |
|
236 err = aIndexArray.InsertInOrder( |
|
237 OMX_SYMBIANINDEXCONFIGAUDIOPCMVOLUMERAMP); |
|
238 |
|
239 if (KErrNone != err && KErrAlreadyExists != err) |
|
240 { |
217 return OMX_ErrorInsufficientResources; |
241 return OMX_ErrorInsufficientResources; |
218 } |
242 } |
219 |
243 |
|
244 err = aIndexArray.InsertInOrder( |
|
245 OMX_SYMBIANINDEXCONFIGAUDIODATAAMOUNT); |
|
246 |
|
247 if (KErrNone != err && KErrAlreadyExists != err) |
|
248 { |
|
249 return OMX_ErrorInsufficientResources; |
|
250 } |
|
251 |
220 return OMX_ErrorNone; |
252 return OMX_ErrorNone; |
221 |
|
222 } |
253 } |
223 |
254 |
224 |
255 |
225 OMX_ERRORTYPE |
256 OMX_ERRORTYPE |
226 COmxILPcmRendererAPB0Port::GetParameter(OMX_INDEXTYPE aParamIndex, |
257 COmxILPcmRendererAPB0Port::GetParameter(OMX_INDEXTYPE aParamIndex, |
370 DEBUG_PRINTF(_L8("COmxILPcmRendererAPB0Port::GetConfig")); |
401 DEBUG_PRINTF(_L8("COmxILPcmRendererAPB0Port::GetConfig")); |
371 |
402 |
372 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
403 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
373 switch(aConfigIndex) |
404 switch(aConfigIndex) |
374 { |
405 { |
375 case OMX_SymbianIndexConfigAudioPcmVolumeRamp: |
406 case OMX_SYMBIANINDEXCONFIGAUDIOPCMVOLUMERAMP: |
376 { |
407 { |
377 if (OMX_ErrorNone != |
408 if (OMX_ErrorNone != |
378 (omxRetValue = |
409 (omxRetValue = |
379 TOmxILUtil::CheckOmxStructSizeAndVersion( |
410 TOmxILUtil::CheckOmxStructSizeAndVersion( |
380 apComponentConfigStructure, |
411 apComponentConfigStructure, |
381 sizeof(OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP)))) |
412 sizeof(OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE)))) |
382 { |
413 { |
383 return omxRetValue; |
414 return omxRetValue; |
384 } |
415 } |
385 |
416 |
386 OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP* |
417 OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE* |
387 pPcmVolumeRamp |
418 pPcmVolumeRamp |
388 = static_cast< |
419 = static_cast< |
389 OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP*>( |
420 OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE*>( |
390 apComponentConfigStructure); |
421 apComponentConfigStructure); |
391 |
422 |
392 *pPcmVolumeRamp = iConfigVolumeRamp; |
423 *pPcmVolumeRamp = iConfigVolumeRamp; |
393 } |
424 } |
394 break; |
425 break; |
395 |
426 |
|
427 case OMX_SYMBIANINDEXCONFIGAUDIODATAAMOUNT: |
|
428 { |
|
429 if (OMX_ErrorNone != |
|
430 (omxRetValue = |
|
431 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
432 apComponentConfigStructure, |
|
433 sizeof(OMX_SYMBIAN_AUDIO_CONFIG_PROCESSEDDATAAMOUNTTYPE)))) |
|
434 { |
|
435 return omxRetValue; |
|
436 } |
|
437 |
|
438 OMX_SYMBIAN_AUDIO_CONFIG_PROCESSEDDATAAMOUNTTYPE* |
|
439 pPcmDataAmount |
|
440 = static_cast< |
|
441 OMX_SYMBIAN_AUDIO_CONFIG_PROCESSEDDATAAMOUNTTYPE*>( |
|
442 apComponentConfigStructure); |
|
443 |
|
444 TInt bytePlayed = iProcessingFunction.GetBytesPlayed(); |
|
445 |
|
446 // Convert into OMX_TICKS |
|
447 // #define OMX_TICKS_PER_SECOND 1000000 |
|
448 |
|
449 #ifndef OMX_SKIP64BIT |
|
450 OMX_TICKS ticks = static_cast<OMX_TICKS>(bytePlayed) * 8 * OMX_TICKS_PER_SECOND / |
|
451 static_cast<OMX_TICKS>(iParamAudioPcm.nBitPerSample) / static_cast<OMX_TICKS>(iParamAudioPcm.nSamplingRate); |
|
452 pPcmDataAmount->nProcessedDataAmount = ticks; |
|
453 #else |
|
454 TInt64 ticks = static_cast<TInt64>(bytePlayed) * 8 * OMX_TICKS_PER_SECOND/ |
|
455 static_cast<TInt64>(iParamAudioPcm.nBitPerSample) / static_cast<TInt64>(iParamAudioPcm.nSamplingRate); |
|
456 |
|
457 pPcmDataAmount->nProcessedDataAmount.nLowPart = ticks & 0xffffffff; |
|
458 pPcmDataAmount->nProcessedDataAmount.nHighPart = ticks >> 32; |
|
459 #endif |
|
460 |
|
461 } |
|
462 break; |
|
463 |
396 case OMX_IndexConfigAudioVolume: |
464 case OMX_IndexConfigAudioVolume: |
397 { |
465 { |
398 if (OMX_ErrorNone != |
466 if (OMX_ErrorNone != |
399 (omxRetValue = |
467 (omxRetValue = |
400 TOmxILUtil::CheckOmxStructSizeAndVersion( |
468 TOmxILUtil::CheckOmxStructSizeAndVersion( |
453 aUpdateProcessingFunction = EFalse; |
521 aUpdateProcessingFunction = EFalse; |
454 |
522 |
455 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
523 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
456 switch(aConfigIndex) |
524 switch(aConfigIndex) |
457 { |
525 { |
458 case OMX_SymbianIndexConfigAudioPcmVolumeRamp: |
526 case OMX_SYMBIANINDEXCONFIGAUDIOPCMVOLUMERAMP: |
459 { |
527 { |
460 if (OMX_ErrorNone != |
528 if (OMX_ErrorNone != |
461 (omxRetValue = |
529 (omxRetValue = |
462 TOmxILUtil::CheckOmxStructSizeAndVersion( |
530 TOmxILUtil::CheckOmxStructSizeAndVersion( |
463 const_cast<OMX_PTR>(apComponentConfigStructure), |
531 const_cast<OMX_PTR>(apComponentConfigStructure), |
464 sizeof(OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP)))) |
532 sizeof(OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE)))) |
465 { |
533 { |
466 return omxRetValue; |
534 return omxRetValue; |
467 } |
535 } |
468 |
536 |
469 const OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP* |
537 const OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE* |
470 pPcmVolumeRamp |
538 pPcmVolumeRamp |
471 = static_cast< |
539 = static_cast< |
472 const OMX_SYMBIAN_AUDIO_CONFIG_PCM_VOLUMERAMP*>( |
540 const OMX_SYMBIAN_AUDIO_CONFIG_VOLUMERAMPTYPE*>( |
473 apComponentConfigStructure); |
541 apComponentConfigStructure); |
474 |
542 |
475 if (iConfigVolumeRamp.nRampDuration != pPcmVolumeRamp->nRampDuration) |
543 if (iConfigVolumeRamp.nRampDuration != pPcmVolumeRamp->nRampDuration) |
476 { |
544 { |
477 // This is an indication to the PortManager that the processing |
545 // This is an indication to the PortManager that the processing |
562 TPtrC8 requestedParameterNamePtr( |
630 TPtrC8 requestedParameterNamePtr( |
563 const_cast<const TUint8*>( |
631 const_cast<const TUint8*>( |
564 reinterpret_cast<TUint8*>(aParameterName))); |
632 reinterpret_cast<TUint8*>(aParameterName))); |
565 |
633 |
566 TPtrC8 parameterNamePtr( |
634 TPtrC8 parameterNamePtr( |
567 reinterpret_cast<const TUint8*>(sOmxSymbianPcmVolumeRamp)); |
635 reinterpret_cast<const TUint8*>(OMX_SYMBIAN_INDEX_CONFIG_AUDIO_VOLUMERAMP_NAME)); |
568 |
636 |
569 if (requestedParameterNamePtr == parameterNamePtr) |
637 if (requestedParameterNamePtr == parameterNamePtr) |
570 { |
638 { |
571 *apIndexType = |
639 *apIndexType = static_cast<OMX_INDEXTYPE>(OMX_SYMBIANINDEXCONFIGAUDIOPCMVOLUMERAMP); |
572 static_cast<OMX_INDEXTYPE>( |
|
573 OMX_SymbianIndexConfigAudioPcmVolumeRamp); |
|
574 |
640 |
575 return OMX_ErrorNone; |
641 return OMX_ErrorNone; |
576 } |
642 } |
|
643 |
|
644 parameterNamePtr.Set(reinterpret_cast<const TUint8*>(OMX_SYMBIAN_INDEX_CONFIG_AUDIO_DATAAMOUNT_NAME)); |
|
645 |
|
646 if (requestedParameterNamePtr == parameterNamePtr) |
|
647 { |
|
648 *apIndexType = static_cast<OMX_INDEXTYPE>(OMX_SYMBIANINDEXCONFIGAUDIODATAAMOUNT); |
|
649 |
|
650 return OMX_ErrorNone; |
|
651 } |
577 |
652 |
578 *apIndexType = OMX_IndexMax; |
653 *apIndexType = OMX_IndexMax; |
579 return OMX_ErrorUnsupportedIndex; |
654 return OMX_ErrorUnsupportedIndex; |
580 } |
655 } |