sl@0: // Copyright (c) 2001-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_AFMT_H__ sl@0: #define __TSU_MMF_AFMT_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: // Forward declaration sl@0: class MMFTestDataSink; sl@0: sl@0: class CTestSuite ; sl@0: class CTestSuite_MMF_AFMT; sl@0: sl@0: class MDataSource; sl@0: class CMMFFormatDecode; sl@0: class CMMFFormatEncode; sl@0: sl@0: // Constants sl@0: const TUint KFormatDefaultFrameSize = 0x1000; sl@0: const TUint KGSMAvgBytesPerSecond = 1625; sl@0: const TInt KOneSecondInMicroSeconds(1000000); sl@0: sl@0: sl@0: // NOTE: With the test files for audio formats, we have to use PCM only, as sl@0: // any other compression type appears to require a whole 'chain' of codecs etc sl@0: // to initialise correctly. This would be better done in System testing. sl@0: #ifdef __WINS__ sl@0: #include "Tsu_mmf_afmt_WINS.h" sl@0: #else sl@0: // ARM build - if flag below set we use C drive for files sl@0: #ifdef __AFMT_USE_C_DRIVE__ sl@0: #include "Tsu_mmf_afmt_WINS.h" sl@0: #else sl@0: #include "Tsu_mmf_afmt_ARM4.h" sl@0: #endif // __AFMT_USE_C_DRIVE__ sl@0: #endif sl@0: sl@0: sl@0: // Other constants sl@0: const TInt KStartFrame = 1; // The first frame in a file. sl@0: sl@0: sl@0: sl@0: enum ENewLType {KNewLUndefined, // Default value (leave if we get this). sl@0: KNewLUid, // Call NewL with a UID sl@0: KNewLFilename, // Call NewL with a filename sl@0: KNewLDescriptor,// Call NewL with a Descriptor of data sl@0: KNewLClip // Call NewL passing in a CMMFClip sl@0: }; sl@0: sl@0: /** @xxxx sl@0: * @class CTestStep_MMF_AFMT TSU_MMF_AFMT.h "TSU_MMF_AFMT.h" sl@0: * @brief Test class that enables MMF Audio Format tests. sl@0: * It's a base class for all test steps. sl@0: */ sl@0: class CTestStep_MMF_AFMT : public CTestStep, public MAsyncEventHandler sl@0: { sl@0: public: // Constructor/Destructor sl@0: CTestStep_MMF_AFMT() : iData(0,0,0) {}; sl@0: virtual ~CTestStep_MMF_AFMT(); sl@0: virtual void Close(); sl@0: sl@0: public: // From CTestStep sl@0: void SetTestSuite(const CTestSuite_MMF_AFMT* aTestSuite ) sl@0: { iAFMTTestSuite = aTestSuite;} sl@0: sl@0: public: // New functions sl@0: virtual void BufferEmptiedCallback(CMMFBuffer* /*aBuffer*/){} sl@0: virtual void BufferFilledCallback(CMMFBuffer* /*aBuffer*/){} sl@0: sl@0: sl@0: protected: // New functions sl@0: sl@0: /** sl@0: * This function creates a datasource object based on either a descriptor sl@0: * or a file. sl@0: * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based. sl@0: * @param aFilename - If filebased, this is the file name passed to the DataSource sl@0: * If descriptor based, the data is read from the file. sl@0: * @param aOffset - The offset from the start of the file to read (for Descriptor sl@0: * based DataSources only) sl@0: */ sl@0: void CreateDataSource(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0); sl@0: sl@0: sl@0: /** sl@0: * This function creates a data sink object from a CMmfFile object. sl@0: * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based [NOTE sl@0: * use of CMmfDescriptor based sinks is currently not supported] sl@0: * @param aFilename - If filebased, this is the file name passed to the DataSource sl@0: * If descriptor based, the data is read from the file. sl@0: * @param aOffset - The offset from the start of the file to read (for Descriptor sl@0: * based DataSources only) sl@0: */ sl@0: void CreateDataSink(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0); sl@0: sl@0: sl@0: /** sl@0: * This function creates a Format object (type of which is specified by 'aUid') and sl@0: * a data source or data sink to go with the object. This function should be used sl@0: * as a quick way for setting up objects for testing. sl@0: * @param aIsFile - ETrue if we are using CMmfFile or EFalse if using sl@0: * CMmfDescriptor as the DataSource. NOTE: CMmfDescriptor support has not sl@0: * yet been added to this test harness for SINKs. Generally it's best to just use sl@0: * CMmfFile based data sources rather than descriptors. sl@0: * @param aFilename - The file which acts as the data sink. For a CMmfFile sl@0: * based object, this is the file that data gets written to. sl@0: * @param aUid - The UID of the format object to be created. sl@0: */ sl@0: void CreateObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid); sl@0: sl@0: sl@0: /** sl@0: * This function is used as a quick way to setup objects for testing. sl@0: * @param aFilename - The file which acts as the data sink. For a CMmfFile sl@0: * based object, this is the file that data gets read/written. sl@0: * @param aUid - The UID of the format object to be created. sl@0: * @return TVerdict - Will always return EPass unless it leaves. sl@0: */ sl@0: TVerdict SetupL(const TDesC& aFilename, TInt aUid); sl@0: sl@0: sl@0: /** sl@0: * This function deletes all of the pointer member variables which may have been sl@0: * initialised. sl@0: */ sl@0: void Cleanup(); sl@0: sl@0: sl@0: /** sl@0: * This function reads from a source file into the member variable heap buffer, 'iDescHBuf'. sl@0: * This can be used to compare the contents of a file with a buffer for example. sl@0: * @param aFilename - The file to read from. sl@0: * @param aPosition - Where to start reading from in the file. sl@0: * @param aSize - How much of the file to read (in bytes) though if you pass '-1', it will sl@0: * try and read the whole file from 'aPosition' onwards. sl@0: */ sl@0: void ReadFileToDescriptorL(const TDesC& aFilename, TInt aPosition, TInt aSize); sl@0: sl@0: sl@0: /** sl@0: * This function can be used to make sure that a specified file is not present sl@0: * before a set of tests are run. sl@0: * @param aFilename - The name of the file to delete/check is not present. sl@0: */ sl@0: void DeleteFileL(const TDesC& aFilename); sl@0: sl@0: sl@0: private: // New functions sl@0: /** sl@0: * This function creates a datasource object based on either a descriptor sl@0: * or a file. sl@0: * @param aIsFile - ETrue if we are using CMmfFile or EFalse if using sl@0: * CMmfDescriptor as the DataSource sl@0: * @param aFilename - The file which acts as the data source. For a CMmfFile sl@0: * based object, this IS the file. For a CMmfDescriptor based object, this sl@0: * file contains the data that is read into the descriptor for test purposes. sl@0: * @param aUid - The UID of the format object to be created. sl@0: */ sl@0: void CreateDecodeObjectL(TBool aBool, const TDesC& aFilename, TInt aUid); sl@0: sl@0: sl@0: /** sl@0: * This function creates a datasink object based on either a descriptor sl@0: * or a file. sl@0: * @param aIsFile - ETrue if we are using CMmfFile or EFalse if using sl@0: * CMmfDescriptor as the DataSource. NOTE: CMmfDescriptor support has not sl@0: * yet been added to this test harness for SINKs. sl@0: * @param aFilename - The file which acts as the data sink. For a CMmfFile sl@0: * based object, this IS the file. sl@0: * @param aUid - The UID of the format object to be created. sl@0: */ sl@0: void CreateEncodeObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid); sl@0: sl@0: //from MAsyncEventHandler sl@0: virtual TInt SendEventToClient(const TMMFEvent& /*aEvent*/) {return KErrNone;}//XXX - can we do better here? sl@0: sl@0: sl@0: protected: sl@0: TBool iDecode; // ETrue if using CMmfXXXFormatRead/MDataSource sl@0: // EFalse if using CMmfXXXFormatWrite/MDataSink sl@0: sl@0: const CTestSuite_MMF_AFMT* iAFMTTestSuite; // pointer to suite which owns this test sl@0: sl@0: MDataSource* iDataSource; // Ptr to a DataSource sl@0: MDataSink* iDataSink; // Ptr to a DataSource sl@0: sl@0: CMMFFormatDecode* iFormatDec; // Ptr to a Format Decode object sl@0: CMMFFormatEncode* iFormatEnc; // Ptr to a Format Encode object sl@0: sl@0: TUid iUID; // UID object sl@0: TPtrC iFilename; // Filename sl@0: TPtrC iPreferredSupplier; // Preferred supplier string sl@0: //PAC TPtrC8 iData; // Used to hold binary data. sl@0: TPtr8 iData; // Used to hold binary data. sl@0: ENewLType iNewL; // Which NewL call to use when create Format object sl@0: sl@0: HBufC8* iDescHBuf; // HBuf for holding descriptor data sl@0: sl@0: private: sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: #endif// TSU_MMF_AFMT_H__ sl@0: