First public contribution.
1 // Copyright (c) 2004-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.
19 #include <mmf/plugin/mmfsbccodecimplementationuids.hrh>
21 #include "TSU_MMF_SbcCodec.h"
22 #include "TSU_MMF_SbcCodecSuite.h"
25 * Size of PCM16 wave file header is 44
27 const TInt KWavFileHeaderSize = 44;
29 * The default buffer size
31 const TUint KDefaultBufferSize = 4096;
34 * UID of sbc encoder ECom plugin
36 const TUid KSbcCodecPluginUid = { KMmfUidCodecPCM16ToSBC };
38 * UID of sbc encoder configuration
40 const TUid KSbcCodecConfigUid = { KMmfUidSBCConfigure };
44 _LIT(KSourceFileDir, "c:\\mm\\mmf\\testfiles\\sbc\\");
45 _LIT(KOutputFileDir, "c:\\mm\\mmf\\testfiles\\sbc\\");
46 _LIT(KReferenceFileDir, "c:\\mm\\mmf\\ref\\sbc\\");
52 * All source and comparison files need to be copied manually onto the flash card.
53 * This code assumes the flash card is represented by drive E: on the target board.
57 * we don't copy all the wave files onto C: as they are too big, leave them on E:
59 _LIT(KSourceFileDir, "e:\\");
61 * This folder keeps all the output files
63 _LIT(KOutputFileDir, "c:\\sbc\\");
65 * This folder keeps all the reference files for comparison
67 _LIT(KReferenceFileDir, "c:\\sbc\\ref\\");
71 // Test source files names
72 _LIT(KTestWavFile01, "sbc_test_01.wav");
73 _LIT(KTestWavFile02, "sbc_test_02.wav");
74 _LIT(KTestWavFile03, "sbc_test_03.wav");
75 _LIT(KTestWavFile04, "sbc_test_04.wav");
76 _LIT(KTestWavFile05, "sbc_test_05.wav");
77 _LIT(KTestWavFile06, "sbc_test_06.wav");
78 _LIT(KTestWavFile07, "sbc_test_07.wav");
79 _LIT(KTestWavFile08, "sbc_test_08.wav");
80 _LIT(KTestWavFile09, "sbc_test_09.wav");
81 _LIT(KTestWavFile10, "sbc_test_10.wav");
83 _LIT(KTestWavFile11, "sbc_test_11.wav");
84 _LIT(KTestWavFile12, "sbc_test_12.wav");
85 _LIT(KTestWavFile13, "sbc_test_13.wav");
86 _LIT(KTestWavFile14, "sbc_test_14.wav");
87 _LIT(KTestWavFile15, "sbc_test_15.wav");
88 _LIT(KTestWavFile16, "sbc_test_16.wav");
89 _LIT(KTestWavFile17, "sbc_test_17.wav");
90 _LIT(KTestWavFile18, "sbc_test_18.wav");
91 _LIT(KTestWavFile19, "sbc_test_19.wav");
92 _LIT(KTestWavFile20, "sbc_test_20.wav");
94 _LIT(KTestWavFile21, "sbc_test_21.wav");
95 _LIT(KTestWavFile22, "sbc_test_22.wav");
96 _LIT(KTestWavFile23, "sbc_test_23.wav");
97 _LIT(KTestWavFile24, "sbc_test_24.wav");
98 _LIT(KTestWavFile25, "sbc_test_25.wav");
99 _LIT(KTestWavFile26, "sbc_test_26.wav");
100 _LIT(KTestWavFile27, "sbc_test_27.wav");
101 _LIT(KTestWavFile28, "sbc_test_28.wav");
103 // Test reference file name
104 _LIT(KRefSbcFile01, "sbc_test_01.sbc");
105 _LIT(KRefSbcFile02, "sbc_test_02.sbc");
106 _LIT(KRefSbcFile03, "sbc_test_03.sbc");
107 _LIT(KRefSbcFile04, "sbc_test_04.sbc");
108 _LIT(KRefSbcFile05, "sbc_test_05.sbc");
109 _LIT(KRefSbcFile06, "sbc_test_06.sbc");
110 _LIT(KRefSbcFile07, "sbc_test_07.sbc");
111 _LIT(KRefSbcFile08, "sbc_test_08.sbc");
112 _LIT(KRefSbcFile09, "sbc_test_09.sbc");
113 _LIT(KRefSbcFile10, "sbc_test_10.sbc");
115 _LIT(KRefSbcFile11, "sbc_test_11.sbc");
116 _LIT(KRefSbcFile12, "sbc_test_12.sbc");
117 _LIT(KRefSbcFile13, "sbc_test_13.sbc");
118 _LIT(KRefSbcFile14, "sbc_test_14.sbc");
119 _LIT(KRefSbcFile15, "sbc_test_15.sbc");
120 _LIT(KRefSbcFile16, "sbc_test_16.sbc");
121 _LIT(KRefSbcFile17, "sbc_test_17.sbc");
122 _LIT(KRefSbcFile18, "sbc_test_18.sbc");
123 _LIT(KRefSbcFile19, "sbc_test_19.sbc");
124 _LIT(KRefSbcFile20, "sbc_test_20.sbc");
126 _LIT(KRefSbcFile21, "sbc_test_21.sbc");
127 _LIT(KRefSbcFile22, "sbc_test_22.sbc");
128 _LIT(KRefSbcFile23, "sbc_test_23.sbc");
129 _LIT(KRefSbcFile24, "sbc_test_24.sbc");
130 _LIT(KRefSbcFile25, "sbc_test_25.sbc");
131 _LIT(KRefSbcFile26, "sbc_test_26.sbc");
132 _LIT(KRefSbcFile27, "sbc_test_27.sbc");
133 _LIT(KRefSbcFile28, "sbc_test_28.sbc");
136 * List of channel mode settings
145 channel mode is Dual Channel
149 channel mode is Stereo
153 channel mode is Joint Stereo
159 * List of allocation method settings
164 allocation method is SNR
168 allocation method is Loudness
174 * Table of all 28 tests configurations, each row contains the following fields in order
175 * subbands, block length, sampling frequency, channel mode, allocation method, bitpool
177 const TInt gSbcConfig[28][6] =
179 // configuration tests (8)
180 { 4, 16, 48000, EMono, ESNR, 18 },
181 { 4, 16, 48000, EDual, ESNR, 16 },
182 { 8, 8, 44100, EMono, ELoud, 32 },
183 { 8, 8, 44100, EJoint, ELoud, 56 },
184 { 8, 4, 32000, EMono, ESNR, 24 },
185 { 8, 4, 32000, EStereo, ESNR, 48 },
186 { 4, 12, 16000, EMono, ELoud, 20 },
187 { 4, 12, 16000, EJoint, ELoud, 42 },
190 { 4, 16, 44100, EMono, ELoud, 15 },
191 { 8, 12, 48000, EJoint, ELoud, 51 },
193 // maximum bit rate tests (8)
194 { 8, 16, 16000, EMono, ELoud, 128 },
195 { 8, 16, 16000, EJoint, ESNR, 249 },
196 { 8, 16, 32000, EMono, ELoud, 76 },
197 { 8, 16, 32000, EJoint, ESNR, 121 },
198 { 8, 16, 44100, EMono, ELoud, 54 },
199 { 8, 16, 44100, EJoint, ESNR, 86 },
200 { 8, 16, 48000, EMono, ELoud, 49 },
201 { 8, 16, 48000, EJoint, ESNR, 78 },
204 { 8, 16, 48000, EMono, ESNR, 29 },
205 { 8, 16, 44100, EJoint, ESNR, 53 },
208 { 8, 16, 44100, EMono, ELoud, 19 },
209 { 8, 16, 48000, EMono, ELoud, 18 },
210 { 8, 16, 44100, EJoint, ELoud, 35 },
211 { 8, 16, 48000, EJoint, ELoud, 33 },
212 { 8, 16, 44100, EMono, ELoud, 31 },
213 { 8, 16, 48000, EMono, ELoud, 29 },
214 { 8, 16, 44100, EJoint, ELoud, 53 },
215 { 8, 16, 48000, EJoint, ELoud, 51 }
219 * This function converts number of subbands into TSBCFrameParameters::TSubbands value
220 * @param "TInt aSubbands"
222 * @return "TSBCFrameParameters::TSubbands"
223 * TSBCFrameParameters::TSubbands value
225 static inline TSBCFrameParameters::TSubbands GetSubbandsL(TInt aSubbands)
229 case 4: return TSBCFrameParameters::E4Subbands;
230 case 8: return TSBCFrameParameters::E8Subbands;
232 User::Leave(KErrArgument);
233 return TSBCFrameParameters::E4Subbands; // just make the compiler happy
237 * This function converts number of blocks into TSBCFrameParameters::TBlockLength value
238 * @param "TInt aBlocks"
240 * @return "TSBCFrameParameters::TBlockLength"
241 * TSBCFrameParameters::TBlockLength value
243 static inline TSBCFrameParameters::TBlockLength GetBlockLengthL(TInt aBlocks)
247 case 4: return TSBCFrameParameters::E4Blocks;
248 case 8: return TSBCFrameParameters::E8Blocks;
249 case 12: return TSBCFrameParameters::E12Blocks;
250 case 16: return TSBCFrameParameters::E16Blocks;
252 User::Leave(KErrArgument);
253 return TSBCFrameParameters::E4Blocks; //just make the compiler happy
257 * This function converts sampling frequency value into TSBCFrameParameters::TSamplingFrequency value
258 * @param "TInt aSampFreq"
259 * real sampling frequency value
260 * @return "TSBCFrameParameters::TSamplingFrequency"
261 * TSBCFrameParameters::TSamplingFrequency value
263 static inline TSBCFrameParameters::TSamplingFrequency GetSampFreqL(TInt aSampFreq)
267 case 16000: return TSBCFrameParameters::E16000Hz;
268 case 32000: return TSBCFrameParameters::E32000Hz;
269 case 44100: return TSBCFrameParameters::E44100Hz;
270 case 48000: return TSBCFrameParameters::E48000Hz;
272 User::Leave(KErrArgument);
273 return TSBCFrameParameters::E16000Hz; // just make the compiler happy
277 * This function converts ChannelMode enum value into TSBCFrameParameters::TChannelMode value
278 * @param "TInt aChnlMode"
279 * ChannelMode enum value
280 * @return "TSBCFrameParameters::TChannelMode"
281 * TSBCFrameParameters::TChannelMode value
283 static inline TSBCFrameParameters::TChannelMode GetChannelModeL(TInt aChnlMode)
287 case EMono: return TSBCFrameParameters::EMono;
288 case EDual: return TSBCFrameParameters::EDualChannel;
289 case EStereo: return TSBCFrameParameters::EStereo;
290 case EJoint: return TSBCFrameParameters::EJointStereo;
292 User::Leave(KErrArgument);
293 return TSBCFrameParameters::EMono; // just make the compiler happy
297 * This function converts AllocMethod enum value into TSBCFrameParameters::TAllocationMethod value
298 * @param "TInt aAllocMthd"
299 * AllocMethod enum value
300 * @return "TSBCFrameParameters::TAllocationMethod"
301 * TSBCFrameParameters::TAllocationMethod value
303 static inline TSBCFrameParameters::TAllocationMethod GetAllocMethodL(TInt aAllocMthd)
307 case ESNR: return TSBCFrameParameters::ESNR;
308 case ELoud: return TSBCFrameParameters::ELoudness;
310 User::Leave(KErrArgument);
311 return TSBCFrameParameters::ESNR;
315 * This function gets the configuration for one test from SbcConfig[28]
316 * @param "TInt aTestNumber"
318 * @return "TSBCFrameParameters"
319 * the sbc frame parameters used to configure sbc codec
321 static TSBCFrameParameters SbcParametersL(TInt aTestNumber)
323 if (aTestNumber < 0 || aTestNumber > 28)
325 User::Leave(KErrArgument);
328 TSBCFrameParameters param;
329 param.SetSubbands(GetSubbandsL(gSbcConfig[aTestNumber - 1][0]) );
330 param.SetBlockLength(GetBlockLengthL(gSbcConfig[aTestNumber - 1][1]) );
331 param.SetSamplingFrequency(GetSampFreqL(gSbcConfig[aTestNumber - 1][2]) );
332 param.SetChannelMode(GetChannelModeL(gSbcConfig[aTestNumber - 1][3]) );
333 param.SetAllocationMethod(GetAllocMethodL(gSbcConfig[aTestNumber - 1][4]) );
334 param.SetBitpool(static_cast<TUint8>(gSbcConfig[aTestNumber - 1][5]) );
341 CTestStep_MMF_SbcCodec::CTestStep_MMF_SbcCodec()
348 CTestStep_MMF_SbcCodec::~CTestStep_MMF_SbcCodec()
353 * This function gets test source file name for one test
354 * @param "TInt aTestNumber"
356 * @return "const TDesC&"
359 const TDesC& CTestStep_MMF_SbcCodec::GetTestFileName(TInt aTestNumber)
363 case 1 : return KTestWavFile01;
364 case 2 : return KTestWavFile02;
365 case 3 : return KTestWavFile03;
366 case 4 : return KTestWavFile04;
367 case 5 : return KTestWavFile05;
368 case 6 : return KTestWavFile06;
369 case 7 : return KTestWavFile07;
370 case 8 : return KTestWavFile08;
371 case 9 : return KTestWavFile09;
372 case 10: return KTestWavFile10;
374 case 11: return KTestWavFile11;
375 case 12: return KTestWavFile12;
376 case 13: return KTestWavFile13;
377 case 14: return KTestWavFile14;
378 case 15: return KTestWavFile15;
379 case 16: return KTestWavFile16;
380 case 17: return KTestWavFile17;
381 case 18: return KTestWavFile18;
382 case 19: return KTestWavFile19;
383 case 20: return KTestWavFile20;
385 case 21: return KTestWavFile21;
386 case 22: return KTestWavFile22;
387 case 23: return KTestWavFile23;
388 case 24: return KTestWavFile24;
389 case 25: return KTestWavFile25;
390 case 26: return KTestWavFile26;
391 case 27: return KTestWavFile27;
392 case 28: return KTestWavFile28;
394 User::Panic(_L("Invalid test number"), KErrArgument);
395 return KTestWavFile01;
399 * This function gets test reference file name for one test
400 * @param "TInt aTestNumber"
402 * @return "const TDesC&"
403 * reference file name
405 const TDesC& CTestStep_MMF_SbcCodec::GetRefFileName(TInt aTestNumber)
409 case 1 : return KRefSbcFile01;
410 case 2 : return KRefSbcFile02;
411 case 3 : return KRefSbcFile03;
412 case 4 : return KRefSbcFile04;
413 case 5 : return KRefSbcFile05;
414 case 6 : return KRefSbcFile06;
415 case 7 : return KRefSbcFile07;
416 case 8 : return KRefSbcFile08;
417 case 9 : return KRefSbcFile09;
418 case 10: return KRefSbcFile10;
420 case 11: return KRefSbcFile11;
421 case 12: return KRefSbcFile12;
422 case 13: return KRefSbcFile13;
423 case 14: return KRefSbcFile14;
424 case 15: return KRefSbcFile15;
425 case 16: return KRefSbcFile16;
426 case 17: return KRefSbcFile17;
427 case 18: return KRefSbcFile18;
428 case 19: return KRefSbcFile19;
429 case 20: return KRefSbcFile20;
431 case 21: return KRefSbcFile21;
432 case 22: return KRefSbcFile22;
433 case 23: return KRefSbcFile23;
434 case 24: return KRefSbcFile24;
435 case 25: return KRefSbcFile25;
436 case 26: return KRefSbcFile26;
437 case 27: return KRefSbcFile27;
438 case 28: return KRefSbcFile28;
440 User::Panic(_L("Invalid test number"), KErrArgument);
441 return KRefSbcFile01;
445 * This function reads source out from source file from a specific position
446 and fill the srouce into the source buffer.
447 * @param "const TDesC& aFileName"
448 * the source file name
449 * @param "TDes8& aSrcBuffer"
451 * @param "TInt aFilePos"
453 * @leave if reading file failed
455 void CTestStep_MMF_SbcCodec::ReadSourceL(const TDesC& aFileName, TDes8& aSrcBuffer, TInt aFilePos)
457 TFileName srcFileName(KSourceFileDir);
458 srcFileName.Append(aFileName);
460 // connect to file service
462 User::LeaveIfError(fs.Connect());
463 CleanupClosePushL(fs);
466 User::LeaveIfError(srcFile.Open(fs, srcFileName, EFileRead | EFileShareAny) );
467 CleanupClosePushL(srcFile);
469 aFilePos += KWavFileHeaderSize; // skip wave file header
470 User::LeaveIfError(srcFile.Seek(ESeekStart, aFilePos) );
471 User::LeaveIfError(srcFile.Read(aSrcBuffer) );
473 CleanupStack::PopAndDestroy(2);
477 * This function writes destination into destination file from a specific position.
478 * @param "const TDesC& aFileName"
479 * the destination file name
480 * @param "TDes8& aDstBuffer"
481 * the destination buffer
482 * @param "TInt aFilePos"
484 * @leave if writing file failed
486 void CTestStep_MMF_SbcCodec::WriteDstToFileL(const TDesC& aFileName, const TDes8& aDstBuffer, TInt aFilePos)
488 TFileName dstFileName(KOutputFileDir);
489 dstFileName.Append(aFileName);
491 // connect to file service
493 User::LeaveIfError(fs.Connect());
494 CleanupClosePushL(fs);
497 TInt err = dstFile.Open(fs, dstFileName, EFileWrite);
498 if (err == KErrNotFound) // file does not exist - create it
500 err = dstFile.Create(fs, dstFileName, EFileWrite);
506 CleanupClosePushL(dstFile);
508 User::LeaveIfError(dstFile.Seek(ESeekStart, aFilePos) );
509 User::LeaveIfError(dstFile.Write(aDstBuffer) );
511 CleanupStack::PopAndDestroy(2);
515 * This function compares two files to check if they are the same.
516 * @param "const TDesC& aFileName"
517 * the compare and reference files name
519 * 0: two files are the same
520 * -1: two files are NOT the same
521 * @leave if reading tow files failed
523 TInt CTestStep_MMF_SbcCodec::CompareFileL(const TDesC& aFileName)
525 TFileName cmpFileName(KOutputFileDir);
526 cmpFileName.Append(aFileName);
528 TFileName refFileName(KReferenceFileDir);
529 refFileName.Append(aFileName);
531 // connect to file service
533 User::LeaveIfError(fs.Connect());
534 CleanupClosePushL(fs);
537 User::LeaveIfError(cmpFile.Open(fs, cmpFileName, EFileRead) );
538 CleanupClosePushL(cmpFile);
541 User::LeaveIfError(refFile.Open(fs, refFileName, EFileRead) );
542 CleanupClosePushL(refFile);
544 TInt cmpFileSize = 0;
545 TInt refFileSize = 0;
547 cmpFile.Size(cmpFileSize);
548 refFile.Size(refFileSize);
550 if (cmpFileSize != refFileSize)
552 CleanupStack::PopAndDestroy(3); // refFile, cmpFile, fs
556 CMMFDataBuffer* cmpFileBuf = CMMFDataBuffer::NewL(KDefaultBufferSize);
557 CleanupStack::PushL(cmpFileBuf);
558 CMMFDataBuffer* refFileBuf = CMMFDataBuffer::NewL(KDefaultBufferSize);
559 CleanupStack::PushL(refFileBuf);
564 User::LeaveIfError(cmpFile.Read(cmpFileBuf->Data() ) );
565 if (cmpFileBuf->Data().Length() == 0) // end of file
570 User::LeaveIfError(refFile.Read(refFileBuf->Data() ) );
571 if (cmpFileBuf->Data() != refFileBuf->Data() )
577 cmpFileBuf->Data().Zero();
578 refFileBuf->Data().Zero();
581 CleanupStack::PopAndDestroy(5); // refFileBuff, cmpFileBuff, refFile, cmpFile, fs
586 * This function is called by two TestNewL() tests, it calls ProcessL() once
587 * and checks the result.
588 * @param "CMMFCodec* aCodec"
591 * EPass: at least one byte src processed and one byte of dst generated and no error
593 * @leave if out of memory or ProcessL() leaves
595 TVerdict CTestStep_MMF_SbcCodec::ProcessOnceForNewL(CMMFCodec* aCodec)
597 TVerdict testResult = EFail;
600 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(KDefaultBufferSize);
601 CleanupStack::PushL(srcBuffer);
602 CMMFDataBuffer* dstBuffer = CMMFDataBuffer::NewL(KDefaultBufferSize);
603 CleanupStack::PushL(dstBuffer);
605 TInt testNumber = 28;
606 TPckgBuf<TSBCFrameParameters> config(SbcParametersL(testNumber) );
607 aCodec->ConfigureL(KSbcCodecConfigUid, config);
609 ReadSourceL(GetTestFileName(testNumber), srcBuffer->Data(), 0);
611 if (srcBuffer->Data().Length() > 0) // end of file
613 TCodecProcessResult result = aCodec->ProcessL(*srcBuffer, *dstBuffer);
615 if (result.iDstBytesAdded > 0 && result.iSrcBytesProcessed > 0)
622 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::ProcessOnceForNewL no source read") );
625 CleanupStack::PopAndDestroy(2); // dstBuffer, srcBuffer
631 * This function tests codec instantiation by ECom plugin UID.
632 * @param "TUid aCodecUID"
635 * EPass: ProcessOnceForNewL() passes
636 * EFail: ProcessOnceForNewL() fails
637 * @leave if CMMFCodec::NewL() leaves
639 TVerdict CTestStep_MMF_SbcCodec::TestNewL(TUid aCodecUID)
641 //create codec from uid
642 CMMFCodec* codec = NULL;
643 TRAPD(err, codec = CMMFCodec::NewL(aCodecUID) );
647 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestNewL Leave occurred in NewL, error code %d"), err);
652 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestNewL NewL returned NULL") );
656 CleanupStack::PushL(codec);
657 TVerdict result = ProcessOnceForNewL(codec);
658 CleanupStack::PopAndDestroy(); //codec
663 * This function tests codec instantiation by two FourCC codes.
664 * @param "const TFourCC& aSrcFourCC"
665 * the FourCC code of source media type
666 * @param "const TFourCC& aDstFourCC"
667 * the FourCC code of destination media type
669 * EPass: ProcessOnceForNewL() passes
670 * EFail: ProcessOnceForNewL() fails
671 * @leave if CMMFCodec::NewL() or ProcessOnceForNewL() leaves
673 TVerdict CTestStep_MMF_SbcCodec::TestNewL(const TFourCC& aSrcFourCC, const TFourCC& aDstFourCC)
675 //create codec from uid
676 CMMFCodec* codec = NULL;
677 TRAPD(err, codec = CMMFCodec::NewL(aSrcFourCC, aDstFourCC) );
681 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestNewL Leave occurred in NewL, error code %d"), err);
686 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestNewL NewL returned NULL") );
690 CleanupStack::PushL(codec);
691 TVerdict result = ProcessOnceForNewL(codec);
692 CleanupStack::PopAndDestroy(); //codec
698 * This function tests ProcessL() function, it checks if ProcessL() returns the
699 * correct result with different buffer size settings
701 * EPass: the results are expected ones.
703 * @leave if out of memory or ProcessL(), ReadSourceL() leaves
705 TVerdict CTestStep_MMF_SbcCodec::TestProcessL()
707 //create codec from uid
708 CMMFCodec* codec = NULL;
709 TRAPD(err, codec = CMMFCodec::NewL(KSbcCodecPluginUid) );
713 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestProcessL Leave occurred in NewL, error code %d"), err);
718 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL NewL returned NULL") );
722 CleanupStack::PushL(codec);
724 const TInt testNumber = 28;
726 TSBCFrameParameters param = SbcParametersL(testNumber);
728 const TUint sbcFrameLength = param.CalcFrameLength();
729 const TUint pcmFrameSize = sizeof(TInt16) * param.BlockLength() * param.Channels() * param.Subbands();
732 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(pcmFrameSize);
733 CleanupStack::PushL(srcBuffer);
735 // dummy buffer, smaller than one frame length
736 CMMFDataBuffer* dummyBuffer = CMMFDataBuffer::NewL(sbcFrameLength - 1);
737 CleanupStack::PushL(dummyBuffer);
740 CMMFDataBuffer* dstBuffer = CMMFDataBuffer::NewL(sbcFrameLength);
741 CleanupStack::PushL(dstBuffer);
743 ReadSourceL(GetTestFileName(testNumber), srcBuffer->Data(), 0);
745 if (static_cast<TUint>(srcBuffer->Data().Length() ) != pcmFrameSize)
747 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL read source failed") );
748 CleanupStack::PopAndDestroy(3); // dstBuffer, srcBuffer, codec
752 TVerdict testResult = EPass;
753 TCodecProcessResult procResult;
755 /** test ProcessL() without ConfigureL() called, should leave with KErrAbort */
757 TRAP(err, procResult = codec->ProcessL(*srcBuffer, *dstBuffer) );
759 if (err != KErrAbort ||
760 procResult.iSrcBytesProcessed != 0 ||
761 procResult.iDstBytesAdded != 0 ||
762 procResult.iStatus != TCodecProcessResult::EProcessError)
764 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL failed, ProcessL didn't leave with KErrAbort when ConfigureL() is not called") );
768 /** test ProcessL() with small dst buffer size, should leave with KErrArgument */
770 TPckgBuf<TSBCFrameParameters> config(param);
771 codec->ConfigureL(KSbcCodecConfigUid, config);
774 TRAP(err, procResult = codec->ProcessL(*srcBuffer, *dummyBuffer) );
776 if (err != KErrArgument ||
777 procResult.iSrcBytesProcessed != 0 ||
778 procResult.iDstBytesAdded != 0 ||
779 procResult.iStatus != TCodecProcessResult::EProcessError)
781 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL failed in ProcessL") );
785 /** test ProcessL() with correct settings, should return EProcessComplete */
788 TRAP(err, procResult = codec->ProcessL(*srcBuffer, *dstBuffer) );
790 if (err != KErrNone ||
791 procResult.iSrcBytesProcessed != pcmFrameSize ||
792 procResult.iDstBytesAdded != sbcFrameLength ||
793 procResult.iStatus != TCodecProcessResult::EProcessComplete)
795 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL failed, ProcessL didn't work propertly with correct settings") );
799 /** test ProcessL() with not enough dst buffer remained, should return EProcessIncomplete */
801 // now the remaining dst buffer size is one byte less than one frame length
802 dstBuffer->SetPosition(1);
805 TRAP(err, procResult = codec->ProcessL(*srcBuffer, *dstBuffer) );
807 if (err != KErrNone ||
808 procResult.iSrcBytesProcessed != 0 ||
809 procResult.iDstBytesAdded != 0 ||
810 procResult.iStatus != TCodecProcessResult::EProcessIncomplete)
812 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL failed, ProcessL didn't return EProcessIncomplete when there is not enough dst buffer") );
816 /** test ProcessL() with not enough src buffer remained, should return EDstNotFilled */
818 // set this position to an even value as only even number of samples will be cached
819 const TInt srcPos = 2;
820 // the remaining src buffer size is less than one frame, it should be cached,
821 // and return EProcessDstNotFilled
822 srcBuffer->SetPosition(srcPos);
823 // now the remaining dst buffer size is one frame length
824 dstBuffer->SetPosition(0);
827 TRAP(err, procResult = codec->ProcessL(*srcBuffer, *dstBuffer) );
829 if (err != KErrNone ||
830 procResult.iSrcBytesProcessed != pcmFrameSize - srcPos ||
831 procResult.iDstBytesAdded != 0 ||
832 procResult.iStatus != TCodecProcessResult::EDstNotFilled)
834 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessL failed, ProcessL didn't return EDstNotFilled when there is not enough src buffer") );
838 CleanupStack::PopAndDestroy(4); // dstBuffer, dummyBuffer, srcBuffer, codec
843 * This function tests the whole encoding routine with a specific settings (e.g.
844 * sbc frameparameters, src buffer size, dst buffer size) and compares the result
845 * file with reference file.
846 * @param "TInt aTestNumber"
848 * @param "TInt aSrcBufSize"
849 * the source buffer size.
850 * @param "TInt aDstBufSize"
851 * the destination buffer size.
853 * EPass: encoded file is the same as the reference file.
854 * EFail: encoded file is NOT the same as the reference file.
855 * @leave if out of memory or ProcessL(), ReadSourceL(), WriteDstToFileL() leaves
857 TVerdict CTestStep_MMF_SbcCodec::TestEncodeL(TInt aTestNumber, TInt aSrcBufSize, TInt aDstBufSize)
859 //create codec from uid
860 CMMFCodec* codec = NULL;
861 TRAPD(err, codec = CMMFCodec::NewL(KSbcCodecPluginUid) );
865 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestEncodeL Leave occurred in NewL, error code %d"), err);
870 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestEncodeL NewL returned NULL") );
874 CleanupStack::PushL(codec);
877 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(aSrcBufSize);
878 CleanupStack::PushL(srcBuffer);
879 CMMFDataBuffer* dstBuffer = CMMFDataBuffer::NewL(aDstBufSize);
880 CleanupStack::PushL(dstBuffer);
882 TPckgBuf<TSBCFrameParameters> config(SbcParametersL(aTestNumber) );
883 codec->ConfigureL(KSbcCodecConfigUid, config);
890 ReadSourceL(GetTestFileName(aTestNumber), srcBuffer->Data(), srcFilePos);
892 if (srcBuffer->Data().Length() == 0) // end of file
897 TCodecProcessResult result = codec->ProcessL(*srcBuffer, *dstBuffer);
899 WriteDstToFileL(GetRefFileName(aTestNumber), dstBuffer->Data(), dstFilePos);
901 srcBuffer->Data().Zero();
902 dstBuffer->Data().Zero();
904 srcFilePos += result.iSrcBytesProcessed;
905 dstFilePos += result.iDstBytesAdded;
908 TVerdict result = EPass;
909 if (CompareFileL(GetRefFileName(aTestNumber) ) != 0)
914 CleanupStack::PopAndDestroy(3); // dstBuffer, srcBuffer, codec
919 * This function tests codec ResetL() function make sure the cach buffer
920 * gets cleared when it gets called. It compares the encoded file with the reference file
922 * EPass: encoded file is the same as the reference file.
923 * EFail: encoded file is NOT the same as the reference file.
924 * @leave if out of memory or ProcessL(), ReadSourceL(), WriteDstToFileL() leaves
926 TVerdict CTestStep_MMF_SbcCodec::TestRepositionL()
928 //create codec from uid
929 CMMFCodec* codec = NULL;
930 TRAPD(err, codec = CMMFCodec::NewL(KSbcCodecPluginUid) );
934 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestRepositionL Leave occurred in NewL, error code %d"), err);
939 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestRepositionL NewL returned NULL") );
943 CleanupStack::PushL(codec);
945 const TInt testNumber = 28;
946 // this size will make sure some samples will be cached,
947 // also make sure it is an EVEN number
948 const TInt srcBufSize = 4094;
949 const TInt dstBufSize = 2048;
952 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(srcBufSize);
953 CleanupStack::PushL(srcBuffer);
954 CMMFDataBuffer* dstBuffer = CMMFDataBuffer::NewL(dstBufSize);
955 CleanupStack::PushL(dstBuffer);
957 TSBCFrameParameters param = SbcParametersL(testNumber);
959 TPckgBuf<TSBCFrameParameters> config(param);
960 codec->ConfigureL(KSbcCodecConfigUid, config);
962 const TUint pcmFrameSize = sizeof(TInt16) * param.BlockLength() * param.Channels() * param.Subbands();
969 ReadSourceL(GetTestFileName(testNumber), srcBuffer->Data(), srcFilePos);
971 if (srcBuffer->Data().Length() == 0) // end of file
976 TCodecProcessResult result = codec->ProcessL(*srcBuffer, *dstBuffer);
978 WriteDstToFileL(GetRefFileName(testNumber), dstBuffer->Data(), dstFilePos);
980 // clear up any cached samples
982 // the iSrcBytesProcessed includes the encoded src size plus the cached src size,
983 // here set the iSrcBytesProcessed to the encoded src size only as we cleared up
984 // the cached samples
985 result.iSrcBytesProcessed -= srcBuffer->Data().Length() % pcmFrameSize;
987 srcBuffer->Data().Zero();
988 dstBuffer->Data().Zero();
990 // set new src file position, which is the end of encoded src (no cached src)
991 srcFilePos += result.iSrcBytesProcessed;
992 // set new dst file position
993 dstFilePos += result.iDstBytesAdded;
996 TVerdict result = EPass;
997 if (CompareFileL(GetRefFileName(testNumber) ) != 0)
1002 CleanupStack::PopAndDestroy(3); // dstBuffer, srcBuffer, codec
1007 * This test tests changing configuration for the codec. It calls ConfigureL() once to
1008 * encode one sbc bitstream, then changes a different configuration by calling ConfigureL()
1009 * and encode another sbc bitstream.
1010 * @return "TVerdict"
1011 * EPass: if encoded sbc files are the same as the reference files.
1013 * @leave if ReadSourceL(), ProcessL() leaves
1015 TVerdict CTestStep_MMF_SbcCodec::TestChangeConfigL()
1017 //create codec from uid
1018 CMMFCodec* codec = NULL;
1019 TRAPD(err, codec = CMMFCodec::NewL(KSbcCodecPluginUid) );
1021 if (err != KErrNone)
1023 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestChangeConfigL Leave occurred in NewL, error code %d"), err);
1028 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestChangeConfigL NewL returned NULL") );
1032 CleanupStack::PushL(codec);
1034 const TInt testNumber[2] = {1, 28};
1035 // this size will make sure some samples will be cached,
1036 // also make sure it is an EVEN number
1037 const TInt srcBufSize = 4094;
1038 const TInt dstBufSize = 2048;
1041 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(srcBufSize);
1042 CleanupStack::PushL(srcBuffer);
1043 CMMFDataBuffer* dstBuffer = CMMFDataBuffer::NewL(dstBufSize);
1044 CleanupStack::PushL(dstBuffer);
1046 TVerdict result = EPass;
1047 for (TInt test = 0; test < 2; test++)
1049 TSBCFrameParameters param = SbcParametersL(testNumber[test]);
1051 TPckgBuf<TSBCFrameParameters> config(param);
1052 codec->ConfigureL(KSbcCodecConfigUid, config);
1055 TInt srcFilePos = 0;
1056 TInt dstFilePos = 0;
1060 ReadSourceL(GetTestFileName(testNumber[test]), srcBuffer->Data(), srcFilePos);
1062 if (srcBuffer->Data().Length() == 0) // end of file
1067 TCodecProcessResult result = codec->ProcessL(*srcBuffer, *dstBuffer);
1069 WriteDstToFileL(GetRefFileName(testNumber[test]), dstBuffer->Data(), dstFilePos);
1071 srcBuffer->Data().Zero();
1072 dstBuffer->Data().Zero();
1074 srcFilePos += result.iSrcBytesProcessed;
1075 dstFilePos += result.iDstBytesAdded;
1078 if (CompareFileL(GetRefFileName(testNumber[test]) ) != 0)
1084 CleanupStack::PopAndDestroy(3); // dstBuffer, srcBuffer, codec
1089 * This tests memory scribble for ProcessL(). It creates a buffer size of frame_length + 2,
1090 * the first byte and last byte are used to detect memory scribble,
1091 * the middle frame_length bytes are used for destination buffer. It calls ProcessL() once.
1092 * and checks if the first or last byte value changed to check memory scribble.
1093 * @return "TVerdict"
1094 * EPass: if there is no momery scribble.
1095 * EFail: if there is momery scribble.
1096 * @leave if ReadSourceL(), ProcessL() leaves
1098 TVerdict CTestStep_MMF_SbcCodec::TestMemoryScribbleL()
1100 //create codec from uid
1101 CMMFCodec* codec = NULL;
1102 TRAPD(err, codec = CMMFCodec::NewL(KSbcCodecPluginUid) );
1104 if (err != KErrNone)
1106 ERR_PRINTF2(_L(">> CTestStep_MMF_SbcCodec::TestMemoryScribbleL Leave occurred in NewL, error code %d"), err);
1111 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestMemoryScribbleL NewL returned NULL") );
1115 CleanupStack::PushL(codec);
1117 const TInt testNumber = 28;
1119 TSBCFrameParameters param = SbcParametersL(testNumber);
1121 TPckgBuf<TSBCFrameParameters> config(param);
1122 codec->ConfigureL(KSbcCodecConfigUid, config);
1124 const TUint sbcFrameLength = param.CalcFrameLength();
1125 const TUint pcmFrameSize = sizeof(TInt16) * param.BlockLength() * param.Channels() * param.Subbands();
1128 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(pcmFrameSize);
1129 CleanupStack::PushL(srcBuffer);
1131 // front and end bytes are used to detect memory scribble
1132 CMMFDataBuffer* buffer = CMMFDataBuffer::NewL(sbcFrameLength + 2);
1133 CleanupStack::PushL(buffer);
1135 TUint8* firstByte = const_cast<TUint8*>(buffer->Data().Ptr() );
1136 TUint8* lastByte = firstByte + sbcFrameLength + 1;
1138 const TUint8 initValue = 0xaa; // 10101010
1140 *firstByte = initValue;
1141 *lastByte = initValue;
1143 CMMFPtrBuffer* dstBuffer = CMMFPtrBuffer::NewL(TPtr8(firstByte + 1, sbcFrameLength) );
1144 CleanupStack::PushL(dstBuffer);
1146 ReadSourceL(GetTestFileName(testNumber), srcBuffer->Data(), 0);
1148 TVerdict testResult = EPass;
1149 if (static_cast<TUint>(srcBuffer->Data().Length() ) == pcmFrameSize)
1151 TCodecProcessResult result = codec->ProcessL(*srcBuffer, *dstBuffer);
1153 if (result.iSrcBytesProcessed != pcmFrameSize ||
1154 result.iDstBytesAdded != sbcFrameLength ||
1155 result.iStatus != TCodecProcessResult::EProcessComplete)
1157 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestMemoryScribbleL failed in ProcessL") );
1161 if (*firstByte != initValue || *lastByte != initValue ) // memory been scribbled
1163 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestMemoryScribbleL memory scribble occured") );
1169 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestMemoryScribbleL read source failed") );
1173 CleanupStack::PopAndDestroy(4); // dstBuffer, buffer, srcBuffer, codec
1178 * This tests all the codec APIs (here we are using TestRepositionL() test as it
1179 * uses all the APIs) and checks if there is any memory leak, it panics if so.
1180 * @return "TVerdict"
1181 * EPass: if there is no momery leak.
1182 * EFail: if there is momery leak.
1183 * @leave if TestRepositionL() leaves
1185 TVerdict CTestStep_MMF_SbcCodec::TestMemoryLeakL()
1197 * This function tests how NewL deals with a memory allocation failure. This test
1198 * will pass if NewL leaves with the correct error code on every memory allocation.
1200 * @return "TVerdict"
1201 * EPass: if the test passes.
1202 * EFail: if the test fails.
1204 TVerdict CTestStep_MMF_SbcCodec::TestNewLOutOfMemoryL()
1206 TVerdict testResult = EPass;
1212 __UHEAP_FAILNEXT(failCount);
1214 CMMFCodec* codec = NULL;
1215 TRAPD(err, codec = CMMFCodec::NewL(KSbcCodecPluginUid) );
1217 // it should return either KErrNone or KErrNoMemory,
1218 // ideally should only return KErrNone when codec is created.
1219 if (err == KErrNone)
1221 TAny *testAlloc = User::Alloc(1);
1224 if (testAlloc == NULL)
1228 User::Free(testAlloc);
1230 else if (err != KErrNoMemory)
1243 INFO_PRINTF2(_L("NewL out of memory test finished at round %d"), failCount);
1249 * This function tests how the ProcessL() would deal with a memory allocation failure.
1250 * @return "TVerdict"
1251 * EPass: if the test passes.
1252 * EFail: if the test fails.
1253 * @leave if out of memory or ConfigureL(), ReadSourceL leaves
1255 TVerdict CTestStep_MMF_SbcCodec::TestProcessLOutOfMemoryL()
1259 CMMFCodec* codec = CMMFCodec::NewL(KSbcCodecPluginUid);
1262 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessLOutOfMemoryL returned NULL") );
1266 CleanupStack::PushL(codec);
1268 const TInt testNumber = 28;
1269 // this size will make sure some samples will be cached,
1270 // also make sure it is an EVEN number
1271 const TInt srcBufSize = 4094;
1272 const TInt dstBufSize = 2048;
1274 TPckgBuf<TSBCFrameParameters> config(SbcParametersL(testNumber) );
1275 codec->ConfigureL(KSbcCodecConfigUid, config);
1278 CMMFDataBuffer* srcBuffer = CMMFDataBuffer::NewL(srcBufSize);
1279 CleanupStack::PushL(srcBuffer);
1280 CMMFDataBuffer* dstBuffer = CMMFDataBuffer::NewL(dstBufSize);
1281 CleanupStack::PushL(dstBuffer);
1283 ReadSourceL(GetTestFileName(testNumber), srcBuffer->Data(), 0);
1284 if (srcBuffer->Data().Length() == 0) // end of file
1286 ERR_PRINTF1(_L(">> CTestStep_MMF_SbcCodec::TestProcessLOutOfMemoryL no source read") );
1290 TVerdict testResult = EPass;
1295 __UHEAP_FAILNEXT(failCount);
1297 TCodecProcessResult dummyResult; // don't care about this result
1298 TRAPD(err, dummyResult = codec->ProcessL(*srcBuffer, *dstBuffer) );
1300 // it should return either KErrNone or KErrNoMemory,
1301 // ideally should only return KErrNone when codec is created.
1302 if (err == KErrNone)
1304 // attempt to allocate another cell. If this fails,
1305 // we have tested all of the memory allocs carried out by NewL.
1306 TAny *testAlloc = User::Alloc(1);
1308 if (testAlloc == NULL)
1312 User::Free(testAlloc);
1314 else if (err != KErrNoMemory)
1325 INFO_PRINTF2(_L("ProcessL out of memory test finished at round %d"), failCount);
1327 CleanupStack::PopAndDestroy(3); // dstBuffer, srcBuffer, codec
1334 //------------------------------------------------------------------
1335 // ** TEST MMF_SBCCODEC STEPS ***
1336 //------------------------------------------------------------------
1341 CTest_MMF_SbcCodec_U_001::CTest_MMF_SbcCodec_U_001()
1343 iTestStepName = _L("MM-MMF-SbcCodec-U-001-HP");
1347 * Instantiate a codec with plugin UID
1348 * @test Req. under test REQ2716
1350 TVerdict CTest_MMF_SbcCodec_U_001::DoTestStepL()
1352 TVerdict testResult = EFail;
1353 TRAPD(err, testResult = TestNewL(KSbcCodecPluginUid) );
1357 INFO_PRINTF2(_L("Test left with status %d"), err);
1365 CTest_MMF_SbcCodec_U_002::CTest_MMF_SbcCodec_U_002()
1367 iTestStepName = _L("MM-MMF-SbcCodec-U-002-HP");
1371 * Instantiate a codec with FourCC Codes
1372 * @test Req. under test REQ2716
1374 TVerdict CTest_MMF_SbcCodec_U_002::DoTestStepL()
1376 TVerdict testResult = EFail;
1377 TRAPD(err, testResult = TestNewL(KMMFFourCCCodePCM16, KMMFFourCCCodeSBC) );
1381 INFO_PRINTF2(_L("Test left with status %d"), err);
1389 CTest_MMF_SbcCodec_U_010::CTest_MMF_SbcCodec_U_010()
1391 iTestStepName = _L("MM-MMF-SbcCodec-U-010-HP");
1396 * This test tests the ProcessL() function with different buffer size settings, and
1397 * check the returned results
1398 * @test Req. under test REQ2716
1400 TVerdict CTest_MMF_SbcCodec_U_010::DoTestStepL()
1402 TVerdict testResult = EFail;
1403 TRAPD(err, testResult = TestProcessL() );
1407 INFO_PRINTF2(_L("Test left with status %d"), err);
1415 CTest_MMF_SbcCodec_U_011::CTest_MMF_SbcCodec_U_011()
1417 iTestStepName = _L("MM-MMF-SbcCodec-U-011-HP");
1421 * Configuration tests
1422 * This test tests if codec supports 8 different settings (see TSS & TP for A2DP spec)
1423 * @test Req. under test REQ2716
1425 TVerdict CTest_MMF_SbcCodec_U_011::DoTestStepL()
1427 TVerdict testResult = EPass;
1428 TInt srcBufSize = KDefaultBufferSize;
1429 TInt dstBufSize = KDefaultBufferSize >> 1;
1431 for (TInt testNumber = 1; testNumber <= 8; testNumber++)
1433 TVerdict result = EFail;
1435 TRAPD(err, result = TestEncodeL(testNumber, srcBufSize, dstBufSize) );
1439 INFO_PRINTF3(_L("Configuration test %d left with status %d"), testNumber, err);
1442 if (result == EFail)
1444 INFO_PRINTF2(_L("Configuration test %d failed"), testNumber);
1448 // This is simulating different src buffer size by decreasing the
1449 // src buffer size number each time, it covers sample caching and
1450 // no caching various cases to make sure the codec can handle different
1451 // src buffer size correctly
1460 CTest_MMF_SbcCodec_U_012::CTest_MMF_SbcCodec_U_012()
1462 iTestStepName = _L("MM-MMF-SbcCodec-U-012-HP");
1466 * Maximum Bit Rate tests
1467 * This test tests sbc coded handles 8 different maximum bit rate settings (see TSS & TP for A2DP spec)
1468 * @test Req. under test REQ2716
1470 TVerdict CTest_MMF_SbcCodec_U_012::DoTestStepL()
1472 TVerdict testResult = EPass;
1473 TInt srcBufSize = KDefaultBufferSize;
1474 TInt dstBufSize = KDefaultBufferSize >> 1;
1476 for (TInt testNumber = 11; testNumber <= 18; testNumber++)
1478 TVerdict result = EFail;
1479 TRAPD(err, result = TestEncodeL(testNumber, srcBufSize, dstBufSize) );
1483 INFO_PRINTF3(_L("Max Bit Rate test %d left with status %d"), testNumber, err);
1486 if (result == EFail)
1488 INFO_PRINTF2(_L("Max Bit Rate test %d failed"), testNumber);
1492 // This is simulating different src buffer size by decreasing the
1493 // src buffer size number each time, it covers sample caching and
1494 // no caching various cases to make sure the codec can handle different
1495 // src buffer size correctly
1504 CTest_MMF_SbcCodec_U_013::CTest_MMF_SbcCodec_U_013()
1506 iTestStepName = _L("MM-MMF-SbcCodec-U-013-HP");
1511 * This test tests sbc codec handles 2 special cases (see TSS & TP for A2DP spec)
1512 * @test Req. under test REQ2716
1514 TVerdict CTest_MMF_SbcCodec_U_013::DoTestStepL()
1516 TVerdict testResult = EPass;
1517 TInt srcBufSize = KDefaultBufferSize;
1518 TInt dstBufSize = KDefaultBufferSize >> 1;
1520 for (TInt testNumber = 19; testNumber <= 20; testNumber++)
1522 TVerdict result = EFail;
1523 TRAPD(err, result = TestEncodeL(testNumber, srcBufSize, dstBufSize) );
1527 INFO_PRINTF3(_L("Special test %d left with status %d"), testNumber, err);
1530 if (result == EFail)
1532 INFO_PRINTF2(_L("Special test %d failed"), testNumber);
1536 // This is simulating different src buffer size by decreasing the
1537 // src buffer size number each time, it covers sample caching and
1538 // no caching various cases to make sure the codec can handle different
1539 // src buffer size correctly
1548 CTest_MMF_SbcCodec_U_014::CTest_MMF_SbcCodec_U_014()
1550 iTestStepName = _L("MM-MMF-SbcCodec-U-014-HP");
1555 * This test tests sbc codec handles 8 typical settings (see TSS & TP for A2DP spec) which
1556 * are required in REQ2716, our sbc encoder has to support these settings.
1557 * @test Req. under test REQ2716
1559 TVerdict CTest_MMF_SbcCodec_U_014::DoTestStepL()
1561 TVerdict testResult = EPass;
1562 TInt srcBufSize = KDefaultBufferSize;
1563 TInt dstBufSize = KDefaultBufferSize >> 1;
1565 for (TInt testNumber = 21; testNumber <= 28; testNumber++)
1567 TVerdict result = EFail;
1568 TRAPD(err, result = TestEncodeL(testNumber, srcBufSize, dstBufSize) );
1572 INFO_PRINTF3(_L("Typical test %d left with status %d"), testNumber, err);
1575 if (result == EFail)
1577 INFO_PRINTF2(_L("Typical test %d failed"), testNumber);
1581 // This is simulating different src buffer size by decreasing the
1582 // src buffer size number each time, it covers sample caching and
1583 // no caching various cases to make sure the codec can handle different
1584 // src buffer size correctly
1593 CTest_MMF_SbcCodec_U_015::CTest_MMF_SbcCodec_U_015()
1595 iTestStepName = _L("MM-MMF-SbcCodec-U-015-HP");
1600 * This test tests ResetL() function and audio sample cach issue
1601 * @test Req. under test REQ2716
1603 TVerdict CTest_MMF_SbcCodec_U_015::DoTestStepL()
1605 TVerdict testResult = EFail;
1606 TRAPD(err, testResult = TestRepositionL() );
1610 INFO_PRINTF2(_L("Reposition test left with status %d"), err);
1615 INFO_PRINTF1(_L("Reposition test passes") );
1624 CTest_MMF_SbcCodec_U_016::CTest_MMF_SbcCodec_U_016()
1626 iTestStepName = _L("MM-MMF-SbcCodec-U-016-HP");
1630 * Change configuration test
1631 * This test tests reconfigure sbc codec by calling ConfigureL() function
1632 * @test Req. under test REQ2716
1634 TVerdict CTest_MMF_SbcCodec_U_016::DoTestStepL()
1636 TVerdict testResult = EFail;
1637 TRAPD(err, testResult = TestChangeConfigL() );
1641 INFO_PRINTF2(_L("Change conguration test left with status %d"), err);
1646 INFO_PRINTF1(_L("Change conguration test passes") );
1655 CTest_MMF_SbcCodec_U_021::CTest_MMF_SbcCodec_U_021()
1657 iTestStepName = _L("MM-MMF-SbcCodec-U-021-HP");
1661 * Memory Scribble test
1662 * @test Req. under test REQ2716
1664 TVerdict CTest_MMF_SbcCodec_U_021::DoTestStepL()
1666 TVerdict testResult = EPass;
1668 TRAPD(err, testResult = TestMemoryScribbleL() );
1672 INFO_PRINTF2(_L("Memory scribble test left with status %d"), err);
1677 INFO_PRINTF1(_L("Memory scribble test passes") );
1686 CTest_MMF_SbcCodec_U_022::CTest_MMF_SbcCodec_U_022()
1688 iTestStepName = _L("MM-MMF-SbcCodec-U-022-HP");
1693 * @test Req. under test REQ2716
1695 TVerdict CTest_MMF_SbcCodec_U_022::DoTestStepL()
1697 TVerdict testResult = EPass;
1699 TRAPD(err, testResult = TestMemoryLeakL() );
1703 INFO_PRINTF2(_L("Memory leak test left with status %d"), err);
1708 INFO_PRINTF1(_L("Memory leak test passes") );
1717 CTest_MMF_SbcCodec_U_023::CTest_MMF_SbcCodec_U_023()
1719 iTestStepName = _L("MM-MMF-SbcCodec-U-023-HP");
1723 * Out of Memory test for NewL()
1724 * @test Req. under test REQ2716
1726 TVerdict CTest_MMF_SbcCodec_U_023::DoTestStepL()
1728 TVerdict testResult = EPass;
1730 TRAPD(err, testResult = TestNewLOutOfMemoryL() );
1734 INFO_PRINTF2(_L("NewL out of memory test left with status %d"), err);
1739 INFO_PRINTF1(_L("NewL out of memory test passes") );
1748 CTest_MMF_SbcCodec_U_024::CTest_MMF_SbcCodec_U_024()
1750 iTestStepName = _L("MM-MMF-SbcCodec-U-024-HP");
1754 * Out of Memory test for ProcessL()
1755 * @test Req. under test REQ2716
1757 TVerdict CTest_MMF_SbcCodec_U_024::DoTestStepL()
1759 TVerdict testResult = EPass;
1761 TRAPD(err, testResult = TestProcessLOutOfMemoryL() );
1765 INFO_PRINTF2(_L("ProcessL out of memory test left with status %d"), err);
1770 INFO_PRINTF1(_L("ProcessL out of memory test passes") );