1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/mdfunittest/codecapi/PU/pcmcodec/src/pcmoutputport.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,95 @@
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 "pcmoutputport.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 +CPcmOutputPort* CPcmOutputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType)
1.29 + {
1.30 + CPcmOutputPort* self = new (ELeave) CPcmOutputPort(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 CPcmOutputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent)
1.38 + {
1.39 + COmxOutputPort::ConstructL(aIndex, aParent);
1.40 + }
1.41 +
1.42 +CPcmOutputPort::CPcmOutputPort(TPcmDataType aDataType) :
1.43 + COmxOutputPort(),
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 CPcmOutputPort::MopConfigure(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 + iSampleRate = config->iRate;
1.57 + iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel;
1.58 + iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse;
1.59 + return KErrNone;
1.60 + }
1.61 + return KErrNotSupported;
1.62 + }
1.63 +
1.64 +void CPcmOutputPort::MopInitialize()
1.65 + {
1.66 + COmxOutputPort::MopInitialize();
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 = MopIndex();
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 + }