First public contribution.
1 // Copyright (c) 2005-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "pcminputport.h"
17 #include "pcmprocessingunit.h"
18 #include <mdf/mdfpuconfig.h>
20 const TUint KSampleRate = 8000;
21 const TUint KMonoChannel = 1;
22 const TUint KStereoChannel = 2;
25 CPcmInputPort* CPcmInputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType)
27 CPcmInputPort* self = new (ELeave) CPcmInputPort(aDataType);
28 CleanupStack::PushL (self);
29 self->ConstructL(aIndex, aParent);
34 void CPcmInputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent)
36 COmxInputPort::ConstructL(aIndex, aParent);
39 CPcmInputPort::CPcmInputPort(TPcmDataType aDataType) :
41 iSampleRate(KSampleRate),
42 iChannels(KMonoChannel),
48 TInt CPcmInputPort::MipConfigure(const TPuConfig& aConfig)
50 if (aConfig.Uid() == TUid::Uid(KUidTTaskConfig))
52 const TTaskConfig* config = TPuTaskConfig::GetStructure(aConfig);
54 iSampleRate = config->iRate;
55 iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel;
56 iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse;
59 return KErrNotSupported;
62 void CPcmInputPort::MipInitialize()
64 OMX_AUDIO_PARAM_PCMMODETYPE pcm;
70 pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
71 pcm.nPortIndex = MipIndex();
72 pcm.nSamplingRate = iSampleRate;
73 pcm.ePCMMode = OMX_AUDIO_PCMModeLinear;
74 pcm.nChannels = iChannels;
75 pcm.bInterleaved = (OMX_BOOL)iInterleaved;
80 pcm.nBitPerSample = 8;
81 pcm.eNumData = OMX_NumericalDataSigned;
84 pcm.nBitPerSample = 8;
85 pcm.eNumData = OMX_NumericalDataUnsigned;
88 pcm.nBitPerSample = 16;
89 pcm.eNumData = OMX_NumericalDataSigned;
94 Component()->OmxSetParameter(OMX_IndexParamAudioPcm, &pcm);