sl@0: // Copyright (c) 2003-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: #ifndef __TSU_MMF_SWCODECDEVICES_H__
sl@0: #define __TSU_MMF_SWCODECDEVICES_H__
sl@0: 
sl@0: #include <testframework.h>
sl@0: #include <mmf/server/mmfcodec.h>
sl@0: #include <mmf/server/mmfbuffer.h>
sl@0: #include <mmf/server/mmfdatabuffer.h>
sl@0: #include <mmf/common/mmfutilities.h>
sl@0: #include <mmf/common/mmffourcc.h>
sl@0: 
sl@0: #include <mmf/common/mmfcontroller.h>
sl@0: #include <mmf/common/mmfcontrollerpluginresolver.h>
sl@0: #include <mmf/plugin/mmfplugininterfaceuids.hrh>
sl@0: 
sl@0: #include "TSU_MMF_ACOD.h"
sl@0: 
sl@0: const TInt PcmToMuLawCompressionTableSize = 256;
sl@0: const TInt MuLawToPcmCompressionTableSize = 256;
sl@0: const TInt PcmToALawCompressionTableSize = 128;
sl@0: const TInt ALawToPcmCompressionTableSize = 256;
sl@0: 
sl@0: class CTestSuite ;
sl@0: class CTestSuite_MMF_SwCodecDevices;
sl@0: 
sl@0: /** 
sl@0:  * @class CTest_MMF_ACOD_U_0001
sl@0:  * @test Req. under test REQ172.6.3 
sl@0:  */
sl@0: class CTest_MMF_Gsm610 : public CTestStep_MMF_SwCodecDevices
sl@0: 	{
sl@0: public:
sl@0: 	CTest_MMF_Gsm610();
sl@0: 	~CTest_MMF_Gsm610();
sl@0: protected:
sl@0: 	void ReadDataL(CMMFDataBuffer*& aBuffer, const TDesC& aFile1);
sl@0: 	void PrintGsm610Frame(TUint8* aGsm610Frame);
sl@0: 	void PrintPcmDataFrame(TUint8* aPcm16Frame);
sl@0: 	TBool CompareEncodeResults( CMMFDataBuffer* aEncoded, CMMFDataBuffer* aRefFrame );
sl@0: 	TBool CompareDecodeResults(CMMFDataBuffer* aEncoded, CMMFDataBuffer* aRefFrame );
sl@0: 	TBool CompareGsm610Frames( TUint8* aGsmFrame,TUint8* aRefGsmFrame );
sl@0: 	void UnpackFrame1(struct codes* aCodeBuf, TUint8* pbuf);
sl@0: 	void UnpackFrame0(struct codes* aCodeBuf, TUint8* pbuf);
sl@0: 	void PackFrame0(struct codes* aCodeBuf, TInt8* pbuf);
sl@0: 	void PackFrame1(struct codes* aCodeBuf, TInt8* pbuf);
sl@0:    
sl@0: 	TBool Compare( codes& aFrame1, codes& aFrame2 );
sl@0: 	void LogGsmFrames( codes& aGsmFrame, codes& aRefGsmFrame );
sl@0: 	void LogGsmFrame ( codes& aFrame );
sl@0: 	void FillPcmBuffer( CMMFDataBuffer& aSrcBuffer );
sl@0: 	void OpenFileL( RFile& aFile, const TDesC& aFileName );
sl@0: 	void ReadDataBufferL( const RFile& aFile, CMMFDataBuffer& aBuffer );
sl@0: 	void CloseFileL( RFile& aFile );
sl@0: 	void ParseFrameL( struct codes& aFrame, TUint8* &aBuffer );
sl@0: 	void ParseCodedDataL( CMMFDataBuffer* aBuffer );
sl@0: protected:
sl@0: 	//[ files for conformance testing of the codec 
sl@0: 	// which are defined in the ETSI standard ]
sl@0: 	TPtrC iSourceDataFile;  // source data file name
sl@0: 	TPtrC iCodedDataFile;   // coded data file name
sl@0: 	TPtrC iDecodedDataFile; // decoded data file name
sl@0: 	RFile iSrcFile;         // src file 
sl@0: 	RFile iCodedFile;       // coded file
sl@0: 	RFile iDecodeFile;      // decoded file
sl@0: 	CMMFDataBuffer* iRefSrcData;    // reference source data
sl@0: 	CMMFDataBuffer* iRefCodedData; // refernce decoded data
sl@0: 	CMMFDataBuffer* iRefDecodedData; // refernce decoded data
sl@0: 	CMMFDataBuffer* iCodedData;   // buffer of coded data
sl@0: 	CMMFDataBuffer* iDecodedData; // buffer of actual decoded data
sl@0: 	CMMFDataBuffer* iScratchData; // buffer of actual decoded data
sl@0: 	RFs iFs;                      // file server
sl@0: 	RFile iFile;
sl@0: 	TInt iNumCodedFrames;         // number of coded frames in src buffer
sl@0: 	} ;
sl@0: 
sl@0: /*
sl@0: *
sl@0: * CTest_MMF_SwCodecDevices_U_0001
sl@0: *
sl@0: **/
sl@0: class CTest_MMF_SwCodecDevices_U_0001: public CTest_MMF_Gsm610
sl@0: {
sl@0: 
sl@0: public:
sl@0: 	CTest_MMF_SwCodecDevices_U_0001();
sl@0: 	~CTest_MMF_SwCodecDevices_U_0001();
sl@0: 	virtual TVerdict DoTestStepL();
sl@0: 	virtual enum TVerdict DoTestStepPreambleL(void);
sl@0: 	virtual enum TVerdict DoTestStepPostambleL(void);
sl@0: };
sl@0: 
sl@0: 
sl@0: /**
sl@0: *
sl@0: * CTest_MMF_SwCodecDevices_U_0002
sl@0: *
sl@0: **/
sl@0: class CTest_MMF_SwCodecDevices_U_0002: public CTest_MMF_Gsm610
sl@0: {
sl@0: public:
sl@0: 	CTest_MMF_SwCodecDevices_U_0002();
sl@0: 	~CTest_MMF_SwCodecDevices_U_0002();
sl@0: 	virtual TVerdict DoTestStepL();
sl@0: 	virtual enum TVerdict DoTestStepPreambleL(void);
sl@0: 	virtual enum TVerdict DoTestStepPostambleL(void);
sl@0: };
sl@0: 
sl@0: /**
sl@0: *
sl@0: * CTest_MMF_SwCodecDevices_U_0003
sl@0: *
sl@0: **/
sl@0: class CTest_MMF_SwCodecDevices_U_0003: public CTest_MMF_Gsm610
sl@0: {
sl@0: public:
sl@0: 	CTest_MMF_SwCodecDevices_U_0003();
sl@0: 	~CTest_MMF_SwCodecDevices_U_0003();
sl@0: 	virtual TVerdict DoTestStepL();
sl@0: 	virtual enum TVerdict DoTestStepPreambleL(void);
sl@0: 	virtual enum TVerdict DoTestStepPostambleL(void);
sl@0: 
sl@0: };
sl@0: 
sl@0: //[ some utility functions to aid mu and alaw codec tests]
sl@0: class TLawUtility
sl@0: 	{
sl@0: 	public:
sl@0:       void FillSrcBufferL( TUint8* aSrcData, TInt aNoSamples, TInt16 aOffset );
sl@0: 	  TBool CompareCodedDataL(TUint8* aCodedData,TUint8* aRefCodedData, TInt aNoSamples );
sl@0: 	  TReal SNRatioL(TUint8* aDecodedData, TUint8* aSrcData, TInt aNoSamples );
sl@0: 	  TBool CompareSNRatiosL( TReal aCodecSN, TReal aCodecSN2, TReal aTolerance );
sl@0: 	  TInt16 AssembleValL(TUint8* aDecodedData);
sl@0: 	  TReal ComputeSNL( TReal aSumSigSquared, TReal aSumErrorSquared );
sl@0: 	  TReal SumSquaredL( TUint8* aData, TInt aNoSamples );
sl@0: 	  TReal SumErrorSquaredL( TUint8* aData, TUint8* aData2, TInt aNoSamples );
sl@0: 	};
sl@0: 
sl@0: //[ This Test compares the Symbian implmentation
sl@0: // against another reference implementation
sl@0: // of the mu law conversion codec due to problems encountered with
sl@0: // gold wave coding which was different ]
sl@0: class CTestMuLawCodec_U_0006: public CTestStep_MMF_SwCodecDevices
sl@0: {
sl@0: public:
sl@0: 	CTestMuLawCodec_U_0006();
sl@0: 	virtual TVerdict DoTestStepL();
sl@0: 	virtual enum TVerdict DoTestStepPreambleL(void);
sl@0: 	virtual enum TVerdict DoTestStepPostambleL(void);
sl@0: private:
sl@0: 	void ConvertPcmMuLawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
sl@0:     void ConvertMuLawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
sl@0: 	TUint8 LinearToMuLawSample(TInt16 aSample );
sl@0: private:
sl@0: 	const static TInt8 MuLawCompressTable[PcmToMuLawCompressionTableSize];
sl@0: 	const static TInt16 MuLawDecompressTable[MuLawToPcmCompressionTableSize];
sl@0: };
sl@0: 
sl@0: //[ This Test compares the Symbian implmentation
sl@0: // against another reference implementation
sl@0: // of the mu law conversion codec due to problems encountered with
sl@0: // gold wave coding which was different ]
sl@0: class CTestALawCodec_U_0004: public CTestStep_MMF_SwCodecDevices
sl@0: {
sl@0: public:
sl@0: 	CTestALawCodec_U_0004();
sl@0: 	virtual TVerdict DoTestStepL();
sl@0: 	virtual enum TVerdict DoTestStepPreambleL(void);
sl@0: 	virtual enum TVerdict DoTestStepPostambleL(void);
sl@0: private:
sl@0:     void ConvertPcmALawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
sl@0:     void ConvertALawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
sl@0: 	TUint8 LinearToALawSample(TInt16 aSample);
sl@0: private:
sl@0: 	const static TInt8  ALawCompressTable[PcmToALawCompressionTableSize];
sl@0: 	const static TInt16 ALawDecompressTable[ALawToPcmCompressionTableSize];
sl@0: };
sl@0: 
sl@0: // This test tests the pcm16 to imaad codec
sl@0: class CTestIMaadCodec: public CTestStep_MMF_SwCodecDevices
sl@0: {
sl@0: public:
sl@0: 	CTestIMaadCodec();
sl@0: 	virtual TVerdict DoTestStepL();
sl@0: 	virtual enum TVerdict DoTestStepPreambleL(void);
sl@0: 	virtual enum TVerdict DoTestStepPostambleL(void);
sl@0: private:
sl@0: 	// fill src buffer with linear ramp
sl@0: 	// for coding purposes
sl@0: 		void  FillSrcBufferL( CMMFDescriptorBuffer& aBuffer );
sl@0: 		TBool CompareResults( TReal aExpectedSNRatioDb, 
sl@0: 			                  CMMFDescriptorBuffer* aSrcBuffer,     
sl@0: 		                      CMMFDescriptorBuffer* aSinkBuffer);
sl@0: };
sl@0: 
sl@0: 
sl@0: //------------------------------------------------------------------ 
sl@0: 
sl@0: #endif// TSU_MMF_SWCODECDEVICES_H__
sl@0: