os/mm/mmdevicefw/mdfunittest/codecapi/PU/pcmcodec/src/pcminputport.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "pcminputport.h"
    17 #include "pcmprocessingunit.h"
    18 #include <mdf/mdfpuconfig.h>
    19 
    20 const TUint KSampleRate 	= 8000;
    21 const TUint KMonoChannel 	= 1;
    22 const TUint KStereoChannel	= 2;
    23 
    24 
    25 CPcmInputPort* CPcmInputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType)
    26 	{
    27 	CPcmInputPort* self = new (ELeave) CPcmInputPort(aDataType);
    28 	CleanupStack::PushL (self);
    29 	self->ConstructL(aIndex, aParent);
    30 	CleanupStack::Pop();
    31 	return self;
    32 	}
    33 	
    34 void CPcmInputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent)
    35 	{
    36 	COmxInputPort::ConstructL(aIndex, aParent);
    37 	}
    38 
    39 CPcmInputPort::CPcmInputPort(TPcmDataType aDataType) :
    40 	COmxInputPort(),
    41 	iSampleRate(KSampleRate),
    42 	iChannels(KMonoChannel),
    43 	iInterleaved(EFalse),
    44 	iDataType(aDataType)
    45 	{
    46 	}
    47 	
    48 TInt CPcmInputPort::MipConfigure(const TPuConfig& aConfig)
    49 	{
    50 	if (aConfig.Uid() == TUid::Uid(KUidTTaskConfig))
    51 		{
    52 		const TTaskConfig* config = TPuTaskConfig::GetStructure(aConfig);	
    53 	
    54 		iSampleRate = config->iRate;
    55 		iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel;
    56 		iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse;
    57 		return KErrNone;
    58 		}
    59 	return KErrNotSupported;	
    60 	}
    61 	
    62 void CPcmInputPort::MipInitialize()
    63 	{
    64 	OMX_AUDIO_PARAM_PCMMODETYPE pcm;
    65 	OMX_VERSIONTYPE ver = 
    66 		{
    67 		1,0
    68 		};
    69 	pcm.nVersion = ver;
    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;
    76 
    77 	switch (iDataType)
    78 		{
    79 	case EPCM8:
    80 		pcm.nBitPerSample = 8;
    81 		pcm.eNumData = OMX_NumericalDataSigned; 
    82 		break;
    83 	case EPCMU8:
    84 		pcm.nBitPerSample = 8;
    85 		pcm.eNumData = OMX_NumericalDataUnsigned; 
    86 		break;
    87 	case EPCM16:
    88 		pcm.nBitPerSample = 16;
    89 		pcm.eNumData = OMX_NumericalDataSigned; 
    90 		break;
    91 		}
    92 	
    93 	// Set Input Port
    94 	Component()->OmxSetParameter(OMX_IndexParamAudioPcm, &pcm);
    95 	}
    96