0
|
1 |
// Copyright (c) 2002-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 file contains test steps exercising the Audio recorder
|
|
15 |
// functions: xxxxxxxxDestination[DataType|BitRate|SampleRate|Format]x
|
|
16 |
// and xxxxxxNumberOfChannelsx
|
|
17 |
//
|
|
18 |
//
|
|
19 |
|
|
20 |
// EPOC includes
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32test.h>
|
|
23 |
#include <e32keys.h>
|
|
24 |
#include <c32comm.h>
|
|
25 |
#include <f32file.h>
|
|
26 |
#include <etel.h>
|
|
27 |
#include <etelmm.h>
|
|
28 |
#include <testframework.h>
|
|
29 |
|
|
30 |
#include <mdaaudiosampleeditor.h>
|
|
31 |
|
|
32 |
// Test system includes
|
|
33 |
#include <testframework.h>
|
|
34 |
|
|
35 |
// Specific includes for this test suite
|
|
36 |
#include "TestStepUnitMMFAudClient.h"
|
|
37 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
38 |
|
|
39 |
// Specific includes for these test steps
|
|
40 |
#include "TestStepRecorder.h"
|
|
41 |
|
|
42 |
|
|
43 |
#include "MmfAudioController.h"
|
|
44 |
#include "mmfclientaudiorecorder.h"
|
|
45 |
#include <mmf/common/mmffourcc.h>
|
|
46 |
//#include <mmf/common/mmfpaniccodes.h>
|
|
47 |
#include <mmf/plugin/mmfformatimplementationuids.hrh>
|
|
48 |
|
|
49 |
|
|
50 |
//
|
|
51 |
// --------------------------------------------
|
|
52 |
//
|
|
53 |
/**
|
|
54 |
*
|
|
55 |
* Static constructor for CTestStepRecorderDestinDataType.
|
|
56 |
*
|
|
57 |
*
|
|
58 |
* @return "CTestStepRecorderDestinDataType*"
|
|
59 |
* The constructed CTestStepRecorderDestinDataType
|
|
60 |
*
|
|
61 |
* @xxxx
|
|
62 |
*
|
|
63 |
*/
|
|
64 |
CTestStepRecorderDestinDataType* CTestStepRecorderDestinDataType::NewL(const TDesC& aTestName, TBool aIsConverterTest)
|
|
65 |
{
|
|
66 |
CTestStepRecorderDestinDataType* self = new(ELeave) CTestStepRecorderDestinDataType(aTestName, aIsConverterTest);
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
/**
|
|
71 |
*
|
|
72 |
* Test step constructor.
|
|
73 |
* Each test step initialises its own name.
|
|
74 |
*
|
|
75 |
* @xxxx
|
|
76 |
*
|
|
77 |
*/
|
|
78 |
CTestStepRecorderDestinDataType::CTestStepRecorderDestinDataType(const TDesC& aTestName, TBool aIsConverterTest)
|
|
79 |
: iIsConverterTest(aIsConverterTest)
|
|
80 |
{
|
|
81 |
// store the name of this test case
|
|
82 |
// this is the name that is used by the script file
|
|
83 |
iTestStepName = aTestName;
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderDestinDataType::~CTestStepRecorderDestinDataType()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderDestinDataType::DoTestStepPreambleL(void)
|
|
105 |
{
|
|
106 |
enum TVerdict verdict;
|
|
107 |
// this installs the scheduler
|
|
108 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
109 |
|
|
110 |
// Printing to the console and log file
|
|
111 |
if (!iIsConverterTest)
|
|
112 |
{
|
|
113 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0264-HP"));
|
|
114 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::xxxDestinationDataTypexx() functions"));
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0557-HP"));
|
|
119 |
INFO_PRINTF1(_L("this is a test of CMdaAudioConvertUtility::xxxDestinationDataTypexx() functions"));
|
|
120 |
}
|
|
121 |
|
|
122 |
if(!(GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName) && // wav
|
|
123 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord4"), iFileName2) && // wav
|
|
124 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToConvert"), iFileName3) // au
|
|
125 |
))
|
|
126 |
{
|
|
127 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
128 |
return EInconclusive;
|
|
129 |
}
|
|
130 |
|
|
131 |
if (!iIsConverterTest)
|
|
132 |
{
|
|
133 |
// create the Recorder utility
|
|
134 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
135 |
return EInconclusive;
|
|
136 |
TRAPD( err, OpenAndStartSchedulerL() );
|
|
137 |
|
|
138 |
if (iRecorder == NULL ||
|
|
139 |
err != KErrNone ||
|
|
140 |
iError != KErrNone ||
|
|
141 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
142 |
return EInconclusive;
|
|
143 |
}
|
|
144 |
else
|
|
145 |
{
|
|
146 |
if ( (iConvert = CMdaAudioConvertUtility::NewL(*this)) == NULL )
|
|
147 |
return EInconclusive;
|
|
148 |
TRAPD( err, OpenAndStartSchedulerL() );
|
|
149 |
|
|
150 |
if (iConvert == NULL ||
|
|
151 |
err != KErrNone ||
|
|
152 |
iError != KErrNone ||
|
|
153 |
iConvert->State() != CMdaAudioConvertUtility::EOpen)
|
|
154 |
return EInconclusive;
|
|
155 |
}
|
|
156 |
|
|
157 |
|
|
158 |
return verdict;
|
|
159 |
|
|
160 |
}
|
|
161 |
|
|
162 |
/**
|
|
163 |
*
|
|
164 |
* Test step Postamble.
|
|
165 |
*
|
|
166 |
* @xxxx
|
|
167 |
*
|
|
168 |
*/
|
|
169 |
enum TVerdict CTestStepRecorderDestinDataType::DoTestStepPostambleL(void)
|
|
170 |
{
|
|
171 |
iFs.Connect();
|
|
172 |
iFileMan = CFileMan::NewL(iFs);
|
|
173 |
iFileMan->Delete(iFileName2);
|
|
174 |
iFileMan->Delete(iFileName3);
|
|
175 |
iFs.Close();
|
|
176 |
delete iFileMan;
|
|
177 |
iFileMan = NULL;
|
|
178 |
if (!iIsConverterTest)
|
|
179 |
{
|
|
180 |
delete iRecorder;
|
|
181 |
iRecorder = NULL;
|
|
182 |
}
|
|
183 |
else
|
|
184 |
{
|
|
185 |
delete iConvert;
|
|
186 |
iConvert = NULL;
|
|
187 |
}
|
|
188 |
|
|
189 |
//[ Destroy the scheduler ]
|
|
190 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
191 |
}
|
|
192 |
|
|
193 |
/**
|
|
194 |
*
|
|
195 |
* Callback Handle.
|
|
196 |
*
|
|
197 |
* @xxxx
|
|
198 |
*
|
|
199 |
*/
|
|
200 |
void CTestStepRecorderDestinDataType::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
201 |
TInt /*aPreviousState*/,
|
|
202 |
TInt /*aCurrentState*/,
|
|
203 |
TInt aErrorcCode)
|
|
204 |
{
|
|
205 |
iError = aErrorcCode;
|
|
206 |
CActiveScheduler::Stop();
|
|
207 |
}
|
|
208 |
|
|
209 |
void CTestStepRecorderDestinDataType::OpenAndStartSchedulerL()
|
|
210 |
{
|
|
211 |
if (!iIsConverterTest)
|
|
212 |
iRecorder->OpenFileL( iFileName );
|
|
213 |
else
|
|
214 |
iConvert->OpenL( iFileName, iFileName3 );
|
|
215 |
|
|
216 |
CActiveScheduler::Start();
|
|
217 |
|
|
218 |
}
|
|
219 |
|
|
220 |
/**
|
|
221 |
*
|
|
222 |
* Do the test step.
|
|
223 |
* Each test step must supply an implementation for DoTestStepL.
|
|
224 |
*
|
|
225 |
* @return "TVerdict"
|
|
226 |
* The result of the test step
|
|
227 |
*
|
|
228 |
* @xxxx
|
|
229 |
*
|
|
230 |
*/
|
|
231 |
TVerdict CTestStepRecorderDestinDataType::DoTestStepL()
|
|
232 |
{
|
|
233 |
iTestStepResult = EPass;
|
|
234 |
TInt err = KErrNone;
|
|
235 |
TFourCC fourCC;
|
|
236 |
RArray<TFourCC> supFourCC;
|
|
237 |
|
|
238 |
if (!iIsConverterTest)
|
|
239 |
{
|
|
240 |
// check the number of supported audio types
|
|
241 |
// just checking that there are some types available
|
|
242 |
// since it's not known how many types are supported each time
|
|
243 |
TRAP(err, iRecorder->GetSupportedDestinationDataTypesL(supFourCC));
|
|
244 |
if (err != KErrNone ||
|
|
245 |
supFourCC.Count() <= 0 ||
|
|
246 |
supFourCC.Find(TFourCC(KMMFFourCCCodeALAW)) < 0 ||
|
|
247 |
supFourCC.Find(TFourCC(KMMFFourCCCodePCM16)) < 0 )
|
|
248 |
return EFail;
|
|
249 |
// get the type of the openned file of known type
|
|
250 |
// and check if type correct
|
|
251 |
TRAP(err, fourCC = iRecorder->DestinationDataTypeL());
|
|
252 |
if (err != KErrNone ||
|
|
253 |
fourCC != KMMFFourCCCodePCM16)
|
|
254 |
return EFail;
|
|
255 |
|
|
256 |
// close this file and
|
|
257 |
iRecorder->Close();
|
|
258 |
//open a new non-existing file for recording
|
|
259 |
TRAP(err, iRecorder->OpenFileL(iFileName2));
|
|
260 |
if (err != KErrNone ||
|
|
261 |
iError != KErrNone)
|
|
262 |
return EInconclusive;
|
|
263 |
|
|
264 |
CActiveScheduler::Start();
|
|
265 |
// set the destination type to a specific one of our choice
|
|
266 |
TRAP(err, iRecorder->SetDestinationDataTypeL(KMMFFourCCCodeIMAD));
|
|
267 |
if (err != KErrNone)
|
|
268 |
return EFail;
|
|
269 |
|
|
270 |
//get the newly set type
|
|
271 |
//and check if it has been set correctly
|
|
272 |
TRAP(err, fourCC = iRecorder->DestinationDataTypeL());
|
|
273 |
if (err != KErrNone ||
|
|
274 |
fourCC != KMMFFourCCCodeIMAD)
|
|
275 |
return EFail;
|
|
276 |
}
|
|
277 |
else // iIsConverterTest
|
|
278 |
{
|
|
279 |
TRAP(err, iConvert->GetSupportedDestinationDataTypesL(supFourCC));
|
|
280 |
if (err != KErrNone ||
|
|
281 |
supFourCC.Count() <= 0 ||
|
|
282 |
supFourCC.Find(TFourCC(KMMFFourCCCodeALAW)) < 0 ||
|
|
283 |
supFourCC.Find(TFourCC(KMMFFourCCCodePCM8)) < 0 )
|
|
284 |
return EFail;
|
|
285 |
|
|
286 |
//TRAP(err, fourCC = iConvert->DestinationDataTypeL());
|
|
287 |
//if (err != KErrNone ||
|
|
288 |
// fourCC != KMMFFourCCCodePCM16)
|
|
289 |
// return EFail;
|
|
290 |
|
|
291 |
// set the destination type to a specific one of our choice
|
|
292 |
TRAP(err, iConvert->SetDestinationDataTypeL(KMMFFourCCCodePCM8));
|
|
293 |
if (err != KErrNone)
|
|
294 |
return EFail;
|
|
295 |
|
|
296 |
//get the newly set type
|
|
297 |
//and check if it has been set correctly
|
|
298 |
TRAP(err, fourCC = iConvert->DestinationDataTypeL());
|
|
299 |
if (err != KErrNone ||
|
|
300 |
fourCC != KMMFFourCCCodePCM8)
|
|
301 |
return EFail;
|
|
302 |
}
|
|
303 |
|
|
304 |
|
|
305 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
306 |
// test steps return a result
|
|
307 |
return iTestStepResult;
|
|
308 |
}
|
|
309 |
|
|
310 |
|
|
311 |
//
|
|
312 |
// --------------------------------------------
|
|
313 |
//
|
|
314 |
/**
|
|
315 |
*
|
|
316 |
* Static constructor for CTestStepRecorderBitRate.
|
|
317 |
*
|
|
318 |
*
|
|
319 |
* @return "CTestStepRecorderBitRate*"
|
|
320 |
* The constructed CTestStepRecorderBitRate
|
|
321 |
*
|
|
322 |
* @xxxx
|
|
323 |
*
|
|
324 |
*/
|
|
325 |
CTestStepRecorderBitRate* CTestStepRecorderBitRate::NewL(const TDesC& aTestName, TBool aIsConverterTest)
|
|
326 |
{
|
|
327 |
CTestStepRecorderBitRate* self = new(ELeave) CTestStepRecorderBitRate(aTestName, aIsConverterTest);
|
|
328 |
return self;
|
|
329 |
}
|
|
330 |
|
|
331 |
/**
|
|
332 |
*
|
|
333 |
* Test step constructor.
|
|
334 |
* Each test step initialises its own name.
|
|
335 |
*
|
|
336 |
* @xxxx
|
|
337 |
*
|
|
338 |
*/
|
|
339 |
CTestStepRecorderBitRate::CTestStepRecorderBitRate(const TDesC& aTestName, TBool aIsConverterTest)
|
|
340 |
: iIsConverterTest(aIsConverterTest)
|
|
341 |
{
|
|
342 |
// store the name of this test case
|
|
343 |
// this is the name that is used by the script file
|
|
344 |
iTestStepName = aTestName;
|
|
345 |
}
|
|
346 |
|
|
347 |
/**
|
|
348 |
*
|
|
349 |
* Test step destructor.
|
|
350 |
*
|
|
351 |
* @xxxx
|
|
352 |
*
|
|
353 |
*/
|
|
354 |
CTestStepRecorderBitRate::~CTestStepRecorderBitRate()
|
|
355 |
{
|
|
356 |
}
|
|
357 |
|
|
358 |
/**
|
|
359 |
*
|
|
360 |
* Test step Preamble.
|
|
361 |
*
|
|
362 |
* @xxxx
|
|
363 |
*
|
|
364 |
*/
|
|
365 |
enum TVerdict CTestStepRecorderBitRate::DoTestStepPreambleL(void)
|
|
366 |
{
|
|
367 |
enum TVerdict verdict;
|
|
368 |
// this installs the scheduler
|
|
369 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
370 |
|
|
371 |
// Printing to the console and log file
|
|
372 |
INFO_PRINTF1(iTestStepName);
|
|
373 |
if (!iIsConverterTest)
|
|
374 |
{
|
|
375 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::xxxBitRatexx() functions"));
|
|
376 |
}
|
|
377 |
else
|
|
378 |
{
|
|
379 |
INFO_PRINTF1(_L("this is a test of CMdaAudioConvertUtility::xxxBitRatexx() functions"));
|
|
380 |
}
|
|
381 |
|
|
382 |
if(!(GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName) && // wav
|
|
383 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord4"), iFileName2) && // wav
|
|
384 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToConvert"), iFileName3) // au
|
|
385 |
))
|
|
386 |
{
|
|
387 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
388 |
return EInconclusive;
|
|
389 |
}
|
|
390 |
|
|
391 |
//delete files that should not be there
|
|
392 |
iFs.Connect();
|
|
393 |
iFileMan = CFileMan::NewL(iFs);
|
|
394 |
iFileMan->Delete(iFileName2);
|
|
395 |
iFileMan->Delete(iFileName3);
|
|
396 |
iFs.Close();
|
|
397 |
delete iFileMan;
|
|
398 |
iFileMan = NULL;
|
|
399 |
|
|
400 |
if (!iIsConverterTest)
|
|
401 |
{
|
|
402 |
// create the Recorder utility
|
|
403 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
404 |
return EInconclusive;
|
|
405 |
|
|
406 |
TInt err;
|
|
407 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
408 |
|
|
409 |
if (iRecorder == NULL ||
|
|
410 |
err != KErrNone ||
|
|
411 |
iError != KErrNone ||
|
|
412 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
413 |
return EInconclusive;
|
|
414 |
}
|
|
415 |
else
|
|
416 |
{
|
|
417 |
// create the Converter utility
|
|
418 |
if ( (iConvert = CMdaAudioConvertUtility::NewL(*this)) == NULL )
|
|
419 |
return EInconclusive;
|
|
420 |
|
|
421 |
TInt err;
|
|
422 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
423 |
|
|
424 |
if (iConvert == NULL ||
|
|
425 |
err != KErrNone ||
|
|
426 |
iError != KErrNone ||
|
|
427 |
iConvert->State() != CMdaAudioConvertUtility::EOpen)
|
|
428 |
return EInconclusive;
|
|
429 |
}
|
|
430 |
|
|
431 |
return verdict;
|
|
432 |
}
|
|
433 |
|
|
434 |
/**
|
|
435 |
*
|
|
436 |
* Test step Postamble.
|
|
437 |
*
|
|
438 |
* @xxxx
|
|
439 |
*
|
|
440 |
*/
|
|
441 |
enum TVerdict CTestStepRecorderBitRate::DoTestStepPostambleL(void)
|
|
442 |
{
|
|
443 |
iFs.Connect();
|
|
444 |
iFileMan = CFileMan::NewL(iFs);
|
|
445 |
iFileMan->Delete(iFileName2);
|
|
446 |
iFileMan->Delete(iFileName3);
|
|
447 |
iFs.Close();
|
|
448 |
delete iFileMan;
|
|
449 |
iFileMan = NULL;
|
|
450 |
if (!iIsConverterTest)
|
|
451 |
{
|
|
452 |
delete iRecorder;
|
|
453 |
iRecorder = NULL;
|
|
454 |
}
|
|
455 |
else
|
|
456 |
{
|
|
457 |
delete iConvert;
|
|
458 |
iConvert = NULL;
|
|
459 |
}
|
|
460 |
|
|
461 |
//[ Destroy the scheduler ]
|
|
462 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
463 |
}
|
|
464 |
|
|
465 |
/**
|
|
466 |
*
|
|
467 |
* Callback Handle.
|
|
468 |
*
|
|
469 |
* @xxxx
|
|
470 |
*
|
|
471 |
*/
|
|
472 |
void CTestStepRecorderBitRate::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
473 |
TInt /*aPreviousState*/,
|
|
474 |
TInt /*aCurrentState*/,
|
|
475 |
TInt aErrorcCode)
|
|
476 |
{
|
|
477 |
iError = aErrorcCode;
|
|
478 |
CActiveScheduler::Stop();
|
|
479 |
}
|
|
480 |
|
|
481 |
void CTestStepRecorderBitRate::OpenAndStartSchedulerL()
|
|
482 |
{
|
|
483 |
if (!iIsConverterTest)
|
|
484 |
iRecorder->OpenFileL( iFileName );
|
|
485 |
else
|
|
486 |
iConvert->OpenL( iFileName, iFileName3 );
|
|
487 |
|
|
488 |
CActiveScheduler::Start();
|
|
489 |
}
|
|
490 |
|
|
491 |
/**
|
|
492 |
*
|
|
493 |
* Do the test step.
|
|
494 |
* Each test step must supply an implementation for DoTestStepL.
|
|
495 |
*
|
|
496 |
* @return "TVerdict"
|
|
497 |
* The result of the test step
|
|
498 |
*
|
|
499 |
* @xxxx
|
|
500 |
*
|
|
501 |
*/
|
|
502 |
TVerdict CTestStepRecorderBitRate::DoTestStepL()
|
|
503 |
{
|
|
504 |
iTestStepResult = EPass;
|
|
505 |
TInt err = KErrNone;
|
|
506 |
TUint bitrate = 0;
|
|
507 |
RArray<TUint> supBitRates;
|
|
508 |
|
|
509 |
if (!iIsConverterTest)
|
|
510 |
{
|
|
511 |
// get the type of the openned file of known bitrate
|
|
512 |
// (wav file 8KHz x 16 bit = 128 Kbps)
|
|
513 |
// and check if type correct
|
|
514 |
TRAP(err, bitrate = iRecorder->DestinationBitRateL());
|
|
515 |
if (err != KErrNone ||
|
|
516 |
bitrate != 128000)
|
|
517 |
return EFail;
|
|
518 |
|
|
519 |
// close this file and
|
|
520 |
iRecorder->Close();
|
|
521 |
|
|
522 |
//open a new non-existing file for recording
|
|
523 |
TRAP(err, iRecorder->OpenFileL(iFileName2));
|
|
524 |
if (err != KErrNone ||
|
|
525 |
iError != KErrNone)
|
|
526 |
return EInconclusive;
|
|
527 |
|
|
528 |
CActiveScheduler::Start();
|
|
529 |
if (iError != KErrNone)
|
|
530 |
return EFail;
|
|
531 |
|
|
532 |
// check the number of supported bitrates
|
|
533 |
// just checking that there are some bitrates available
|
|
534 |
TRAP(err, iRecorder->GetSupportedBitRatesL(supBitRates));
|
|
535 |
if ( err != KErrNotSupported ) // KErrNotSupported expected
|
|
536 |
{
|
|
537 |
if (err != KErrNone ||
|
|
538 |
supBitRates.Count() <= 0 )
|
|
539 |
return EFail;
|
|
540 |
}
|
|
541 |
|
|
542 |
// set the destination bitrate to a specific one of our choice
|
|
543 |
TRAP(err, iRecorder->SetDestinationBitRateL(64000));
|
|
544 |
|
|
545 |
//NB KErrNotSupported is a valid response, the format used may not support this ability
|
|
546 |
//If it is supported, read the value to confirm it was correctly set.
|
|
547 |
if ( err != KErrNotSupported )
|
|
548 |
{
|
|
549 |
if (err != KErrNone)
|
|
550 |
return EFail;
|
|
551 |
|
|
552 |
//get the newly set type
|
|
553 |
//and check if it has been set correctly
|
|
554 |
TRAP(err, bitrate = iRecorder->DestinationBitRateL());
|
|
555 |
if ( err != KErrNotSupported )
|
|
556 |
{
|
|
557 |
if (err != KErrNone ||
|
|
558 |
bitrate != 64000)
|
|
559 |
return EFail;
|
|
560 |
}
|
|
561 |
}
|
|
562 |
TInt errorSetDestinationBitRate = err;
|
|
563 |
|
|
564 |
//get the newly set type
|
|
565 |
//and check if it has been set correctly
|
|
566 |
TRAP(err, bitrate = iRecorder->DestinationBitRateL());
|
|
567 |
if ( err != KErrNotSupported )
|
|
568 |
{
|
|
569 |
if (err != KErrNone ||
|
|
570 |
(errorSetDestinationBitRate == KErrNone && bitrate != 64000))
|
|
571 |
return EFail;
|
|
572 |
}
|
|
573 |
}
|
|
574 |
else // IsConverterTest == ETrue
|
|
575 |
{
|
|
576 |
// get source file known bitrate
|
|
577 |
// (wav file 8KHz x 16 bit = 128 Kbps)
|
|
578 |
// and check if type correct
|
|
579 |
TRAP(err, bitrate = iConvert->SourceBitRateL());
|
|
580 |
if (err != KErrNone ||
|
|
581 |
bitrate != 128000)
|
|
582 |
return EFail;
|
|
583 |
|
|
584 |
// check the number of supported bitrates
|
|
585 |
// just checking that there are some bitrates available
|
|
586 |
TRAP(err, iConvert->GetSupportedConversionBitRatesL(supBitRates));
|
|
587 |
if ( err != KErrNotSupported ) // KErrNotSupported expected
|
|
588 |
{
|
|
589 |
if (err != KErrNone ||
|
|
590 |
supBitRates.Count() <= 0 )
|
|
591 |
return EFail;
|
|
592 |
}
|
|
593 |
|
|
594 |
// set the destination bitrate to a specific one of our choice
|
|
595 |
TRAP(err, iConvert->SetDestinationBitRateL(64000));
|
|
596 |
|
|
597 |
//NB KErrNotSupported is a valid response, the format used may not support this ability
|
|
598 |
//If it is supported, read the value to confirm it was correctly set.
|
|
599 |
if ( err != KErrNotSupported )
|
|
600 |
{
|
|
601 |
if (err != KErrNone)
|
|
602 |
return EFail;
|
|
603 |
}
|
|
604 |
TInt errSetDestinationBitRate = err;
|
|
605 |
|
|
606 |
//get the newly set type
|
|
607 |
//and check if it has been set correctly
|
|
608 |
TRAP(err, bitrate = iConvert->DestinationBitRateL());
|
|
609 |
if ( err != KErrNotSupported )
|
|
610 |
{
|
|
611 |
if ((err == KErrNone && errSetDestinationBitRate == KErrNone && bitrate != 64000)
|
|
612 |
|| (err != KErrNone))
|
|
613 |
return EFail;
|
|
614 |
}
|
|
615 |
}
|
|
616 |
|
|
617 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
618 |
// test steps return a result
|
|
619 |
return iTestStepResult;
|
|
620 |
}
|
|
621 |
|
|
622 |
//
|
|
623 |
// --------------------------------------------
|
|
624 |
//
|
|
625 |
/**
|
|
626 |
*
|
|
627 |
* Static constructor for CTestStepRecorderSampleRate.
|
|
628 |
*
|
|
629 |
*
|
|
630 |
* @return "CTestStepRecorderSampleRate*"
|
|
631 |
* The constructed CTestStepRecorderSampleRate
|
|
632 |
*
|
|
633 |
* @xxxx
|
|
634 |
*
|
|
635 |
*/
|
|
636 |
CTestStepRecorderSampleRate* CTestStepRecorderSampleRate::NewL(const TDesC& aTestName, TBool aIsConverterTest)
|
|
637 |
{
|
|
638 |
CTestStepRecorderSampleRate* self = new(ELeave) CTestStepRecorderSampleRate(aTestName, aIsConverterTest);
|
|
639 |
return self;
|
|
640 |
}
|
|
641 |
|
|
642 |
/**
|
|
643 |
*
|
|
644 |
* Test step constructor.
|
|
645 |
* Each test step initialises its own name.
|
|
646 |
*
|
|
647 |
* @xxxx
|
|
648 |
*
|
|
649 |
*/
|
|
650 |
CTestStepRecorderSampleRate::CTestStepRecorderSampleRate(const TDesC& aTestName, TBool aIsConverterTest)
|
|
651 |
: iIsConverterTest(aIsConverterTest)
|
|
652 |
{
|
|
653 |
// store the name of this test case
|
|
654 |
// this is the name that is used by the script file
|
|
655 |
iTestStepName = aTestName;
|
|
656 |
}
|
|
657 |
|
|
658 |
/**
|
|
659 |
*
|
|
660 |
* Test step destructor.
|
|
661 |
*
|
|
662 |
* @xxxx
|
|
663 |
*
|
|
664 |
*/
|
|
665 |
CTestStepRecorderSampleRate::~CTestStepRecorderSampleRate()
|
|
666 |
{
|
|
667 |
}
|
|
668 |
|
|
669 |
/**
|
|
670 |
*
|
|
671 |
* Test step Preamble.
|
|
672 |
*
|
|
673 |
* @xxxx
|
|
674 |
*
|
|
675 |
*/
|
|
676 |
enum TVerdict CTestStepRecorderSampleRate::DoTestStepPreambleL(void)
|
|
677 |
{
|
|
678 |
enum TVerdict verdict;
|
|
679 |
// this installs the scheduler
|
|
680 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
681 |
|
|
682 |
// Printing to the console and log file
|
|
683 |
INFO_PRINTF1(iTestStepName);
|
|
684 |
if (!iIsConverterTest)
|
|
685 |
{
|
|
686 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::xxxSampleRatexx() functions"));
|
|
687 |
}
|
|
688 |
else
|
|
689 |
{
|
|
690 |
INFO_PRINTF1(_L("this is a test of CMdaAudioConvertUtility::xxxSampleRatexx() functions"));
|
|
691 |
}
|
|
692 |
|
|
693 |
if(!(GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName) && // wav
|
|
694 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord4"), iFileName2) && // wav
|
|
695 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToConvert"), iFileName3) // au
|
|
696 |
))
|
|
697 |
{
|
|
698 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
699 |
return EInconclusive;
|
|
700 |
}
|
|
701 |
|
|
702 |
if (!iIsConverterTest)
|
|
703 |
{
|
|
704 |
// create the Recorder utility
|
|
705 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
706 |
return EInconclusive;
|
|
707 |
|
|
708 |
TInt err;
|
|
709 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
710 |
|
|
711 |
if (iRecorder == NULL ||
|
|
712 |
err != KErrNone ||
|
|
713 |
iError != KErrNone ||
|
|
714 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
715 |
return EInconclusive;
|
|
716 |
}
|
|
717 |
else
|
|
718 |
{
|
|
719 |
// create the Converter utility
|
|
720 |
if ( (iConvert = CMdaAudioConvertUtility::NewL(*this)) == NULL )
|
|
721 |
return EInconclusive;
|
|
722 |
|
|
723 |
TInt err;
|
|
724 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
725 |
|
|
726 |
if (iConvert == NULL ||
|
|
727 |
err != KErrNone ||
|
|
728 |
iError != KErrNone ||
|
|
729 |
iConvert->State() != CMdaAudioConvertUtility::EOpen)
|
|
730 |
return EInconclusive;
|
|
731 |
}
|
|
732 |
|
|
733 |
return verdict;
|
|
734 |
}
|
|
735 |
|
|
736 |
/**
|
|
737 |
*
|
|
738 |
* Test step Postamble.
|
|
739 |
*
|
|
740 |
* @xxxx
|
|
741 |
*
|
|
742 |
*/
|
|
743 |
enum TVerdict CTestStepRecorderSampleRate::DoTestStepPostambleL(void)
|
|
744 |
{
|
|
745 |
iFs.Connect();
|
|
746 |
iFileMan = CFileMan::NewL(iFs);
|
|
747 |
iFileMan->Delete(iFileName2);
|
|
748 |
iFileMan->Delete(iFileName3);
|
|
749 |
iFs.Close();
|
|
750 |
delete iFileMan;
|
|
751 |
iFileMan = NULL;
|
|
752 |
if (!iIsConverterTest)
|
|
753 |
{
|
|
754 |
delete iRecorder;
|
|
755 |
iRecorder = NULL;
|
|
756 |
}
|
|
757 |
else
|
|
758 |
{
|
|
759 |
delete iConvert;
|
|
760 |
iConvert = NULL;
|
|
761 |
}
|
|
762 |
|
|
763 |
//[ Destroy the scheduler ]
|
|
764 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
765 |
}
|
|
766 |
|
|
767 |
/**
|
|
768 |
*
|
|
769 |
* Callback Handle.
|
|
770 |
*
|
|
771 |
* @xxxx
|
|
772 |
*
|
|
773 |
*/
|
|
774 |
void CTestStepRecorderSampleRate::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
775 |
TInt /*aPreviousState*/,
|
|
776 |
TInt /*aCurrentState*/,
|
|
777 |
TInt aErrorcCode)
|
|
778 |
{
|
|
779 |
iError = aErrorcCode;
|
|
780 |
CActiveScheduler::Stop();
|
|
781 |
}
|
|
782 |
|
|
783 |
void CTestStepRecorderSampleRate::OpenAndStartSchedulerL()
|
|
784 |
{
|
|
785 |
if (!iIsConverterTest)
|
|
786 |
iRecorder->OpenFileL( iFileName );
|
|
787 |
else
|
|
788 |
iConvert->OpenL( iFileName, iFileName3 );
|
|
789 |
|
|
790 |
CActiveScheduler::Start();
|
|
791 |
}
|
|
792 |
|
|
793 |
/**
|
|
794 |
*
|
|
795 |
* Do the test step.
|
|
796 |
* Each test step must supply an implementation for DoTestStepL.
|
|
797 |
*
|
|
798 |
* @return "TVerdict"
|
|
799 |
* The result of the test step
|
|
800 |
*
|
|
801 |
* @xxxx
|
|
802 |
*
|
|
803 |
*/
|
|
804 |
TVerdict CTestStepRecorderSampleRate::DoTestStepL()
|
|
805 |
{
|
|
806 |
iTestStepResult = EPass;
|
|
807 |
TInt err = KErrNone;
|
|
808 |
TUint samplerate = 0;
|
|
809 |
RArray<TUint> supSampleRates;
|
|
810 |
|
|
811 |
if (!iIsConverterTest)
|
|
812 |
{
|
|
813 |
// get the type of the openned file of known bitrate
|
|
814 |
// (wav file 8KHz)
|
|
815 |
// and check if type correct
|
|
816 |
TRAP(err, samplerate = iRecorder->DestinationSampleRateL());
|
|
817 |
if (err != KErrNone ||
|
|
818 |
samplerate != 8000)
|
|
819 |
{
|
|
820 |
INFO_PRINTF3(_L("iRecorder->DestinationSampleRateL() test failed (err=%d, samplerate=%d)"),
|
|
821 |
err, samplerate);
|
|
822 |
return EFail;
|
|
823 |
}
|
|
824 |
|
|
825 |
// close this file and
|
|
826 |
iRecorder->Close();
|
|
827 |
|
|
828 |
//open a new non-existing file for recording
|
|
829 |
TRAP(err, iRecorder->OpenFileL(iFileName2));
|
|
830 |
if (err != KErrNone ||
|
|
831 |
iError != KErrNone)
|
|
832 |
{
|
|
833 |
INFO_PRINTF3(_L("iRecorder->OpenFileL() test failed (err=%d, iError=%d)"), err, iError);
|
|
834 |
return EInconclusive;
|
|
835 |
}
|
|
836 |
CActiveScheduler::Start();
|
|
837 |
|
|
838 |
// check the number of supported bitrates
|
|
839 |
// just checking that there are some sample rates available
|
|
840 |
TRAP(err, iRecorder->GetSupportedSampleRatesL(supSampleRates));
|
|
841 |
if (err != KErrNone ||
|
|
842 |
supSampleRates.Count() <= 0 )
|
|
843 |
{
|
|
844 |
INFO_PRINTF3(_L("iRecorder->GetSupportedSampleRatesL() test failed (err=%d, count=%d)"),
|
|
845 |
err, supSampleRates.Count());
|
|
846 |
return EFail;
|
|
847 |
}
|
|
848 |
|
|
849 |
// set the destination samplerate to a specific one of our choice
|
|
850 |
TRAP(err, iRecorder->SetDestinationSampleRateL(supSampleRates[0]) ); //4000));
|
|
851 |
if (err != KErrNone)
|
|
852 |
{
|
|
853 |
INFO_PRINTF2(_L("iRecorder->SetDestinationSampleRateL() test failed (err=%d)"), err);
|
|
854 |
return EFail;
|
|
855 |
}
|
|
856 |
|
|
857 |
//get the newly set sample rate
|
|
858 |
//and check if it has been set correctly
|
|
859 |
TRAP(err, samplerate = iRecorder->DestinationSampleRateL());
|
|
860 |
if (err != KErrNone ||
|
|
861 |
samplerate != supSampleRates[0])
|
|
862 |
{
|
|
863 |
INFO_PRINTF3(_L("iRecorder->DestinationSampleRateL() test failed (err=%d, samplerate=%d)"),
|
|
864 |
err, supSampleRates[0]);
|
|
865 |
return EFail;
|
|
866 |
}
|
|
867 |
}
|
|
868 |
else // isConverterTest == ETrue
|
|
869 |
{
|
|
870 |
// get the known sample rate of the source file
|
|
871 |
// (wav file 8KHz)
|
|
872 |
// and check if type correct
|
|
873 |
TRAP(err, samplerate = iConvert->SourceSampleRateL());
|
|
874 |
if (err != KErrNone ||
|
|
875 |
samplerate != 8000)
|
|
876 |
{
|
|
877 |
INFO_PRINTF3(_L("iConvert->SourceSampleRateL() test failed (err=%d, samplerate=%d)"), err, samplerate);
|
|
878 |
return EFail;
|
|
879 |
}
|
|
880 |
|
|
881 |
// check the number of supported bitrates
|
|
882 |
// just checking that there are some sample rates available
|
|
883 |
TRAP(err, iConvert->GetSupportedConversionSampleRatesL(supSampleRates));
|
|
884 |
if (err != KErrNone ||
|
|
885 |
supSampleRates.Count() <= 0 )
|
|
886 |
{
|
|
887 |
INFO_PRINTF3(_L("iConvert->GetSupportedConversionSampleRatesL() test failed (err=%d, count=%d)"),
|
|
888 |
err, supSampleRates.Count());
|
|
889 |
return EFail;
|
|
890 |
}
|
|
891 |
|
|
892 |
// set the destination samplerate to a specific one of our choice
|
|
893 |
TRAP(err, iConvert->SetDestinationSampleRateL(supSampleRates[0]) ); //4000));
|
|
894 |
if (err != KErrNone)
|
|
895 |
{
|
|
896 |
INFO_PRINTF2(_L("iConvert->SetDestinationSampleRateL() test failed (err=%d)"), err);
|
|
897 |
return EFail;
|
|
898 |
}
|
|
899 |
|
|
900 |
//get the newly set sample rate
|
|
901 |
//and check if it has been set correctly
|
|
902 |
TRAP(err, samplerate = iConvert->DestinationSampleRateL());
|
|
903 |
if (err != KErrNone ||
|
|
904 |
samplerate != supSampleRates[0])
|
|
905 |
{
|
|
906 |
INFO_PRINTF3(_L("iConvert->DestinationSampleRateL() test failed (err=%d, samplerate=%d)"),
|
|
907 |
err, supSampleRates[0]);
|
|
908 |
return EFail;
|
|
909 |
}
|
|
910 |
}
|
|
911 |
|
|
912 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
913 |
// test steps return a result
|
|
914 |
return iTestStepResult;
|
|
915 |
}
|
|
916 |
|
|
917 |
//
|
|
918 |
// --------------------------------------------
|
|
919 |
//
|
|
920 |
/**
|
|
921 |
*
|
|
922 |
* Static constructor for CTestStepRecorderFormat.
|
|
923 |
*
|
|
924 |
*
|
|
925 |
* @return "CTestStepRecorderFormat*"
|
|
926 |
* The constructed CTestStepRecorderFormat
|
|
927 |
*
|
|
928 |
* @xxxx
|
|
929 |
*
|
|
930 |
*/
|
|
931 |
CTestStepRecorderFormat* CTestStepRecorderFormat::NewL(const TDesC& aTestName, TBool aIsConverterTest)
|
|
932 |
{
|
|
933 |
CTestStepRecorderFormat* self = new(ELeave) CTestStepRecorderFormat(aTestName, aIsConverterTest);
|
|
934 |
return self;
|
|
935 |
}
|
|
936 |
|
|
937 |
/**
|
|
938 |
*
|
|
939 |
* Test step constructor.
|
|
940 |
* Each test step initialises its own name.
|
|
941 |
*
|
|
942 |
* @xxxx
|
|
943 |
*
|
|
944 |
*/
|
|
945 |
CTestStepRecorderFormat::CTestStepRecorderFormat(const TDesC& aTestName, TBool aIsConverterTest)
|
|
946 |
: iIsConverterTest(aIsConverterTest)
|
|
947 |
{
|
|
948 |
// store the name of this test case
|
|
949 |
// this is the name that is used by the script file
|
|
950 |
iTestStepName = aTestName;
|
|
951 |
}
|
|
952 |
|
|
953 |
/**
|
|
954 |
*
|
|
955 |
* Test step destructor.
|
|
956 |
*
|
|
957 |
* @xxxx
|
|
958 |
*
|
|
959 |
*/
|
|
960 |
CTestStepRecorderFormat::~CTestStepRecorderFormat()
|
|
961 |
{
|
|
962 |
}
|
|
963 |
|
|
964 |
/**
|
|
965 |
*
|
|
966 |
* Test step Preamble.
|
|
967 |
*
|
|
968 |
* @xxxx
|
|
969 |
*
|
|
970 |
*/
|
|
971 |
enum TVerdict CTestStepRecorderFormat::DoTestStepPreambleL(void)
|
|
972 |
{
|
|
973 |
enum TVerdict verdict;
|
|
974 |
// this installs the scheduler
|
|
975 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
976 |
|
|
977 |
// Printing to the console and log file
|
|
978 |
INFO_PRINTF1(iTestStepName);
|
|
979 |
if (!iIsConverterTest)
|
|
980 |
{
|
|
981 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::xxxFormatxx() functions"));
|
|
982 |
}
|
|
983 |
else
|
|
984 |
{
|
|
985 |
INFO_PRINTF1(_L("this is a test of CMdaAudioConvertUtility::xxxFormatxx() functions"));
|
|
986 |
}
|
|
987 |
|
|
988 |
if(!(GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName) && // wav
|
|
989 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord5"), iFileName2) && // wav
|
|
990 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToConvert"), iFileName3) // au
|
|
991 |
))
|
|
992 |
{
|
|
993 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
994 |
return EInconclusive;
|
|
995 |
}
|
|
996 |
|
|
997 |
if (!iIsConverterTest)
|
|
998 |
{
|
|
999 |
// create the Recorder utility
|
|
1000 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
1001 |
return EInconclusive;
|
|
1002 |
|
|
1003 |
TInt err;
|
|
1004 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
1005 |
|
|
1006 |
if (iRecorder == NULL ||
|
|
1007 |
err != KErrNone ||
|
|
1008 |
iError != KErrNone ||
|
|
1009 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
1010 |
return EInconclusive;
|
|
1011 |
}
|
|
1012 |
else
|
|
1013 |
{
|
|
1014 |
// create the Converter utility
|
|
1015 |
if ( (iConvert = CMdaAudioConvertUtility::NewL(*this)) == NULL )
|
|
1016 |
return EInconclusive;
|
|
1017 |
|
|
1018 |
TInt err;
|
|
1019 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
1020 |
|
|
1021 |
if (iConvert == NULL ||
|
|
1022 |
err != KErrNone ||
|
|
1023 |
iError != KErrNone ||
|
|
1024 |
iConvert->State() != CMdaAudioConvertUtility::EOpen)
|
|
1025 |
return EInconclusive;
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
return verdict;
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
/**
|
|
1032 |
*
|
|
1033 |
* Test step Postamble.
|
|
1034 |
*
|
|
1035 |
* @xxxx
|
|
1036 |
*
|
|
1037 |
*/
|
|
1038 |
enum TVerdict CTestStepRecorderFormat::DoTestStepPostambleL(void)
|
|
1039 |
{
|
|
1040 |
iFs.Connect();
|
|
1041 |
iFileMan = CFileMan::NewL(iFs);
|
|
1042 |
iFileMan->Delete(iFileName2);
|
|
1043 |
iFileMan->Delete(iFileName3);
|
|
1044 |
iFs.Close();
|
|
1045 |
delete iFileMan;
|
|
1046 |
iFileMan = NULL;
|
|
1047 |
if (!iIsConverterTest)
|
|
1048 |
{
|
|
1049 |
delete iRecorder;
|
|
1050 |
iRecorder = NULL;
|
|
1051 |
}
|
|
1052 |
else
|
|
1053 |
{
|
|
1054 |
delete iConvert;
|
|
1055 |
iConvert = NULL;
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
//[ Destroy the scheduler ]
|
|
1059 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
1060 |
}
|
|
1061 |
|
|
1062 |
/**
|
|
1063 |
*
|
|
1064 |
* Callback Handle.
|
|
1065 |
*
|
|
1066 |
* @xxxx
|
|
1067 |
*
|
|
1068 |
*/
|
|
1069 |
void CTestStepRecorderFormat::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
1070 |
TInt /*aPreviousState*/,
|
|
1071 |
TInt /*aCurrentState*/,
|
|
1072 |
TInt aErrorcCode)
|
|
1073 |
{
|
|
1074 |
iError = aErrorcCode;
|
|
1075 |
CActiveScheduler::Stop();
|
|
1076 |
}
|
|
1077 |
|
|
1078 |
void CTestStepRecorderFormat::OpenAndStartSchedulerL()
|
|
1079 |
{
|
|
1080 |
if (!iIsConverterTest)
|
|
1081 |
iRecorder->OpenFileL( iFileName );
|
|
1082 |
else
|
|
1083 |
iConvert->OpenL( iFileName, iFileName3 );
|
|
1084 |
|
|
1085 |
CActiveScheduler::Start();
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
/**
|
|
1089 |
*
|
|
1090 |
* Do the test step.
|
|
1091 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1092 |
*
|
|
1093 |
* @return "TVerdict"
|
|
1094 |
* The result of the test step
|
|
1095 |
*
|
|
1096 |
* @xxxx
|
|
1097 |
*
|
|
1098 |
*/
|
|
1099 |
TVerdict CTestStepRecorderFormat::DoTestStepL()
|
|
1100 |
{
|
|
1101 |
iTestStepResult = EPass;
|
|
1102 |
TInt err = KErrNone;
|
|
1103 |
TUid format = TUid::Null();
|
|
1104 |
|
|
1105 |
if (!iIsConverterTest)
|
|
1106 |
{
|
|
1107 |
// get the format of the openned file of known format
|
|
1108 |
// (wav file 8KHz)
|
|
1109 |
// and check if type correct
|
|
1110 |
TRAP(err, format = iRecorder->DestinationFormatL());
|
|
1111 |
if (err != KErrNone ||
|
|
1112 |
format != TUid::Uid(KMmfUidFormatWAVWrite) )
|
|
1113 |
return EFail;
|
|
1114 |
|
|
1115 |
// close this file and
|
|
1116 |
iRecorder->Close();
|
|
1117 |
|
|
1118 |
//open a new non-existing file for recording
|
|
1119 |
TRAP(err, iRecorder->OpenFileL(iFileName2));
|
|
1120 |
if (err != KErrNone ||
|
|
1121 |
iError != KErrNone)
|
|
1122 |
return EInconclusive;
|
|
1123 |
CActiveScheduler::Start();
|
|
1124 |
// set the destination format to a specific one of our choice
|
|
1125 |
TRAP(err, iRecorder->SetDestinationFormatL(TUid::Uid(KMmfUidFormatAUWrite) ) );
|
|
1126 |
if (err != KErrNone)
|
|
1127 |
return EFail;
|
|
1128 |
|
|
1129 |
//get the newly set format
|
|
1130 |
//and check if it has been set correctly
|
|
1131 |
TRAP(err, format = iRecorder->DestinationFormatL());
|
|
1132 |
if (err != KErrNone ||
|
|
1133 |
format != TUid::Uid(KMmfUidFormatAUWrite) )
|
|
1134 |
return EFail;
|
|
1135 |
}
|
|
1136 |
else // isConverterTest == ETrue
|
|
1137 |
{
|
|
1138 |
// get the format of the source file of known format
|
|
1139 |
// (wav file 8KHz)
|
|
1140 |
// and check if type correct
|
|
1141 |
TRAP(err, format = iConvert->SourceFormatL());
|
|
1142 |
if (err != KErrNone ||
|
|
1143 |
format != TUid::Uid(KMmfUidFormatWAVRead) )
|
|
1144 |
return EFail;
|
|
1145 |
|
|
1146 |
// set the destination format to a specific one of our choice
|
|
1147 |
TRAP(err, iConvert->SetDestinationFormatL(TUid::Uid(KMmfUidFormatAUWrite) ) );
|
|
1148 |
if (err != KErrNone)
|
|
1149 |
return EFail;
|
|
1150 |
|
|
1151 |
//get the newly set format
|
|
1152 |
//and check if it has been set correctly
|
|
1153 |
TRAP(err, format = iConvert->DestinationFormatL());
|
|
1154 |
if (err != KErrNone ||
|
|
1155 |
format != TUid::Uid(KMmfUidFormatAUWrite) )
|
|
1156 |
return EFail;
|
|
1157 |
}
|
|
1158 |
|
|
1159 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1160 |
// test steps return a result
|
|
1161 |
return iTestStepResult;
|
|
1162 |
}
|
|
1163 |
|
|
1164 |
//
|
|
1165 |
// ----------CTestStepRecorderChannels----------
|
|
1166 |
//
|
|
1167 |
/**
|
|
1168 |
*
|
|
1169 |
* Static constructor for CTestStepRecorderChannels.
|
|
1170 |
*
|
|
1171 |
*
|
|
1172 |
* @return "CTestStepRecorderChannels*"
|
|
1173 |
* The constructed CTestStepRecorderChannels
|
|
1174 |
*
|
|
1175 |
* @xxxx
|
|
1176 |
*
|
|
1177 |
*/
|
|
1178 |
CTestStepRecorderChannels* CTestStepRecorderChannels::NewL(const TDesC& aTestName, TBool aIsConverterTest)
|
|
1179 |
{
|
|
1180 |
CTestStepRecorderChannels* self = new(ELeave) CTestStepRecorderChannels(aTestName, aIsConverterTest);
|
|
1181 |
return self;
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
/**
|
|
1185 |
*
|
|
1186 |
* Test step constructor.
|
|
1187 |
* Each test step initialises its own name.
|
|
1188 |
*
|
|
1189 |
* @xxxx
|
|
1190 |
*
|
|
1191 |
*/
|
|
1192 |
CTestStepRecorderChannels::CTestStepRecorderChannels(const TDesC& aTestName, TBool aIsConverterTest)
|
|
1193 |
: iIsConverterTest(aIsConverterTest)
|
|
1194 |
{
|
|
1195 |
// store the name of this test case
|
|
1196 |
// this is the name that is used by the script file
|
|
1197 |
iTestStepName = aTestName;
|
|
1198 |
}
|
|
1199 |
|
|
1200 |
/**
|
|
1201 |
*
|
|
1202 |
* Test step destructor.
|
|
1203 |
*
|
|
1204 |
* @xxxx
|
|
1205 |
*
|
|
1206 |
*/
|
|
1207 |
CTestStepRecorderChannels::~CTestStepRecorderChannels()
|
|
1208 |
{
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
/**
|
|
1212 |
*
|
|
1213 |
* Test step Preamble.
|
|
1214 |
*
|
|
1215 |
* @xxxx
|
|
1216 |
*
|
|
1217 |
*/
|
|
1218 |
enum TVerdict CTestStepRecorderChannels::DoTestStepPreambleL(void)
|
|
1219 |
{
|
|
1220 |
enum TVerdict verdict;
|
|
1221 |
// this installs the scheduler
|
|
1222 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
1223 |
|
|
1224 |
// Printing to the console and log file
|
|
1225 |
INFO_PRINTF1(iTestStepName);
|
|
1226 |
if (!iIsConverterTest)
|
|
1227 |
{
|
|
1228 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::xxxChannelsx() functions"));
|
|
1229 |
}
|
|
1230 |
else
|
|
1231 |
{
|
|
1232 |
INFO_PRINTF1(_L("this is a test of CMdaAudioConvertUtility::xxxChannelsx() functions"));
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
if(!(GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName) && // wav
|
|
1236 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord4"), iFileName2) && // wav
|
|
1237 |
GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToConvert"), iFileName3) // au
|
|
1238 |
))
|
|
1239 |
{
|
|
1240 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
1241 |
return EInconclusive;
|
|
1242 |
}
|
|
1243 |
|
|
1244 |
if (!iIsConverterTest)
|
|
1245 |
{
|
|
1246 |
// create the Recorder utility
|
|
1247 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
1248 |
return EInconclusive;
|
|
1249 |
|
|
1250 |
TInt err;
|
|
1251 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
1252 |
|
|
1253 |
if (iRecorder == NULL ||
|
|
1254 |
err != KErrNone ||
|
|
1255 |
iError != KErrNone ||
|
|
1256 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
1257 |
return EInconclusive;
|
|
1258 |
}
|
|
1259 |
else
|
|
1260 |
{
|
|
1261 |
// create the Converter utility
|
|
1262 |
if ( (iConvert = CMdaAudioConvertUtility::NewL(*this)) == NULL )
|
|
1263 |
return EInconclusive;
|
|
1264 |
|
|
1265 |
TInt err;
|
|
1266 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
1267 |
|
|
1268 |
if (iConvert == NULL ||
|
|
1269 |
err != KErrNone ||
|
|
1270 |
iError != KErrNone ||
|
|
1271 |
iConvert->State() != CMdaAudioConvertUtility::EOpen)
|
|
1272 |
return EInconclusive;
|
|
1273 |
}
|
|
1274 |
|
|
1275 |
return verdict;
|
|
1276 |
}
|
|
1277 |
|
|
1278 |
/**
|
|
1279 |
*
|
|
1280 |
* Test step Postamble.
|
|
1281 |
*
|
|
1282 |
* @xxxx
|
|
1283 |
*
|
|
1284 |
*/
|
|
1285 |
enum TVerdict CTestStepRecorderChannels::DoTestStepPostambleL(void)
|
|
1286 |
{
|
|
1287 |
iFs.Connect();
|
|
1288 |
iFileMan = CFileMan::NewL(iFs);
|
|
1289 |
iFileMan->Delete(iFileName2);
|
|
1290 |
iFileMan->Delete(iFileName3);
|
|
1291 |
iFs.Close();
|
|
1292 |
delete iFileMan;
|
|
1293 |
iFileMan = NULL;
|
|
1294 |
if (!iIsConverterTest)
|
|
1295 |
{
|
|
1296 |
delete iRecorder;
|
|
1297 |
iRecorder = NULL;
|
|
1298 |
}
|
|
1299 |
else
|
|
1300 |
{
|
|
1301 |
delete iConvert;
|
|
1302 |
iConvert = NULL;
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
//[ Destroy the scheduler ]
|
|
1306 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
1307 |
}
|
|
1308 |
|
|
1309 |
/**
|
|
1310 |
*
|
|
1311 |
* Callback Handle.
|
|
1312 |
*
|
|
1313 |
* @xxxx
|
|
1314 |
*
|
|
1315 |
*/
|
|
1316 |
void CTestStepRecorderChannels::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
1317 |
TInt /*aPreviousState*/,
|
|
1318 |
TInt /*aCurrentState*/,
|
|
1319 |
TInt aErrorcCode)
|
|
1320 |
{
|
|
1321 |
iError = aErrorcCode;
|
|
1322 |
CActiveScheduler::Stop();
|
|
1323 |
}
|
|
1324 |
|
|
1325 |
void CTestStepRecorderChannels::OpenAndStartSchedulerL()
|
|
1326 |
{
|
|
1327 |
if (!iIsConverterTest)
|
|
1328 |
iRecorder->OpenFileL( iFileName );
|
|
1329 |
else
|
|
1330 |
iConvert->OpenL( iFileName, iFileName3 );
|
|
1331 |
|
|
1332 |
CActiveScheduler::Start();
|
|
1333 |
}
|
|
1334 |
|
|
1335 |
/**
|
|
1336 |
*
|
|
1337 |
* Do the test step.
|
|
1338 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1339 |
*
|
|
1340 |
* @return "TVerdict"
|
|
1341 |
* The result of the test step
|
|
1342 |
*
|
|
1343 |
* @xxxx
|
|
1344 |
*
|
|
1345 |
*/
|
|
1346 |
TVerdict CTestStepRecorderChannels::DoTestStepL()
|
|
1347 |
{
|
|
1348 |
iTestStepResult = EPass;
|
|
1349 |
TInt err = KErrNone;
|
|
1350 |
TUint channels = 0;
|
|
1351 |
RArray<TUint> supChannels;
|
|
1352 |
|
|
1353 |
if (!iIsConverterTest)
|
|
1354 |
{
|
|
1355 |
// get the number of channels of the openned file of known channels number
|
|
1356 |
// (wav mono file 8KHz)
|
|
1357 |
// and check if channels correct
|
|
1358 |
TRAP(err, channels = iRecorder->DestinationNumberOfChannelsL());
|
|
1359 |
if (err != KErrNone ||
|
|
1360 |
channels != 1)
|
|
1361 |
return EFail;
|
|
1362 |
|
|
1363 |
// close this file
|
|
1364 |
iRecorder->Close();
|
|
1365 |
|
|
1366 |
//open a new non-existing file for recording
|
|
1367 |
TRAP(err, iRecorder->OpenFileL(iFileName2));
|
|
1368 |
if (err != KErrNone ||
|
|
1369 |
iError != KErrNone)
|
|
1370 |
return EInconclusive;
|
|
1371 |
|
|
1372 |
CActiveScheduler::Start();
|
|
1373 |
// get the supported num of channels
|
|
1374 |
TRAP(err, iRecorder->GetSupportedNumberOfChannelsL(supChannels));
|
|
1375 |
if (err != KErrNone ||
|
|
1376 |
supChannels.Count() <= 0 )
|
|
1377 |
return EFail;
|
|
1378 |
|
|
1379 |
// set the destination number of channels to a specific one of our choice
|
|
1380 |
TRAP(err, iRecorder->SetDestinationNumberOfChannelsL(2));
|
|
1381 |
if (err != KErrNone)
|
|
1382 |
return EFail;
|
|
1383 |
|
|
1384 |
//get the newly set number of channels
|
|
1385 |
//and check if it has been set correctly
|
|
1386 |
TRAP(err, channels = iRecorder->DestinationNumberOfChannelsL());
|
|
1387 |
if (err != KErrNone ||
|
|
1388 |
channels != 2)
|
|
1389 |
return EFail;
|
|
1390 |
}
|
|
1391 |
else // isConverterTest == ETrue
|
|
1392 |
{
|
|
1393 |
// get the number of channels of the source file of known channels number
|
|
1394 |
// (wav mono file 8KHz)
|
|
1395 |
// and check if channels correct
|
|
1396 |
TRAP(err, channels = iConvert->SourceNumberOfChannelsL());
|
|
1397 |
if (err != KErrNone ||
|
|
1398 |
channels != 1)
|
|
1399 |
return EFail;
|
|
1400 |
|
|
1401 |
// get the supported num of channels
|
|
1402 |
TRAP(err, iConvert->GetSupportedConversionNumberOfChannelsL(supChannels));
|
|
1403 |
if (err != KErrNone ||
|
|
1404 |
supChannels.Count() <= 0 )
|
|
1405 |
return EFail;
|
|
1406 |
|
|
1407 |
// set the destination number of channels to a specific one of our choice
|
|
1408 |
TRAP(err, iConvert->SetDestinationNumberOfChannelsL(2));
|
|
1409 |
if (err != KErrNone)
|
|
1410 |
return EFail;
|
|
1411 |
|
|
1412 |
//get the newly set number of channels
|
|
1413 |
//and check if it has been set correctly
|
|
1414 |
TRAP(err, channels = iConvert->DestinationNumberOfChannelsL());
|
|
1415 |
if (err != KErrNone ||
|
|
1416 |
channels != 2)
|
|
1417 |
return EFail;
|
|
1418 |
}
|
|
1419 |
|
|
1420 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1421 |
// test steps return a result
|
|
1422 |
return iTestStepResult;
|
|
1423 |
}
|
|
1424 |
|
|
1425 |
|