os/mm/mmlibs/mmfw/tsrc/mmfunittest/ctlfrm/mp3/MmfMP3NullCodec/mmfmp3Codec.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2003-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 // This is a test codec which takes MP3 data & gives it back to the datapath
    15 // pretending it has converted it to PCM16 data thus producing lots of noise
    16 // 
    17 //
    18 
    19 #include <e32std.h>
    20 
    21 #include <mmf/plugin/mmfcodecimplementationuids.hrh>
    22 #include <ecom/implementationproxy.h>
    23 
    24 #include "MP3Uids.hrh"
    25 
    26 #include "mmfmp3Codec.h"
    27 
    28 //*******************************************************************
    29 //*  MP3 Codec to 16 bit PCM Class:
    30 //*******************************************************************
    31 
    32 // __________________________________________________________________________
    33 // Implementation
    34 
    35 CMMFCodec* CMMFMP3To16PcmCodec::NewL(TAny* aInitParams)
    36 	{
    37 	CMMFMP3To16PcmCodec* self=new(ELeave) CMMFMP3To16PcmCodec();
    38 	CleanupStack::PushL(self);
    39 	self->ConstructL(aInitParams);
    40 	CleanupStack::Pop(self);
    41 	return STATIC_CAST( CMMFCodec*, self );
    42 	}
    43 
    44 CMMFMP3To16PcmCodec::~CMMFMP3To16PcmCodec()
    45 	{
    46 	}
    47 
    48 CMMFMP3To16PcmCodec::CMMFMP3To16PcmCodec()
    49 	{
    50 
    51 	}
    52 
    53 void CMMFMP3To16PcmCodec::ConstructL(TAny* /*aInitParams*/)
    54 	{
    55 	
    56 	}
    57 
    58 void CMMFMP3To16PcmCodec::ResetL()
    59 	{
    60 	}
    61 
    62 
    63 TCodecProcessResult CMMFMP3To16PcmCodec::ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst)
    64 	{
    65 
    66 	TCodecProcessResult result;
    67 	result.iStatus = TCodecProcessResult::EProcessIncomplete; // dest full
    68 	result.iSrcBytesProcessed = 0;
    69 	result.iDstBytesAdded = 0;
    70 
    71 	// convert from generic CMMFBuffer to CMMFDataBuffer
    72 	const CMMFDataBuffer* src = STATIC_CAST(const CMMFDataBuffer*, &aSrc);
    73 	CMMFDataBuffer* dst = STATIC_CAST(CMMFDataBuffer*, &aDst);
    74 
    75 	TUint srcLen = src->Data().Length() - src->Position();
    76 	TUint dstMaxLen = dst->Data().MaxLength() - dst->Position();
    77 	TUint dstLen = dstMaxLen;
    78 	
    79 	dst->Data().SetLength(0);
    80 
    81 	if (srcLen == 0)
    82 		{
    83 		result.iStatus = TCodecProcessResult::EDstNotFilled;	// get some more source data
    84 		}
    85 	else
    86 		{
    87 		TPtrC8 srcPtrC(src->Data().Ptr(), dstLen);
    88 
    89 		dst->Data() = srcPtrC;
    90 		
    91 		result.iSrcBytesProcessed = srcLen;
    92 		result.iDstBytesAdded = dst->Data().Length();
    93 		result.iStatus = TCodecProcessResult::EProcessIncomplete; // dest full
    94 		}
    95 
    96 	return result;
    97 	}
    98 
    99 
   100 // __________________________________________________________________________
   101 // Exported proxy for instantiation method resolution
   102 // Define the interface UIDs
   103 
   104 
   105 const TImplementationProxy ImplementationTable[] = 
   106 	{
   107 		IMPLEMENTATION_PROXY_ENTRY(KUidMP3ImplementationCodec,	CMMFMP3To16PcmCodec::NewL)
   108 	};
   109 
   110 
   111 
   112 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   113 	{
   114 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   115 
   116 	return ImplementationTable;
   117 	}
   118