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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __TSU_MMF_AFMT_H__
17 #define __TSU_MMF_AFMT_H__
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>
26 // Forward declaration
27 class MMFTestDataSink;
30 class CTestSuite_MMF_AFMT;
33 class CMMFFormatDecode;
34 class CMMFFormatEncode;
37 const TUint KFormatDefaultFrameSize = 0x1000;
38 const TUint KGSMAvgBytesPerSecond = 1625;
39 const TInt KOneSecondInMicroSeconds(1000000);
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.
46 #include "Tsu_mmf_afmt_WINS.h"
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"
52 #include "Tsu_mmf_afmt_ARM4.h"
53 #endif // __AFMT_USE_C_DRIVE__
58 const TInt KStartFrame = 1; // The first frame in a file.
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
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.
74 class CTestStep_MMF_AFMT : public CTestStep, public MAsyncEventHandler
76 public: // Constructor/Destructor
77 CTestStep_MMF_AFMT() : iData(0,0,0) {};
78 virtual ~CTestStep_MMF_AFMT();
81 public: // From CTestStep
82 void SetTestSuite(const CTestSuite_MMF_AFMT* aTestSuite )
83 { iAFMTTestSuite = aTestSuite;}
85 public: // New functions
86 virtual void BufferEmptiedCallback(CMMFBuffer* /*aBuffer*/){}
87 virtual void BufferFilledCallback(CMMFBuffer* /*aBuffer*/){}
90 protected: // New functions
93 * This function creates a datasource object based on either a descriptor
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)
101 void CreateDataSource(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0);
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)
113 void CreateDataSink(const TBool& aFile, const TDesC& aFilename, const TUint& aOffset=0);
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.
128 void CreateObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid);
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.
138 TVerdict SetupL(const TDesC& aFilename, TInt aUid);
142 * This function deletes all of the pointer member variables which may have been
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.
156 void ReadFileToDescriptorL(const TDesC& aFilename, TInt aPosition, TInt aSize);
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.
164 void DeleteFileL(const TDesC& aFilename);
167 private: // New functions
169 * This function creates a datasource object based on either a descriptor
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.
178 void CreateDecodeObjectL(TBool aBool, const TDesC& aFilename, TInt aUid);
182 * This function creates a datasink object based on either a descriptor
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.
191 void CreateEncodeObjectL(TBool aIsFile, const TDesC& aFilename, TInt aUid);
193 //from MAsyncEventHandler
194 virtual TInt SendEventToClient(const TMMFEvent& /*aEvent*/) {return KErrNone;}//XXX - can we do better here?
198 TBool iDecode; // ETrue if using CMmfXXXFormatRead/MDataSource
199 // EFalse if using CMmfXXXFormatWrite/MDataSink
201 const CTestSuite_MMF_AFMT* iAFMTTestSuite; // pointer to suite which owns this test
203 MDataSource* iDataSource; // Ptr to a DataSource
204 MDataSink* iDataSink; // Ptr to a DataSource
206 CMMFFormatDecode* iFormatDec; // Ptr to a Format Decode object
207 CMMFFormatEncode* iFormatEnc; // Ptr to a Format Encode object
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
216 HBufC8* iDescHBuf; // HBuf for holding descriptor data
228 #endif// TSU_MMF_AFMT_H__