os/mm/mmdevicefw/mdfunittest/codecapi/PU/pcmcodec/src/pcminputport.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmdevicefw/mdfunittest/codecapi/PU/pcmcodec/src/pcminputport.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,96 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "pcminputport.h"
    1.20 +#include "pcmprocessingunit.h"
    1.21 +#include <mdf/mdfpuconfig.h>
    1.22 +
    1.23 +const TUint KSampleRate 	= 8000;
    1.24 +const TUint KMonoChannel 	= 1;
    1.25 +const TUint KStereoChannel	= 2;
    1.26 +
    1.27 +
    1.28 +CPcmInputPort* CPcmInputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType)
    1.29 +	{
    1.30 +	CPcmInputPort* self = new (ELeave) CPcmInputPort(aDataType);
    1.31 +	CleanupStack::PushL (self);
    1.32 +	self->ConstructL(aIndex, aParent);
    1.33 +	CleanupStack::Pop();
    1.34 +	return self;
    1.35 +	}
    1.36 +	
    1.37 +void CPcmInputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent)
    1.38 +	{
    1.39 +	COmxInputPort::ConstructL(aIndex, aParent);
    1.40 +	}
    1.41 +
    1.42 +CPcmInputPort::CPcmInputPort(TPcmDataType aDataType) :
    1.43 +	COmxInputPort(),
    1.44 +	iSampleRate(KSampleRate),
    1.45 +	iChannels(KMonoChannel),
    1.46 +	iInterleaved(EFalse),
    1.47 +	iDataType(aDataType)
    1.48 +	{
    1.49 +	}
    1.50 +	
    1.51 +TInt CPcmInputPort::MipConfigure(const TPuConfig& aConfig)
    1.52 +	{
    1.53 +	if (aConfig.Uid() == TUid::Uid(KUidTTaskConfig))
    1.54 +		{
    1.55 +		const TTaskConfig* config = TPuTaskConfig::GetStructure(aConfig);	
    1.56 +	
    1.57 +		iSampleRate = config->iRate;
    1.58 +		iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel;
    1.59 +		iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse;
    1.60 +		return KErrNone;
    1.61 +		}
    1.62 +	return KErrNotSupported;	
    1.63 +	}
    1.64 +	
    1.65 +void CPcmInputPort::MipInitialize()
    1.66 +	{
    1.67 +	OMX_AUDIO_PARAM_PCMMODETYPE pcm;
    1.68 +	OMX_VERSIONTYPE ver = 
    1.69 +		{
    1.70 +		1,0
    1.71 +		};
    1.72 +	pcm.nVersion = ver;
    1.73 +	pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
    1.74 +	pcm.nPortIndex = MipIndex();
    1.75 +	pcm.nSamplingRate = iSampleRate;
    1.76 +	pcm.ePCMMode = OMX_AUDIO_PCMModeLinear;
    1.77 +	pcm.nChannels = iChannels;
    1.78 +	pcm.bInterleaved = (OMX_BOOL)iInterleaved;
    1.79 +
    1.80 +	switch (iDataType)
    1.81 +		{
    1.82 +	case EPCM8:
    1.83 +		pcm.nBitPerSample = 8;
    1.84 +		pcm.eNumData = OMX_NumericalDataSigned; 
    1.85 +		break;
    1.86 +	case EPCMU8:
    1.87 +		pcm.nBitPerSample = 8;
    1.88 +		pcm.eNumData = OMX_NumericalDataUnsigned; 
    1.89 +		break;
    1.90 +	case EPCM16:
    1.91 +		pcm.nBitPerSample = 16;
    1.92 +		pcm.eNumData = OMX_NumericalDataSigned; 
    1.93 +		break;
    1.94 +		}
    1.95 +	
    1.96 +	// Set Input Port
    1.97 +	Component()->OmxSetParameter(OMX_IndexParamAudioPcm, &pcm);
    1.98 +	}
    1.99 +