os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestConverter.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 program is designed the test of the MMF_ACLNT.
    15 // 
    16 //
    17 
    18 /**
    19  @file TestConverter.cpp
    20 */
    21 
    22 #include "TestConverter.h"
    23 #include "mmfwavformat.h"
    24 #include <mmfformatimplementationuids.hrh>
    25 #include <mdaaudiosampleplayer.h>	
    26 #include "WavDecodeUtility.h"		
    27 
    28 // from "mmfauformat.h" :
    29 const TUint KAuFileUncompressedDataHeaderSize = 24 ; // 6 times 4 byte quantities
    30 
    31 _LIT(KAclntConConfigKeyName, "configAudio");
    32 _LIT(KAclntConDurationKeyName, "configAudio2");
    33 _LIT(KAclntConPositionKeyName, "configAudio3");
    34 _LIT(KAclntConQueryKeyName, "configAudio4");
    35 _LIT(KAclntConDestBitRateKeyName, "configAudio5");
    36 _LIT(KAclntConDestSampleRateKeyName, "configAudio6");
    37 _LIT(KAclntConDestNumberChannelsKeyName, "configAudio7");
    38 _LIT(KAclntConDestDataTypeKeyName, "configAudio8");
    39 _LIT(KAclntConDestFormatKeyName, "configAudio9");
    40 _LIT(KAclntConSourceInfoKeyName, "configAudio10");
    41 
    42 
    43 /**
    44  * Constructor
    45  */
    46 CTestMmfAclntDoConv::CTestMmfAclntDoConv(const TDesC& aTestName, const TDesC& aSectName, 
    47 										 const TDesC& aKeyName, 
    48 										 const TDesC& aSectName2, const TDesC& aKeyName2,
    49 										 TInt	aBits,
    50 										 FormatSpec aFormat)
    51 	{
    52 	// store the name of this test case
    53 	// this is the name that is used by the script file
    54 	// Each test step initialises it's own name
    55 	iTestStepName = aTestName;
    56 	iSectName = aSectName;
    57 	iKeyName = aKeyName;
    58 	iSectName2 = aSectName2;
    59 	iKeyName2 = aKeyName2;
    60 	iBits = aBits;
    61 	iFormat = aFormat;
    62 	}
    63 
    64 CTestMmfAclntDoConv* CTestMmfAclntDoConv::NewL(const TDesC& aTestName, const TDesC& aSectName, 
    65 											   const TDesC& aKeyName, const TDesC& aSectName2, 
    66 											   const TDesC& aKeyName2,
    67 											   TInt	aBits,
    68 											   FormatSpec aFormat)
    69 	{
    70 	CTestMmfAclntDoConv* self = new (ELeave) CTestMmfAclntDoConv(aTestName, aSectName, aKeyName, aSectName2, aKeyName2, aBits, aFormat);
    71 	return self;
    72 	}
    73 
    74 void CTestMmfAclntDoConv::MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
    75 	{
    76 	iError = aErrorCode;
    77 	iObject = aObject;
    78 	iPreviousState = aPreviousState;
    79 	iCurrentState = aCurrentState;
    80 	INFO_PRINTF1( _L("CTestMmfAclntDoConv : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
    81 	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
    82 	CActiveScheduler::Stop();
    83 	}
    84 
    85 TVerdict CTestMmfAclntDoConv::DoTestStepL()
    86 	{
    87 	INFO_PRINTF1( _L("TestConverter : Do Convert"));
    88 
    89 	TVerdict ret = EFail;
    90 
    91 	TBuf<KSizeBuf>	filename1;
    92 	TPtrC filename11, filename2;
    93 	if ((!GetStringFromConfig(iSectName, iKeyName, filename11)) || 
    94 		(!GetStringFromConfig( iSectName2, iKeyName2, filename2)))
    95 		return EInconclusive;
    96 
    97 	GetDriveName(filename1);
    98 	filename1.Append(filename11);
    99 
   100 
   101 	//delete previos output file
   102 	RFs	theFs;
   103 	User::LeaveIfError(theFs.Connect());
   104 	theFs.Delete(filename2);	
   105 	theFs.MkDirAll(filename2);
   106 
   107 	theFs.Close();
   108 
   109 
   110 	TMdaUL16RawAudioCodec	theCodecUnsupported;
   111 
   112 	TMdaPcmWavCodec			theCodecWav8Bit(TMdaPcmWavCodec::E8BitPcm);
   113 	TMdaPcmWavCodec			theCodecWav16Bit(TMdaPcmWavCodec::E16BitPcm);
   114 	
   115 	TMdaPackage*			theCodec = NULL;
   116 	switch(iBits)
   117 		{
   118 		case 0:	theCodec = &theCodecWav8Bit; break;
   119 		case 1:	theCodec = &theCodecWav16Bit; break;
   120 		case -1:	theCodec = &theCodecUnsupported; break;
   121 		default: break;
   122 		}
   123 
   124 	if(theCodec == NULL)
   125 		return EInconclusive;
   126 
   127 	iError = KErrTimedOut;
   128 
   129 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
   130 	CleanupStack::PushL(converter);
   131 
   132 	TMdaFileClipLocation	theLocation(filename2);
   133 	TMdaWavClipFormat		theMdaFormat;
   134 	TMmfAclntWavEncodeClipFormat theMmfFormat;
   135 	TMdaClipFormat* useFormat;
   136 
   137 	if(iFormat == MdaFormatSpec)
   138 		useFormat = &theMdaFormat;
   139 	else
   140 		useFormat = &theMmfFormat;
   141 
   142 		converter->OpenL(filename1,
   143 						&theLocation,	// Normally file or descriptor
   144 						useFormat,
   145 						theCodec);
   146 	
   147 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   148 	CActiveScheduler::Start();
   149 
   150 	if(iError == KErrNone)
   151 		ret = DoTestL(converter);
   152 	else if(iError != KErrNone && iBits == -1)
   153 		ret = EPass;
   154 
   155 	if (iError != KErrNone)
   156 		ERR_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
   157 	CleanupStack::PopAndDestroy(converter);
   158 	User::After(KOneSecond);
   159 	return ret;	
   160 	}
   161 
   162 TVerdict CTestMmfAclntDoConv::DoTestL(CMdaAudioConvertUtility* aConverter)
   163 	{
   164 	TVerdict ret = EFail;
   165 
   166 	iError = KErrTimedOut;
   167 
   168 	// Convert 44100 -> 8000 sample rate
   169 	const TUint KAclntDestSampleRate = 8000;
   170 	aConverter->SetDestinationSampleRateL(KAclntDestSampleRate);
   171 
   172 	// Output as AU file
   173 	aConverter->SetDestinationFormatL(TUid::Uid(KMmfUidFormatAUWrite));
   174 
   175 	aConverter->ConvertL();
   176 
   177 	INFO_PRINTF1( _L("Convert CMdaAudioConvertUtility"));
   178 	CActiveScheduler::Start();
   179 
   180 	// XXX Improve test. e.g. check that a valid AU file is written
   181 	if(iError == KErrNone)
   182 		{
   183 		ret = EPass;
   184 		}
   185 	else
   186 		{
   187 		INFO_PRINTF2(_L("Error returned in MoscoStateChangeEvent callback: %d"), iError);
   188 		ret = EFail;
   189 		}
   190 
   191 	if (ret == EPass)
   192 		{
   193 		CActiveScheduler::Start();
   194 
   195 		// XXX Improve test. e.g. check that a valid AU file is written
   196 		if(iError == KErrNone)
   197 			{
   198 			ret = EPass;
   199 			}
   200 		else
   201 			{
   202 			INFO_PRINTF2(_L("Error returned in MoscoStateChangeEvent callback: %d"), iError);
   203 			ret = EFail;
   204 			}
   205 		}
   206 
   207 	return ret;
   208 	}
   209 
   210 //------------------------------------------------------------------
   211 
   212 /**
   213  * Constructor
   214  */
   215 CTestMmfAclntConCloseOpen::CTestMmfAclntConCloseOpen(const TDesC& aTestName)
   216 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, EFalse)
   217 	{}
   218 
   219 CTestMmfAclntConCloseOpen* CTestMmfAclntConCloseOpen::NewL(const TDesC& aTestName)
   220 	{
   221 	CTestMmfAclntConCloseOpen* self = new (ELeave) CTestMmfAclntConCloseOpen(aTestName);
   222 	return self;
   223 	}
   224 
   225 /**
   226  * Open source and destination audio. Close them and open a new source and destination.
   227  */
   228 TVerdict CTestMmfAclntConCloseOpen::DoTestL(CMdaAudioConvertUtility* aConverter)
   229 	{
   230 	INFO_PRINTF1( _L("TestConverter : Close/Open"));
   231 
   232 	TVerdict ret = EFail;
   233 
   234 	SetupFormatL(iTestFormat);
   235 
   236 	
   237 	TPtrC toFilename, fromFilename;
   238 	if ((!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), fromFilename)) || (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), toFilename)))
   239 		return EInconclusive;
   240 
   241 	
   242 	TMdaFileClipLocation location(toFilename);
   243 
   244 	iError = KErrTimedOut;
   245 	aConverter->Close(); 
   246 
   247 	iError = KErrTimedOut;
   248 	aConverter->OpenL(fromFilename, &location, iFormat, iCodec, NULL);
   249 
   250 	// wait for open
   251 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   252 	CActiveScheduler::Start();
   253 
   254 	if(iError == KErrNone)
   255 		ret = EPass;
   256 
   257 	return ret;
   258 	}
   259 
   260 //------------------------------------------------------------------
   261 
   262 /**
   263  * Constructor
   264  */
   265 CTestMmfAclntConWindow::CTestMmfAclntConWindow(const TDesC& aTestName)
   266 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, EFalse)
   267 	{}
   268 
   269 CTestMmfAclntConWindow* CTestMmfAclntConWindow::NewL(const TDesC& aTestName)
   270 	{
   271 	CTestMmfAclntConWindow* self = new (ELeave) CTestMmfAclntConWindow(aTestName);
   272 	return self;
   273 	}
   274 
   275 /**
   276  * Set convert window. Enquire window. Delete window
   277  */
   278 TVerdict CTestMmfAclntConWindow::DoTestL(CMdaAudioConvertUtility* aConverter)
   279 	{
   280 	INFO_PRINTF1( _L("*** Converter set window test\n"));
   281 
   282 	TVerdict ret = EFail;
   283 	TInt64 temp1, temp2;
   284 
   285 	temp1 = aConverter->Duration().Int64()/4;	// set start at first quarter of clip
   286 	temp2 = TInt64(3) * (aConverter->Duration().Int64()/4);	// set end at 3rd quarter of clip
   287 	ASSERT(temp2 > temp1);	// temp1 = start, temp2 = end
   288 
   289 	TInt windowDuration = (I64INT(temp2) - I64INT(temp1));
   290 
   291 	TTimeIntervalMicroSeconds endTime(temp2); 
   292 	TTimeIntervalMicroSeconds startTime(temp1);
   293 
   294 	INFO_PRINTF4(_L("StartTime = %d EndTime = %d WindowDuration = %d"),
   295 		I64INT(startTime.Int64()), I64INT(endTime.Int64()), windowDuration);
   296 	aConverter->SetPlayWindow(startTime,endTime);
   297 
   298 
   299 	TRAP(iError,aConverter->SetDestinationNumberOfChannelsL(1));
   300 	if (iError != KErrNone)
   301 		return ret ;
   302 
   303 	iError = KErrTimedOut;
   304 	INFO_PRINTF1( _L("CMdaAudioConvertUtility::ConvertL"));
   305 	aConverter->ConvertL();
   306 
   307 
   308 	CActiveScheduler::Start();	// initial MoscoStateChangeEvent callback
   309 	if (iError == KErrNone)
   310 		{
   311 		CActiveScheduler::Start();	// conversion starts here
   312 
   313 		if (iError == KErrNone)
   314 			{
   315 			// Check file size is as expected
   316 			TPtrC filename;
   317 			if (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), filename))
   318 				{
   319 				INFO_PRINTF1(_L("Error getting filename from ini file"));
   320 				ret = EInconclusive;
   321 				}
   322 			else
   323 				{
   324 				ret = CheckFileSize(filename, KConverterWindowFileSize);
   325 				}
   326 			}
   327 		}
   328 	else
   329 		{
   330 		INFO_PRINTF2(_L("iError = %d"), iError);
   331 		ret = EFail;
   332 		}
   333 
   334 	// Test clear window
   335 	if (ret == EPass)
   336 		{
   337 		INFO_PRINTF1(_L("*** Converter clear window test\n"));
   338 		iError = KErrTimedOut;
   339 		aConverter->ClearPlayWindow();
   340 		aConverter->ConvertL();
   341 
   342 		CActiveScheduler::Start();	// initial MoscoStateChangeEvent callback
   343 		if (iError == KErrNone)
   344 			{
   345 			CActiveScheduler::Start();	// conversion starts here
   346 
   347 			if (iError == KErrNone)
   348 				{
   349 				TPtrC filename;
   350 				if (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), filename))
   351 					{
   352 					INFO_PRINTF1(_L("Error getting filename from ini file"));
   353 					ret = EInconclusive;
   354 					}
   355 				else
   356 					{
   357 					// Second convert will be appended to the first
   358 					ret = CheckFileSize(filename, KConverterWindowPlusNormalFileSize);
   359 					}
   360 				}
   361 			}
   362 		else
   363 			{
   364 			INFO_PRINTF2(_L("iError = %d"), iError);
   365 			ret = EFail;
   366 			}
   367 		}
   368 
   369 	return ret;
   370 	}
   371 
   372 TVerdict CTestMmfAclntConWindow::CheckFileSize(const TDesC& aFilename, const TInt aExpectedSize)
   373 	{
   374 	TVerdict verdict = EFail;
   375 	RFile file;
   376 	RFs fs;
   377 	
   378 	TInt ret = fs.Connect();
   379 	if (ret != KErrNone)
   380 		{
   381 		INFO_PRINTF1(_L("Error opening file system!"));
   382 		return EInconclusive;
   383 		}
   384 
   385 	// Check file size matches expected size
   386 	TInt err = file.Open(fs, aFilename, EFileRead);
   387 	if (err != KErrNone)
   388 		{
   389 		INFO_PRINTF2(_L("Error opening converted file (%d)"), err);
   390 		verdict = EInconclusive;
   391 		}
   392 	else
   393 		{
   394 		TInt size = 0;
   395 		err = file.Size(size);
   396 		if (err != KErrNone || size != aExpectedSize)
   397 			{
   398 			if (err != KErrNone)
   399 				INFO_PRINTF2(_L("Error getting file size (%d)"), err);
   400 			else
   401 				INFO_PRINTF3(_L("Converted file size incorrect (expected %d, got %d)"), aExpectedSize, size);
   402 			verdict = EFail;
   403 			}
   404 		else
   405 			{
   406 			INFO_PRINTF1(_L("Converted file size as expected (test passed)"));
   407 			verdict = EPass;
   408 			}
   409 		file.Close();
   410 		}
   411 	fs.Close();
   412 
   413 	return verdict;
   414 	}
   415 
   416 //------------------------------------------------------------------
   417 
   418 /**
   419  * Constructor
   420  */
   421 CTestMmfAclntConDuration::CTestMmfAclntConDuration(const TDesC& aTestName)
   422 	:CTestMmfAclntConConfig(aTestName,EPcm16Wav, EFalse)
   423 	{}
   424 
   425 CTestMmfAclntConDuration* CTestMmfAclntConDuration::NewL(const TDesC& aTestName)
   426 	{
   427 	CTestMmfAclntConDuration* self = new (ELeave) CTestMmfAclntConDuration(aTestName);
   428 	return self;
   429 	}
   430 
   431 void CTestMmfAclntConDuration::GetKeyName(TDes& aDes)
   432 	{
   433 	aDes = KAclntConDurationKeyName;
   434 	}
   435 
   436 /** Enquire duration
   437  */
   438 TVerdict CTestMmfAclntConDuration::DoTestL(CMdaAudioConvertUtility* aConverter)
   439 	{
   440 	INFO_PRINTF1( _L("TestConverter : Duration"));
   441 	TVerdict ret = EFail;
   442 
   443 	TTimeIntervalMicroSeconds duration(KSoundFileLength); // 8 second sound file!
   444 	//since format+codec have wrrong default values
   445 	TRAP(iError,aConverter->SetDestinationSampleRateL(8000));
   446 	TRAP(iError,aConverter->SetDestinationNumberOfChannelsL(1));
   447 	//TRAP(iError,aConverter->ConvertL());
   448 
   449 	if(KErrNone == iError && (aConverter->Duration() == duration))
   450 		{
   451 		INFO_PRINTF3(_L("Duration  = %f mkS Record time  =  %f mkS"),
   452 				I64REAL(duration.Int64()), 
   453 				I64REAL(aConverter->RecordTimeAvailable().Int64()));
   454 		ret = EPass;
   455 		}
   456 	else
   457 		{
   458 		TInt64		durationExpected = duration.Int64();
   459 		
   460 		TInt64		durationReceived = aConverter->Duration().Int64();	
   461 		INFO_PRINTF3( _L("Expected duration: %f, received duration: %f"), I64REAL(durationExpected), I64REAL(durationReceived));
   462 
   463 		}
   464 	return ret;
   465 	}
   466 
   467 void CTestMmfAclntConDuration::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
   468 	{
   469 	iError = aErrorCode;
   470 	INFO_PRINTF1( _L("CTestMmfAclntDelete : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
   471 	INFO_PRINTF2( _L("iError %d"), iError);
   472 	CActiveScheduler::Stop();
   473 	}
   474 
   475 //------------------------------------------------------------------
   476 
   477 /**
   478  * Constructor
   479  */
   480 CTestMmfAclntConPosition::CTestMmfAclntConPosition(const TDesC& aTestName,const	TTimeIntervalMicroSeconds aPosition)
   481 	:CTestMmfAclntConConfig(aTestName,EPcm16Wav, EFalse)
   482 	{
   483 	iPosition = aPosition;
   484 	}
   485 
   486 CTestMmfAclntConPosition* CTestMmfAclntConPosition::NewL(const TDesC& aTestName,const TTimeIntervalMicroSeconds aPosition)
   487 	{
   488 	CTestMmfAclntConPosition* self = new (ELeave) CTestMmfAclntConPosition(aTestName, aPosition);
   489 	return self;
   490 	}
   491 
   492 void CTestMmfAclntConPosition::GetKeyName(TDes& aDes)
   493 	{
   494 	aDes = KAclntConPositionKeyName;
   495 	}
   496 
   497 /**
   498  * Set position and enquire position. Sound is always set to minus one
   499  * frame, becuase DevSound has to play something. (Even if set to the end of the clip).
   500  *
   501  */
   502 TVerdict CTestMmfAclntConPosition::DoTestL(CMdaAudioConvertUtility* aConverter)
   503 	{
   504 	INFO_PRINTF1( _L("TestConverter : Position"));
   505 	TVerdict ret = EFail; 
   506 
   507 	//  Set position: middle of clip.
   508 	if (I64INT(iPosition.Int64()) == 0)
   509 		iPosition = I64INT(aConverter->Duration().Int64())/2;
   510 	// Set position: end of clip.
   511 	if (I64INT(iPosition.Int64()) == -1)
   512 		iPosition = aConverter->Duration();
   513 
   514 	// Position is beyond the end of the clips duration.
   515 	// so check that the value is clipped.
   516 	if(aConverter->Duration() < iPosition)
   517 		{
   518 		TInt64 temp = (aConverter->Duration().Int64() / KPcm16FrameInterval) - 1; // -1 for DevSound
   519 		aConverter->SetPosition(iPosition);
   520 
   521 		TInt64 theReceived = aConverter->Position().Int64();
   522 		TInt64 theExpected = temp * KPcm16FrameInterval;
   523 
   524 		TBool theRes = TimeComparison(I64INT(theReceived), I64INT(theExpected), KExpectedDeviation);
   525 
   526 		if(theRes == (TBool) ETrue)
   527 			ret = EPass;
   528 		INFO_PRINTF3( _L("Expected position : %d, Received position : %d"), theExpected, theReceived);
   529 		}
   530 	// Position is before the beginning of the clip
   531 	// so check that the value is zero
   532 	else if(iPosition < TTimeIntervalMicroSeconds(0))
   533 		{
   534 		TInt	theExpected = 0;
   535 		aConverter->SetPosition(iPosition);
   536 		TInt	theReceived = I64INT(aConverter->Position().Int64());
   537 		TBool theRes = TimeComparison(theReceived, theExpected, 0);
   538 		if(theRes)
   539 			ret = EPass;
   540 		INFO_PRINTF3( _L("Expected position : %d, Received position : %d"), theExpected, theReceived);
   541 		}
   542 	else
   543 		{
   544 		
   545 		//Original
   546 		/*
   547 		aConverter->SetPosition(iPosition);
   548 		aConverter->ConvertL();
   549 		CActiveScheduler::Start();
   550 
   551 		TInt64 temp = (iPosition.Int64() / KPcm16FrameInterval) - 1; // -1 for DevSound
   552 		
   553 		TInt	theReceived = I64INT(aConverter->Position().Int64());
   554 		TInt	theExpected = I64INT(temp) * KPcm16FrameInterval;
   555 
   556 		TBool theRes = TimeComparison(theReceived, theExpected, KExpectedDeviation);
   557 
   558 		if(theRes == (TBool) ETrue)
   559 			{
   560 			ret = EPass;
   561 			}
   562 		INFO_PRINTF3( _L("Expected position : %d, Received position : %d"), theExpected, theReceived);
   563 		*/
   564 
   565 
   566 		//Amendment
   567 		TInt	theDurationa = I64INT(aConverter->Duration().Int64());
   568 
   569 		aConverter->SetPosition(iPosition);
   570 		TInt	theExpected = I64INT(aConverter->Position().Int64());
   571 
   572 			//ConvertL requires two CActiveScheduler::Start()
   573 		aConverter->ConvertL();
   574 		CActiveScheduler::Start();
   575 		CActiveScheduler::Start();
   576 			
   577 		TPtrC toFilename, fromFilename;
   578 		GetStringFromConfig(_L("SectionFour"), _L("configAudio"), fromFilename); 
   579 		GetStringFromConfig(_L("SectionFour"), _L("configAudio12"), toFilename);
   580 		TMdaFileClipLocation location2(toFilename);
   581 		aConverter->OpenL(fromFilename, &location2, iFormat, iCodec);
   582 		CActiveScheduler::Start();
   583 
   584 		TInt	theDurationb = I64INT(aConverter->Duration().Int64());
   585 		TInt	theReceived = theDurationa - theDurationb;
   586 
   587 		TBool theRes = TimeComparison(theReceived, theExpected, KDeviation);
   588 		
   589 
   590 		if(theRes == (TBool) ETrue)
   591 			{
   592 			ret = EPass;
   593 			}
   594 		INFO_PRINTF3( _L("Expected position : %d, Received position : %d"), theExpected, theReceived);
   595 
   596 		}
   597 		
   598 	return ret;
   599 	}
   600 
   601 //------------------------------------------------------------------
   602 
   603 /**
   604  * Constructor
   605  */
   606 CTestMmfAclntConConfig::CTestMmfAclntConConfig(const TDesC& aTestName, const TTestFormat aFormat, const TBool aNegative)
   607 	{
   608 	iTestStepName = aTestName;
   609 	iThisIsNegativeTest = aNegative;
   610 	iTestFormat = aFormat;
   611 	}
   612 
   613 CTestMmfAclntConConfig* CTestMmfAclntConConfig::NewL(const TDesC& aTestName, const TTestFormat aFormat, const TBool aNegative)
   614 	{
   615 	CTestMmfAclntConConfig* self = new (ELeave) CTestMmfAclntConConfig(aTestName, aFormat, aNegative);
   616 	return self;
   617 	}
   618 
   619 void CTestMmfAclntConConfig::MoscoStateChangeEvent(CBase* /*aObject*/, 
   620 												   TInt /*aPreviousState*/, 
   621 												   TInt /*aCurrentState*/, 
   622 												   TInt aErrorCode)
   623 	{
   624 	iError = aErrorCode;
   625 	INFO_PRINTF1( _L("CTestMmfAclntConConfig : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
   626 	INFO_PRINTF2( _L("iError %d"), iError);
   627 
   628 	CActiveScheduler::Stop();
   629 	}
   630 
   631 void CTestMmfAclntConConfig::GetKeyName(TDes& aDes)
   632 	{
   633 	aDes = KAclntConConfigKeyName;
   634 	}
   635 
   636 TVerdict CTestMmfAclntConConfig::DoTestStepPreambleL()
   637 	{
   638 	TVerdict ret = EPass;
   639 
   640 	SetupFormatL(iTestFormat);
   641 
   642 	TBuf<64> keyName;
   643 	GetKeyName(keyName);
   644 
   645 	// Make sure file doesn't exist (maybe from a previous test)
   646 	TParse fullFileName;
   647 	TPtrC filename;
   648 	if(!GetStringFromConfig(_L("SectionFour"), keyName, filename))
   649 		return EInconclusive;
   650 
   651 	// parse the filenames
   652 		if(!fullFileName.Set(filename, &KDefault, NULL))
   653 		{
   654 		RFs fs;
   655 		User::LeaveIfError(fs.Connect());
   656 
   657 		TInt error = fs.Delete(fullFileName.FullName());
   658 		if(error == KErrPathNotFound)
   659 			{
   660 				error = fs.MkDirAll(fullFileName.DriveAndPath());
   661 				INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName());	
   662 			}
   663 		else if(error == KErrNotFound)
   664 			INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName());	
   665 		else if(error==KErrNone)
   666 			INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName());	
   667 		else
   668 			ret = EInconclusive;
   669 		fs.Close();
   670 		}
   671 	if((ret == EInconclusive) || (ret == EFail))
   672 		{
   673 		return ret;	
   674 		}
   675 	return CTestMmfAclntStep::DoTestStepPreambleL();
   676 	}
   677 
   678 /**
   679  * Set config destination clip
   680  */
   681 TVerdict CTestMmfAclntConConfig::DoTestStepL()
   682 	{
   683 	INFO_PRINTF1( _L("TestConverter : Config"));
   684 	TVerdict ret = EFail;
   685 
   686 	TPtrC toFilename, fromFilename;
   687 	if ((!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), fromFilename)) 
   688 		|| (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), toFilename)))
   689 		return EInconclusive;
   690 
   691 	// Delete the old file if it exists
   692 	RFs fs;
   693 	TInt err = fs.Connect();
   694 	if (err != KErrNone)
   695 		{
   696 		INFO_PRINTF2(_L("Error doing fs.Connect (%d)"), err);
   697 		return EInconclusive;
   698 		}
   699 
   700 	err = fs.Delete(toFilename);
   701 	if ((err != KErrNone) && (err != KErrNotFound))
   702 		{
   703 		INFO_PRINTF3(_L("Error deleting 'toFilename' (%S) %d"), &toFilename, err);
   704 		return EInconclusive;
   705 		}
   706 	fs.Close();
   707 
   708 	TMdaFileClipLocation location(toFilename);
   709 	iError = KErrTimedOut;
   710 
   711 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
   712 	CleanupStack::PushL(converter);
   713 
   714 	if (iThisIsNegativeTest)
   715 		{
   716 		iAudioSettings.iSampleRate = KInvalidNumber;
   717 		iAudioSettings.iChannels = KInvalidNumber;
   718 		converter->OpenL(fromFilename, &location, iFormat, iCodec, &iAudioSettings);
   719 		}
   720 	else
   721 		{
   722 		  converter->OpenL(fromFilename, &location, iFormat, iCodec);
   723 		}
   724 
   725 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   726 	CActiveScheduler::Start();
   727 
   728 	//TRAP(iError, converter->SetDestinationNumberOfChannelsL(1));
   729 
   730 	if (iError == KErrNone)
   731 		ret = DoTestL(converter);
   732 
   733 	if (ret == EFail)
   734 		INFO_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
   735 
   736 	if(iThisIsNegativeTest && iError == KErrNotSupported)
   737 		{
   738 			ret = EPass;	
   739 		}
   740 
   741 	CleanupStack::PopAndDestroy(converter);
   742 	User::After(KOneSecond);
   743 	return ret;	
   744 	
   745 	}
   746 
   747 TVerdict CTestMmfAclntConConfig::DoTestL(CMdaAudioConvertUtility* aConverter)
   748 	{
   749 	TVerdict ret = EFail;
   750 
   751 	iError = KErrTimedOut;
   752 
   753 	aConverter->ConvertL(); 
   754 	INFO_PRINTF1( _L("Convert CMdaAudioConvertUtility"));
   755 	CActiveScheduler::Start();
   756 
   757 	// a negative test will fail succesfully at this point
   758 	if (!iThisIsNegativeTest)
   759 		ret = EPass;
   760 	else if (iError == KErrNotSupported)
   761 		ret = EPass;
   762 	return ret;
   763 	}
   764 
   765 //------------------------------------------------------------------
   766 
   767 /**
   768  * Constructor
   769  */
   770 CTestMmfAclntConQuery::CTestMmfAclntConQuery(const TDesC& aTestName)
   771 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, EFalse)
   772 	{}
   773 
   774 CTestMmfAclntConQuery* CTestMmfAclntConQuery::NewL(const TDesC& aTestName)
   775 	{
   776 	CTestMmfAclntConQuery* self = new (ELeave) CTestMmfAclntConQuery(aTestName);
   777 	return self;
   778 	}
   779 
   780 void CTestMmfAclntConQuery::GetKeyName(TDes& aDes)
   781 	{
   782 	aDes = KAclntConQueryKeyName;
   783 	}
   784 
   785 TVerdict CTestMmfAclntConQuery::DoTestStepL()
   786 	{
   787 	INFO_PRINTF1( _L("TestConverter : ConQuery"));
   788 	TVerdict ret = EFail;
   789 
   790 	TPtrC toFilename, fromFilename;
   791 	if ((!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), fromFilename)) 
   792 	//if ((!GetStringFromConfig(_L("SectionSeven"), _L("auFile"), fromFilename)) 
   793 	//if ((!GetStringFromConfig(_L("SectionSeven"), _L("rawFile"), fromFilename)) 
   794 	|| (!GetStringFromConfig(_L("SectionFour"), _L("configAudio4"), toFilename)))
   795 		return EInconclusive;
   796 
   797 	TMdaFileClipLocation location(toFilename);
   798 	iError = KErrTimedOut;
   799 
   800 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
   801 	CleanupStack::PushL(converter);
   802 
   803 	converter->OpenL(fromFilename, &location, iFormat, iCodec);
   804 
   805 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   806 	CActiveScheduler::Start();
   807 
   808 	if (iError == KErrNone)
   809 		ret = DoTestL(converter);
   810 
   811 	if (ret == EFail)
   812 		INFO_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
   813 
   814 
   815 	CleanupStack::PopAndDestroy(converter);
   816 	User::After(KOneSecond);
   817 	return ret;	
   818 	
   819 	}
   820 
   821 /**
   822  * query transformations available.
   823  */
   824 TVerdict CTestMmfAclntConQuery::DoTestL(CMdaAudioConvertUtility* aConverter)
   825 	{
   826 	INFO_PRINTF1( _L("TestConverter : Query Transactions"));
   827 	RArray<TFourCC>		theSupportedDataTypes;
   828 
   829 	TInt err ; 
   830 	TRAP(err,aConverter->GetSupportedDestinationDataTypesL(theSupportedDataTypes));
   831 	if(err!=KErrNone)
   832 		{
   833 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::GetSupportedDataTypesL left with error %d"),err);
   834 		return EFail;
   835 		}
   836 	
   837 	TUint8		theBuffer8[KSizeBuf];
   838 
   839 	INFO_PRINTF1( _L("The supported available transformation"));
   840 	for(TInt	index = 0; index < theSupportedDataTypes.Count() ; index++)
   841 		{
   842 		 TFourCC&	four = 	theSupportedDataTypes[index];
   843 		
   844 		 TPtr8		ptrFour(theBuffer8, KSizeBuf);
   845 		 four.FourCC(&ptrFour);
   846 		 TBuf<KSizeBuf>	theBuf;
   847 		 
   848 		 theBuf.Copy(ptrFour);
   849 		
   850 		 INFO_PRINTF3( _L("%d  %S"), index, &theBuf);
   851 
   852 		}
   853 	
   854 	return EPass;	
   855 	}
   856 
   857 //-------------------------------------------------------------------
   858 
   859 // Negative tests
   860 
   861 //-------------------------------------------------------------------
   862 
   863 /**
   864  * Constructor
   865  */
   866 CTestMmfAclntDelete::CTestMmfAclntDelete()
   867 	{
   868 	// store the name of this test case
   869 	// this is the name that is used by the script file
   870 	// Each test step initialises it's own name
   871 	iTestStepName = _L("MM-MMF-ACLNT-I-1051-CP");
   872 	}
   873 
   874 void CTestMmfAclntDelete::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
   875 	{
   876 	iError = aErrorCode;
   877 	INFO_PRINTF1( _L("CTestMmfAclntDelete : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
   878 	INFO_PRINTF2( _L("iError %d"), iError);
   879 	CActiveScheduler::Stop();
   880 	}
   881 
   882 /**
   883  * Conversion utility - Delete object before conversion operation has completed.
   884  */
   885 TVerdict CTestMmfAclntDelete::DoTestStepL( void )
   886 	{
   887 	INFO_PRINTF1( _L("TestConverter : Delete"));
   888 
   889 	TPtrC sourceFileName, targetFileName;
   890 	if((!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), sourceFileName)) || 
   891 		(!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), targetFileName)))
   892 		return EInconclusive;
   893 	
   894 	RFs		theFs;
   895 	theFs.Connect();
   896 	theFs.Delete(targetFileName);
   897 	theFs.Close();
   898 
   899 
   900 	iError = KErrTimedOut;
   901 	TMdaFileClipLocation location(targetFileName);
   902 	TMdaWavClipFormat	format;
   903 	TMdaPcmWavCodec		codec;
   904 
   905 	__MM_HEAP_MARK;
   906 
   907 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
   908 	CleanupStack::PushL(converter);
   909 	converter->OpenL(sourceFileName,&location, &format, &codec);
   910 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   911 	CActiveScheduler::Start();
   912 
   913 	if(iError == KErrNone)
   914 		{
   915 		converter->ConvertL(); 
   916 		INFO_PRINTF1( _L("Convert CMdaAudioConvertUtility"));
   917 		//User::After(3 * KOneSecond);		
   918 		CleanupStack::PopAndDestroy(converter);
   919 		User::After(KOneSecond);
   920 		INFO_PRINTF1( _L("Destroy CMdaAudioConvertUtility"));
   921 		__MM_HEAP_MARKEND;
   922 		User::Heap().Check();
   923 
   924 		return	EPass;
   925 		}
   926 
   927 	ERR_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
   928 
   929 	CleanupStack::PopAndDestroy(converter);
   930 	User::After(KOneSecond);
   931 	return EFail;
   932 	}
   933 
   934 //------------------------------------------------------------------
   935 
   936 /**
   937  * Constructor
   938  */
   939 CTestMmfAclntOpenWhileConvert::CTestMmfAclntOpenWhileConvert(const TDesC& aTestName)
   940 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav,EFalse)
   941 	{
   942 	}
   943 
   944 CTestMmfAclntOpenWhileConvert* CTestMmfAclntOpenWhileConvert::NewL(const TDesC& aTestName)
   945 	{
   946 	CTestMmfAclntOpenWhileConvert* self = new (ELeave) CTestMmfAclntOpenWhileConvert(aTestName);
   947 	return self;
   948 	}
   949 
   950 /**
   951  * Open new file while audio converter is converting. Open a new audio file.
   952  */
   953 TVerdict CTestMmfAclntOpenWhileConvert::DoTestL(CMdaAudioConvertUtility* aConverter)
   954 	{
   955 	INFO_PRINTF1( _L("TestConverter : Open/Convert"));
   956 
   957 	TPtrC auFilename, wavFilename;
   958 	//if((!GetStringFromConfig(_L("SectionFour"), _L("auAudioFile"), auFilename)) || 
   959 	//	(!GetStringFromConfig(_L("SectionFour"), _L("wavAudioFile"), wavFilename)))
   960 	if((!GetStringFromConfig(_L("SectionOne"), _L("PCM8"), auFilename)) || 
   961 		(!GetStringFromConfig(_L("SectionFour"), _L("PCM16_out"), wavFilename)))
   962 		return EInconclusive;
   963 	
   964 	RFs	theFs;
   965 	User::LeaveIfError(theFs.Connect());
   966 	theFs.Delete(wavFilename);
   967 	theFs.MkDirAll(wavFilename);
   968 	theFs.Close();
   969 
   970 
   971 	iError = KErrTimedOut;
   972 	TMdaFileClipLocation location(wavFilename);
   973 	TMdaWavClipFormat format;
   974 	TMdaPcmWavCodec		codec(TMdaPcmWavCodec::E16BitPcm);
   975 
   976 	aConverter->ConvertL(); 
   977 	INFO_PRINTF1( _L("Convert CMdaAudioConvertUtility"));
   978 	User::After(KOneSecond);		
   979 
   980 	
   981 	aConverter->OpenL(auFilename,&location, &format, &codec);
   982 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   983 	// wait for open
   984 	CActiveScheduler::Start();
   985 
   986 	if(iError == KErrInUse || iError == KErrNone)
   987 		return	EPass;
   988 	return EFail;
   989 	}
   990 
   991 //------------------------------------------------------------------
   992 
   993 CTestMmfAclntConvertDestBitRate::CTestMmfAclntConvertDestBitRate(const TDesC& aTestName, TBool aNegative)
   994 	: CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative)
   995 	{}
   996 
   997 CTestMmfAclntConvertDestBitRate* CTestMmfAclntConvertDestBitRate::NewL(const TDesC& aTestName, TBool aNegative)
   998 	{
   999 	CTestMmfAclntConvertDestBitRate* self = new (ELeave) CTestMmfAclntConvertDestBitRate(aTestName,aNegative);
  1000 	return self;
  1001 	}
  1002 
  1003 void CTestMmfAclntConvertDestBitRate::GetKeyName(TDes& aDes)
  1004 	{
  1005 	aDes = KAclntConDestBitRateKeyName;
  1006 	}
  1007 
  1008 TVerdict CTestMmfAclntConvertDestBitRate::DoTestL(CMdaAudioConvertUtility* aConverter)
  1009 	{
  1010 	INFO_PRINTF1( _L("TestConvertUtils : Destination Bit Rate"));
  1011 	TVerdict ret = EPass;
  1012 	TInt err = KErrNone;
  1013 	RArray<TUint> rates;
  1014 	TRAP(err,aConverter->GetSupportedConversionBitRatesL(rates));
  1015 	// in Typhoon KErrNotSupported is expected
  1016 	if(err==KErrNotSupported)
  1017 		{
  1018 		//test the other bitrate functions for code coverage (and behaviour)
  1019 		TRAP(err,aConverter->SetDestinationBitRateL(100)); // arbitrary value since KErrNotSupported is expected anyway
  1020 		if (err != KErrNotSupported)
  1021 			return EFail;
  1022 		
  1023 		TUint rate=0;
  1024 		TRAP(err, rate=aConverter->DestinationBitRateL());
  1025 		if (err != KErrNone)	
  1026 			return EFail;
  1027 		
  1028 		INFO_PRINTF3(_L("CMdaAudioConvertUtility::GetSupportedConversionBitRatesL() leave with error %d bitrate of %d"),err,rate);
  1029 		ret = EPass;
  1030 		return ret;
  1031 		}
  1032 	if(err!=KErrNone)
  1033 		{
  1034 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::GetSupportedConversionBitRatesL() leave with error %d"),iError);
  1035 		ret = EFail;
  1036 		return ret;
  1037 		}
  1038 	TInt numRates = rates.Count();
  1039 	for(TInt i=0;i<numRates;i++)
  1040 		{
  1041 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SetDestinationBitRateL (%d)"),rates[i]);
  1042 		TRAP(iError,aConverter->SetDestinationBitRateL(rates[i]));
  1043 		if(iError != KErrNone)
  1044 			{
  1045 			INFO_PRINTF2(_L("CMdaAudioConvertUtility::SetDestinationBitRateL left with error %d"),iError);
  1046 			ret = EFail;
  1047 			}
  1048 		else// no error, get rate
  1049 			{
  1050 			TUint rate=0;
  1051 			TRAP(iError,rate = aConverter->DestinationBitRateL());
  1052 			//TRAP(err, aConverter->ConvertL());
  1053 			//CActiveScheduler::Start();
  1054 
  1055 			if(iError!=KErrNone)
  1056 				{
  1057 				INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationBitRateL leave with error %d"),iError);
  1058 				ret = EFail;
  1059 				}
  1060 			else
  1061 				{
  1062 				if(rate!=rates[i])
  1063 					{
  1064 					ret = EFail;
  1065 					INFO_PRINTF1(_L("Rate mismatch"));
  1066 					}
  1067 					else
  1068 					{	
  1069 					INFO_PRINTF1(_L("Rates match"));
  1070 					}
  1071 				}
  1072 			}
  1073 		}
  1074 	return ret;
  1075 	}
  1076 
  1077 
  1078 //------------------------------------------------------------------
  1079 
  1080 CTestMmfAclntConvertDestDataType::CTestMmfAclntConvertDestDataType(const TDesC& aTestName, TBool aNegative)
  1081 	: CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative)
  1082 	{}
  1083 
  1084 CTestMmfAclntConvertDestDataType* CTestMmfAclntConvertDestDataType::NewL(const TDesC& aTestName, TBool aNegative)
  1085 	{
  1086 	CTestMmfAclntConvertDestDataType* self = new (ELeave) CTestMmfAclntConvertDestDataType(aTestName,aNegative);
  1087 	return self;
  1088 	}
  1089 
  1090 void CTestMmfAclntConvertDestDataType::GetKeyName(TDes& aDes)
  1091 	{
  1092 	aDes = KAclntConDestDataTypeKeyName;
  1093 	}
  1094 
  1095 TVerdict CTestMmfAclntConvertDestDataType::DoTestL(CMdaAudioConvertUtility* aConverter)
  1096 	{
  1097 	INFO_PRINTF1( _L("TestConvertUtils : Destination data type"));
  1098 
  1099 	TVerdict ret = EFail;
  1100 	TInt err = KErrNone;
  1101 	RArray<TFourCC> SupportedDataTypes ;
  1102 	TFourCC dataType;
  1103 
  1104 	TRAP(err,aConverter->GetSupportedDestinationDataTypesL(SupportedDataTypes));
  1105 	if(err!=KErrNone)
  1106 		{
  1107 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::GetSupportedBitRatesL leave with error %d"),err);
  1108 		ret = EFail;
  1109 		return ret;
  1110 		}
  1111 
  1112 	TInt numRates = SupportedDataTypes.Count();
  1113 	ret = EPass ;
  1114 
  1115 	for(TInt i=0;i<numRates;i++)
  1116 		{
  1117 		dataType = SupportedDataTypes[i] ;
  1118 		TUint8 char1 = TUint8( dataType.FourCC() ) ;
  1119 		TUint8 char2 = TUint8( dataType.FourCC() >> 8 ) ;
  1120 		TUint8 char3 = TUint8( dataType.FourCC() >> 16 ) ;
  1121 		TUint8 char4 = TUint8( dataType.FourCC() >> 24 ) ;
  1122 		//fourCCString->Format( _L8("%1c%1c%1c%1c"), char1, char2, char3, char4 ) ;
  1123 		INFO_PRINTF5(_L("dataType.FourCC= %1c%1c%1c%1c"), char1, char2, char3, char4);
  1124 		TRAP(err,aConverter->SetDestinationDataTypeL(SupportedDataTypes[i]));
  1125 
  1126 		if(err!=KErrNone)
  1127 			{
  1128 			INFO_PRINTF2(_L("CMdaAudioConvertUtility::SetDestinationDataTypeL leave with error %d"),err);
  1129 			return EFail;
  1130 			}
  1131 
  1132 		TRAP(err,dataType = aConverter->DestinationDataTypeL());
  1133 
  1134 		if(err!=KErrNone)
  1135 			{
  1136 			INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationDataTypeL leave with error %d"),err);
  1137 			return EFail;
  1138 			}
  1139 
  1140 		if(dataType!=SupportedDataTypes[i])
  1141 			ret = EFail;
  1142 		}
  1143 	return ret;
  1144 	}
  1145 
  1146 
  1147 //------------------------------------------------------------------
  1148 
  1149 CTestMmfAclntConvertDestFormat::CTestMmfAclntConvertDestFormat(const TDesC& aTestName, TBool aNegative)
  1150 	: CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative)
  1151 	{}
  1152 
  1153 CTestMmfAclntConvertDestFormat* CTestMmfAclntConvertDestFormat::NewL(const TDesC& aTestName, TBool aNegative)
  1154 	{
  1155 	CTestMmfAclntConvertDestFormat* self = new (ELeave) CTestMmfAclntConvertDestFormat(aTestName,aNegative) ;
  1156 	return self;
  1157 	}
  1158 
  1159 void CTestMmfAclntConvertDestFormat::GetKeyName(TDes& aDes)
  1160 	{
  1161 	aDes = KAclntConDestFormatKeyName;
  1162 	}
  1163 
  1164 TVerdict CTestMmfAclntConvertDestFormat::DoTestL(CMdaAudioConvertUtility* aConverter)
  1165 	{
  1166 	INFO_PRINTF1( _L("TestConvertUtils : Destination format"));
  1167 	TVerdict ret = EFail;
  1168 	TInt err = KErrNone;
  1169 	TUid format1(KUidMdaWavCodec) ;	//Why not?
  1170 	TUid format2 ;
  1171 
  1172 	TRAP(err,format1 = aConverter->DestinationFormatL());
  1173 	if(err!=KErrNone)
  1174 		{
  1175 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationFormatL leave with error %d"),err);
  1176 		return ret;
  1177 		}
  1178 
  1179 	TRAP(err,aConverter->SetDestinationFormatL(format1));
  1180 	if(err!=KErrNone)
  1181 		{
  1182 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SetDestinationFormatL leave with error %d"),err);
  1183 		return ret;
  1184 		}
  1185 
  1186 	TRAP(err,format2 = aConverter->DestinationFormatL());
  1187 	if(err!=KErrNone)
  1188 		{
  1189 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationFormatL leave with error %d"),err);
  1190 		return ret;
  1191 		}
  1192 
  1193 	if(format1 == format2)
  1194 		ret = EPass;
  1195 	return ret;
  1196 	}
  1197 
  1198 
  1199 //------------------------------------------------------------------
  1200 
  1201 CTestMmfAclntConvertDestSampleRate::CTestMmfAclntConvertDestSampleRate(const TDesC& aTestName, TBool aNegative)
  1202 	: CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative)
  1203 	{}
  1204 
  1205 CTestMmfAclntConvertDestSampleRate* CTestMmfAclntConvertDestSampleRate::NewL(const TDesC& aTestName, TBool aNegative)
  1206 	{
  1207 	CTestMmfAclntConvertDestSampleRate* self = new (ELeave) CTestMmfAclntConvertDestSampleRate(aTestName,aNegative);
  1208 	return self;
  1209 	}
  1210 
  1211 void CTestMmfAclntConvertDestSampleRate::GetKeyName(TDes& aDes)
  1212 	{
  1213 	aDes = KAclntConDestSampleRateKeyName;
  1214 	}
  1215 
  1216 /**
  1217  * Set config destination clip
  1218  */
  1219 TVerdict CTestMmfAclntConvertDestSampleRate::DoTestStepL()
  1220 	{
  1221 	INFO_PRINTF1( _L("TestConverter : Config"));
  1222 	TVerdict ret = EFail;
  1223 
  1224 	TPtrC toFilename, fromFilename;
  1225 
  1226 //	if ((!GetStringFromConfig(_L("SectionOne"), _L("Pcm16Mono44khz"), fromFilename)) 
  1227 	if ((!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), fromFilename)) 
  1228 		|| (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), toFilename)))
  1229 		return EInconclusive;
  1230 
  1231 	// Delete the old file if it exists
  1232 	RFs fs;
  1233 	TInt err = fs.Connect();
  1234 	if (err != KErrNone)
  1235 		{
  1236 		INFO_PRINTF2(_L("Error doing fs.Connect (%d)"), err);
  1237 		return EInconclusive;
  1238 		}
  1239 
  1240 	err = fs.Delete(toFilename);
  1241 	if ((err != KErrNone) && (err != KErrNotFound))
  1242 		{
  1243 		INFO_PRINTF3(_L("Error deleting 'toFilename' (%S) %d"), &toFilename, err);
  1244 		return EInconclusive;
  1245 		}
  1246 	fs.Close();
  1247 
  1248 	TMdaFileClipLocation location(toFilename);
  1249 	iError = KErrTimedOut;
  1250 
  1251 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
  1252 	CleanupStack::PushL(converter);
  1253 
  1254 	if (iThisIsNegativeTest)
  1255 		{
  1256 		iAudioSettings.iSampleRate = KInvalidNumber;
  1257 		iAudioSettings.iChannels = KInvalidNumber;
  1258 		converter->OpenL(fromFilename, &location, iFormat, iCodec, &iAudioSettings);
  1259 		}
  1260 	else
  1261 		{
  1262 		  converter->OpenL(fromFilename, &location, iFormat, iCodec);
  1263 		}
  1264 
  1265 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
  1266 	CActiveScheduler::Start();
  1267 
  1268 	if (iError == KErrNone)
  1269 		ret = DoTestL(converter);
  1270 
  1271 	if (ret == EFail)
  1272 		INFO_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
  1273 
  1274 	if(iThisIsNegativeTest && iError == KErrNotSupported)
  1275 		{
  1276 			ret = EPass;	
  1277 		}
  1278 
  1279 	CleanupStack::PopAndDestroy(converter);
  1280 	User::After(KOneSecond);
  1281 	return ret;	
  1282 	
  1283 	}
  1284 
  1285 void CTestMmfAclntConvertDestSampleRate::MoscoStateChangeEvent(CBase* /*aObject*/, 
  1286 													TInt aPreviousState,
  1287 													TInt aCurrentState,
  1288 													TInt aErrorCode)
  1289 	{
  1290 	iError = aErrorCode;
  1291 	//iObject = aObject;
  1292 	TInt PreviousState = aPreviousState;
  1293 	TInt CurrentState = aCurrentState;
  1294 	INFO_PRINTF1( _L("CTestMmfAclntConvertDestSampleRate : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
  1295 	INFO_PRINTF4( _L("iError %d PreviousState %d -> CurrentState %d"), 
  1296 			iError, PreviousState, CurrentState);
  1297 	if( CurrentState != CMdaAudioClipUtility::EPlaying) 
  1298 	 //give a chace to finish conversion
  1299 		CActiveScheduler::Stop();
  1300 	}
  1301 
  1302 
  1303 TVerdict CTestMmfAclntConvertDestSampleRate::DoTestL(CMdaAudioConvertUtility* aConverter)
  1304 	{
  1305 	INFO_PRINTF1( _L("TestConvertUtils : Destination Sample Rate"));
  1306 	TVerdict ret = EFail;
  1307 	
  1308 	TInt err = KErrNone;
  1309 	RArray<TUint> supportedSampleRates ;
  1310 
  1311 
  1312 	TRAP(err,aConverter->GetSupportedConversionSampleRatesL(supportedSampleRates));
  1313 	if(err!=KErrNone)
  1314 		{
  1315 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::GetSupportedConversionSampleRatesL() leave with error %d"),err);
  1316 		ret = EFail;
  1317 		return ret;
  1318 		}
  1319 
  1320 	TInt numRates = supportedSampleRates.Count();
  1321 	if( 0 != numRates)
  1322 		{
  1323 		ret = EPass ;
  1324 		for(TInt i=0;i<numRates;i++)
  1325 			{
  1326 			// Delete the output file if it exists
  1327 			// Necessary otherwise we will open the output file for conversion and 
  1328 			// use the sample rate of the file
  1329 			TPtrC toFilename;
  1330 			if (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), toFilename))
  1331 				{
  1332 				INFO_PRINTF1(_L("Error finding filename in INI file"));
  1333 				return EInconclusive;
  1334 				}
  1335 
  1336 			RFs fs;
  1337 			TInt err = fs.Connect();
  1338 			if (err != KErrNone)
  1339 				{
  1340 				INFO_PRINTF2(_L("Error doing fs.Connect (%d)"), err);
  1341 				return EInconclusive;
  1342 				}
  1343 
  1344 			err = fs.Delete(toFilename);
  1345 			if ((err != KErrNone) && (err != KErrNotFound))
  1346 				{
  1347 				INFO_PRINTF3(_L("Error deleting 'toFilename' (%S) %d"), &toFilename, err);
  1348 				return EInconclusive;
  1349 				}
  1350 			fs.Close();
  1351 
  1352 			// Do the conversion
  1353 			TUint SampleRate = supportedSampleRates[i] ;
  1354 			INFO_PRINTF2(_L("SampleRate = %d"), SampleRate);
  1355 			TRAP(err,aConverter->SetDestinationSampleRateL(SampleRate));
  1356 			if(err!=KErrNone)
  1357 				{
  1358 				INFO_PRINTF2(_L("CMdaAudioConvertUtility::SetDestinationSampleRateL() leave with error %d"),err);
  1359 				ret = EFail;
  1360 				return ret;
  1361 				}
  1362 
  1363 			TRAP(err, aConverter->ConvertL());
  1364 			CActiveScheduler::Start();
  1365 
  1366 			if(err!=KErrNone)
  1367 				{
  1368 				INFO_PRINTF2(_L("CMdaAudioConvertUtility::ConvertL leave with error %d"),err);
  1369 				ret = EFail;
  1370 				break ;
  1371 				}
  1372 
  1373 			TRAP(err,SampleRate = aConverter->DestinationSampleRateL());
  1374 			if(err!=KErrNone)
  1375 				{
  1376 				INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationSampleRateL leave with error %d"),err);
  1377 				ret = EFail;
  1378 				break ;
  1379 				}
  1380 
  1381 			if(SampleRate != supportedSampleRates[i])
  1382 				{
  1383 				INFO_PRINTF1(_L("CMdaAudioConvertUtility::DestinationSampleRateL does not match the sample rate set"));
  1384 				ret = EFail;
  1385 				}
  1386 
  1387 			}
  1388 		}
  1389 	else
  1390 		{
  1391 		INFO_PRINTF1(_L("CMdaAudioConvertUtility::GetSupportedConversionSampleRatesL() returned empy array."));
  1392 		ret = EFail;
  1393 		}
  1394 	return ret;
  1395 	}
  1396 
  1397 
  1398 //------------------------------------------------------------------
  1399 
  1400 CTestMmfAclntConvertDestNumberOfChannels::CTestMmfAclntConvertDestNumberOfChannels(const TDesC& aTestName, TBool aNegative)
  1401 	: CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative)
  1402 	{}
  1403 
  1404 CTestMmfAclntConvertDestNumberOfChannels* CTestMmfAclntConvertDestNumberOfChannels::NewL(const TDesC& aTestName, TBool aNegative)
  1405 	{
  1406 	CTestMmfAclntConvertDestNumberOfChannels* self = new (ELeave) CTestMmfAclntConvertDestNumberOfChannels(aTestName,aNegative);
  1407 	return self;
  1408 	}
  1409 
  1410 void CTestMmfAclntConvertDestNumberOfChannels::GetKeyName(TDes& aDes)
  1411 	{
  1412 	aDes = KAclntConDestNumberChannelsKeyName;
  1413 	}
  1414 
  1415 TVerdict CTestMmfAclntConvertDestNumberOfChannels::DoTestL(CMdaAudioConvertUtility* aConverter)
  1416 	{
  1417 	INFO_PRINTF1( _L("TestConvertUtils : Destination Number of Channels"));
  1418 	TVerdict ret = EFail;
  1419 	
  1420 	TInt err = KErrNone;
  1421 	RArray<TUint> aSupportedNumberOfChannels ;
  1422 
  1423 	TRAP(err,aConverter->GetSupportedConversionNumberOfChannelsL(aSupportedNumberOfChannels));
  1424 	if(err!=KErrNone)
  1425 		{
  1426 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL() leave with error %d"),err);
  1427 		ret = EFail;
  1428 		return ret;
  1429 		}
  1430 
  1431 	TInt numRates = aSupportedNumberOfChannels.Count();
  1432 	
  1433 	ret = EPass ;
  1434 
  1435 	for(TInt i=0;i<numRates;i++)
  1436 		{
  1437 		TUint NumberOfChannels = aSupportedNumberOfChannels[i] ;
  1438 		INFO_PRINTF2(_L("NumberOfChannels = %d"), NumberOfChannels);
  1439 		TRAP(err,aConverter->SetDestinationNumberOfChannelsL(aSupportedNumberOfChannels[i]));
  1440 
  1441 		if(err!=KErrNone)
  1442 			{
  1443 			INFO_PRINTF2(_L("CMdaAudioConvertUtility::SetDestinationNumberOfChannelL() leave with error %d"),err);
  1444 			return ret;
  1445 			}
  1446 		TRAP(err,NumberOfChannels = aConverter->DestinationNumberOfChannelsL());
  1447 
  1448 		if(err!=KErrNone)
  1449 			{
  1450 			INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationNumberOfChannelL leave with error %d"),err);
  1451 			return EFail;
  1452 			}
  1453 
  1454 		if(NumberOfChannels != aSupportedNumberOfChannels[i])
  1455 			ret = EFail;
  1456 		}
  1457 	return ret;
  1458 	}
  1459 
  1460 //------------------------------------------------------------------
  1461 
  1462 CTestMmfAclntConvertSourceInfo::CTestMmfAclntConvertSourceInfo(const TDesC& aTestName, TBool aNegative)
  1463 	: CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative)
  1464 	{}
  1465 
  1466 CTestMmfAclntConvertSourceInfo* CTestMmfAclntConvertSourceInfo::NewL(const TDesC& aTestName, TBool aNegative)
  1467 	{
  1468 	CTestMmfAclntConvertSourceInfo* self = new (ELeave) CTestMmfAclntConvertSourceInfo(aTestName,aNegative);
  1469 	return self;
  1470 	}
  1471 
  1472 void CTestMmfAclntConvertSourceInfo::GetKeyName(TDes& aDes)
  1473 	{
  1474 	aDes = KAclntConSourceInfoKeyName;
  1475 	}
  1476 
  1477 TVerdict CTestMmfAclntConvertSourceInfo::DoTestL(CMdaAudioConvertUtility* aConverter)
  1478 	{
  1479 	INFO_PRINTF1( _L("TestConvertUtils : Source Info"));
  1480 	TVerdict ret = EFail;
  1481 	
  1482 	TInt err = KErrNone;
  1483 	TUint NumberOfChannels = 0 ;
  1484 	TRAP(err,NumberOfChannels = aConverter->SourceNumberOfChannelsL());
  1485 	if(err!=KErrNone)
  1486 		{
  1487 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SourceNumberOfChannelL leave with error %d"),err);
  1488 		return EFail;
  1489 		}
  1490 	INFO_PRINTF2(_L("NumberOfChannels = %d"), NumberOfChannels);
  1491 
  1492 	TUint BitRate = 0 ;
  1493 	TRAP(err,BitRate = aConverter->SourceBitRateL());
  1494 	if(err!=KErrNone)
  1495 		{
  1496 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SourceBitRateL leave with error %d"),err);
  1497 		return EFail;
  1498 		}
  1499 	INFO_PRINTF2(_L("BitRate = %d"), BitRate);
  1500 
  1501 	TUint SampleRate = 0 ;
  1502 	TRAP(err,SampleRate = aConverter->SourceSampleRateL());
  1503 	if(err!=KErrNone)
  1504 		{
  1505 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SourceSampleRateL leave with error %d"),err);
  1506 		return EFail;
  1507 		}
  1508 	INFO_PRINTF2(_L("SampleRate = %d"), SampleRate);
  1509 
  1510 
  1511 	TUid Format(KUidMdaWavCodec)  ;
  1512 	TRAP(err,Format = aConverter->SourceFormatL());
  1513 	if(err!=KErrNone)
  1514 		{
  1515 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SourceFormatL leave with error %d"),err);
  1516 		return EFail;
  1517 		}
  1518 	INFO_PRINTF2(_L("Format = %d"), Format);
  1519 
  1520 	TFourCC dataType;
  1521 	TRAP(err,dataType = aConverter->SourceDataTypeL());
  1522 
  1523 	if(err!=KErrNone)
  1524 		{
  1525 		INFO_PRINTF2(_L("CMdaAudioConvertUtility::SourceDataTypeL leave with error %d"),err);
  1526 		return EFail;
  1527 		}
  1528 	TUint8 char1 = TUint8( dataType.FourCC() ) ;
  1529 	TUint8 char2 = TUint8( dataType.FourCC() >> 8 ) ;
  1530 	TUint8 char3 = TUint8( dataType.FourCC() >> 16 ) ;
  1531 	TUint8 char4 = TUint8( dataType.FourCC() >> 24 ) ;
  1532 	INFO_PRINTF5(_L("dataType.FourCC= %1c%1c%1c%1c"), char1, char2, char3, char4);
  1533 
  1534 	ret = EPass;
  1535 
  1536 	return ret ;
  1537 	}
  1538 
  1539 //------------------------------------------------------------------
  1540 
  1541 CTestMmfAclntConvertLength::CTestMmfAclntConvertLength(const TDesC& aTestName, TBool aNegative)
  1542 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative) 
  1543 	{
  1544 	}
  1545 
  1546 CTestMmfAclntConvertLength* CTestMmfAclntConvertLength::NewL(const TDesC& aTestName, TBool aNegative)
  1547 	{
  1548 	CTestMmfAclntConvertLength* self = new (ELeave) CTestMmfAclntConvertLength(aTestName, aNegative);
  1549 	return self;
  1550 	}
  1551 
  1552 /** 
  1553  *Set maximum length of file in bytes and Convertord
  1554  */
  1555 TVerdict CTestMmfAclntConvertLength::DoTestL(CMdaAudioConvertUtility* aConvertUtil)
  1556 	{
  1557 	INFO_PRINTF1( _L("TestConvertor : Length"));
  1558 
  1559 	TVerdict ret = EFail;
  1560 	//TTimeIntervalMicroSeconds ConvertTime(aConvertUtil->Duration());
  1561 	
  1562 	aConvertUtil->SetMaxWriteLength(800);
  1563 
  1564 	TRAP(iError, aConvertUtil->PlayL()) ;
  1565 
  1566 	if(iError != KErrNone) 
  1567 		return EFail;
  1568 
  1569 	CActiveScheduler::Start();
  1570 
  1571 	aConvertUtil->Stop() ;
  1572 
  1573 	//until DEF011919 is not fixed
  1574 	//if(aConvertUtil->Duration() != ConvertTime)
  1575 	ret = EPass;
  1576 
  1577 	return	ret;
  1578 	}
  1579 //------------------------------------------------------------------
  1580 
  1581 /**
  1582  * Constructor
  1583  */
  1584 CTestMmfAclntConvertRepeat::CTestMmfAclntConvertRepeat(const TDesC& aTestName, TBool aNegative)
  1585 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative) 
  1586 	{}
  1587 
  1588 CTestMmfAclntConvertRepeat* CTestMmfAclntConvertRepeat::NewL(const TDesC& aTestName, TBool aNegative)
  1589 	{
  1590 	CTestMmfAclntConvertRepeat* self = new (ELeave) CTestMmfAclntConvertRepeat(aTestName,aNegative);
  1591 	return self;
  1592 	}
  1593 
  1594 /**
  1595  * Set repeats
  1596  */
  1597 TVerdict CTestMmfAclntConvertRepeat::DoTestL(CMdaAudioConvertUtility* aConvertUtil)
  1598 	{
  1599 	INFO_PRINTF1( _L("TestConvert : Repeats"));
  1600 
  1601  	iError = KErrTimedOut;
  1602 
  1603 	TTimeIntervalMicroSeconds silence(0);
  1604 	//just to sutisfy CCover, actualy does nothing
  1605 	aConvertUtil->SetRepeats(NUMBER_OF_REPEATS,silence);
  1606 
  1607 	//TInt duration = I64INT(aConvertUtil->Duration().Int64());
  1608 
  1609 	iError = KErrTimedOut;
  1610 	INFO_PRINTF1( _L("Play CMdaAudioConvertUtility"));
  1611 	//just to sutisfy CCover, actualy calls ConvertL() see
  1612 	TRAP(iError, aConvertUtil->PlayL()) ;
  1613 	if(iError != KErrNone)
  1614 		return EFail;
  1615 
  1616 	CActiveScheduler::Start();
  1617 
  1618 	//TUint actualDuration = I64INT(aConvertUtil->Duration().Int64()) ;
  1619 
  1620 	//INFO_PRINTF2(_L("Repeats : %d"), NUMBER_OF_REPEATS);
  1621 	//INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
  1622 	//	iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
  1623 
  1624 	if(iError == KErrNone)
  1625 		return EPass;
  1626 
  1627 	return	EFail ;
  1628 	}
  1629 
  1630 //------------------------------------------------------------------
  1631 
  1632 /**
  1633  * Constructor
  1634  */
  1635 CTestMmfAclntConvertCrop::CTestMmfAclntConvertCrop(const TDesC& aTestName, const TBool aCropToEnd, TBool aNegative)
  1636 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative), 
  1637 	iCropToEnd(aCropToEnd)	
  1638 	{
  1639 	}
  1640 
  1641 CTestMmfAclntConvertCrop* CTestMmfAclntConvertCrop::NewL(const TDesC& aTestName, const TBool aCropToEnd, TBool aNegative)
  1642 	{
  1643 	CTestMmfAclntConvertCrop* self = new (ELeave) CTestMmfAclntConvertCrop(aTestName, aCropToEnd, aNegative);
  1644 	return self;
  1645 	}
  1646 
  1647 
  1648 /**
  1649  * Set config destination clip
  1650  */
  1651 TVerdict CTestMmfAclntConvertCrop::DoTestStepL()
  1652 	{
  1653 	INFO_PRINTF1( _L("TestConverter : Config"));
  1654 	TVerdict ret = EFail;
  1655 
  1656 	TPtrC fromFilename;
  1657 	if ((!GetStringFromConfig(_L("SectionOne"), _L("PCM16"), fromFilename))
  1658 		|| (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), iToFilename))
  1659 		|| (!GetStringFromConfig(_L("SectionFour"), _L("configAudio11"), iToFilename2)))
  1660 		return EInconclusive;
  1661 
  1662 	iError = KErrTimedOut;
  1663 
  1664 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
  1665 	CleanupStack::PushL(converter);
  1666 	TMdaFileClipLocation	location(iToFilename);
  1667 
  1668 	if (iThisIsNegativeTest)
  1669 		{
  1670 		iAudioSettings.iSampleRate = KInvalidNumber;
  1671 		iAudioSettings.iChannels = KInvalidNumber;
  1672 		//to keep CCover happy
  1673 		converter->OpenL(fromFilename, iToFilename2) ;
  1674 			//&location, iFormat, iCodec, &iAudioSettings);
  1675 		}
  1676 	else
  1677 		{
  1678 		converter->OpenL(fromFilename, &location, iFormat, iCodec);
  1679 		}
  1680 
  1681 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
  1682 	CActiveScheduler::Start();
  1683 
  1684 	if (iError == KErrNone)
  1685 		ret = DoTestL(converter);
  1686 
  1687 	CleanupStack::PopAndDestroy(converter);
  1688 	User::After(KOneSecond);
  1689 
  1690 	if (ret == EFail)
  1691 		{
  1692 		INFO_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
  1693 		return ret;
  1694 		}
  1695 
  1696 	if(iThisIsNegativeTest && iError == KErrNotSupported)
  1697 		{
  1698 			ret = EPass;
  1699 		}
  1700 
  1701 	return ret;
  1702 
  1703 	}
  1704 
  1705 
  1706 void CTestMmfAclntConvertCrop::MoscoStateChangeEvent(CBase* /*aObject*/,
  1707 													TInt aPreviousState,
  1708 													TInt aCurrentState,
  1709 													TInt aErrorCode)
  1710 	{
  1711 	iError = aErrorCode;
  1712 	//iObject = aObject;
  1713 	TInt PreviousState = aPreviousState;
  1714 	TInt CurrentState = aCurrentState;
  1715 	INFO_PRINTF1( _L("CTestMmfAclntDoConv : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
  1716 	INFO_PRINTF4( _L("iError %d PreviousState %d -> CurrentState %d"), 
  1717 			iError, PreviousState, CurrentState);
  1718 	//if( CurrentState != CMdaAudioClipUtility::ERecording) 
  1719 	 //give a chance to finish conversion
  1720 		CActiveScheduler::Stop();
  1721 	}
  1722 
  1723 TVerdict CTestMmfAclntConvertCrop::DoTestStepPostambleL()
  1724 	{
  1725 	if (iThisIsNegativeTest)
  1726 		{
  1727 		RFs fs;
  1728 		User::LeaveIfError(fs.Connect());
  1729 
  1730 		TInt error = fs.Delete(iToFilename2);
  1731 		if(error == KErrPathNotFound)
  1732 			return EInconclusive;
  1733 		}
  1734 
  1735 	return CTestMmfAclntStep::DoTestStepPostambleL();
  1736 	}
  1737 
  1738 /**
  1739  * Audio croping.
  1740  */
  1741 TVerdict CTestMmfAclntConvertCrop::DoTestL(CMdaAudioConvertUtility* aConvert)
  1742 	{
  1743 	if (iThisIsNegativeTest)
  1744 		{
  1745 		TInt err = KErrNone;
  1746 		TRAP(err, aConvert->ConvertL());
  1747 		CActiveScheduler::Start();
  1748 		if( err != KErrNone || iError != KErrNone) 
  1749 			return EFail;
  1750 		CActiveScheduler::Start();
  1751 		if( err != KErrNone || iError != KErrNone) 
  1752 			return EFail;
  1753 
  1754 		TTimeIntervalMicroSeconds cropPoint( TTimeIntervalMicroSeconds(aConvert->Duration().Int64()/2) );
  1755 		TTimeIntervalMicroSeconds cropPoint2( TTimeIntervalMicroSeconds(aConvert->Duration().Int64()*2/3) );
  1756 
  1757 		aConvert->SetPosition(cropPoint);
  1758 		// 1st crop
  1759 		TRAP(err, aConvert->CropL());
  1760 		if(err != KErrNone) 
  1761 			return EFail;
  1762 
  1763 		// position beyond the end of the cropped file
  1764 		aConvert->SetPosition(cropPoint2);
  1765 		// 2nd crop
  1766 		TRAP(err, aConvert->CropL());
  1767 		if(err != KErrArgument) 
  1768 			return EFail;
  1769 
  1770 		return EPass;
  1771 		}
  1772 	else
  1773 		{
  1774 		TInt err = KErrNone;
  1775 		TRAP(err, aConvert->ConvertL());
  1776 		CActiveScheduler::Start();
  1777 		if( err != KErrNone || iError != KErrNone) 
  1778 			return EFail;
  1779 		CActiveScheduler::Start();
  1780 		if( err != KErrNone || iError != KErrNone) 
  1781 			return EFail;
  1782 
  1783 		TTimeIntervalMicroSeconds origDuration( TTimeIntervalMicroSeconds(aConvert->Duration().Int64() ));
  1784 		TTimeIntervalMicroSeconds cropPoint( origDuration.Int64()*2/3);
  1785 		aConvert->SetPosition(cropPoint);
  1786 
  1787 		INFO_PRINTF4(_L("crop point %d, duration %d, cropToEnd %d"),
  1788 			I64INT(cropPoint.Int64()), 
  1789 			I64INT(origDuration.Int64()),
  1790 			iCropToEnd);
  1791 
  1792 		if(iCropToEnd)
  1793 			{
  1794 			TRAP(iError, aConvert->CropL());
  1795 			}
  1796 		else
  1797 			{
  1798 			TRAP(iError, aConvert->CropFromBeginningL());
  1799 			}
  1800 		if(iError != KErrNone)
  1801 			{
  1802 			ERR_PRINTF2(_L("Crop left with error =  %d"),iError);
  1803 				return EFail;
  1804 			}
  1805 
  1806 		// Check if the cropped duration is within the deviation from the expected duration
  1807 		// NB : there is no converter API to check the destination(sink) duration after cropping
  1808 		// but we can check cropping by reopening the file and checking its new duration
  1809 
  1810 		TMdaFileClipLocation	location(iToFilename);
  1811 		aConvert->OpenL(iToFilename, &location, iFormat, iCodec);
  1812 		CActiveScheduler::Start();
  1813 
  1814 		TTimeIntervalMicroSeconds newDuration( TTimeIntervalMicroSeconds(aConvert->Duration().Int64() ));
  1815 		TTimeIntervalMicroSeconds expectedDuration;
  1816 		
  1817 		if (iCropToEnd)
  1818 			expectedDuration = cropPoint;
  1819 		else
  1820 			expectedDuration = origDuration.Int64() - cropPoint.Int64();
  1821 
  1822 		INFO_PRINTF3(_L("new duration %d, expected %d"),
  1823 			I64INT(newDuration.Int64()), 
  1824 			I64INT(expectedDuration.Int64()));
  1825 
  1826 		// check for match within deviation
  1827 		// We should query the duration of one 4K buffer, then use that as the jitter
  1828 		// on whatever file we are testing.
  1829 		TUint bitRate = 0 ;
  1830 		TRAP(err,bitRate = aConvert->DestinationBitRateL());
  1831 		if(err!=KErrNone)
  1832 			{
  1833 			INFO_PRINTF2(_L("CMdaAudioConvertUtility::DestinationBitRateL leave with error %d"),err);
  1834 			return EFail;
  1835 			}
  1836 		INFO_PRINTF2(_L("Bit rate = %d"), bitRate);
  1837 		// buffer duration = no. bytes / byte rate
  1838 		TUint bufDuration = (4096000 / (bitRate / 8)) + 1;	// get it in 1/1000 sec, and round up
  1839 		TInt64 dev(bufDuration * 1000);
  1840 
  1841 		INFO_PRINTF2(_L("Buffer duration = %d"), I64INT(dev));
  1842 		TBool durationMatch = EFalse;
  1843 		if (newDuration == expectedDuration)
  1844 			durationMatch = ETrue;
  1845 		else if (newDuration < expectedDuration)
  1846 			{
  1847 			if (expectedDuration <= newDuration.Int64() + dev)
  1848 				durationMatch = ETrue;
  1849 			}
  1850 		else if (newDuration > expectedDuration)
  1851 			{
  1852 			if (expectedDuration >= newDuration.Int64() - dev)
  1853 				durationMatch = ETrue;
  1854 			}
  1855 
  1856 		if (!durationMatch)
  1857 				{
  1858 				ERR_PRINTF1(_L("Cropped duration out of expected range"));
  1859 				return EFail;
  1860 				}
  1861 		return EPass;
  1862 		}
  1863 
  1864 	}
  1865 
  1866 
  1867 //------------------------------------------------------------------
  1868 
  1869 /**
  1870  * Constructor
  1871  */
  1872 CTestMmfAclntConvertStop::CTestMmfAclntConvertStop(const TDesC& aTestName, TBool aNegative)
  1873 	:CTestMmfAclntConConfig(aTestName, EPcm16Wav, aNegative) 
  1874 	{
  1875 	}
  1876 
  1877 CTestMmfAclntConvertStop* CTestMmfAclntConvertStop::NewL(const TDesC& aTestName, TBool aNegative)
  1878 	{
  1879 	CTestMmfAclntConvertStop* self = new (ELeave) CTestMmfAclntConvertStop(aTestName, aNegative);
  1880 	return self;
  1881 	}
  1882 
  1883 
  1884 void CTestMmfAclntConvertStop::MoscoStateChangeEvent(CBase* /*aObject*/, 
  1885 													TInt aPreviousState,
  1886 													TInt aCurrentState,
  1887 													TInt aErrorCode)
  1888 	{
  1889 	iError = aErrorCode;
  1890 	//iObject = aObject;
  1891 	TInt PreviousState = aPreviousState;
  1892 	TInt CurrentState = aCurrentState;
  1893 	INFO_PRINTF1( _L("CTestMmfAclntDoConv : MMdaObjectStateChangeObserver Callback for CMdaAudioConvertUtility complete"));
  1894 	INFO_PRINTF4( _L("iError %d PreviousState %d -> CurrentState %d"), 
  1895 			iError, PreviousState, CurrentState);
  1896 	if( CurrentState != CMdaAudioClipUtility::ERecording) 
  1897 	 //give a chance to finish conversion
  1898 		CActiveScheduler::Stop();
  1899 	}
  1900 
  1901 /**
  1902  * Set config destination clip
  1903  */
  1904 TVerdict CTestMmfAclntConvertStop::DoTestStepL()
  1905 	{
  1906 	INFO_PRINTF1( _L("TestConverter : Config"));
  1907 	TVerdict ret = EFail;
  1908 //stolen from  #include <MMFMdaClient.h>
  1909 //static const TUid KUidMmfAudioController	= {0x101F5022};
  1910 
  1911 	TPtrC toFilename, fromFilename;
  1912 	if ((!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), fromFilename))
  1913 		|| (!GetStringFromConfig(_L("SectionFour"), _L("configAudio"), toFilename)))
  1914 		return EInconclusive;
  1915 
  1916 	//TMdaFileClipLocation toLocation(toFilename);
  1917 	//TMdaFileClipLocation fromLocation(fromFilename);
  1918 	iError = KErrTimedOut;
  1919 
  1920 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
  1921 	CleanupStack::PushL(converter);
  1922 
  1923 	if (iThisIsNegativeTest)
  1924 		{
  1925 		iAudioSettings.iSampleRate = KInvalidNumber;
  1926 		iAudioSettings.iChannels = KInvalidNumber;
  1927 		//to keep CCover happy
  1928 		//converter->OpenL(&fromLocation, &toLocation, 
  1929 		//	KUidMdaWavPcmCodec, KUidMdaClipFormatAu, KFourCCNULL);
  1930 		converter->OpenL(fromFilename, toFilename) ;
  1931 		}
  1932 	else										   
  1933 		{
  1934 		//converter->OpenL(&fromLocation, &toLocation, 
  1935 		//	KUidMmfAudioController, KUidMdaWavPcmCodec, TFourCC('A', 'L', 'A', 'W'));
  1936 		converter->OpenL(fromFilename, toFilename) ;
  1937 		}
  1938 
  1939 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
  1940 	CActiveScheduler::Start();
  1941 
  1942 	if (iError == KErrNone)
  1943 		ret = DoTestL(converter);
  1944 
  1945 	if (ret == EFail)
  1946 		INFO_PRINTF2( _L("CMdaAudioConvertUtility failed with error %d"),iError );
  1947 
  1948 	if(iThisIsNegativeTest && iError == KErrNotSupported)
  1949 		{
  1950 			ret = EPass;	
  1951 		}
  1952 
  1953 	CleanupStack::PopAndDestroy(converter);
  1954 	User::After(KOneSecond);
  1955 	return ret;	
  1956 	
  1957 	}
  1958 
  1959 
  1960 /**
  1961  * Conversion stoping.
  1962  */
  1963 TVerdict CTestMmfAclntConvertStop::DoTestL(CMdaAudioConvertUtility* aConvert)
  1964 	{
  1965 	INFO_PRINTF1( _L("TestConvert : Stop"));
  1966 
  1967 	TRAP(iError, aConvert->ConvertL()) ;
  1968 
  1969 	if(iError != KErrNone) 
  1970 		return EFail;
  1971 
  1972 	CActiveScheduler::Start();
  1973 
  1974 	aConvert->Stop() ;
  1975 	CActiveScheduler::Start();
  1976 
  1977 	return	EPass ;
  1978 	}
  1979 
  1980 //------------------------------------------------------------------
  1981 
  1982 /**
  1983  * Constructor
  1984  */
  1985 CTestMmfAclntConvertDes::CTestMmfAclntConvertDes(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes)
  1986 	{
  1987 	// store the name of this test case
  1988 	// this is the name that is used by the script file
  1989 	// Each test step initialises it's own name
  1990 	iTestStepName = aTestName;
  1991 	iSectName = aSectName;
  1992 	iKeyName = aKeyName;
  1993 	iTestFormat = aFormat;
  1994 	iCreateDes = aCreateDes;
  1995 	iSize = 0;
  1996 	iAudio = NULL;
  1997 	//128K heap size
  1998 	iHeapSize = 0x20000;
  1999 	}
  2000 
  2001 CTestMmfAclntConvertDes* CTestMmfAclntConvertDes::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat,const TBool aCreateDes)
  2002 	{
  2003 	CTestMmfAclntConvertDes* self = new (ELeave) CTestMmfAclntConvertDes(aTestName,aSectName,aKeyName,aFormat,aCreateDes);
  2004 	return self;
  2005 	}
  2006 
  2007 CTestMmfAclntConvertDes* CTestMmfAclntConvertDes::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes)
  2008 	{
  2009 	CTestMmfAclntConvertDes* self = CTestMmfAclntConvertDes::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateDes);
  2010 	CleanupStack::PushL(self);
  2011 	return self;
  2012 	}
  2013 
  2014 void CTestMmfAclntConvertDes::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
  2015 	{
  2016 	iError = aErrorCode;
  2017 	INFO_PRINTF4( _L("MMdaObjectStateChangeObserver: previous state: %d current state: %d error: %d"),aPreviousState, aCurrentState, aErrorCode);
  2018 	CActiveScheduler::Stop();
  2019 	}
  2020 
  2021 TVerdict CTestMmfAclntConvertDes::DoTestStepPreambleL()
  2022 	{
  2023 
  2024 	SetupFormatL(iTestFormat);
  2025 
  2026 	RFs fs;
  2027 	RFile file;
  2028 
  2029 	// Connect to file server
  2030 	User::LeaveIfError(fs.Connect());
  2031 
  2032 	// get the filename from the config (.ini) file
  2033 	TBuf<KSizeBuf>	filename;
  2034 	TPtrC			filename1; 
  2035 	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
  2036 		return EInconclusive;
  2037 	GetDriveName(filename);
  2038 	filename.Append(filename1);
  2039 
  2040 	// opem the file to see if it exists and get the size
  2041 	User::LeaveIfError(file.Open(fs,filename,EFileRead));
  2042 	CleanupClosePushL(file);
  2043 
  2044 	User::LeaveIfError(file.Size(iSize));
  2045 	INFO_PRINTF2(_L("size of file is %d\n"),iSize);
  2046 
  2047 	// read the file into a descriptor and use CWavDecodeUtility
  2048 	// to examine the WAV file to get the data length etc.
  2049 	HBufC8* imageData = HBufC8::NewLC(iSize);
  2050 	TPtr8 imageDataPtr(imageData->Des());
  2051 	User::LeaveIfError(file.Read(imageDataPtr));
  2052 
  2053 	CWavDecodeUtility* decodeUtility = CWavDecodeUtility::NewL(imageDataPtr);
  2054 	CleanupStack::PushL(decodeUtility);
  2055 
  2056 	iDataLengthSource = decodeUtility->GetDataLength();
  2057 	iSamples = decodeUtility->GetSamples();
  2058 	iChannels = decodeUtility->GetChannels();
  2059 
  2060 	INFO_PRINTF2( _L("Sample Rate = %d"), decodeUtility->GetSampleRate());
  2061 
  2062 	INFO_PRINTF2( _L("Data length = %d"), iDataLengthSource);
  2063 	INFO_PRINTF2( _L("Channels = %d"), iChannels);
  2064 	INFO_PRINTF2( _L("Num of samples = %d"), iSamples);
  2065 
  2066 	CleanupStack::PopAndDestroy(3,&file); // decodeUtility, imageData, file
  2067 
  2068 	switch (iTestFormat)
  2069 		{
  2070 		case EPcm16Wav:
  2071 			iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL())
  2072 			iFrameSize = 4096;
  2073 			iFileSizeSink = KWavFileUncompressedDataHeaderSize + iSamples * iChannels * 16 /*BitsPerSample*/ / 8;
  2074 			break;
  2075 		
  2076 		case EAlawWav:
  2077 			iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL())
  2078 			iFrameSize = 4096;
  2079 			iFileSizeSink = KWavFileUncompressedDataHeaderSize + iSamples * iChannels * 8 /*BitsPerSample*/ / 8;
  2080 			break;
  2081 		
  2082 		case EPcm8:
  2083 			iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL())
  2084 			iFrameSize = 4096;
  2085 			iFileSizeSink = KWavFileUncompressedDataHeaderSize + iSamples * iChannels * 8 /*BitsPerSample*/ / 8;
  2086 			break;
  2087 		
  2088 		case EImaAdpcmWav:
  2089 		case EImasPcmWav:
  2090 			iHeaderSize = KWavFileCompressedDataHeaderSize + KImaAdpcmFactChunkSize;
  2091 			iFrameSize = 4096;
  2092 			break;
  2093 
  2094 		case EMulawRaw:
  2095 			iHeaderSize = 0;
  2096 			iFrameSize = 4096;
  2097 			iFileSizeSink = iSamples * iChannels * 8 /*BitsPerSample*/ / 8;
  2098 			break;
  2099 		
  2100 		case EPcmU8:
  2101 			iHeaderSize = 0;
  2102 			iFrameSize = 4096;
  2103 			iFileSizeSink = iSamples * iChannels * 8 /*BitsPerSample*/ / 8;
  2104 			break;
  2105 		
  2106 		case EPcmU16:
  2107 			iHeaderSize = 0;
  2108 			iFrameSize = 4096;
  2109 			iFileSizeSink = iSamples * iChannels * 16 /*BitsPerSample*/ / 8;
  2110 			break;
  2111 
  2112 		case EGsmWav:
  2113 			iHeaderSize = KWavFileCompressedDataHeaderSize + KGSMFactChunkSize;
  2114 			iFrameSize = 4096;
  2115 			break;
  2116 
  2117 		case E16BitAu:
  2118 			iHeaderSize = KAuFileUncompressedDataHeaderSize;
  2119 			iFrameSize = 4096;
  2120 			iFileSizeSink = iHeaderSize + iSamples * iChannels * 16 /*BitsPerSample*/ / 8;
  2121 
  2122 		default:				   
  2123 			/*skip*/ ;
  2124 			iHeaderSize = 0;
  2125 			iFrameSize = 1;
  2126 			break ;
  2127 		}
  2128 
  2129 	return CTestMmfAclntStep::DoTestStepPreambleL();
  2130 	}
  2131 
  2132 TVerdict CTestMmfAclntConvertDes::DoTestStepPostambleL()
  2133 	{
  2134 	delete iAudio;
  2135 	return CTestMmfAclntStep::DoTestStepPostambleL();
  2136 	}
  2137 
  2138 void CTestMmfAclntConvertDes::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
  2139 	{
  2140 	iError = aError;
  2141 	iDuration = aDuration;
  2142 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
  2143 	CActiveScheduler::Stop();
  2144 	}
  2145 
  2146 void CTestMmfAclntConvertDes::MapcPlayComplete(TInt aError)
  2147 	{
  2148 	iError = aError;
  2149 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
  2150 	CActiveScheduler::Stop();
  2151 	}
  2152 
  2153 /**
  2154  * Open a descriptor and Convertord
  2155  */
  2156 TVerdict CTestMmfAclntConvertDes::DoTestStepL( void )
  2157 	{
  2158 	INFO_PRINTF1( _L("TestConvertor : Convert Des"));
  2159 	TVerdict ret = EPass;
  2160 	HBufC8* audioTo = NULL;
  2161 	TMdaDesClipLocation* toLocation = NULL;
  2162 
  2163 	CMdaAudioConvertUtility* ConvertUtil = CMdaAudioConvertUtility::NewL(*this);
  2164 	CleanupStack::PushL(ConvertUtil);
  2165 
  2166 	TBuf<KSizeBuf>	filename;
  2167 	TPtrC			filename1;
  2168 	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
  2169 			return EInconclusive;
  2170 	GetDriveName(filename);
  2171 	filename.Append(filename1);
  2172 	//output buffer 2 much than input one
  2173 	audioTo = HBufC8::NewMaxLC(iSize*2);
  2174 	TPtr8 toBufferDes(audioTo->Des());
  2175 	toBufferDes.SetLength(0);
  2176 
  2177 	toLocation = new (ELeave) TMdaDesClipLocation(toBufferDes);
  2178 	CleanupStack::PushL(toLocation);
  2179 
  2180 	ConvertUtil->OpenL(filename, toLocation, 
  2181 			iFormat, iCodec) ; 
  2182 	
  2183 	iError = KErrTimedOut;
  2184 
  2185 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
  2186 	CActiveScheduler::Start();
  2187 
  2188 	if(iError == KErrNone)
  2189 		{
  2190 		iError = KErrTimedOut;
  2191 		ConvertUtil->ConvertL();
  2192 		INFO_PRINTF1( _L("Convertord CMdaAudioConvertUtility"));
  2193 		CActiveScheduler::Start(); // open->Convertord
  2194 
  2195 		if (iError == KErrNone)
  2196 			{
  2197 			// wait to run out of space Convertording
  2198 			CActiveScheduler::Start();
  2199 
  2200 			if(iError == KErrNone)
  2201 				{	
  2202 				INFO_PRINTF3(_L("Length %d, expected = %d"), audioTo->Length(), iFileSizeSink);
  2203 				// compare length with expected
  2204 				if (iFileSizeSink > 0)
  2205 					{
  2206 					//is it a good size?
  2207 					if((audioTo->Length()) != (static_cast<TInt> (iFileSizeSink)) )
  2208 						{
  2209 						ret = EFail;
  2210 						}
  2211 					}
  2212 				else
  2213 					{
  2214 					ret = EInconclusive;
  2215 					}
  2216 
  2217 				// For good measure,
  2218 				// check the validity of the conversion by comparing duration 
  2219 				// with original file - but not for raw files
  2220 				if (iHeaderSize > 0)
  2221 					{
  2222 					CMdaAudioPlayerUtility* player = NULL;
  2223 					player = CMdaAudioPlayerUtility::NewDesPlayerL(*audioTo, *this);
  2224 					CleanupStack::PushL(player);
  2225 
  2226 					// Wait for init callback
  2227 					INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
  2228 					CActiveScheduler::Start();
  2229 
  2230 					player->Play();
  2231 					// Wait for play complete callback
  2232 					INFO_PRINTF1( _L("CMdaAudioPlayerUtility::Play()"));
  2233 					CActiveScheduler::Start();
  2234 
  2235 					INFO_PRINTF3( _L("Duration = %ld, expected = %ld"), I64LOW(player->Duration().Int64()), I64LOW(ConvertUtil->Duration().Int64()));
  2236 
  2237 					if (iError != KErrNone)
  2238 						{
  2239 						ERR_PRINTF2( _L("Play failed with error : %d"),iError);
  2240 						ret = EFail;
  2241 						}
  2242 					else if (ConvertUtil->Duration() != player->Duration())
  2243 						{
  2244 						ERR_PRINTF3( _L("Actual Duration : %ld does not match the Expected Duration : %ld"),player->Duration().Int64(), ConvertUtil->Duration().Int64());
  2245 						ret = EFail;
  2246 						}
  2247 
  2248 					CleanupStack::PopAndDestroy(player);
  2249 					}
  2250 				}
  2251 			}
  2252 		}
  2253 
  2254 #if defined __WRITE_CONVERSION_TO_FILE
  2255 	{
  2256 	_LIT(KFileOutRaw, "\\TEST.AU");
  2257 	RFs fs;
  2258 
  2259 	fs.Connect();
  2260 	RFile file;
  2261 	file.Replace(fs, KFileOutRaw(), EFileWrite);
  2262 	file.Write(audioTo->Des());
  2263 	TInt len = audioTo->Length();
  2264 	file.Size(len);
  2265 	file.Close();
  2266 	fs.Close();
  2267 	}
  2268 #endif
  2269 	if (ret != EPass)
  2270 		ERR_PRINTF2( _L("CMdaAudioConvertorderUtility failed with error %d"),iError );
  2271 
  2272 	CleanupStack::PopAndDestroy(toLocation);
  2273 	CleanupStack::PopAndDestroy(audioTo);
  2274 	CleanupStack::PopAndDestroy(ConvertUtil);	
  2275 
  2276 	User::After(KOneSecond);
  2277 	return ret;
  2278 
  2279 	}
  2280 //---------------------------------------------------------------------
  2281 /**
  2282  * Constructor
  2283  */
  2284 CTestMmfAclntConvertUrl::CTestMmfAclntConvertUrl(const TDesC& aTestName, TBool aNegative)
  2285 	:CTestMmfAclntConConfig(aTestName, EAlawWav, aNegative) 
  2286 	{}
  2287 
  2288 CTestMmfAclntConvertUrl* CTestMmfAclntConvertUrl::NewL(const TDesC& aTestName, TBool aNegative)
  2289 	{
  2290 	CTestMmfAclntConvertUrl* self = new (ELeave) CTestMmfAclntConvertUrl(aTestName,aNegative);
  2291 	return self;
  2292 	}
  2293 
  2294 /**
  2295  * Set Urls
  2296  */
  2297 TVerdict CTestMmfAclntConvertUrl::DoTestStepL()
  2298 	{
  2299 	INFO_PRINTF1( _L("TestConvert : Urls"));
  2300 	TVerdict ret = EFail;
  2301 	TMdaUrlClipLocation* toLocation = new (ELeave)
  2302 		TMdaUrlClipLocation(_L("http://www.symbian.com"),KUseDefaultIap);
  2303 	CleanupStack::PushL(toLocation);
  2304 
  2305 	CMdaAudioConvertUtility* ConvertUtil = CMdaAudioConvertUtility::NewL(*this);
  2306 	CleanupStack::PushL(ConvertUtil);
  2307 
  2308 	TBuf<KSizeBuf>	fromFileName;
  2309 	TPtrC			pFromFileName;
  2310 	if(!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), pFromFileName))
  2311 			return EInconclusive;
  2312 	GetDriveName(fromFileName);
  2313 	fromFileName.Append(pFromFileName);
  2314 
  2315 	TRAP(iError, ConvertUtil->OpenL(fromFileName, toLocation, iFormat, iCodec)) ;
  2316 	if(iError == KErrNone)
  2317 	{
  2318 		//should not work for time being
  2319 		iError = KErrTimedOut;
  2320 		INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
  2321 		CActiveScheduler::Start();
  2322 		if(iError == KErrNotSupported)
  2323 			ret = EPass ;
  2324 		else
  2325 			{
  2326 
  2327    			TRAP(iError, ConvertUtil->ConvertL()) ;
  2328 			if(iError != KErrNone)
  2329 				{
  2330 				ERR_PRINTF2(_L("Convert left with error =  %d"),iError);
  2331 				ret = EFail;
  2332 				}
  2333 				
  2334 			CActiveScheduler::Start();
  2335 			if(iError == KErrNotSupported)
  2336 				ret = EPass ;
  2337 			}
  2338 		//CActiveScheduler::Start();
  2339 	}
  2340 	else if(iError == KErrNotSupported)
  2341 	{  //expected result
  2342 	
  2343 		ERR_PRINTF2(_L("OpenL left with error =  %d. It's OK for now!"),iError);
  2344 		ret = EPass ;	
  2345 	}
  2346 
  2347 	CleanupStack::PopAndDestroy(ConvertUtil);
  2348 	CleanupStack::PopAndDestroy(toLocation);
  2349 	return ret;
  2350 	}