os/mm/mmplugins/lib3gpunittest/src/tsu_3gplibrary_composer_api.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) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <e32std.h>
    17 #include "tsu_3gplibrary_composer_api.h"
    18 
    19 _LIT8(KDummyData, "DummyData");
    20 _LIT8(KFtypAtom, "ftyp");
    21 _LIT8(K3g2Brand, "3g2a");	// 3g2a
    22 _LIT8(K3gpBrand, "3gp");	// 3gp4, 3gp6
    23 _LIT8(KMp4Brand, "mp42");	// mp42 
    24 
    25 _LIT(KLargeVideoFile, "c:\\3gplibrary\\cube-xvid-640x480-10fps-10s.3gp");
    26 const TInt KLargeFileWriteBufferSize = 16384;  // 16K
    27 const TInt KLargeFileWriteBufferMaxCount = 15;
    28 const TInt64 K3GigaBytes = 0xC0000000;
    29 
    30 // -----------------------------------------------------------------------------
    31 // C3GPLibComposeBase - this should not be used directly
    32 // -----------------------------------------------------------------------------
    33 //     
    34 C3GPLibComposeBase::C3GPLibComposeBase()
    35 	{
    36 	}
    37 
    38 TVerdict C3GPLibComposeBase::doTestStepPreambleL()
    39 	{
    40 	// ensure there's always a Active Scheduler for the Composer
    41 	if (!CActiveScheduler::Current())
    42 		{
    43 		iScheduler = new (ELeave) CActiveScheduler;
    44 		CActiveScheduler::Install(iScheduler);	
    45 		}
    46 	
    47 	SetTestStepResult(EPass);
    48 	return TestStepResult();
    49 	}
    50 
    51 TVerdict C3GPLibComposeBase::doTestStepPostambleL()
    52 	{
    53 	if (iScheduler)
    54 		{
    55 		CActiveScheduler::Install(NULL);
    56 		delete iScheduler;
    57 		}
    58 	
    59 	return TestStepResult();
    60 	}
    61 
    62 TVerdict C3GPLibComposeBase::doTestStepL()
    63 	{
    64 	if (TestStepResult() != EPass)
    65 		{
    66 		return TestStepResult();
    67 		}
    68 	SetTestStepError(KErrNone);
    69 	
    70 	C3GPCompose* composer = doTestStepCreateComposerL(); 
    71 	CleanupStack::PushL(composer);
    72 	
    73 	doTestStepComposeOpenL(*composer);
    74 	if (TestStepResult() == EPass)
    75 		{
    76 		// set it to EFail, if both calls below does not leave, then it will be reset
    77 		// back to EPass
    78 		SetTestStepResult(EFail);
    79 		doTestStepComposeWriteVideoAudioL(*composer);
    80 		doTestStepComposeSetUserDataL(*composer);
    81 		SetTestStepResult(EPass);
    82 		}
    83 		
    84 	TInt err = composer->Complete();
    85 	if (err != KErrNone)
    86 		{
    87 		SetTestStepResult(EFail);
    88 		User::Leave(err);
    89 		}
    90 	CleanupStack::PopAndDestroy(composer);	
    91 	
    92 	return TestStepResult();
    93 	}
    94 
    95 C3GPCompose* C3GPLibComposeBase::doTestStepCreateComposerL()
    96 	{
    97 	return C3GPCompose::NewL();
    98 	}
    99 
   100 void C3GPLibComposeBase::doTestStepComposeWriteVideoAudioL(C3GPCompose& /* aComposer */)
   101 	{
   102 	}
   103 
   104 void C3GPLibComposeBase::doTestStepComposeSetUserDataL(C3GPCompose& /* aComposer */)
   105 	{
   106 	}
   107 
   108 // -----------------------------------------------------------------------------
   109 // C3GPLibComposeFilename
   110 // -----------------------------------------------------------------------------
   111 //     
   112 C3GPLibComposeFilename::C3GPLibComposeFilename()
   113 	{
   114 	}
   115 
   116 TVerdict C3GPLibComposeFilename::doTestStepPreambleL()
   117 	{
   118 	// ensure all basic setup is completed first
   119 	C3GPLibComposeBase::doTestStepPreambleL();	
   120 	if (TestStepResult() == EPass)
   121 		{
   122 		TPtrC fileNamePtr;
   123 		if (GetStringFromConfig(ConfigSection(), _L("filename"), fileNamePtr))
   124 			{
   125 			// save a copy of the filename specified for the test
   126 			iFilename.CreateL(fileNamePtr);		
   127 			}
   128 		else 
   129 			{
   130 			// cannot find filename!
   131 			ERR_PRINTF1(_L("Filename not specified.  Test cannot proceed."));
   132 			SetTestStepResult(ETestSuiteError);
   133 			}
   134 		}
   135 	
   136 	return TestStepResult();
   137 	}
   138 
   139 TVerdict C3GPLibComposeFilename::doTestStepPostambleL()
   140 	{
   141 	iFilename.Close();
   142 	
   143 	// clean up all composer test base setups
   144 	C3GPLibComposeBase::doTestStepPostambleL();
   145 	
   146 	return TestStepResult();
   147 	}
   148 
   149 void C3GPLibComposeFilename::doTestStepComposeOpenL(C3GPCompose& aComposer)
   150 	{
   151 	T3GPAudioPropertiesMpeg4Audio audio(100, KDummyData);
   152 	T3GPVideoPropertiesAvc video(100, TSize(100, 100), KDummyData);
   153 	
   154 	TInt err = aComposer.Open(E3GP3GP, &video, &audio, iFilename);
   155 	if (err != KErrNone)
   156 		{		
   157 		if (!ShouldRunOOMTest())
   158 			{
   159 			ERR_PRINTF2(_L("C3GPCompose::Open failed with error = %d"), err);
   160 			}
   161 		SetTestStepError(err);
   162 		SetTestStepResult(EFail);
   163 		}
   164 	else 
   165 		{
   166 		INFO_PRINTF1(_L("C3GPCompose::Open completes with no error"));
   167 		SetTestStepResult(EPass);
   168 		}
   169 	}
   170 
   171 // -----------------------------------------------------------------------------
   172 // C3GPLibComposeWithoutOpen
   173 // -----------------------------------------------------------------------------
   174 //     
   175 C3GPLibComposeWithoutOpen::C3GPLibComposeWithoutOpen()
   176 	{
   177 	}
   178 
   179 void C3GPLibComposeWithoutOpen::doTestStepComposeOpenL(C3GPCompose& /* aComposer */)
   180 	{
   181 	// This test needs the composer NOT initialised.  Do nothing here
   182 	}
   183 
   184 void C3GPLibComposeWithoutOpen::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
   185 	{
   186 	if (TestStepResult() != EPass)
   187 		{
   188 		return;
   189 		}
   190 	
   191 	TInt err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue);
   192 	if (err != KErrNotReady)
   193 		{
   194 		ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame failed with error = %d instead of KErrNotReady"), err);
   195 		SetTestStepResult(EFail);				
   196 		}
   197 	
   198 	if (TestStepResult() == EPass)
   199 		{
   200 		T3GPFrameDependencies dependencies;	
   201 		err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue, dependencies);
   202 		if (err != KErrNotReady)
   203 			{
   204 			ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame failed with error = %d instead of KErrNotReady"), err);
   205 			SetTestStepResult(EFail);				
   206 			}		
   207 		}
   208 	
   209 	if (TestStepResult() == EPass)
   210 		{
   211 		err = aComposer.WriteAudioFrames(KDummyData, 100);
   212 		if (err != KErrNotReady)
   213 			{
   214 			ERR_PRINTF2(_L("C3GPCompose::WriteAudioFrames failed with error = %d instead of KErrNotReady"), err);			
   215 			SetTestStepResult(EFail);				
   216 			}				
   217 		}	
   218 	}
   219 
   220 void C3GPLibComposeWithoutOpen::doTestStepComposeSetUserDataL(C3GPCompose& aComposer)
   221 	{
   222 	if (TestStepResult() != EPass)
   223 		{
   224 		return;
   225 		}
   226 	
   227 	TInt err = aComposer.SetUserData(E3GPUdtaMoov, KDummyData);
   228 	if (err != KErrNotReady)
   229 		{
   230 		ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err);			
   231 		SetTestStepResult(EFail);				
   232 		}				
   233 	
   234 	if (TestStepResult() == EPass)
   235 		{
   236 		err = aComposer.SetUserData(E3GPUdtaVideoTrak, KDummyData);
   237 		if (err != KErrNotReady)
   238 			{
   239 			ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err);			
   240 			SetTestStepResult(EFail);				
   241 			}
   242 		}
   243 
   244 	if (TestStepResult() == EPass)
   245 		{
   246 		err = aComposer.SetUserData(E3GPUdtaAudioTrak, KDummyData);
   247 		if (err != KErrNotReady)
   248 			{
   249 			ERR_PRINTF2(_L("C3GPCompose::SetUserData failed with error = %d instead of KErrNotReady"), err);			
   250 			SetTestStepResult(EFail);				
   251 			}
   252 		}
   253 	}
   254 
   255 // -----------------------------------------------------------------------------
   256 // C3GPLibComposeFile
   257 // -----------------------------------------------------------------------------
   258 //     
   259 C3GPLibComposeFile::C3GPLibComposeFile() :
   260 	iInputFileFormat(E3GP3GP),
   261 	iVideoType(E3GPNoVideo),
   262 	iAudioType(E3GPNoAudio)
   263 	{
   264 	}
   265 
   266 TVerdict C3GPLibComposeFile::doTestStepPreambleL()
   267 	{
   268 	// ensure the base class setup is completed first
   269 	C3GPLibComposeBase::doTestStepPreambleL();
   270 	if (TestStepResult() == EPass)
   271 		{		
   272 		TInt temp;
   273 		if (GetIntFromConfig(ConfigSection(), _L("inputFormat"), temp))
   274 			{
   275 			iInputFileFormat = (T3GPFileFormatType)temp;
   276 			
   277 			if (GetIntFromConfig(ConfigSection(), _L("video"), temp))
   278 				{
   279 				iVideoType = (T3GPVideoType)temp;
   280 				}
   281 			
   282 			if (GetIntFromConfig(ConfigSection(), _L("audio"), temp))
   283 				{
   284 				iAudioType = (T3GPAudioType)temp;
   285 				}
   286 				
   287 			if (iVideoType == E3GPNoVideo && iAudioType == E3GPNoAudio)
   288 				{
   289 				// At least audio or video should be specified
   290 				ERR_PRINTF1(_L("Specify at least video or audio"));
   291 				SetTestStepResult(ETestSuiteError);
   292 				}			
   293 			else
   294 				{
   295 				#ifdef __WINSCW__
   296 				_LIT(KTestFolderName, "testFolderNameEmu");
   297 				#else
   298 				_LIT(KTestFolderName, "testFolderNameHw");
   299 				#endif
   300 
   301 				TPtrC testFolderName;
   302 				if (GetStringFromConfig(_L("general"), KTestFolderName, testFolderName))
   303 					{
   304 					TInt err = iFs.Connect();					
   305 					if (err == KErrNone)
   306 						{			
   307 						iFs.MkDirAll(testFolderName);
   308 
   309 						TFileName fileName;												
   310 						// Create a temp file for the composer to write data into
   311 						err = iFile.Temp(iFs, testFolderName, fileName, EFileShareExclusive);						
   312 						if (err == KErrNone)
   313 							{
   314 							iFileName.CreateL(fileName);						
   315 							}
   316 						}
   317 					
   318 					if (err != KErrNone)
   319 						{
   320 						ERR_PRINTF1(_L("Fail to create temp file for testing."));
   321 						SetTestStepResult(ETestSuiteError);
   322 						}			
   323 					}
   324 				else
   325 					{
   326 					ERR_PRINTF1(_L("Fail to provide test directory."));			
   327 					SetTestStepResult(ETestSuiteError);
   328 					}
   329 				}				
   330 			}
   331 		else 
   332 			{
   333 			// file format has to be specified 
   334 			ERR_PRINTF1(_L("Specify file format of the file to be composed"));
   335 			SetTestStepResult(ETestSuiteError);		
   336 			}
   337 		}
   338 
   339 	return TestStepResult();
   340 	}
   341 
   342 TVerdict C3GPLibComposeFile::doTestStepPostambleL()
   343 	{	
   344 	// clean up of temp file
   345 	iFile.Close();
   346 	iFs.Delete(iFileName);	
   347 	iFs.Close();
   348 	
   349 	iFileName.Close();
   350 	
   351 	// clean up all composer test base setups	
   352 	C3GPLibComposeBase::doTestStepPostambleL();
   353 
   354 	return TestStepResult();
   355 	}
   356 
   357 void C3GPLibComposeFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
   358 	{
   359 	T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
   360 	CleanupStack::PushL(video);
   361 	
   362 	T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); 
   363 	CleanupStack::PushL(audio);
   364 
   365 	TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile);
   366 	if (err == KErrNone)
   367 		{
   368 		SetTestStepResult(EPass);
   369 		}
   370 	else 
   371 		{		
   372 		if (!ShouldRunOOMTest())
   373 			{
   374 			ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err);
   375 			}
   376 		SetTestStepError(err);
   377 		SetTestStepResult(EInconclusive);
   378 		} 
   379 	
   380 	CleanupStack::PopAndDestroy(2);	// audio, video
   381 	}
   382 
   383 void C3GPLibComposeFile::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
   384 	{
   385 	// add a dummy video frame.  The content is of no importance for this test case, 
   386 	// only the file format is of interest
   387 	TInt err = KErrNone;
   388 	
   389 	if (iVideoType != E3GPNoVideo)
   390 		{
   391 		err = aComposer.WriteVideoFrame(KDummyData, 10, ETrue);
   392 		if (err != KErrNone)
   393 			{
   394 			ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
   395 			}
   396 		}
   397 	
   398 	if (err == KErrNone && iAudioType != E3GPNoAudio)
   399 		{
   400 		// add a dummy audio frame.  The content is of no importance for this test case, 
   401 		// only the file format is of interest
   402 		err = aComposer.WriteAudioFrames(KDummyData, 10);
   403 		if (err != KErrNone)
   404 			{			
   405 			ERR_PRINTF2(_L("Fail to write audio frame, err = %d"), err);
   406 			} 	
   407 		}
   408 
   409 	if (err != KErrNone)
   410 		{			
   411 		SetTestStepResult(EInconclusive); 
   412 		} 		
   413 	}
   414 
   415 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupVideoPropertiesL()
   416 	{
   417 	if (iVideoType == E3GPNoVideo)
   418 		{
   419 		return NULL;
   420 		}
   421 
   422 	// create a dummy video property for setting the composer
   423 	T3GPVideoPropertiesBase* video = NULL;
   424 	switch(iVideoType)
   425 		{
   426 		case E3GPMpeg4Video:
   427 			video = SetupMpeg4VideoL();		
   428 			break;
   429 			
   430 		case E3GPAvcProfileBaseline:
   431 		case E3GPAvcProfileMain:
   432 		case E3GPAvcProfileExtended:
   433 		case E3GPAvcProfileHigh:
   434 			video = SetupAvcVideoL();
   435 			break;
   436 			
   437 		case E3GPH263Profile0:
   438 		case E3GPH263Profile3:
   439 			video = SetupH263VideoL();
   440 			break;
   441 			
   442 		default:
   443 			User::Leave(KErrUnknown);
   444 		}
   445 	
   446 	return video;
   447 	}
   448 
   449 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupAvcVideoL()
   450 	{
   451 	T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(1000, TSize(100, 100), KDummyData);
   452 	return video;
   453 	}
   454 
   455 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupH263VideoL()
   456 	{
   457 	T3GPVideoPropertiesH263::TProfile profile = T3GPVideoPropertiesH263::EProfile0;
   458 	if (iVideoType == E3GPH263Profile3)
   459 		{
   460 		profile = T3GPVideoPropertiesH263::EProfile3;
   461 		}
   462 	T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesH263(1000, TSize(100, 100), 10, profile);	
   463 	return video;
   464 	}
   465 
   466 T3GPVideoPropertiesBase* C3GPLibComposeFile::SetupMpeg4VideoL()
   467 	{
   468 	T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesMpeg4Video(1000, TSize(100, 100), 4000, 400, KDummyData);
   469 	return video;
   470 	}
   471 
   472 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupAudioPropertiesL()
   473 	{
   474 	if (iAudioType == E3GPNoAudio)
   475 		{
   476 		return NULL;
   477 		}
   478 
   479 	// create a dummy audio property for setting the composer
   480 	T3GPAudioPropertiesBase* audio = NULL;
   481 	switch(iAudioType)
   482 		{
   483 		case E3GPMpeg4Video:
   484 			audio = SetupMpeg4AudioL();
   485 			break;
   486 			
   487 		case E3GPQcelp13K:
   488 			audio = SetupQcelpAudioL();
   489 			break;
   490 			
   491 		case E3GPAmrNB:			
   492 		case E3GPAmrWB:
   493 			audio = SetupAmrAudioL();
   494 			break;
   495 			
   496 		default:
   497 			User::Leave(KErrUnknown);
   498 			break;
   499 		}
   500 	
   501 	return audio;
   502 	}
   503 
   504 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupQcelpAudioL()
   505 	{
   506 	// for this test's purpose, just use the default QCELP sample entry storage mode 
   507 	T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesQcelp(1000, 10);
   508 	return audio;
   509 	}
   510 
   511 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupAmrAudioL()
   512 	{
   513 	T3GPAudioPropertiesAmr::TSpeechCodec codec = T3GPAudioPropertiesAmr::EAmrWB;
   514 	if (iAudioType == E3GPAmrNB)
   515 		{
   516 		codec = T3GPAudioPropertiesAmr::EAmrNB;
   517 		}
   518 	T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesAmr(1000, 10, 150, codec);
   519 	return audio;
   520 	}
   521 
   522 T3GPAudioPropertiesBase* C3GPLibComposeFile::SetupMpeg4AudioL()
   523 	{
   524 	T3GPAudioPropertiesBase* audio = new (ELeave)T3GPAudioPropertiesMpeg4Audio(1000, KDummyData);
   525 	return audio;
   526 	}
   527 
   528 // -----------------------------------------------------------------------------
   529 // C3GPLibComposeFileWithFileFormatCheck
   530 // -----------------------------------------------------------------------------
   531 //     
   532 C3GPLibComposeFileWithFileFormatCheck::C3GPLibComposeFileWithFileFormatCheck() :
   533 	iOutputFileFormat(E3GP3GP)
   534 	{
   535 	}
   536 
   537 TVerdict C3GPLibComposeFileWithFileFormatCheck::doTestStepPreambleL()
   538 	{
   539 	// ensure base class setup is completed first
   540 	C3GPLibComposeFile::doTestStepPreambleL();
   541 	
   542 	if (TestStepResult() == EPass)
   543 		{
   544 		TInt temp;
   545 		if (!GetIntFromConfig(ConfigSection(), _L("outputFormat"), temp))
   546 			{
   547 			ERR_PRINTF1(_L("outputFormat not specified"));
   548 			SetTestStepResult(ETestSuiteError);
   549 			}
   550 		else 
   551 			{	
   552 			iOutputFileFormat = (T3GPFileFormatType)temp;		
   553 			}
   554 		}
   555 	
   556 	return TestStepResult();
   557 	}
   558 
   559 TVerdict C3GPLibComposeFileWithFileFormatCheck::doTestStepL()
   560 	{
   561 	if (TestStepResult() != EPass)
   562 		{
   563 		return TestStepResult();
   564 		}
   565 	
   566 	// this triggers: 
   567 	// 1. Create a composer
   568 	// 2. Open the composer - C3GPLibComposeFileFormatCheck::doTestStepComposeOpenL
   569 	// 3. Write Video & Audio Data - C3GPLibComposeFileFormatCheck::doTestStepComposeWriteVideoAudioL
   570 	// 4. Write User Data - C3GPLibComposeFileFormatCheck::doTestStepComposeSetUserDataL
   571 	// 5. Complete the composer 
   572 	TVerdict verdict = C3GPLibComposeFile::doTestStepL();
   573 	if (verdict == EPass)
   574 		{
   575 		// once the file is composed, it can be verified if the file composed is the same as the 
   576 		// expected file format 
   577 		verdict = VerifyFileFormatL(iFile);
   578 		}
   579 	else
   580 		{
   581 		INFO_PRINTF1(_L("<C3GPLibComposeFileWithFileFormatCheck> C3GPLibComposeFile::doTestStepL returns failed result"));		
   582 		}
   583 	SetTestStepResult(verdict);
   584 		
   585 	if (!ShouldRunOOMTest())
   586 		{
   587 		INFO_PRINTF2(_L("C3GPLibComposeFile::doTestStepL returns %d"), TestStepResult());	
   588 		}
   589 	return TestStepResult();		
   590 	}
   591 
   592 TVerdict C3GPLibComposeFileWithFileFormatCheck::VerifyFileFormatL(const RFile& aFile) 
   593 	{
   594 	// Seek to the beginning of the file
   595 	TInt pos = 0;	
   596 	User::LeaveIfError(aFile.Seek(ESeekStart, pos));
   597 	
   598 	TVerdict verdict = EFail;
   599 	TBuf8<4> atom;
   600 
   601 	while(ETrue)
   602 		{
   603 		// read the file content and search for the 'ftyp' atom to check
   604 		// the 32bit value of brand attribute immediately following the 'ftyp' type.
   605 		User::LeaveIfError(aFile.Read(atom));
   606 		if (atom.Length() < atom.MaxLength())
   607 			{
   608 			break;
   609 			}
   610 			
   611 		// read 4 bytes at a time, if 'ftyp' is found
   612 		if (Mem::Compare((&KFtypAtom)->Ptr(), (&KFtypAtom)->Length(), atom.Ptr(), atom.Length()) == 0)
   613 			{
   614 			// read 4 more bytes, and it should contain the brand value
   615 			User::LeaveIfError(aFile.Read(atom));
   616 			if (atom.Length() < atom.MaxLength())
   617 				{
   618 				// cannot read brand value, test failed.
   619 				ERR_PRINTF1(_L("Failed to read enough data for comparison."));						
   620 				break;
   621 				}
   622 			
   623 			switch(iOutputFileFormat)
   624 				{
   625 				case E3GP3G2:
   626 					{
   627 					// check if file type is 3G2
   628 					if (!ShouldRunOOMTest())
   629 						{
   630 						INFO_PRINTF1(_L("Check 3GP2 file format."));
   631 						}
   632 					if (Mem::Compare((&K3g2Brand)->Ptr(), (&K3g2Brand)->Length(), atom.Ptr(), atom.Length()) == 0)
   633 						{
   634 						verdict = EPass;
   635 						break;
   636 						}
   637 					}
   638 				break;
   639 			
   640 				case E3GPMP4:
   641 					{
   642 					if (!ShouldRunOOMTest())
   643 						{
   644 						INFO_PRINTF1(_L("Check MP4 file format."));
   645 						}
   646 					// check if file type is MP4
   647 					if (Mem::Compare((&KMp4Brand)->Ptr(), (&KMp4Brand)->Length(), atom.Ptr(), atom.Length()) == 0)
   648 						{
   649 						verdict = EPass;
   650 						}
   651 					}
   652 				break;
   653 				
   654 				case E3GP3GP:
   655 					{
   656 					if (!ShouldRunOOMTest())
   657 						{
   658 						INFO_PRINTF1(_L("Check 3GP file format."));
   659 						}
   660 					// check if file type is 3GP
   661 					// Both 3gp4 & 3gp6 are valid brands, thus checking ONLY "3gp" instead of the full atom size 
   662 					if (Mem::Compare((&K3gpBrand)->Ptr(), (&K3gpBrand)->Length(), atom.Ptr(), (&K3gpBrand)->Length()) == 0)						
   663 						{
   664 						verdict = EPass;
   665 						}					
   666 					}
   667 				break;		
   668 					
   669 				default:
   670 					INFO_PRINTF1(_L("Unknown format expected."));																					
   671 					verdict = EInconclusive;	
   672 				break;	
   673 				}
   674 			
   675 			// ftyp is found, regardless of the result, finish reading the file
   676 			break;
   677 			}
   678 		}
   679 		
   680 	return verdict;
   681 	}
   682 
   683 // -----------------------------------------------------------------------------
   684 // C3GPLibComposeFrameDependency
   685 // -----------------------------------------------------------------------------
   686 //     
   687 C3GPLibComposeFrameDependency::C3GPLibComposeFrameDependency()
   688 	{
   689 	}
   690 
   691 void C3GPLibComposeFrameDependency::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
   692 	{
   693 	TInt err = KErrNone;
   694 	T3GPFrameDependencies dep;
   695 		
   696 	for (TInt i = 0; i <= (TInt)E3GPDependencyNone; i++)
   697 		{
   698 		for (TInt j = 0; j <= (TInt)E3GPDependencyNone; j++)
   699 			{
   700 			for (TInt k = 0; k <= (TInt)E3GPRedundancyNone; k++)
   701 				{
   702 				dep.iDependsOn = (T3GPVideoFrameDependency)i;
   703 				dep.iIsDependedOn = (T3GPVideoFrameDependency)j;
   704 				dep.iHasRedundancy = (T3GPVideoFrameRedundancy)k;
   705 
   706 				// add a dummy video frame.  The content is of no importance for this test case, 
   707 				// only the different dependency/redundancy is the focus of this test
   708 				err = aComposer.WriteVideoFrame(KDummyData, 100, ETrue, dep);
   709 				if (err != KErrNone)
   710 					{
   711 					ERR_PRINTF2(_L("C3GPCompose::WriteVideoFrame (with frame dependency) failed with error = %d"), err);
   712 					SetTestStepResult(EFail);
   713 					break;
   714 					}
   715 				}
   716 			}
   717 		}
   718 	}
   719 
   720 // -----------------------------------------------------------------------------
   721 // C3GPLibComposeVideoProperties
   722 // -----------------------------------------------------------------------------
   723 //     
   724 C3GPLibComposeVideoProperties::C3GPLibComposeVideoProperties()
   725 	{	
   726 	}
   727 
   728 TVerdict C3GPLibComposeVideoProperties::doTestStepPreambleL()
   729 	{
   730 	C3GPLibComposeFile::doTestStepPreambleL();
   731 	if (TestStepResult() != EPass)
   732 		{
   733 		return TestStepResult();
   734 		}
   735 		
   736 	TInt temp;
   737 	TBool result = ETrue;
   738 	result = GetIntFromConfig(ConfigSection(), _L("width"), temp);
   739 	if (result)
   740 		{
   741 		iSize.iWidth = temp;
   742 		result = GetIntFromConfig(ConfigSection(), _L("height"), temp); 
   743 		if (result)
   744 			{
   745 			iSize.iHeight = temp;
   746 			result = GetIntFromConfig(ConfigSection(), _L("timescale"), temp);
   747 			if (result)
   748 				{
   749 				iTimescale = temp;
   750 				}			
   751 			}
   752 		}
   753 	
   754 	if (result && 
   755 	        (iVideoType == E3GPMpeg4Video ||
   756 	         iVideoType == E3GPAvcProfileBaseline ||
   757 	         iVideoType == E3GPAvcProfileMain ||
   758 	         iVideoType == E3GPAvcProfileExtended ||
   759 	         iVideoType == E3GPAvcProfileHigh )
   760         )
   761 		{
   762 		TPtrC decoder;
   763 		result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder);
   764 		if (result)
   765 			{	
   766 			iDecoderSpecInfo.CreateL(decoder.Length());
   767 			iDecoderSpecInfo.Copy(decoder);
   768 			}
   769 		}
   770 	
   771 	if (result && (iVideoType == E3GPMpeg4Video))
   772 		{
   773 		result = GetIntFromConfig(ConfigSection(), _L("avgBR"), temp);
   774 		if (result)
   775 			{
   776 			iAvgBitRate = temp;
   777 			result = GetIntFromConfig(ConfigSection(), _L("maxBR"), temp);
   778 			if (result)
   779 				{
   780 				iMaxBitRate = temp;
   781 				}			
   782 			}
   783 		}	
   784 	
   785 	if (result && (iVideoType == E3GPH263Profile0 || iVideoType == E3GPH263Profile3))
   786 		{
   787 		result = GetIntFromConfig(ConfigSection(), _L("level"), temp);
   788 		if (result)
   789 			{
   790 			iVideoLevel = temp;
   791 			}
   792 		}
   793 	
   794 	if (!result)
   795 		{
   796 		ERR_PRINTF1(_L("Cannot retrieve necessary video properties to complete this test."));
   797 		SetTestStepResult(ETestSuiteError);		
   798 		}
   799 
   800 	return TestStepResult();
   801 	}
   802 
   803 TVerdict C3GPLibComposeVideoProperties::doTestStepPostambleL()
   804 	{	
   805 	iDecoderSpecInfo.Close();
   806 	
   807 	// clean up base class setups	
   808 	C3GPLibComposeFile::doTestStepPostambleL();
   809 	
   810 	return TestStepResult();
   811 	}
   812 
   813 T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupAvcVideoL()
   814 	{
   815 	T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(iTimescale, iSize, iDecoderSpecInfo);
   816 	return video;
   817 	}
   818 
   819 T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupH263VideoL()
   820 	{
   821 	T3GPVideoPropertiesH263::TProfile profile = T3GPVideoPropertiesH263::EProfile0;
   822 	if (iVideoType == E3GPH263Profile3)
   823 		{
   824 		profile = T3GPVideoPropertiesH263::EProfile3;
   825 		}
   826 	T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesH263(iTimescale, iSize, iVideoLevel, profile);	
   827 	return video;
   828 	}
   829 
   830 T3GPVideoPropertiesBase* C3GPLibComposeVideoProperties::SetupMpeg4VideoL()
   831 	{
   832 	T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesMpeg4Video(iTimescale, 
   833 																				iSize, 
   834 																				iMaxBitRate, 
   835 																				iAvgBitRate, 
   836 																				iDecoderSpecInfo);
   837 	return video;
   838 	}
   839 
   840 // -----------------------------------------------------------------------------
   841 // C3GPLibComposeWithSpecificBufferSize
   842 // -----------------------------------------------------------------------------
   843 //     
   844 C3GPLibComposeWithSpecificBufferSize::C3GPLibComposeWithSpecificBufferSize()
   845 	{	
   846 	}
   847 
   848 TVerdict C3GPLibComposeWithSpecificBufferSize::doTestStepPreambleL()
   849 	{
   850 	TVerdict verdict = C3GPLibComposeFile::doTestStepPreambleL();
   851 	if (verdict != EPass)
   852 		{
   853 		return verdict;
   854 		}
   855 		
   856 	TInt temp;
   857 	if (GetIntFromConfig(ConfigSection(), _L("bufferSize"), temp))
   858 		{
   859 		iBufferSize = temp;		
   860 		if (GetIntFromConfig(ConfigSection(), _L("bufferCount"), temp)) 
   861 			{
   862 			iBufferMaxCount = temp;
   863 			}
   864 		else
   865 			{
   866 			ERR_PRINTF1(_L("C3GPLibComposeWithSpecificBufferSize cannot read Buffer Max Count"));		
   867 			SetTestStepResult(ETestSuiteError);			
   868 			}
   869 		}
   870 	else
   871 		{
   872 		ERR_PRINTF1(_L("C3GPLibComposeWithSpecificBufferSize cannot read Buffer Size"));		
   873 		SetTestStepResult(ETestSuiteError);
   874 		}
   875 	
   876 	return TestStepResult(); 
   877 	}
   878 	
   879 C3GPCompose* C3GPLibComposeWithSpecificBufferSize::doTestStepCreateComposerL()
   880 	{
   881 	return C3GPCompose::NewL(iBufferSize, iBufferMaxCount);
   882 	}
   883 
   884 // -----------------------------------------------------------------------------
   885 // C3GPLibComposeUserData
   886 // -----------------------------------------------------------------------------
   887 //     
   888 C3GPLibComposeUserData::C3GPLibComposeUserData() :
   889 	iUdtaLocation(-1)
   890 	{
   891 	}
   892 
   893 TVerdict C3GPLibComposeUserData::doTestStepPreambleL()	
   894 	{
   895 	// ensure all basic setup is completed first
   896 	C3GPLibComposeFile::doTestStepPreambleL();	
   897 	if (TestStepResult() == EPass)
   898 		{
   899 		GetBoolFromConfig(ConfigSection(), _L("udtaMoov"), iUdtaMoov);
   900 		GetBoolFromConfig(ConfigSection(), _L("udtaVideo"), iUdtaVideo);
   901 		GetBoolFromConfig(ConfigSection(), _L("udtaAudio"), iUdtaAudio);
   902 		GetIntFromConfig(ConfigSection(), _L("udtaLocation"), iUdtaLocation);
   903 		
   904 		if (!iUdtaMoov && !iUdtaVideo && !iUdtaAudio && iUdtaLocation == -1)
   905 			{
   906 			ERR_PRINTF1(_L("No user data location is specified.  Test cannot proceed."));
   907 			SetTestStepResult(ETestSuiteError);												
   908 			}
   909 		else
   910 			{
   911 			TPtrC userDataPtr;
   912 			if (GetStringFromConfig(ConfigSection(), _L("userData"), userDataPtr))
   913 				{					
   914 				iUserData.CreateL(userDataPtr.Length());
   915 				iUserData.Copy(userDataPtr);
   916 				}
   917 			else
   918 				{
   919 				// user data not specified, use dummy data
   920 				iUserData.CreateL(KDummyData);
   921 				}
   922 			}
   923 		}
   924 	
   925 	return TestStepResult();
   926 	}
   927 	
   928 TVerdict C3GPLibComposeUserData::doTestStepPostambleL()
   929 	{	
   930 	iUserData.Close();
   931 	
   932 	// clean up base class setups	
   933 	C3GPLibComposeFile::doTestStepPostambleL();
   934 	
   935 	return TestStepResult();
   936 	}
   937 
   938 void C3GPLibComposeUserData::doTestStepComposeSetUserDataL(C3GPCompose& aComposer)
   939 	{
   940 	TInt err = KErrNone;
   941 	if (iUdtaVideo)
   942 		{
   943 		err = aComposer.SetUserData(E3GPUdtaVideoTrak, iUserData);
   944 		if (err != KErrNone)
   945 			{
   946 			ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaVideoTrak) fails with %d"), err);
   947 			SetTestStepError(err);
   948 			}
   949 		}
   950 	if (iUdtaAudio)
   951 		{
   952 		err = aComposer.SetUserData(E3GPUdtaAudioTrak, iUserData);
   953 		if (err != KErrNone)
   954 			{
   955 			ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaAudioTrak) fails with %d"), err);
   956 			SetTestStepError(err);
   957 			}
   958 		}
   959 	if (iUdtaMoov)
   960 		{
   961 		err = aComposer.SetUserData(E3GPUdtaMoov, iUserData);
   962 		if (err != KErrNone)
   963 			{
   964 			ERR_PRINTF2(_L("C3GPComposer::SetUserData(E3GPUdtaMoov) fails with %d"), err);
   965 			SetTestStepError(err);
   966 			}
   967 		}
   968 	
   969 	if (iUdtaLocation != -1)
   970 		{
   971 		// if a specific user data location has been specified, try it!
   972 		err = aComposer.SetUserData((T3GPUdtaLocation)iUdtaLocation, iUserData);
   973 		if (err != KErrNone)
   974 			{
   975 			ERR_PRINTF3(_L("C3GPComposer::SetUserData(%d) fails with %d"), iUdtaLocation, err);
   976 			SetTestStepError(err);
   977 			}		
   978 		}
   979 	}
   980 
   981 // -----------------------------------------------------------------------------
   982 // C3GPLibComposeWithFlag
   983 // -----------------------------------------------------------------------------
   984 //     
   985 C3GPLibComposeWithFlag::C3GPLibComposeWithFlag()
   986 	{
   987 	}
   988 
   989 TVerdict C3GPLibComposeWithFlag::doTestStepPreambleL()
   990 	{
   991 	// ensure the base class setup is completed first
   992 	C3GPLibComposeFile::doTestStepPreambleL();
   993 	if (TestStepResult() == EPass)
   994 		{		
   995 		if (!GetIntFromConfig(ConfigSection(), _L("flag"), iComposeFlag))
   996 			{
   997 			ERR_PRINTF1(_L("C3GPLibComposeWithFlag::doTestStepPreambleL cannot retrieve any composer flags."));
   998 			SetTestStepResult(ETestSuiteError);
   999 			}
  1000 		}
  1001 	return TestStepResult();
  1002 	}
  1003 
  1004 void C3GPLibComposeWithFlag::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1005 	{
  1006 	T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
  1007 	CleanupStack::PushL(video);
  1008 	
  1009 	T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); 
  1010 	CleanupStack::PushL(audio);
  1011 
  1012 	TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile, iComposeFlag);
  1013 	if (err == KErrNone)
  1014 		{
  1015 		SetTestStepResult(EPass);
  1016 		}
  1017 	else 
  1018 		{		
  1019 		ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err);
  1020 		SetTestStepResult(EInconclusive);
  1021 		} 
  1022 	
  1023 	CleanupStack::PopAndDestroy(2);	// audio, video
  1024 	}
  1025 
  1026 // -----------------------------------------------------------------------------
  1027 // C3GPLibComposeAudioProperties
  1028 // -----------------------------------------------------------------------------
  1029 //     
  1030 C3GPLibComposeAudioProperties::C3GPLibComposeAudioProperties()
  1031 	{	
  1032 	}
  1033 
  1034 TVerdict C3GPLibComposeAudioProperties::doTestStepPreambleL()
  1035 	{
  1036 	C3GPLibComposeFile::doTestStepPreambleL();
  1037 	if (TestStepResult() != EPass)
  1038 		{
  1039 		return TestStepResult();
  1040 		}
  1041 		
  1042 	TInt temp;
  1043 	TBool result = ETrue;
  1044 	result = GetIntFromConfig(ConfigSection(), _L("timescale"), temp);
  1045 	if (result)
  1046 		{
  1047 		iTimescale = temp;
  1048 		}			
  1049 	
  1050 	if (result && (iAudioType == E3GPQcelp13K))
  1051 		{
  1052 		result = GetIntFromConfig(ConfigSection(), _L("storage"), temp);
  1053 		if (result)
  1054 			{
  1055 			iQCelpMode = (T3GPQcelpStorageMode) temp;
  1056 			if (iQCelpMode == E3GPMP4AudioDescriptionBox)
  1057 				{
  1058 				TPtrC decoder;
  1059 				result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder);
  1060 				if (result)
  1061 					{	
  1062 					iDecoderSpecInfo.CreateL(decoder.Length());
  1063 					iDecoderSpecInfo.Copy(decoder);
  1064 					}				
  1065 				}
  1066 			}
  1067 		
  1068 		if (result)
  1069 			{
  1070 			result = GetIntFromConfig(ConfigSection(), _L("fps"), iFps);
  1071 			}		
  1072 		}
  1073 
  1074 	if (result && (iAudioType == E3GPMpeg4Audio))
  1075 		{
  1076 		TPtrC decoder;
  1077 		result = GetStringFromConfig(ConfigSection(), _L("decoderSpecInfo"), decoder);
  1078 		if (result)
  1079 			{	
  1080 			iDecoderSpecInfo.CreateL(decoder.Length());
  1081 			iDecoderSpecInfo.Copy(decoder);
  1082 			}						
  1083 		}
  1084 	
  1085 	if (result && (iAudioType == E3GPAmrNB || iAudioType == E3GPAmrWB))
  1086 		{
  1087 		result = GetIntFromConfig(ConfigSection(), _L("modeSet"), iModeSet);
  1088 		if (result)
  1089 			{
  1090 			result = GetIntFromConfig(ConfigSection(), _L("fps"), iFps);
  1091 			}
  1092 		}
  1093 		
  1094 	if (!result)
  1095 		{
  1096 		//  
  1097 		ERR_PRINTF1(_L("Cannot retrieve necessary a properties to complete this test."));
  1098 		SetTestStepResult(ETestSuiteError);		
  1099 		}
  1100 
  1101 	return TestStepResult();
  1102 	}
  1103 
  1104 TVerdict C3GPLibComposeAudioProperties::doTestStepPostambleL()
  1105 	{	
  1106 	iDecoderSpecInfo.Close();
  1107 	
  1108 	// clean up base class setups	
  1109 	C3GPLibComposeFile::doTestStepPostambleL();
  1110 	
  1111 	return TestStepResult();
  1112 	}
  1113 
  1114 T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupQcelpAudioL()
  1115 	{
  1116 	T3GPAudioPropertiesBase* audio = NULL;
  1117 	
  1118 	if (iQCelpMode == E3GPQcelpSampleEntryBox)
  1119 		{		
  1120 		audio = new (ELeave) T3GPAudioPropertiesQcelp(iTimescale, iFps);
  1121 		}
  1122 	else if (iQCelpMode == E3GPMP4AudioDescriptionBox)
  1123 		{
  1124 		audio = new (ELeave) T3GPAudioPropertiesQcelp(iTimescale, iFps, iDecoderSpecInfo);
  1125 		}
  1126 	else
  1127 		{
  1128 		User::Leave(KErrNotFound);
  1129 		}
  1130 	
  1131 	return audio;
  1132 	}
  1133 
  1134 T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupAmrAudioL()
  1135 	{
  1136 	T3GPAudioPropertiesAmr::TSpeechCodec codec = T3GPAudioPropertiesAmr::EAmrWB;
  1137 	if (iAudioType == E3GPAmrNB)
  1138 		{
  1139 		codec = T3GPAudioPropertiesAmr::EAmrNB;
  1140 		}
  1141 	T3GPAudioPropertiesBase* audio = new (ELeave) T3GPAudioPropertiesAmr(iTimescale, iFps, iModeSet, codec);
  1142 	return audio;
  1143 	}
  1144 
  1145 T3GPAudioPropertiesBase* C3GPLibComposeAudioProperties::SetupMpeg4AudioL()
  1146 	{
  1147 	T3GPAudioPropertiesBase* audio = new (ELeave)T3GPAudioPropertiesMpeg4Audio(iTimescale, iDecoderSpecInfo);
  1148 	return audio;
  1149 	}
  1150 
  1151 // -----------------------------------------------------------------------------
  1152 // C3GPLibComposeWithNoAudioVideo
  1153 // -----------------------------------------------------------------------------
  1154 //     
  1155 C3GPLibComposeWithNoAudioVideo::C3GPLibComposeWithNoAudioVideo()
  1156 	{
  1157 	}
  1158 
  1159 TVerdict C3GPLibComposeWithNoAudioVideo::doTestStepPreambleL()
  1160 	{
  1161 	// ensure the base class setup is completed first
  1162 	C3GPLibComposeFile::doTestStepPreambleL();
  1163 	if (TestStepResult() == EPass)
  1164 		{
  1165 		// reset the video / audio type both of No Video & No Audio
  1166 		iVideoType = E3GPNoVideo;
  1167 		iAudioType = E3GPNoAudio;		
  1168 		}
  1169 	
  1170 	return TestStepResult();
  1171 	}
  1172 
  1173 // -----------------------------------------------------------------------------
  1174 // C3GPLibComposeAudioFrames
  1175 // -----------------------------------------------------------------------------
  1176 //     
  1177 C3GPLibComposeAudioFrames::C3GPLibComposeAudioFrames()
  1178 	{
  1179 	}
  1180 
  1181 TVerdict C3GPLibComposeAudioFrames::doTestStepPreambleL()
  1182 	{
  1183 	// ensure all basic setup is completed first
  1184 	C3GPLibComposeFile::doTestStepPreambleL();	
  1185 	if (TestStepResult() == EPass)
  1186 		{
  1187 		if (GetIntFromConfig(ConfigSection(), _L("duration"), iDuration))
  1188 			{
  1189 			TPtrC audioFramePtr;
  1190 			if (GetStringFromConfig(ConfigSection(), _L("audioFrame"), audioFramePtr))
  1191 				{					
  1192 				iAudioFrames.CreateL(audioFramePtr.Length());
  1193 				iAudioFrames.Copy(audioFramePtr);					
  1194 				}
  1195 			else
  1196 				{
  1197 				// cannot find expected error!
  1198 				ERR_PRINTF1(_L("audioFrame not specified.  Test cannot proceed."));
  1199 				SetTestStepResult(ETestSuiteError);									
  1200 				}
  1201 			}
  1202 		else
  1203 			{
  1204 			// cannot find expected error!
  1205 			ERR_PRINTF1(_L("duration not specified.  Test cannot proceed."));
  1206 			SetTestStepResult(ETestSuiteError);				
  1207 			}
  1208 		} 
  1209 	
  1210 	return TestStepResult();
  1211 	}
  1212 
  1213 TVerdict C3GPLibComposeAudioFrames::doTestStepPostambleL()
  1214 	{
  1215 	// cleanup
  1216 	iAudioFrames.Close();
  1217 	
  1218 	// ensure all base cleanup is done
  1219 	C3GPLibComposeFile::doTestStepPostambleL();
  1220 	
  1221 	return TestStepResult();
  1222 	}
  1223 
  1224 void C3GPLibComposeAudioFrames::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
  1225 	{
  1226 	// add the audio frame  
  1227 	TInt err = aComposer.WriteAudioFrames(iAudioFrames, iDuration); 
  1228 	if (err != KErrNone)
  1229 		{			
  1230 		if (!ShouldRunOOMTest())
  1231 			{
  1232 			INFO_PRINTF2(_L("C3GPCompose::WriteAudioFrames returns %d"), err);		
  1233 			}
  1234 		SetTestStepError(err); 
  1235 		}
  1236 	}
  1237 
  1238 // -----------------------------------------------------------------------------
  1239 // C3GPLibComposeVideoFrame
  1240 // -----------------------------------------------------------------------------
  1241 //     
  1242 C3GPLibComposeVideoFrame::C3GPLibComposeVideoFrame()
  1243 	{
  1244 	}
  1245 
  1246 TVerdict C3GPLibComposeVideoFrame::doTestStepPreambleL()
  1247 	{
  1248 	// ensure all basic setup is completed first
  1249 	C3GPLibComposeFile::doTestStepPreambleL();	
  1250 	if (TestStepResult() == EPass)
  1251 		{
  1252 		if (GetBoolFromConfig(ConfigSection(), _L("keyFrame"), iKeyFrame))
  1253 			{
  1254 			if (GetIntFromConfig(ConfigSection(), _L("duration"), iDuration))
  1255 				{
  1256 				TPtrC framePtr;
  1257 				if (GetStringFromConfig(ConfigSection(), _L("videoFrame"), framePtr))
  1258 					{					
  1259 					iVideoFrame.CreateL(framePtr.Length());
  1260 					iVideoFrame.Copy(framePtr);
  1261 
  1262 					TInt dependsOn;
  1263 					TInt isDependedOn;
  1264 					TInt hasRedundancy;
  1265 					if (GetIntFromConfig(ConfigSection(), _L("dependsOn"), dependsOn) &&
  1266 						GetIntFromConfig(ConfigSection(), _L("isDependedOn"), isDependedOn) && 							
  1267 						GetIntFromConfig(ConfigSection(), _L("hasRedundancy"), hasRedundancy))
  1268 						{
  1269 						iDependencies = new (ELeave) T3GPFrameDependencies();
  1270 						iDependencies->iDependsOn = (T3GPVideoFrameDependency) dependsOn;
  1271 						iDependencies->iIsDependedOn = (T3GPVideoFrameDependency) isDependedOn;
  1272 						iDependencies->iHasRedundancy = (T3GPVideoFrameRedundancy) hasRedundancy;
  1273 						}
  1274 					}
  1275 				else
  1276 					{
  1277 					// cannot find expected error!
  1278 					ERR_PRINTF1(_L("videoFrame not specified.  Test cannot proceed."));
  1279 					SetTestStepResult(ETestSuiteError);									
  1280 					}
  1281 				}
  1282 			else
  1283 				{
  1284 				// cannot find expected error!
  1285 				ERR_PRINTF1(_L("duration not specified.  Test cannot proceed."));
  1286 				SetTestStepResult(ETestSuiteError);				
  1287 				}
  1288 			}
  1289 		else 
  1290 			{
  1291 			// cannot find expected error!
  1292 			ERR_PRINTF1(_L("keyFrame not specified.  Test cannot proceed."));
  1293 			SetTestStepResult(ETestSuiteError);
  1294 			}
  1295 		}
  1296 	
  1297 	return TestStepResult();
  1298 	}
  1299 
  1300 TVerdict C3GPLibComposeVideoFrame::doTestStepPostambleL()
  1301 	{
  1302 	// cleanup
  1303 	iVideoFrame.Close();
  1304 	delete iDependencies;
  1305 	
  1306 	// ensure all base cleanup is done
  1307 	C3GPLibComposeFile::doTestStepPostambleL();
  1308 	
  1309 	return TestStepResult();
  1310 	}
  1311 
  1312 void C3GPLibComposeVideoFrame::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
  1313 	{
  1314 	// add the video frame
  1315 	TInt err = KErrNone;
  1316 	if (iDependencies)
  1317 		{
  1318 		err = aComposer.WriteVideoFrame(iVideoFrame, iDuration, iKeyFrame, *iDependencies);		
  1319 		}
  1320 	else
  1321 		{
  1322 		err = aComposer.WriteVideoFrame(iVideoFrame, iDuration, iKeyFrame);		
  1323 		}
  1324 	
  1325 	if (err != KErrNone)
  1326 		{			
  1327 		INFO_PRINTF2(_L("C3GPCompose::WriteVideoFrame returns %d"), err);		
  1328 		SetTestStepError(err); 
  1329 		} 		
  1330 	}
  1331 
  1332 // -----------------------------------------------------------------------------
  1333 // C3GPLibComposeOpenAgain
  1334 // -----------------------------------------------------------------------------
  1335 //     
  1336 C3GPLibComposeOpenAgain::C3GPLibComposeOpenAgain()
  1337 	{	
  1338 	}
  1339 
  1340 void C3GPLibComposeOpenAgain::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1341 	{
  1342 	C3GPLibComposeFile::doTestStepComposeOpenL(aComposer);
  1343 	if (TestStepResult() == EPass)
  1344 		{		
  1345 		// ensure the composer is opened, then try open it again!		
  1346 		T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
  1347 		CleanupStack::PushL(video);
  1348 		
  1349 		T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); 
  1350 		CleanupStack::PushL(audio);
  1351 		
  1352 		// retrieve the current location of the temp file created when 
  1353 		// opening the composer the first time in C3GPLibComposeFile::doTestStepComposeOpenL
  1354 		RBuf folderName;
  1355 		folderName.CreateL(KMaxFileName);
  1356 		CleanupClosePushL(folderName);
  1357 		User::LeaveIfError(iFile.FullName(folderName));
  1358 				
  1359 		TParsePtrC folderParse(folderName);
  1360 		TPtrC folder = folderParse.DriveAndPath();
  1361 		
  1362 		// create another file temp file within the same folder
  1363 		RFile file;
  1364 		TFileName fileName; 
  1365 		User::LeaveIfError(file.Temp(iFs, folder, fileName, EFileWrite));
  1366 
  1367 		TInt err = aComposer.Open(iInputFileFormat, video, audio, file);		
  1368 		TInt err2 = aComposer.Open(iInputFileFormat, video, audio, fileName);
  1369 		if (err != KErrNone && err == err2)
  1370 			{
  1371 			SetTestStepError(err);
  1372 			}
  1373 		else
  1374 			{
  1375 			INFO_PRINTF1(_L("C3GPLibComposeOpenAgain C3GPCompose::Open returns inconsistent error."));			
  1376 			}
  1377 		
  1378 		// clean up
  1379 		file.Close();
  1380 		iFs.Delete(fileName);
  1381 		
  1382 		CleanupStack::PopAndDestroy(3);	// audio, video, folderName
  1383 		}
  1384 	}
  1385 
  1386 // -----------------------------------------------------------------------------
  1387 // C3GPLibComposeOpenReadOnlyFile
  1388 // -----------------------------------------------------------------------------
  1389 //     
  1390 C3GPLibComposeOpenReadOnlyFile::C3GPLibComposeOpenReadOnlyFile()
  1391 	{	
  1392 	}
  1393 
  1394 void C3GPLibComposeOpenReadOnlyFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1395 	{
  1396 	RBuf fileName;
  1397 	fileName.CreateL(KMaxFilename);
  1398 	CleanupClosePushL(fileName);
  1399 
  1400 	// change the file to be opened to be a READ-ONLY file
  1401 	User::LeaveIfError(iFile.FullName(fileName));
  1402 	iFile.Close();
  1403 	
  1404 	User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareReadersOnly));
  1405 	CleanupStack::PopAndDestroy(&fileName);
  1406 	
  1407 	C3GPLibComposeWithFlag::doTestStepComposeOpenL(aComposer);
  1408 	}
  1409 
  1410 TVerdict C3GPLibComposeOpenReadOnlyFile::doTestStepL()
  1411 	{	
  1412 	TVerdict verdict(EFail);
  1413 	
  1414 	TRAP_IGNORE(verdict = C3GPLibComposeWithFlag::doTestStepL());
  1415 	
  1416 	return verdict;
  1417 	}
  1418 
  1419 // -----------------------------------------------------------------------------
  1420 // C3GPLibComposeOpenedFile
  1421 // -----------------------------------------------------------------------------
  1422 //     
  1423 C3GPLibComposeOpenedFile::C3GPLibComposeOpenedFile()
  1424 	{	
  1425 	}
  1426 
  1427 void C3GPLibComposeOpenedFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1428 	{
  1429 	RBuf fileName;
  1430 	fileName.CreateL(KMaxFilename);
  1431 	CleanupClosePushL(fileName);
  1432 
  1433 	// change the file to be opened to be a READ-ONLY file
  1434 	User::LeaveIfError(iFile.FullName(fileName));
  1435 	iFile.Close();
  1436 	
  1437 	User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareAny));
  1438 	
  1439 	T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
  1440 	CleanupStack::PushL(video);
  1441 	
  1442 	T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); 
  1443 	CleanupStack::PushL(audio);
  1444 
  1445 	TInt err1 = aComposer.Open(iInputFileFormat, video, audio, fileName);
  1446 	if (err1 != KErrNone)
  1447 		{
  1448 		if (!ShouldRunOOMTest())
  1449 			{
  1450 			ERR_PRINTF2(_L("C3GPLibComposeOpenedFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err1);		
  1451 			}
  1452 		
  1453 		iFile.Close();
  1454 		User::LeaveIfError(iFile.Open(iFs, fileName, EFileShareReadersOrWriters));
  1455 		TInt err2 = aComposer.Open(iInputFileFormat, video, audio, fileName);
  1456 		
  1457 		if (err1 == err2)
  1458 			{
  1459 			SetTestStepError(err1);
  1460 			}
  1461 		}
  1462 	
  1463 	CleanupStack::PopAndDestroy(3);	// audio, video, fileName
  1464 	}
  1465 
  1466 // -----------------------------------------------------------------------------
  1467 // C3GPLibComposeMultiComposeOnSameFile
  1468 // -----------------------------------------------------------------------------
  1469 //     
  1470 C3GPLibComposeMultiComposeOnSameFile::C3GPLibComposeMultiComposeOnSameFile()
  1471 	{	
  1472 	}
  1473 
  1474 void C3GPLibComposeMultiComposeOnSameFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1475 	{
  1476 	C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
  1477 	if (TestStepError() == KErrNone && TestStepResult() == EPass)
  1478 		{
  1479 		T3GPAudioPropertiesMpeg4Audio audio(100, KDummyData);
  1480 		T3GPVideoPropertiesAvc video(100, TSize(100, 100), KDummyData);
  1481 		C3GPCompose* composer2 = C3GPCompose::NewL();
  1482 		
  1483 		TInt err = composer2->Open(E3GP3GP, &video, &audio, iFilename);
  1484 		if (err != KErrNone)
  1485 			{		
  1486 			SetTestStepError(err);
  1487 			}
  1488 			
  1489 		// close the composer
  1490 		composer2->Complete();
  1491 		delete composer2;
  1492 		} 
  1493 	}
  1494 
  1495 // -----------------------------------------------------------------------------
  1496 // C3GPLibComposeMultiComposers
  1497 // -----------------------------------------------------------------------------
  1498 //     
  1499 C3GPLibComposeMultiComposers::C3GPLibComposeMultiComposers()
  1500 	{	
  1501 	}
  1502 
  1503 void C3GPLibComposeMultiComposers::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1504 	{
  1505 	C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
  1506 	if (TestStepError() == KErrNone && TestStepResult() == EPass)
  1507 		{
  1508 		#ifdef __WINSCW__
  1509 		_LIT(KTestFolderName, "testFolderNameEmu");
  1510 		#else
  1511 		_LIT(KTestFolderName, "testFolderNameHw");
  1512 		#endif
  1513 
  1514 		TPtrC testFolderName;
  1515 		if (!GetStringFromConfig(_L("general"), KTestFolderName, testFolderName))
  1516 			{
  1517 			User::Leave(KErrNotFound);
  1518 			}
  1519 		
  1520 		TFileName fileName;
  1521 		RFs fs;
  1522 		User::LeaveIfError(fs.Connect());
  1523 		CleanupClosePushL(fs);
  1524 
  1525 		// Composer 2
  1526 		T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData);
  1527 		T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData);
  1528 		
  1529 		RFile file1;
  1530 		CleanupClosePushL(file1);		
  1531 		User::LeaveIfError(file1.Temp(fs, testFolderName, fileName, EFileShareExclusive));
  1532 		
  1533 		C3GPCompose* composer2 = C3GPCompose::NewL();		
  1534 		CleanupStack::PushL(composer2);
  1535 		User::LeaveIfError(composer2->Open(E3GP3GP, &video1, &audio1, file1));
  1536 			
  1537 		// composer 3
  1538 		T3GPAudioPropertiesMpeg4Audio audio2(50, KDummyData);
  1539 		T3GPVideoPropertiesAvc video2(50, TSize(20, 20), KDummyData);
  1540 		
  1541 		RFile file2;
  1542 		CleanupClosePushL(file2);		
  1543 		User::LeaveIfError(file2.Temp(fs, testFolderName, fileName, EFileShareExclusive));
  1544 		
  1545 		C3GPCompose* composer3 = C3GPCompose::NewL();		
  1546 		CleanupStack::PushL(composer3);
  1547 		User::LeaveIfError(composer3->Open(E3GP3GP, &video2, &audio2, file2));
  1548 		
  1549 		// write some data into composer 1, then 2, then 3
  1550 		User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse));
  1551 		User::LeaveIfError(composer2->WriteVideoFrame(KDummyData, 10, EFalse));
  1552 		User::LeaveIfError(composer3->WriteVideoFrame(KDummyData, 10, EFalse));
  1553 		
  1554 		// clean up for composer 3
  1555 		User::LeaveIfError(composer3->Complete());
  1556 		CleanupStack::PopAndDestroy(composer3);		
  1557 		CleanupStack::PopAndDestroy(&file2);	
  1558 		
  1559 		// Parse file2
  1560 		C3GPParse* parser = C3GPParse::NewL();
  1561 		CleanupStack::PushL(parser);
  1562 		User::LeaveIfError(parser->Open(fileName));
  1563 		
  1564 		// write some data into composer 1 & 2
  1565 		User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse));				
  1566 		User::LeaveIfError(composer2->WriteVideoFrame(KDummyData, 10, EFalse));
  1567 		
  1568 		// close parser and delete the file
  1569 		User::LeaveIfError(parser->Complete());
  1570 		CleanupStack::PopAndDestroy(parser);
  1571 		User::LeaveIfError(fs.Delete(fileName));	// delete the temp file created
  1572 		
  1573 		// clean up for composer 2
  1574 		User::LeaveIfError(composer2->Complete());	
  1575 		file1.FullName(fileName);					// retrieve the full name of file1
  1576 		CleanupStack::PopAndDestroy(composer2);	
  1577 		CleanupStack::PopAndDestroy(&file1);
  1578 		User::LeaveIfError(fs.Delete(fileName));	// delete the temp file created
  1579 		
  1580 		// cleanup
  1581 		CleanupStack::PopAndDestroy(&fs);
  1582 		
  1583 		// write some data into composer 1
  1584 		User::LeaveIfError(aComposer.WriteVideoFrame(KDummyData, 10, EFalse));		
  1585 		} 
  1586 	}
  1587 
  1588 // -----------------------------------------------------------------------------
  1589 // C3GPLibComposeCloseComposerWithoutComplete
  1590 // -----------------------------------------------------------------------------
  1591 //     
  1592 C3GPLibComposeCloseComposerWithoutComplete::C3GPLibComposeCloseComposerWithoutComplete()
  1593 	{	
  1594 	}
  1595 
  1596 void C3GPLibComposeCloseComposerWithoutComplete::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1597 	{
  1598 	// close the composer, then delete the file
  1599 	aComposer.Complete();
  1600 		
  1601 	RFs fs;
  1602 	User::LeaveIfError(fs.Connect());
  1603 	CleanupClosePushL(fs);
  1604 		
  1605 	// ignore any error
  1606 	fs.Delete(iFilename);
  1607 
  1608 	// Reopens it
  1609 	T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData);
  1610 	T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData);
  1611 
  1612 	C3GPCompose* composer = C3GPCompose::NewL();		
  1613 	CleanupStack::PushL(composer);
  1614 	User::LeaveIfError(composer->Open(E3GP3GP, &video1, &audio1, iFilename));
  1615 		
  1616 	// write some data into composer 1, then 2, then 3
  1617 	User::LeaveIfError(composer->WriteVideoFrame(KDummyData, 10, EFalse));
  1618 	
  1619 	// delete the composer before calling Complete
  1620 	CleanupStack::PopAndDestroy(composer);
  1621 	
  1622 	RFile file;
  1623 	CleanupClosePushL(file);
  1624 	User::LeaveIfError(file.Open(fs, iFilename, EFileRead));
  1625 	
  1626 	TInt fileSize = 0;
  1627 	User::LeaveIfError(file.Size(fileSize));
  1628 
  1629 	if (fileSize == 0)
  1630 		{
  1631 		SetTestStepResult(EFail);
  1632 		}
  1633 	
  1634 	CleanupStack::PopAndDestroy(2);	// file, fs
  1635 
  1636 	// continue the test
  1637 	C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
  1638 	}
  1639 
  1640 // -----------------------------------------------------------------------------
  1641 // C3GPLibComposePanic
  1642 // -----------------------------------------------------------------------------
  1643 //     
  1644 C3GPLibComposePanic::C3GPLibComposePanic()
  1645 	{	
  1646 	}
  1647 
  1648 TVerdict C3GPLibComposePanic::doTestStepPreambleL()
  1649 	{
  1650 	TVerdict verdict = C3GPLibComposeFilename::doTestStepPreambleL();
  1651 	if (TestStepResult() == EPass)
  1652 		{
  1653 		if (!GetBoolFromConfig(ConfigSection(), _L("panic"), iPanic))
  1654 			{
  1655 			ERR_PRINTF1(_L("Test setting panic not specified.  Test cannot proceed."));			
  1656 			SetTestStepResult(ETestSuiteError);
  1657 			}
  1658 		else 
  1659 			{
  1660 			TPtrC strPtr;
  1661 			if (GetStringFromConfig(ConfigSection(), _L("dir"), strPtr))
  1662 				{
  1663 				// save a copy of the dir specified for the test
  1664 				iDir.CreateL(strPtr);		
  1665 				}
  1666 			else 
  1667 				{
  1668 				// cannot find filename!
  1669 				ERR_PRINTF1(_L("Dir not specified.  Test cannot proceed."));
  1670 				SetTestStepResult(ETestSuiteError);
  1671 				}
  1672 			}
  1673 		}
  1674 	
  1675 	return TestStepResult();
  1676 	}
  1677 
  1678 void C3GPLibComposePanic::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1679 	{
  1680 	// close the composer, then delete the file
  1681 	aComposer.Complete();
  1682 		
  1683 	RFs fs;
  1684 	User::LeaveIfError(fs.Connect());
  1685 	CleanupClosePushL(fs);
  1686 		
  1687 	// retrieve the number of items in the directory
  1688 	CDir* dirList = NULL;
  1689 	User::LeaveIfError(fs.GetDir(iDir, KEntryAttNormal, ESortNone, dirList));			
  1690 	TInt orgCount = dirList->Count();
  1691 	delete dirList;
  1692 
  1693 	// Reopens it
  1694 	T3GPAudioPropertiesMpeg4Audio audio1(100, KDummyData);
  1695 	T3GPVideoPropertiesAvc video1(100, TSize(100, 100), KDummyData);
  1696 
  1697 	C3GPCompose* composer = C3GPCompose::NewL();		
  1698 	CleanupStack::PushL(composer);
  1699 	User::LeaveIfError(composer->Open(E3GP3GP, &video1, &audio1, iFilename));
  1700 		
  1701 	// write some data into composer 1, then 2, then 3
  1702 	User::LeaveIfError(composer->WriteVideoFrame(KDummyData, 10, EFalse));
  1703 	
  1704 	if (iPanic)
  1705 		{
  1706 		// force a panic so that the composed file and the temporary file is left in the 
  1707 		// directory
  1708 		User::Panic(_L("Testing"), KErrArgument);
  1709 		}
  1710 	
  1711 	// delete the composer before calling Complete
  1712 	composer->Complete();
  1713 	CleanupStack::PopAndDestroy(composer);
  1714 	
  1715 	User::LeaveIfError(fs.GetDir(iDir, KEntryAttNormal, ESortNone, dirList));			
  1716 	TInt newCount = dirList->Count();
  1717 	delete dirList;
  1718 	
  1719 	// When cleaned up properly, only the composed file should be left within the directory.
  1720 	if (!(newCount == 1 && orgCount > 0))
  1721 		{
  1722 		SetTestStepResult(EFail);
  1723 		}
  1724 	
  1725 	CleanupStack::PopAndDestroy();	// fs
  1726 
  1727 	// continue the test
  1728 	C3GPLibComposeFilename::doTestStepComposeOpenL(aComposer);
  1729 	}
  1730 
  1731 TVerdict C3GPLibComposePanic::doTestStepPostambleL()
  1732 	{
  1733 	iDir.Close();
  1734 	return 	C3GPLibComposeFilename::doTestStepPostambleL();
  1735 	}
  1736 
  1737 // -----------------------------------------------------------------------------
  1738 // C3GPLibComposeLargeFile
  1739 // -----------------------------------------------------------------------------
  1740 //     
  1741 C3GPLibComposeLargeFile::C3GPLibComposeLargeFile()
  1742 	{	
  1743 	}
  1744 
  1745 TVerdict C3GPLibComposeLargeFile::doTestStepPreambleL()
  1746 	{
  1747 	// ensure the base class setup is completed first
  1748 	C3GPLibComposeBase::doTestStepPreambleL();
  1749 	if (TestStepResult() == EPass)
  1750 		{		
  1751 		TInt temp;
  1752 		if (GetIntFromConfig(ConfigSection(), _L("inputFormat"), temp))
  1753 			{
  1754 			iInputFileFormat = (T3GPFileFormatType)temp;
  1755 			
  1756 			if (GetIntFromConfig(ConfigSection(), _L("video"), temp))
  1757 				{
  1758 				iVideoType = (T3GPVideoType)temp;
  1759 				}
  1760 			
  1761 			if (GetIntFromConfig(ConfigSection(), _L("audio"), temp))
  1762 				{
  1763 				iAudioType = (T3GPAudioType)temp;
  1764 				}
  1765 				
  1766 			if (iVideoType == E3GPNoVideo && iAudioType == E3GPNoAudio)
  1767 				{
  1768 				// At least audio or video should be specified
  1769 				ERR_PRINTF1(_L("Specify at least video or audio"));
  1770 				SetTestStepResult(ETestSuiteError);
  1771 				}			
  1772 			else
  1773 				{
  1774 				#ifdef __WINSCW__
  1775 				_LIT(KOutputDir, "filenameEmu");
  1776 				#else
  1777 				_LIT(KOutputDir, "filenameHw");
  1778 				#endif
  1779 
  1780 				TPtrC fileNamePtr;
  1781 				if (GetStringFromConfig(ConfigSection(), KOutputDir, fileNamePtr))
  1782 					{
  1783 					iFileName.CreateL(fileNamePtr);
  1784 					User::LeaveIfError(iFs.Connect());
  1785 
  1786 					TInt err = iFs.MkDirAll(iFileName);
  1787 					if (err != KErrNone && err != KErrAlreadyExists)
  1788 						{
  1789 						User::Leave(err);
  1790 						}
  1791 
  1792 					err = iFile64.Create(iFs, iFileName, EFileShareAny|EFileStream|EFileWrite);
  1793 					if (err == KErrAlreadyExists)
  1794 						{
  1795 						User::LeaveIfError(iFile64.Replace(iFs, iFileName, EFileShareAny|EFileStream|EFileWrite));
  1796 						}
  1797 					else
  1798 						{
  1799 						User::LeaveIfError(err);
  1800 						}	
  1801 					}
  1802 				else 
  1803 					{
  1804 					// cannot find filename!
  1805 					ERR_PRINTF1(_L("Filename not specified.  Test cannot proceed."));
  1806 					SetTestStepResult(ETestSuiteError);
  1807 					}
  1808 				}				
  1809 			}
  1810 		else 
  1811 			{
  1812 			// file format has to be specified 
  1813 			ERR_PRINTF1(_L("Specify file format of the file to be composed"));
  1814 			SetTestStepResult(ETestSuiteError);		
  1815 			}
  1816 
  1817 		if (!GetIntFromConfig(ConfigSection(), _L("flag"), iComposeFlag))
  1818 			{
  1819 			iComposeFlag = E3GPNoFlag;
  1820 			}
  1821 		}
  1822 
  1823 	return TestStepResult();
  1824 	}
  1825 
  1826 TVerdict C3GPLibComposeLargeFile::doTestStepPostambleL()
  1827 	{	
  1828 	// clean up of temp file
  1829 	iFile64.Close();
  1830 	iFs.Delete(iFileName);
  1831 	iFs.Close();
  1832 	
  1833 	iFileName.Close();
  1834 	
  1835 	// clean up all composer test base setups	
  1836 	C3GPLibComposeBase::doTestStepPostambleL();
  1837 
  1838 	return TestStepResult();
  1839 	}
  1840 
  1841 C3GPCompose* C3GPLibComposeLargeFile::doTestStepCreateComposerL()
  1842 	{
  1843 	return C3GPCompose::NewL(KLargeFileWriteBufferSize, KLargeFileWriteBufferMaxCount);
  1844 	}
  1845 
  1846 void C3GPLibComposeLargeFile::doTestStepComposeOpenL(C3GPCompose& aComposer)
  1847 	{
  1848 	T3GPVideoPropertiesBase* video = SetupVideoPropertiesL();
  1849 	CleanupStack::PushL(video);
  1850 	
  1851 	T3GPAudioPropertiesBase* audio = SetupAudioPropertiesL(); 
  1852 	CleanupStack::PushL(audio);
  1853 
  1854 	TInt err = aComposer.Open(iInputFileFormat, video, audio, iFile64, iComposeFlag);
  1855 	if (err == KErrNone)
  1856 		{
  1857 		SetTestStepResult(EPass);
  1858 		}
  1859 	else 
  1860 		{		
  1861 		if (!ShouldRunOOMTest())
  1862 			{
  1863 			ERR_PRINTF2(_L("C3GPLibComposeFile::doTestStepComposeOpenL => C3GPComposer::Open returns = %d"), err);
  1864 			}
  1865 		SetTestStepError(err);
  1866 		SetTestStepResult(EInconclusive);
  1867 		} 
  1868 	
  1869 	CleanupStack::PopAndDestroy(2);	// audio, video
  1870 	}
  1871 
  1872 void C3GPLibComposeLargeFile::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
  1873 	{
  1874 	RBuf8 videoBuf1;
  1875 	CleanupClosePushL(videoBuf1);		
  1876 	TBool keyFrame1;
  1877 	TUint videoTimestampMS = 0;	
  1878 	TUint videoTS1;
  1879 	TUint frameSize = 0;
  1880 	T3GPFrameDependencies aDependencies;		
  1881 	
  1882 	RFile fileName;
  1883 	CleanupClosePushL(fileName);		
  1884 	User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead));	
  1885 	
  1886 	C3GPParse* parser = C3GPParse::NewL();
  1887 	CleanupStack::PushL(parser);
  1888 	User::LeaveIfError(parser->Open(fileName));
  1889 	User::LeaveIfError(parser->GetVideoFrameSize(frameSize));
  1890 	User::LeaveIfError(videoBuf1.Create((TInt)frameSize));
  1891 	User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1));
  1892 
  1893 	TInt error = parser->GetVideoFrameDependencies(aDependencies);
  1894 	if (error != KErrNone)
  1895 		{
  1896 		aDependencies.iDependsOn = E3GPDependencyUnknown;
  1897 		aDependencies.iIsDependedOn = E3GPDependencyUnknown;
  1898 		aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
  1899 		}
  1900 
  1901 	TInt err = KErrNone;
  1902 	TInt64 size = 0;
  1903 	TTime startTime;
  1904 	TTime endTime;
  1905 	startTime.UniversalTime();				
  1906 
  1907 	// create a 3GB video file
  1908 	TInt videoLength = videoBuf1.Length();
  1909 	while (size + videoLength < K3GigaBytes)
  1910 	    {  				
  1911 		err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies);
  1912 		if (err != KErrNone)
  1913 			{
  1914 			ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
  1915 			break;
  1916 			}			
  1917 		iFile64.Size(size);
  1918 	    }
  1919 
  1920 	endTime.UniversalTime();
  1921 	TTimeIntervalMinutes composeTime;				
  1922 	endTime.MinutesFrom(startTime, composeTime);	 
  1923 	INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size);   		    		
  1924 
  1925 	if (err != KErrNone)
  1926 		{			
  1927 		SetTestStepResult(EFail); 
  1928 		}
  1929 
  1930 	User::LeaveIfError(parser->Complete());
  1931 	CleanupStack::PopAndDestroy(3, &videoBuf1); 		
  1932 	}
  1933 
  1934 // -----------------------------------------------------------------------------
  1935 // C3GPLibComposeLargeFileUserData
  1936 // -----------------------------------------------------------------------------
  1937 //     
  1938 C3GPLibComposeLargeFileUserData::C3GPLibComposeLargeFileUserData()
  1939 	{	
  1940 	}
  1941 
  1942 void C3GPLibComposeLargeFileUserData::doTestStepComposeSetUserDataL(C3GPCompose& aComposer)
  1943 	{
  1944 	TInt bufferUdtaSize = 0;
  1945 	TBuf8<256> bufferUdta;
  1946 	TUint8* ptr = const_cast<TUint8*>(bufferUdta.Ptr());
  1947 	TInt size = 0;
  1948 				
  1949 	_LIT8(KTitle,"titl");
  1950 	_LIT8(KData1,"This Udta titl test data 01!!<end>");
  1951 	size = KTitle().Length() + KData1().Length() + 4;
  1952 	WriteInt32(ptr, size);	
  1953 	ptr += 4;
  1954 	Mem::Copy(ptr, KTitle().Ptr(), KTitle().Length());
  1955 	ptr += KTitle().Length();
  1956 	Mem::Copy(ptr, KData1().Ptr(), KData1().Length());
  1957 	ptr += KData1().Length();
  1958 	bufferUdtaSize += size;
  1959 
  1960 	_LIT8(KTitle1,"titl");
  1961 	_LIT8(KData2,"This Udta titl test data 02!!blahblahblahbla<end>");
  1962 	size = KTitle1().Length() + KData2().Length() + 4;
  1963 	WriteInt32(ptr, size);	
  1964 	ptr += 4;
  1965 	Mem::Copy(ptr, KTitle1().Ptr(), KTitle1().Length());
  1966 	ptr += KTitle1().Length();
  1967 	Mem::Copy(ptr, KData2().Ptr(), KData2().Length());
  1968 	ptr += KData2().Length();
  1969 	bufferUdtaSize += size;
  1970 
  1971 	_LIT8(KTitle2,"titl");
  1972 	_LIT8(KData3,"This Udta titl test data 03!!Moreblahblahblahblahblahblahblahblahblah<end>");
  1973 	size = KTitle2().Length() + KData3().Length() + 4;
  1974 	WriteInt32(ptr, size);	
  1975 	ptr += 4;
  1976 	Mem::Copy(ptr, KTitle2().Ptr(), KTitle2().Length());
  1977 	ptr += KTitle2().Length();
  1978 	Mem::Copy(ptr, KData3().Ptr(), KData3().Length());
  1979 	ptr += KData3().Length();
  1980 	bufferUdtaSize += size;
  1981 		
  1982 	bufferUdta.SetLength(bufferUdtaSize);			
  1983 	TInt error = aComposer.SetUserData(E3GPUdtaVideoTrak, bufferUdta);
  1984 
  1985 	if (error != KErrNone)
  1986 		{
  1987 		ERR_PRINTF2(_L("C3GPComposer::SetUserData failed with %d"), error);
  1988 		SetTestStepError(error);
  1989 		}
  1990 	}
  1991 
  1992 void C3GPLibComposeLargeFileUserData::WriteInt32(TUint8* aPtr, TInt32 aData)
  1993 	{
  1994 	aPtr[0] = TUint8(aData>>24);
  1995 	aPtr[1] = TUint8(aData>>16);
  1996 	aPtr[2] = TUint8(aData>>8);
  1997 	aPtr[3] = TUint8(aData);
  1998 	}
  1999 
  2000 // -----------------------------------------------------------------------------
  2001 // C3GPLibComposeLargeFile32bitAPI
  2002 // -----------------------------------------------------------------------------
  2003 //     
  2004 C3GPLibComposeLargeFile32bitAPI::C3GPLibComposeLargeFile32bitAPI()
  2005 	{	
  2006 	}
  2007 
  2008 C3GPCompose* C3GPLibComposeLargeFile32bitAPI::doTestStepCreateComposerL()
  2009 	{
  2010 	return C3GPCompose::NewL(KLargeFileWriteBufferSize, KLargeFileWriteBufferMaxCount);
  2011 	}
  2012 
  2013 void C3GPLibComposeLargeFile32bitAPI::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
  2014 	{
  2015 	RBuf8 videoBuf1;
  2016 	CleanupClosePushL(videoBuf1);		
  2017 	TBool keyFrame1;
  2018 	TUint videoTimestampMS = 0;	
  2019 	TUint videoTS1;
  2020 	TUint frameSize = 0;
  2021 	T3GPFrameDependencies aDependencies;		
  2022 	
  2023 	RFile fileName;
  2024 	CleanupClosePushL(fileName);		
  2025 	User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead));	
  2026 	
  2027 	C3GPParse* parser = C3GPParse::NewL();
  2028 	CleanupStack::PushL(parser);
  2029 	User::LeaveIfError(parser->Open(fileName));
  2030 	User::LeaveIfError(parser->GetVideoFrameSize(frameSize));
  2031 	User::LeaveIfError(videoBuf1.Create((TInt)frameSize));
  2032 	User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1));
  2033 
  2034 	TInt error = parser->GetVideoFrameDependencies(aDependencies);
  2035 	if (error != KErrNone)
  2036 		{
  2037 		aDependencies.iDependsOn = E3GPDependencyUnknown;
  2038 		aDependencies.iIsDependedOn = E3GPDependencyUnknown;
  2039 		aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
  2040 		}
  2041 
  2042 	TInt err = KErrNone;
  2043 	TInt size = 0;
  2044 	TTime startTime;
  2045 	TTime endTime;
  2046 	startTime.UniversalTime();				
  2047 
  2048 	// create a 3GB video file
  2049 	TInt videoLength = videoBuf1.Length();
  2050 	while (size + videoLength < K3GigaBytes)
  2051 	    {  				
  2052 		err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies);
  2053 		if (err != KErrNone)
  2054 			{
  2055 			ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
  2056 			break;
  2057 			}			
  2058 		iFile.Size(size);
  2059 	    }
  2060 
  2061 	endTime.UniversalTime();
  2062 	TTimeIntervalMinutes composeTime;				
  2063 	endTime.MinutesFrom(startTime, composeTime);	 
  2064 	INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size);   		    		
  2065 
  2066 	err = aComposer.Complete();
  2067 	if (err != KErrNone)
  2068 		{			
  2069 		SetTestStepError(err); 
  2070 		}
  2071 
  2072 	User::LeaveIfError(parser->Complete());
  2073 	CleanupStack::PopAndDestroy(3, &videoBuf1); 		
  2074 	}
  2075 
  2076 // -----------------------------------------------------------------------------
  2077 // C3GPLibComposeLargeFileDiskFull
  2078 // -----------------------------------------------------------------------------
  2079 //     
  2080 C3GPLibComposeLargeFileDiskFull::C3GPLibComposeLargeFileDiskFull()
  2081 	{	
  2082 	}
  2083 
  2084 void C3GPLibComposeLargeFileDiskFull::doTestStepComposeWriteVideoAudioL(C3GPCompose& aComposer)
  2085 	{
  2086 	RBuf8 videoBuf1;
  2087 	CleanupClosePushL(videoBuf1);		
  2088 	TBool keyFrame1;
  2089 	TUint videoTimestampMS = 0;	
  2090 	TUint videoTS1;
  2091 	TUint frameSize = 0;
  2092 	T3GPFrameDependencies aDependencies;		
  2093 	
  2094 	RFile fileName;
  2095 	CleanupClosePushL(fileName);		
  2096 	User::LeaveIfError(fileName.Open(iFs, KLargeVideoFile(), EFileRead));	
  2097 	
  2098 	C3GPParse* parser = C3GPParse::NewL();
  2099 	CleanupStack::PushL(parser);
  2100 	User::LeaveIfError(parser->Open(fileName));
  2101 	User::LeaveIfError(parser->GetVideoFrameSize(frameSize));
  2102 	User::LeaveIfError(videoBuf1.Create((TInt)frameSize));
  2103 	User::LeaveIfError(parser->ReadVideoFrame(videoBuf1, keyFrame1, videoTimestampMS, videoTS1));
  2104 
  2105 	TInt error = parser->GetVideoFrameDependencies(aDependencies);
  2106 	if (error != KErrNone)
  2107 		{
  2108 		aDependencies.iDependsOn = E3GPDependencyUnknown;
  2109 		aDependencies.iIsDependedOn = E3GPDependencyUnknown;
  2110 		aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
  2111 		}
  2112 
  2113 	TInt err = KErrNone;
  2114 	TInt64 size = 0;
  2115 	TTime startTime;
  2116 	TTime endTime;
  2117 	startTime.UniversalTime();				
  2118 
  2119 	// create a 3GB video file
  2120 	TInt videoLength = videoBuf1.Length();
  2121 	while (size + videoLength < K3GigaBytes)
  2122 	    {  				
  2123 		err = aComposer.WriteVideoFrame(videoBuf1, 100, keyFrame1, aDependencies);
  2124 		if (err != KErrNone)
  2125 			{
  2126 			ERR_PRINTF2(_L("Fail to write video frame, err = %d"), err);
  2127 			break;
  2128 			}			
  2129 		iFile64.Size(size);
  2130 	    }
  2131 
  2132 	endTime.UniversalTime();
  2133 	TTimeIntervalMinutes composeTime;				
  2134 	endTime.MinutesFrom(startTime, composeTime);	 
  2135 	INFO_PRINTF3(_L("Took %d minutes to compose a video file of size %d bytes"), composeTime.Int(), size);   		    		
  2136 
  2137 	if (err != KErrNone)
  2138 		{			
  2139 		SetTestStepError(err); 
  2140 		}
  2141 
  2142 	User::LeaveIfError(parser->Complete());
  2143 	CleanupStack::PopAndDestroy(3, &videoBuf1); 
  2144 	
  2145 	// ignore the error
  2146 	aComposer.Complete();		
  2147 	}
  2148 
  2149 // -----------------------------------------------------------------------------
  2150 // C3GPLibComposeFileWithAvcProfileCheck
  2151 // -----------------------------------------------------------------------------
  2152 //
  2153 
  2154 const TInt KAvcDecoderConfigRecordLength = 7;
  2155 
  2156 _LIT8(KAvcCTag, "avcC");
  2157 
  2158 const TUint8 KAvcConfigVersion = 1;
  2159 
  2160 const TUint8 KAvcProfileByteBaseline = 66;
  2161 const TUint8 KAvcProfileByteExtended = 77;
  2162 const TUint8 KAvcProfileByteMain = 88;
  2163 const TUint8 KAvcProfileByteHigh = 100;
  2164 
  2165 C3GPLibComposeFileWithAvcProfileCheck::C3GPLibComposeFileWithAvcProfileCheck()
  2166     : iAvcDecoderConfigRecord( KAvcDecoderConfigRecordLength )
  2167     {
  2168     }
  2169 
  2170 TVerdict C3GPLibComposeFileWithAvcProfileCheck::doTestStepL()
  2171     {
  2172     if (TestStepResult() != EPass)
  2173         {
  2174         return TestStepResult();
  2175         }
  2176     
  2177     // this triggers: 
  2178     // 1. Create a composer
  2179     // 2. Open the composer - C3GPLibComposeFileFormatCheck::doTestStepComposeOpenL
  2180     // 3. Write Video & Audio Data - C3GPLibComposeFileFormatCheck::doTestStepComposeWriteVideoAudioL
  2181     // 4. Write User Data - C3GPLibComposeFileFormatCheck::doTestStepComposeSetUserDataL
  2182     // 5. Complete the composer 
  2183     TVerdict verdict = C3GPLibComposeFile::doTestStepL();
  2184     if (verdict == EPass)
  2185         {
  2186         // once the file is composed, it can be verified if the file composed has the same
  2187         // AVC profile.
  2188         verdict = VerifyAvcProfileL(iFile);
  2189         }
  2190     else
  2191         {
  2192         INFO_PRINTF1(_L("<C3GPLibComposeFileWithAvcProfileCheck> C3GPLibComposeFile::doTestStepL returns failed result"));      
  2193         }
  2194     SetTestStepResult(verdict);
  2195         
  2196     if (!ShouldRunOOMTest())
  2197         {
  2198         INFO_PRINTF2(_L("C3GPLibComposeFileWithAvcProfileCheck::doTestStepL returns %d"), TestStepResult());   
  2199         }
  2200     return TestStepResult();        
  2201     }
  2202 
  2203 /*
  2204  * The aDecoderSpecificInfo argument is used by 3GPlib to populate the
  2205  * avcC box. As this contains details of the AVC profile which is being
  2206  * checked by this test we cannot use KDummyData as the other tests do.
  2207  * 
  2208  */
  2209 T3GPVideoPropertiesBase* C3GPLibComposeFileWithAvcProfileCheck::SetupAvcVideoL()
  2210     {
  2211     // See ISO 14496-15, chapter 5.2.4.1.1 for details of these...
  2212     // config version (always 1)
  2213     iAvcDecoderConfigRecord[0] = KAvcConfigVersion;
  2214     // constraint flags
  2215     iAvcDecoderConfigRecord[2] = 0; // dummy data 
  2216     // level
  2217     iAvcDecoderConfigRecord[3] = 0; // dummy data
  2218     // reserved (6bits) + lengthSizeMinusOne (2bits)
  2219     iAvcDecoderConfigRecord[4] = 0xFC; // 111111 00
  2220     // reserved (3bits) + numOfSeqParamSets (5bits)
  2221     iAvcDecoderConfigRecord[5] = 0xE0; // 111 00000
  2222     // numOfPicParamSets
  2223     iAvcDecoderConfigRecord[6] = 0;
  2224     
  2225     switch( iVideoType )
  2226         {
  2227         case E3GPAvcProfileBaseline:
  2228             iAvcDecoderConfigRecord[1] = KAvcProfileByteBaseline;
  2229             break;    
  2230 
  2231         case E3GPAvcProfileMain:
  2232             iAvcDecoderConfigRecord[1] = KAvcProfileByteMain;
  2233             break;
  2234 
  2235         case E3GPAvcProfileExtended:
  2236             iAvcDecoderConfigRecord[1] = KAvcProfileByteExtended;
  2237             break;
  2238 
  2239         case E3GPAvcProfileHigh:
  2240             iAvcDecoderConfigRecord[1] = KAvcProfileByteHigh;
  2241             break;
  2242             
  2243         default:
  2244             User::Leave(KErrUnknown);
  2245         }
  2246     T3GPVideoPropertiesBase* video = new (ELeave) T3GPVideoPropertiesAvc(1000, TSize(100, 100), iAvcDecoderConfigRecord );
  2247     return video;
  2248     }
  2249 
  2250 TVerdict C3GPLibComposeFileWithAvcProfileCheck::VerifyAvcProfileL(const RFile& aFile) 
  2251     {
  2252     // Seek to the beginning of the file
  2253     TInt pos = 0;   
  2254     User::LeaveIfError(aFile.Seek(ESeekStart, pos));
  2255     
  2256     TVerdict verdict = EFail;
  2257     TBuf8<4> atom;
  2258     TBuf8<1> byte;
  2259     TInt rewind = -1 * ( atom.MaxLength() - 1 );
  2260     TInt tmp = rewind;
  2261     
  2262     while(ETrue)
  2263         {
  2264         // Search for the 'avcC' atom to check the profile that follows it.
  2265         
  2266         // Read in next 4 bytes
  2267         User::LeaveIfError(aFile.Read(atom));
  2268         if (atom.Length() < atom.MaxLength())
  2269             {
  2270             break;
  2271             }
  2272             
  2273         // Check if 'avcC' was found
  2274         if (Mem::Compare((&KAvcCTag)->Ptr(), (&KAvcCTag)->Length(), atom.Ptr(), atom.Length()) == 0)
  2275             {
  2276             // read next byte, and it should contain config version (always 1)
  2277             User::LeaveIfError(aFile.Read(byte));
  2278             if( byte[0] != KAvcConfigVersion )
  2279                 {
  2280                 ERR_PRINTF2(_L("avcC atom config type not as expected! (%d instead of 1)"), byte[0] );                      
  2281                 break;
  2282                 }
  2283             
  2284             // read next byte, and it should contain profile indication
  2285             User::LeaveIfError(aFile.Read(byte));
  2286             switch( iVideoType )
  2287                 {
  2288                 case E3GPAvcProfileBaseline:
  2289                     if( byte[0] == KAvcProfileByteBaseline )
  2290                         {
  2291                         verdict = EPass;
  2292                         }
  2293                     else
  2294                         {
  2295                         ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteBaseline );                      
  2296                         }
  2297                     break;
  2298                     
  2299 
  2300                 case E3GPAvcProfileMain:
  2301                     if( byte[0] == KAvcProfileByteMain )
  2302                         {
  2303                         verdict = EPass;
  2304                         }
  2305                     else
  2306                         {
  2307                         ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteMain );                      
  2308                         }
  2309                     break;
  2310                 
  2311 
  2312                 case E3GPAvcProfileExtended:
  2313                     if( byte[0] == KAvcProfileByteExtended )
  2314                         {
  2315                         verdict = EPass;
  2316                         }
  2317                     else
  2318                         {
  2319                         ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteExtended );                      
  2320                         }
  2321                     break;
  2322                     
  2323 
  2324                 case E3GPAvcProfileHigh:
  2325                     if( byte[0] == KAvcProfileByteHigh )
  2326                         {
  2327                         verdict = EPass;
  2328                         }
  2329                     else
  2330                         {
  2331                         ERR_PRINTF3(_L("avcC atom config type not as expected! (%d instead of %d)"), byte[0], KAvcProfileByteHigh );                      
  2332                         }
  2333                     break;
  2334                     
  2335                 default:
  2336                     ERR_PRINTF2(_L("avcC has unknown profile indication: %d"), byte[0] );
  2337                 }         
  2338             
  2339             // 'avcC' was found, regardless of the result, finish reading the file
  2340             break;
  2341             }
  2342         else
  2343             {
  2344             // The 4 bytes read were not 'avcC'.
  2345             // Need to rewind by 3 bytes since we need to step through the file
  2346             // byte-by-byte...
  2347             tmp = rewind; // Avoid rewind value being changed by Seek() function
  2348             User::LeaveIfError( aFile.Seek( ESeekCurrent, tmp ) );
  2349             }
  2350         }
  2351         
  2352     return verdict;
  2353     }
  2354