os/mm/mmlibs/mmfw/tsrc/mmfunittest/AFMT/TSU_MMF_AFMT.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2001-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 //
    15 
    16 #ifndef __TSU_MMF_AFMT_H__
    17 #define __TSU_MMF_AFMT_H__
    18 
    19 #include <testframework.h>
    20 #include <mmf/server/mmfbuffer.h>
    21 #include <mmf/server/mmfdatabuffer.h>
    22 #include <mmf/common/mmfutilities.h>
    23 #include <mmf/common/mmffourcc.h>
    24 #include <mmf/server/mmfdatasink.h>
    25 
    26 // Forward declaration
    27 class MMFTestDataSink;
    28 
    29 class CTestSuite ;
    30 class CTestSuite_MMF_AFMT;
    31 
    32 class MDataSource;
    33 class CMMFFormatDecode;
    34 class CMMFFormatEncode;
    35 
    36 // Constants
    37 const TUint KFormatDefaultFrameSize = 0x1000;
    38 const TUint KGSMAvgBytesPerSecond = 1625;
    39 const TInt KOneSecondInMicroSeconds(1000000);
    40 
    41 
    42 // NOTE: With the test files for audio formats, we have to use PCM only, as
    43 // any other compression type appears to require a whole 'chain' of codecs etc
    44 // to initialise correctly.  This would be better done in System testing.
    45 #ifdef __WINS__
    46 	#include "Tsu_mmf_afmt_WINS.h"
    47 #else 
    48 	// ARM build - if flag below set we use C drive for files
    49 	#ifdef __AFMT_USE_C_DRIVE__
    50 		#include "Tsu_mmf_afmt_WINS.h"
    51 	#else
    52 		#include "Tsu_mmf_afmt_ARM4.h"
    53 	#endif // __AFMT_USE_C_DRIVE__
    54 #endif
    55 
    56 
    57 // Other constants
    58 const TInt KStartFrame	= 1;				// The first frame in a file.
    59 
    60 
    61 
    62 enum ENewLType {KNewLUndefined, // Default value (leave if we get this).
    63 				KNewLUid,		// Call NewL with a UID
    64 				KNewLFilename,	// Call NewL with a filename
    65 				KNewLDescriptor,// Call NewL with a Descriptor of data
    66 				KNewLClip		// Call NewL passing in a CMMFClip
    67 				};
    68 
    69 /** @xxxx
    70  * @class CTestStep_MMF_AFMT TSU_MMF_AFMT.h "TSU_MMF_AFMT.h"
    71  * @brief Test class that enables MMF Audio Format tests.
    72  * It's a base class for all test steps.
    73  */
    74 class CTestStep_MMF_AFMT : public CTestStep, public MAsyncEventHandler
    75 	{
    76 public:	// Constructor/Destructor
    77 	CTestStep_MMF_AFMT() : iData(0,0,0) {};
    78 	virtual ~CTestStep_MMF_AFMT();
    79 	virtual void Close();
    80 	
    81 public: // From CTestStep
    82 	void SetTestSuite(const CTestSuite_MMF_AFMT* aTestSuite )
    83 		{ iAFMTTestSuite = aTestSuite;}  
    84 
    85 public: // New functions
    86 	virtual void BufferEmptiedCallback(CMMFBuffer* /*aBuffer*/){}	
    87 	virtual void BufferFilledCallback(CMMFBuffer* /*aBuffer*/){}	
    88 
    89 	
    90 protected:	// New functions
    91 
    92 	/** 
    93 	 * This function creates a datasource object based on either a descriptor
    94 	 * or a file.
    95 	 * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based.
    96 	 * @param aFilename - If filebased, this is the file name passed to the DataSource
    97 	 *					  If descriptor based, the data is read from the file.
    98 	 * @param aOffset - The offset from the start of the file to read (for Descriptor
    99 	 *				     based DataSources only)
   100 	 */
   101 	void CreateDataSource(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0);
   102 
   103 
   104 	/** 
   105 	 * This function creates a data sink object from a CMmfFile object.
   106 	 * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based [NOTE 
   107 	 * use of CMmfDescriptor based sinks is currently not supported]
   108 	 * @param aFilename - If filebased, this is the file name passed to the DataSource
   109 	 *					  If descriptor based, the data is read from the file.
   110 	 * @param aOffset - The offset from the start of the file to read (for Descriptor
   111 	 *				     based DataSources only)
   112 	 */
   113 	void CreateDataSink(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0);
   114 
   115 
   116 	/** 
   117 	 * This function creates a Format object (type of which is specified by 'aUid') and
   118 	 * a data source or data sink to go with the object.  This function should be used
   119 	 * as a quick way for setting up objects for testing.
   120 	 * @param aIsFile -  ETrue if we are using CMmfFile or EFalse if using 
   121 	 * CMmfDescriptor as the DataSource. NOTE: CMmfDescriptor support has not
   122 	 * yet been added to this test harness for SINKs.  Generally it's best to just use
   123 	 * CMmfFile based data sources rather than descriptors.
   124 	 * @param aFilename - The file which acts as the data sink.  For a CMmfFile
   125 	 * based object, this is the file that data gets written to.
   126 	 * @param aUid - The UID of the format object to be created.
   127 	 */
   128 	void CreateObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid);
   129 
   130 
   131 	/** 
   132 	 * This function is used as a quick way to setup objects for testing.
   133 	 * @param aFilename - The file which acts as the data sink.  For a CMmfFile
   134 	 * based object, this is the file that data gets read/written.
   135 	 * @param aUid - The UID of the format object to be created.
   136 	 * @return TVerdict - Will always return EPass unless it leaves.
   137 	 */
   138 	TVerdict SetupL(const TDesC& aFilename, TInt aUid);
   139 
   140 
   141 	/**
   142 	 * This function deletes all of the pointer member variables which may have been 
   143 	 * initialised.
   144 	 */
   145 	void Cleanup();
   146 
   147 
   148 	/**
   149 	 * This function reads from a source file into the member variable heap buffer, 'iDescHBuf'.
   150 	 * This can be used to compare the contents of a file with a buffer for example.
   151 	 * @param aFilename - The file to read from.
   152 	 * @param aPosition - Where to start reading from in the file.
   153 	 * @param aSize - How much of the file to read (in bytes) though if you pass '-1', it will
   154 	 * try and read the whole file from 'aPosition' onwards.
   155 	 */
   156 	void ReadFileToDescriptorL(const TDesC& aFilename, TInt aPosition, TInt aSize);
   157 
   158 
   159 	/**
   160 	 * This function can be used to make sure that a specified file is not present
   161 	 * before a set of tests are run.
   162 	 * @param aFilename - The name of the file to delete/check is not present.
   163 	 */
   164 	void DeleteFileL(const TDesC& aFilename);
   165 		
   166 
   167 private: // New functions
   168 	/** 
   169 	 * This function creates a datasource object based on either a descriptor
   170 	 * or a file.
   171 	 * @param aIsFile -  ETrue if we are using CMmfFile or EFalse if using 
   172 	 * CMmfDescriptor as the DataSource
   173 	 * @param aFilename - The file which acts as the data source.  For a CMmfFile
   174 	 * based object, this IS the file.  For a CMmfDescriptor based object, this
   175 	 * file contains the data that is read into the descriptor for test purposes.
   176 	 * @param aUid - The UID of the format object to be created.
   177 	 */
   178 	void CreateDecodeObjectL(TBool aBool, const TDesC& aFilename, TInt aUid);
   179 
   180 
   181 	/** 
   182 	 * This function creates a datasink object based on either a descriptor
   183 	 * or a file.
   184 	 * @param aIsFile -  ETrue if we are using CMmfFile or EFalse if using 
   185 	 * CMmfDescriptor as the DataSource. NOTE: CMmfDescriptor support has not
   186 	 * yet been added to this test harness for SINKs.
   187 	 * @param aFilename - The file which acts as the data sink.  For a CMmfFile
   188 	 * based object, this IS the file.  
   189 	 * @param aUid - The UID of the format object to be created.
   190 	 */
   191 	void CreateEncodeObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid);
   192 
   193 	//from MAsyncEventHandler
   194 	virtual TInt SendEventToClient(const TMMFEvent& /*aEvent*/) {return KErrNone;}//XXX - can we do better here?
   195 
   196 
   197 protected:	
   198 	TBool iDecode;	// ETrue if using CMmfXXXFormatRead/MDataSource
   199 					// EFalse if using CMmfXXXFormatWrite/MDataSink
   200 
   201 	const CTestSuite_MMF_AFMT* iAFMTTestSuite; // pointer to suite which owns this test
   202 
   203 	MDataSource* iDataSource;		// Ptr to a DataSource
   204 	MDataSink*	 iDataSink;			// Ptr to a DataSource
   205 
   206 	CMMFFormatDecode* iFormatDec;	// Ptr to a Format Decode object
   207 	CMMFFormatEncode* iFormatEnc;	// Ptr to a Format Encode object
   208 
   209 	TUid iUID;						// UID object
   210 	TPtrC iFilename;				// Filename
   211 	TPtrC iPreferredSupplier;		// Preferred supplier string
   212 //PAC	TPtrC8 iData;					// Used to hold binary data.
   213 	TPtr8 iData;					// Used to hold binary data.
   214 	ENewLType iNewL;				// Which NewL call to use when create Format object
   215 
   216 	HBufC8* iDescHBuf;				// HBuf for holding descriptor data	
   217 
   218 private:
   219 	};
   220 
   221 
   222 
   223 
   224 
   225 
   226 
   227 
   228 #endif// TSU_MMF_AFMT_H__
   229