sl@0: /* sl@0: * Copyright (c) 1997-2002 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: sl@0: sl@0: sl@0: #include "MMFAudioS16ToPcmU16Codec.h" sl@0: sl@0: // __________________________________________________________________________ sl@0: // Implementation sl@0: sl@0: CMMFCodec* CMMFAudioS16PcmU16Codec::NewL(TAny* aInitParams) sl@0: { sl@0: CMMFAudioS16PcmU16Codec* self=new(ELeave) CMMFAudioS16PcmU16Codec(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aInitParams); sl@0: CleanupStack::Pop(self); sl@0: return STATIC_CAST( CMMFCodec*, self ); sl@0: } sl@0: sl@0: CMMFAudioS16PcmU16Codec::~CMMFAudioS16PcmU16Codec() sl@0: { sl@0: } sl@0: sl@0: CMMFAudioS16PcmU16Codec::CMMFAudioS16PcmU16Codec() sl@0: { sl@0: } sl@0: sl@0: void CMMFAudioS16PcmU16Codec::ConstructL(TAny* /*aInitParams*/) sl@0: { sl@0: } sl@0: sl@0: sl@0: //this codec has a does not expand or shrink destination data sl@0: TCodecProcessResult CMMFAudioS16PcmU16Codec::ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst) sl@0: { sl@0: sl@0: TCodecProcessResult result; sl@0: result.iStatus = TCodecProcessResult::EProcessIncomplete; sl@0: sl@0: //convert from generic CMMFBuffer to CMMFDataBuffer sl@0: iSrc = STATIC_CAST(const CMMFDataBuffer*, &aSrc); sl@0: iDst = STATIC_CAST(CMMFDataBuffer*, &aDst); sl@0: sl@0: const TUint dstMaxLen = iDst->Data().MaxLength(); sl@0: sl@0: if (!dstMaxLen) sl@0: User::Leave(KErrArgument); sl@0: sl@0: //don't scribble Destination (pDst) by only consuming enough source to fill pDst sl@0: TUint srcUse = dstMaxLen - iDst->Position(); sl@0: const TUint srcLen = iSrc->Data().Length(); sl@0: const TUint sourceRemain = srcLen - iSrc->Position(); sl@0: sl@0: //make sure we don't blow source by checking against remaining sl@0: //and clipping to minimum remaining if necessary sl@0: srcUse = (srcUseData().Ptr()); sl@0: pSrc += iSrc->Position(); sl@0: TUint8* pDst = CONST_CAST(TUint8*,iDst->Data().Ptr()); sl@0: pDst += iDst->Position(); sl@0: sl@0: //divide by TWO as 2 bytes are equal to 1 sample sl@0: iAudioS16ToU16Pcm.Convert(pSrc, pDst, srcUse / 2); sl@0: sl@0: if (srcUse + iDst->Position() < dstMaxLen) sl@0: result.iStatus = TCodecProcessResult::EDstNotFilled; sl@0: sl@0: else if (srcUse + iSrc->Position() >= srcLen) sl@0: result.iStatus = TCodecProcessResult::EProcessComplete; sl@0: sl@0: result.iSrcBytesProcessed = srcUse; sl@0: result.iDstBytesAdded = srcUse; sl@0: sl@0: iDst->Data().SetLength(iDst->Position() + srcUse); sl@0: sl@0: return result; sl@0: sl@0: }