sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "pcminputport.h" sl@0: #include "pcmprocessingunit.h" sl@0: #include sl@0: sl@0: const TUint KSampleRate = 8000; sl@0: const TUint KMonoChannel = 1; sl@0: const TUint KStereoChannel = 2; sl@0: sl@0: sl@0: CPcmInputPort* CPcmInputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType) sl@0: { sl@0: CPcmInputPort* self = new (ELeave) CPcmInputPort(aDataType); sl@0: CleanupStack::PushL (self); sl@0: self->ConstructL(aIndex, aParent); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: void CPcmInputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent) sl@0: { sl@0: COmxInputPort::ConstructL(aIndex, aParent); sl@0: } sl@0: sl@0: CPcmInputPort::CPcmInputPort(TPcmDataType aDataType) : sl@0: COmxInputPort(), sl@0: iSampleRate(KSampleRate), sl@0: iChannels(KMonoChannel), sl@0: iInterleaved(EFalse), sl@0: iDataType(aDataType) sl@0: { sl@0: } sl@0: sl@0: TInt CPcmInputPort::MipConfigure(const TPuConfig& aConfig) sl@0: { sl@0: if (aConfig.Uid() == TUid::Uid(KUidTTaskConfig)) sl@0: { sl@0: const TTaskConfig* config = TPuTaskConfig::GetStructure(aConfig); sl@0: sl@0: iSampleRate = config->iRate; sl@0: iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel; sl@0: iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse; sl@0: return KErrNone; sl@0: } sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: void CPcmInputPort::MipInitialize() sl@0: { sl@0: OMX_AUDIO_PARAM_PCMMODETYPE pcm; sl@0: OMX_VERSIONTYPE ver = sl@0: { sl@0: 1,0 sl@0: }; sl@0: pcm.nVersion = ver; sl@0: pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE); sl@0: pcm.nPortIndex = MipIndex(); sl@0: pcm.nSamplingRate = iSampleRate; sl@0: pcm.ePCMMode = OMX_AUDIO_PCMModeLinear; sl@0: pcm.nChannels = iChannels; sl@0: pcm.bInterleaved = (OMX_BOOL)iInterleaved; sl@0: sl@0: switch (iDataType) sl@0: { sl@0: case EPCM8: sl@0: pcm.nBitPerSample = 8; sl@0: pcm.eNumData = OMX_NumericalDataSigned; sl@0: break; sl@0: case EPCMU8: sl@0: pcm.nBitPerSample = 8; sl@0: pcm.eNumData = OMX_NumericalDataUnsigned; sl@0: break; sl@0: case EPCM16: sl@0: pcm.nBitPerSample = 16; sl@0: pcm.eNumData = OMX_NumericalDataSigned; sl@0: break; sl@0: } sl@0: sl@0: // Set Input Port sl@0: Component()->OmxSetParameter(OMX_IndexParamAudioPcm, &pcm); sl@0: } sl@0: