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.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "pcminputport.h"
sl@0
    17
#include "pcmprocessingunit.h"
sl@0
    18
#include <mdf/mdfpuconfig.h>
sl@0
    19
sl@0
    20
const TUint KSampleRate 	= 8000;
sl@0
    21
const TUint KMonoChannel 	= 1;
sl@0
    22
const TUint KStereoChannel	= 2;
sl@0
    23
sl@0
    24
sl@0
    25
CPcmInputPort* CPcmInputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType)
sl@0
    26
	{
sl@0
    27
	CPcmInputPort* self = new (ELeave) CPcmInputPort(aDataType);
sl@0
    28
	CleanupStack::PushL (self);
sl@0
    29
	self->ConstructL(aIndex, aParent);
sl@0
    30
	CleanupStack::Pop();
sl@0
    31
	return self;
sl@0
    32
	}
sl@0
    33
	
sl@0
    34
void CPcmInputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent)
sl@0
    35
	{
sl@0
    36
	COmxInputPort::ConstructL(aIndex, aParent);
sl@0
    37
	}
sl@0
    38
sl@0
    39
CPcmInputPort::CPcmInputPort(TPcmDataType aDataType) :
sl@0
    40
	COmxInputPort(),
sl@0
    41
	iSampleRate(KSampleRate),
sl@0
    42
	iChannels(KMonoChannel),
sl@0
    43
	iInterleaved(EFalse),
sl@0
    44
	iDataType(aDataType)
sl@0
    45
	{
sl@0
    46
	}
sl@0
    47
	
sl@0
    48
TInt CPcmInputPort::MipConfigure(const TPuConfig& aConfig)
sl@0
    49
	{
sl@0
    50
	if (aConfig.Uid() == TUid::Uid(KUidTTaskConfig))
sl@0
    51
		{
sl@0
    52
		const TTaskConfig* config = TPuTaskConfig::GetStructure(aConfig);	
sl@0
    53
	
sl@0
    54
		iSampleRate = config->iRate;
sl@0
    55
		iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel;
sl@0
    56
		iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse;
sl@0
    57
		return KErrNone;
sl@0
    58
		}
sl@0
    59
	return KErrNotSupported;	
sl@0
    60
	}
sl@0
    61
	
sl@0
    62
void CPcmInputPort::MipInitialize()
sl@0
    63
	{
sl@0
    64
	OMX_AUDIO_PARAM_PCMMODETYPE pcm;
sl@0
    65
	OMX_VERSIONTYPE ver = 
sl@0
    66
		{
sl@0
    67
		1,0
sl@0
    68
		};
sl@0
    69
	pcm.nVersion = ver;
sl@0
    70
	pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
sl@0
    71
	pcm.nPortIndex = MipIndex();
sl@0
    72
	pcm.nSamplingRate = iSampleRate;
sl@0
    73
	pcm.ePCMMode = OMX_AUDIO_PCMModeLinear;
sl@0
    74
	pcm.nChannels = iChannels;
sl@0
    75
	pcm.bInterleaved = (OMX_BOOL)iInterleaved;
sl@0
    76
sl@0
    77
	switch (iDataType)
sl@0
    78
		{
sl@0
    79
	case EPCM8:
sl@0
    80
		pcm.nBitPerSample = 8;
sl@0
    81
		pcm.eNumData = OMX_NumericalDataSigned; 
sl@0
    82
		break;
sl@0
    83
	case EPCMU8:
sl@0
    84
		pcm.nBitPerSample = 8;
sl@0
    85
		pcm.eNumData = OMX_NumericalDataUnsigned; 
sl@0
    86
		break;
sl@0
    87
	case EPCM16:
sl@0
    88
		pcm.nBitPerSample = 16;
sl@0
    89
		pcm.eNumData = OMX_NumericalDataSigned; 
sl@0
    90
		break;
sl@0
    91
		}
sl@0
    92
	
sl@0
    93
	// Set Input Port
sl@0
    94
	Component()->OmxSetParameter(OMX_IndexParamAudioPcm, &pcm);
sl@0
    95
	}
sl@0
    96