sl@0: // Copyright (c) 1997-2009 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: #include "MMFMuLawToPcm16Codec.h" sl@0: sl@0: // __________________________________________________________________________ sl@0: // Implementation sl@0: sl@0: CMMFCodec* CMMFMulawPcm16Codec::NewL(TAny* aInitParams) sl@0: { sl@0: CMMFMulawPcm16Codec* self=new(ELeave) CMMFMulawPcm16Codec(); 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: CMMFMulawPcm16Codec::~CMMFMulawPcm16Codec() sl@0: { sl@0: } sl@0: sl@0: CMMFMulawPcm16Codec::CMMFMulawPcm16Codec() sl@0: { sl@0: } sl@0: sl@0: void CMMFMulawPcm16Codec::ConstructL(TAny* /*aInitParams*/) sl@0: { sl@0: } sl@0: sl@0: sl@0: //this codec expands 1 byte to 2 bytes sl@0: TCodecProcessResult CMMFMulawPcm16Codec::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()) / 2; 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: sl@0: iMulawTo16Pcm.Convert(pSrc, pDst, srcUse ); sl@0: sl@0: if ((srcUse * 2) + 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 * 2; sl@0: sl@0: iDst->Data().SetLength(iDst->Position() + (srcUse * 2)); sl@0: sl@0: return result; sl@0: }