os/mm/mmplugins/lib3gpunittest/src/parserapi.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.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <mmf/common/mmferrors.h>
sl@0
    17
#include <caf/caf.h>
sl@0
    18
#include "tsu3gplibraryapi.h"
sl@0
    19
sl@0
    20
using namespace ContentAccess;
sl@0
    21
sl@0
    22
// --------------------------
sl@0
    23
// C3GPLibParser_base 
sl@0
    24
// --------------------------
sl@0
    25
//
sl@0
    26
TVerdict C3GPLibParser_base::doTestStepPreambleL()
sl@0
    27
	{
sl@0
    28
	SetTestStepResult(EPass);
sl@0
    29
	SetTestStepError(KErrNone);
sl@0
    30
	
sl@0
    31
	TPtrC testSection = ConfigSection();
sl@0
    32
	
sl@0
    33
	TInt err = iTestSection.Create(testSection.Length());
sl@0
    34
	if( err != KErrNone )
sl@0
    35
		{
sl@0
    36
		ERR_PRINTF2(_L("Cannot create buffer for inputFilename. err = %d"), err);
sl@0
    37
		SetTestStepResult(EInconclusive);
sl@0
    38
		return TestStepResult();
sl@0
    39
		}
sl@0
    40
	iTestSection += testSection;
sl@0
    41
	
sl@0
    42
	TBuf<20> testFolderName;
sl@0
    43
	testFolderName.Zero();
sl@0
    44
	if (ConfigSection().Compare(_L("3GP-H264-MP4-LARGE")) == 0)
sl@0
    45
		{
sl@0
    46
 		#ifdef __WINSCW__
sl@0
    47
 		testFolderName.Append(_L("inputFileEmu"));
sl@0
    48
 		#else
sl@0
    49
 		testFolderName.Append(_L("inputFileHw"));
sl@0
    50
 		#endif		
sl@0
    51
		}
sl@0
    52
	else	
sl@0
    53
		{
sl@0
    54
 		testFolderName.Append(_L("inputFile"));
sl@0
    55
		}
sl@0
    56
	
sl@0
    57
	TPtrC inputFile;
sl@0
    58
	if(!GetStringFromConfig(ConfigSection(), testFolderName, inputFile))
sl@0
    59
		{
sl@0
    60
		ERR_PRINTF1(_L("Cannot read inputFile from ini file."));
sl@0
    61
		SetTestStepResult(ETestSuiteError);
sl@0
    62
		return TestStepResult();
sl@0
    63
		}
sl@0
    64
	err = iInputFile.Create(inputFile.Length() + 1);
sl@0
    65
	if( err != KErrNone )
sl@0
    66
		{
sl@0
    67
		ERR_PRINTF2(_L("Cannot create buffer for inputFilename. err = %d"), err);
sl@0
    68
		SetTestStepResult(EInconclusive);
sl@0
    69
		return TestStepResult();
sl@0
    70
		}
sl@0
    71
	iInputFile += inputFile;
sl@0
    72
	iInputFile.ZeroTerminate();
sl@0
    73
	
sl@0
    74
	return TestStepResult();
sl@0
    75
	}
sl@0
    76
sl@0
    77
TVerdict C3GPLibParser_base::doTestStepPostambleL()
sl@0
    78
	{
sl@0
    79
	iInputFile.Close();
sl@0
    80
	iTestSection.Close();
sl@0
    81
	
sl@0
    82
	// Close file
sl@0
    83
	iSourceFile.Close();
sl@0
    84
	iSourceFile64.Close();
sl@0
    85
sl@0
    86
    //Close the file server session
sl@0
    87
    iFsSession.Close();
sl@0
    88
    
sl@0
    89
	return TestStepResult();
sl@0
    90
	}
sl@0
    91
sl@0
    92
TInt C3GPLibParser_base::CheckError(TInt aError, TInt aExpectError, const TDesC& aFunction)
sl@0
    93
	{
sl@0
    94
	if (aError != aExpectError)
sl@0
    95
		{
sl@0
    96
		ERR_PRINTF4(_L("%S expected %d, but returns %d; "), &aFunction, aExpectError, aError);
sl@0
    97
		if (aError != KErrNone)
sl@0
    98
			{
sl@0
    99
			return aError;
sl@0
   100
			}
sl@0
   101
		// expected an error, but return KErrNone
sl@0
   102
		return KErrGeneral;
sl@0
   103
		}
sl@0
   104
	return KErrNone;
sl@0
   105
	}
sl@0
   106
sl@0
   107
void C3GPLibParser_base::ParserOpenL(C3GPParse* aParser, TInt aExpectedError)
sl@0
   108
	{
sl@0
   109
	ASSERT(aParser);
sl@0
   110
	
sl@0
   111
	TInt err = aParser->Open();
sl@0
   112
	if (aExpectedError == KErrInUse && err == KErrNone)
sl@0
   113
		{
sl@0
   114
		err = aParser->Open();
sl@0
   115
		}
sl@0
   116
sl@0
   117
	if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError)
sl@0
   118
		{
sl@0
   119
		INFO_PRINTF2(_L("Parser open using buffer mode (OOM), returns %d"), err);
sl@0
   120
		User::Leave(err);
sl@0
   121
		}
sl@0
   122
sl@0
   123
	if (!ShouldRunOOMTest())
sl@0
   124
		{
sl@0
   125
		INFO_PRINTF2(_L("Parser open using buffer mode, returns %d"), err);
sl@0
   126
		}
sl@0
   127
sl@0
   128
	User::LeaveIfError(CheckError(err, aExpectedError, _L("aParser->Open() buffer mode")));
sl@0
   129
	}
sl@0
   130
sl@0
   131
void C3GPLibParser_base::ParserOpenFileL(C3GPParse* aParser, TInt aExpectedError)
sl@0
   132
	{
sl@0
   133
	ASSERT(aParser);
sl@0
   134
	
sl@0
   135
	TInt err = aParser->Open(iInputFile);
sl@0
   136
	if (aExpectedError == KErrInUse && err == KErrNone)
sl@0
   137
		{
sl@0
   138
		err = aParser->Open(iInputFile);
sl@0
   139
		}
sl@0
   140
sl@0
   141
	if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError)
sl@0
   142
		{
sl@0
   143
		INFO_PRINTF2(_L("Parser open using file path (OOM), returns %d"), err);
sl@0
   144
		User::Leave(err);
sl@0
   145
		}
sl@0
   146
sl@0
   147
	if (!ShouldRunOOMTest())
sl@0
   148
		{
sl@0
   149
		INFO_PRINTF2(_L("Parser open using file path, returns %d"), err);
sl@0
   150
		}
sl@0
   151
	
sl@0
   152
	User::LeaveIfError(CheckError(err, aExpectedError, _L("aParser->Open() file path")));
sl@0
   153
	}
sl@0
   154
sl@0
   155
void C3GPLibParser_base::ParserCompleteL(C3GPParse* aParser)
sl@0
   156
	{
sl@0
   157
	ASSERT(aParser);
sl@0
   158
	
sl@0
   159
	TInt err = aParser->Complete();
sl@0
   160
	User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->Complete()")));
sl@0
   161
	}
sl@0
   162
	
sl@0
   163
void C3GPLibParser_base::FileOpenL(TUint aFileMode)	
sl@0
   164
	{
sl@0
   165
	iSourceFile.Close();
sl@0
   166
	//Create a connection to the file server    
sl@0
   167
    User::LeaveIfError(iFsSession.Connect());
sl@0
   168
    
sl@0
   169
    //Open the source file passing in the file server session handle, source 
sl@0
   170
    //file path and file access mode 
sl@0
   171
    User::LeaveIfError(iSourceFile.Open(iFsSession, iInputFile, aFileMode ));
sl@0
   172
	}
sl@0
   173
sl@0
   174
void C3GPLibParser_base::FileClose()	
sl@0
   175
	{
sl@0
   176
	// Close file
sl@0
   177
	iSourceFile.Close();
sl@0
   178
sl@0
   179
    //Close the file server session
sl@0
   180
    iFsSession.Close();
sl@0
   181
	}
sl@0
   182
sl@0
   183
void C3GPLibParser_base::FileOpen64L(TUint aFileMode)	
sl@0
   184
	{
sl@0
   185
	iSourceFile64.Close();
sl@0
   186
	//Create a connection to the file server    
sl@0
   187
    User::LeaveIfError(iFsSession.Connect());
sl@0
   188
    
sl@0
   189
    //Open the source file passing in the file server session handle, source 
sl@0
   190
    //file path and file access mode 
sl@0
   191
    User::LeaveIfError(iSourceFile64.Open(iFsSession, iInputFile, aFileMode ));
sl@0
   192
	}
sl@0
   193
sl@0
   194
void C3GPLibParser_base::FileClose64()	
sl@0
   195
	{
sl@0
   196
	// Close file
sl@0
   197
	iSourceFile64.Close();
sl@0
   198
sl@0
   199
    //Close the file server session
sl@0
   200
    iFsSession.Close();
sl@0
   201
	}
sl@0
   202
sl@0
   203
void C3GPLibParser_base::ParserOpenFileHandleL(C3GPParse* aParser, TUint aFileMode, TInt aExpectedError)
sl@0
   204
	{
sl@0
   205
	ASSERT(aParser);
sl@0
   206
   
sl@0
   207
	FileOpenL(aFileMode);
sl@0
   208
    TInt err = aParser->Open(iSourceFile);	
sl@0
   209
    if (aExpectedError == KErrInUse && err == KErrNone)
sl@0
   210
		{
sl@0
   211
		err = aParser->Open(iSourceFile);
sl@0
   212
		}
sl@0
   213
sl@0
   214
	if (err != KErrNone && err != aExpectedError)
sl@0
   215
		{
sl@0
   216
		FileClose();
sl@0
   217
sl@0
   218
		if (ShouldRunOOMTest())
sl@0
   219
			{
sl@0
   220
			INFO_PRINTF2(_L("Parser open using file handle (OOM), returns %d"), err);
sl@0
   221
			User::Leave(err);
sl@0
   222
			}
sl@0
   223
		}
sl@0
   224
sl@0
   225
	if (!ShouldRunOOMTest())
sl@0
   226
		{
sl@0
   227
		INFO_PRINTF2(_L("Parser open using file handle, returns %d"), err);		
sl@0
   228
		}
sl@0
   229
sl@0
   230
	if (err == aExpectedError ) 
sl@0
   231
		{
sl@0
   232
		err = KErrNone;
sl@0
   233
		}
sl@0
   234
	User::LeaveIfError(err);
sl@0
   235
	}
sl@0
   236
sl@0
   237
void C3GPLibParser_base::ParserCompleteHandleL(C3GPParse* aParser)
sl@0
   238
	{
sl@0
   239
	ASSERT(aParser);
sl@0
   240
	
sl@0
   241
	TInt err = aParser->Complete();
sl@0
   242
	if (err != KErrNone)
sl@0
   243
		{
sl@0
   244
		ERR_PRINTF2(_L("aParser->Complete() file handle failed with %d"), err);
sl@0
   245
		}
sl@0
   246
	
sl@0
   247
	FileClose();
sl@0
   248
    User::LeaveIfError(err);
sl@0
   249
	}
sl@0
   250
sl@0
   251
void C3GPLibParser_base::ParserOpenFileHandle64L(C3GPParse* aParser, TUint aFileMode, TInt aExpectedError)
sl@0
   252
	{
sl@0
   253
	ASSERT(aParser);
sl@0
   254
   
sl@0
   255
	FileOpen64L(aFileMode);
sl@0
   256
    TInt err = aParser->Open(iSourceFile64);	
sl@0
   257
    if (aExpectedError == KErrInUse && err == KErrNone)
sl@0
   258
		{
sl@0
   259
		err = aParser->Open(iSourceFile64);
sl@0
   260
		}
sl@0
   261
sl@0
   262
	if (err != KErrNone && err != aExpectedError)
sl@0
   263
		{
sl@0
   264
		FileClose();
sl@0
   265
sl@0
   266
		if (ShouldRunOOMTest())
sl@0
   267
			{
sl@0
   268
			INFO_PRINTF2(_L("Parser open using 64bit file handle (OOM), returns %d"), err);
sl@0
   269
			User::Leave(err);
sl@0
   270
			}
sl@0
   271
		}
sl@0
   272
sl@0
   273
	if (!ShouldRunOOMTest())
sl@0
   274
		{
sl@0
   275
		INFO_PRINTF2(_L("Parser open using 64bit file handle, returns %d"), err);		
sl@0
   276
		}
sl@0
   277
sl@0
   278
	if (err == aExpectedError ) 
sl@0
   279
		{
sl@0
   280
		err = KErrNone;
sl@0
   281
		}
sl@0
   282
	User::LeaveIfError(err);
sl@0
   283
	}
sl@0
   284
sl@0
   285
void C3GPLibParser_base::ParserCompleteHandle64L(C3GPParse* aParser)
sl@0
   286
	{
sl@0
   287
	ASSERT(aParser);
sl@0
   288
	
sl@0
   289
	TInt err = aParser->Complete();
sl@0
   290
	if (err != KErrNone)
sl@0
   291
		{
sl@0
   292
		ERR_PRINTF2(_L("aParser->Complete() 64bit file handle failed with %d"), err);
sl@0
   293
		}
sl@0
   294
	
sl@0
   295
	FileClose64();
sl@0
   296
    User::LeaveIfError(err);
sl@0
   297
	}
sl@0
   298
sl@0
   299
void C3GPLibParser_base::ParserOpenCafLC(C3GPParse* aParser, TInt aExpectedError)
sl@0
   300
	{
sl@0
   301
	ASSERT(aParser);
sl@0
   302
	CContent* content = CContent::NewLC(iInputFile, EContentShareReadWrite);	
sl@0
   303
	CData* data = content->OpenContentL(EPeek);	
sl@0
   304
	
sl@0
   305
	CleanupStack::PushL(data);
sl@0
   306
sl@0
   307
	TInt err = aParser->Open(*data);
sl@0
   308
	if (aExpectedError == KErrInUse && err == KErrNone)
sl@0
   309
		{
sl@0
   310
		err = aParser->Open(*data);
sl@0
   311
		}
sl@0
   312
sl@0
   313
	if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError)
sl@0
   314
		{
sl@0
   315
		INFO_PRINTF2(_L("Parser open using CAF (OOM), returns %d"), err);
sl@0
   316
		User::Leave(err);	
sl@0
   317
		}
sl@0
   318
sl@0
   319
	if (!ShouldRunOOMTest())
sl@0
   320
		{
sl@0
   321
		INFO_PRINTF2(_L("Parser open using CAF, returns %d"), err);
sl@0
   322
		}
sl@0
   323
sl@0
   324
	if (err == aExpectedError)
sl@0
   325
		{
sl@0
   326
		err = KErrNone;
sl@0
   327
		}
sl@0
   328
	User::LeaveIfError(err);
sl@0
   329
	}
sl@0
   330
sl@0
   331
void C3GPLibParser_base::ParserCompleteCafL(C3GPParse* aParser)
sl@0
   332
	{
sl@0
   333
	ASSERT(aParser);
sl@0
   334
	TInt err = aParser->Complete();
sl@0
   335
	if ( err != KErrNone )
sl@0
   336
		{
sl@0
   337
		ERR_PRINTF2(_L("parse->Complete() CAF failed with %d."), err);
sl@0
   338
		}
sl@0
   339
sl@0
   340
	CleanupStack::PopAndDestroy(2); // content, data
sl@0
   341
	User::LeaveIfError(err);
sl@0
   342
	}
sl@0
   343
sl@0
   344
// Retrieve both video & audio stream properties
sl@0
   345
TInt C3GPLibParser_base::GetClipProperties(C3GPParse* aParse, TInt& aVideoError, TUint& aVideoLength, TUint& aAudioLength)
sl@0
   346
	{
sl@0
   347
	TInt err = KErrCorrupt;
sl@0
   348
	T3GPVideoType videoType;
sl@0
   349
	TReal frameRate;
sl@0
   350
	TUint avgBitRate;
sl@0
   351
	TSize videoSize;
sl@0
   352
	TUint timeScale;
sl@0
   353
	
sl@0
   354
	aVideoError = aParse->GetVideoProperties(videoType, aVideoLength, frameRate, avgBitRate, videoSize, timeScale);
sl@0
   355
	
sl@0
   356
	if (aVideoError == KErrNone || aVideoError == KErrNotSupported || aVideoError == KErr3gpLibMoreDataRequired)
sl@0
   357
		{
sl@0
   358
		T3GPAudioType audioType;
sl@0
   359
		TInt framesPerSample;
sl@0
   360
		err = aParse->GetAudioProperties(audioType, aAudioLength, framesPerSample, avgBitRate, timeScale);
sl@0
   361
		}	
sl@0
   362
	return err;
sl@0
   363
	}
sl@0
   364
sl@0
   365
// Get both audio and video decorder information
sl@0
   366
TInt C3GPLibParser_base::ParserGetDecoderInfo(C3GPParse* aParser)
sl@0
   367
	{
sl@0
   368
	TInt dsiSize;
sl@0
   369
	RBuf8 dsiBuffer;
sl@0
   370
	
sl@0
   371
	TInt err = aParser->GetAudioDecoderSpecificInfoSize(dsiSize);
sl@0
   372
	if ( err == KErrNone )
sl@0
   373
		{		
sl@0
   374
		err = dsiBuffer.Create(dsiSize);
sl@0
   375
		if ( err != KErrNone )
sl@0
   376
			{
sl@0
   377
			ERR_PRINTF2(_L("dsiBuffer.Create failed with %d"), err);
sl@0
   378
			dsiBuffer.Close();
sl@0
   379
			return err;
sl@0
   380
			}
sl@0
   381
		
sl@0
   382
		err = aParser->GetAudioDecoderSpecificInfo(dsiBuffer);
sl@0
   383
		}
sl@0
   384
	if ( err != KErrNone )
sl@0
   385
		{
sl@0
   386
		if (!ShouldRunOOMTest())
sl@0
   387
			{
sl@0
   388
			ERR_PRINTF3(_L("GetAudioDecoderSpecificInfo/Size() failed with %d, size %d"), err, dsiSize);
sl@0
   389
			}
sl@0
   390
		dsiBuffer.Close();
sl@0
   391
		return err;
sl@0
   392
		}
sl@0
   393
	
sl@0
   394
	err = aParser->GetVideoDecoderSpecificInfoSize(dsiSize);
sl@0
   395
	if ( err != KErrNone && err != KErrNotSupported)
sl@0
   396
		{
sl@0
   397
		dsiBuffer.Close();
sl@0
   398
		ERR_PRINTF2(_L("parse->GetVideoDecoderSpecificInfoSize() failed with %d"), err);
sl@0
   399
		return err;
sl@0
   400
		}
sl@0
   401
	if (err != KErrNotSupported)
sl@0
   402
		{
sl@0
   403
		dsiBuffer.Close();
sl@0
   404
		err = dsiBuffer.Create(dsiSize);	
sl@0
   405
		if ( err != KErrNone )
sl@0
   406
			{
sl@0
   407
			ERR_PRINTF2(_L("dsiBuffer.Create failed with %d"), err);
sl@0
   408
			dsiBuffer.Close();
sl@0
   409
			return err;
sl@0
   410
			}
sl@0
   411
		
sl@0
   412
		err = aParser->GetVideoDecoderSpecificInfo(dsiBuffer);
sl@0
   413
		if ( err != KErrNone )
sl@0
   414
			{
sl@0
   415
			ERR_PRINTF2(_L("VideoDecoderSpecificInfo() failed with %d"), err);
sl@0
   416
			}
sl@0
   417
		}
sl@0
   418
	dsiBuffer.Close();
sl@0
   419
	return err;
sl@0
   420
	}
sl@0
   421
sl@0
   422
// Read data from file and insert it to the buffer
sl@0
   423
void C3GPLibParser_base::InsertDataL(C3GPParse* aParse, RFile aFile, TInt aBufferSize, TInt aPos)
sl@0
   424
	{
sl@0
   425
	TInt err = KErrNone;
sl@0
   426
	RBuf8 buffer;
sl@0
   427
	CleanupClosePushL(buffer);
sl@0
   428
	buffer.CreateL(aBufferSize);
sl@0
   429
	err = aFile.Read(aPos, buffer); 
sl@0
   430
	if (err == KErrNone)
sl@0
   431
		{
sl@0
   432
		err = aParse->InsertData(buffer);
sl@0
   433
		if ( err != KErrNone )
sl@0
   434
			{
sl@0
   435
			ERR_PRINTF2(_L("parse->InsertData() failed with %d"), err);
sl@0
   436
			}
sl@0
   437
		}
sl@0
   438
	else
sl@0
   439
		{
sl@0
   440
		ERR_PRINTF2(_L("aFile.Read(aPos, buffer) failed with %d"), err);
sl@0
   441
		}
sl@0
   442
	buffer.Close();
sl@0
   443
	CleanupStack::PopAndDestroy(&buffer);
sl@0
   444
	User::LeaveIfError(err);
sl@0
   445
	}
sl@0
   446
sl@0
   447
// Read audio or video frame(s) depending on the input parameter synchronously
sl@0
   448
TInt C3GPLibParser_base::ReadAudioVideoFrame(C3GPParse* aParse, TBool aRepeat, TBool aReadAudio)
sl@0
   449
	{
sl@0
   450
	TInt err = KErrNone;
sl@0
   451
	// If repeat, read all frames; otherwise, read only one frame
sl@0
   452
	while (err == KErrNone)
sl@0
   453
		{
sl@0
   454
		TUint size;		
sl@0
   455
		if (aReadAudio)
sl@0
   456
			{
sl@0
   457
			err = aParse->GetAudioFramesSize(size);
sl@0
   458
			}
sl@0
   459
		else
sl@0
   460
			{
sl@0
   461
			err = aParse->GetVideoFrameSize(size);
sl@0
   462
			}
sl@0
   463
		
sl@0
   464
		if (err == KErrNone)
sl@0
   465
			{
sl@0
   466
			TUint timeStampInMs;
sl@0
   467
			TUint timeStampInTimescale;
sl@0
   468
			RBuf8 buffer;
sl@0
   469
			err = buffer.Create(size);				
sl@0
   470
			if (err != KErrNone)
sl@0
   471
				{
sl@0
   472
				ERR_PRINTF2(_L("buffer.Create(size) failed with %d"), err);
sl@0
   473
				buffer.Close();
sl@0
   474
				return err;
sl@0
   475
				}
sl@0
   476
			
sl@0
   477
			if (aReadAudio)
sl@0
   478
				{				
sl@0
   479
				TInt returnedFrames;
sl@0
   480
				err = aParse->ReadAudioFrames(buffer, returnedFrames, timeStampInMs, timeStampInTimescale);
sl@0
   481
				}
sl@0
   482
			else
sl@0
   483
				{
sl@0
   484
				TBool keyframe;
sl@0
   485
				err = aParse->ReadVideoFrame(buffer, keyframe, timeStampInMs, timeStampInTimescale);
sl@0
   486
				}
sl@0
   487
			
sl@0
   488
			if (err != KErrNone && err != KErrNotFound && err != KErr3gpLibMoreDataRequired)
sl@0
   489
				{
sl@0
   490
				if (aReadAudio)
sl@0
   491
					{
sl@0
   492
					ERR_PRINTF3(_L("parse->GetAudioFrames() failed with %d; frame size: %d"), err, size);
sl@0
   493
					}
sl@0
   494
				else
sl@0
   495
					{
sl@0
   496
					ERR_PRINTF3(_L("parse->GetVideoFrame() failed with %d; frame size: %d"), err, size);
sl@0
   497
					}
sl@0
   498
				buffer.Close();
sl@0
   499
				return err;
sl@0
   500
				}
sl@0
   501
			buffer.Close();
sl@0
   502
			}
sl@0
   503
		
sl@0
   504
		if (!aRepeat)
sl@0
   505
			{
sl@0
   506
			break;
sl@0
   507
			}
sl@0
   508
		}
sl@0
   509
	return err;
sl@0
   510
	}
sl@0
   511
sl@0
   512
// Retrieve user data atom.
sl@0
   513
TInt C3GPLibParser_base::CallUDTApi(C3GPParse* aParse, TUint32 aUdtType, TUint& aIndex, T3GPUdtaLocation aLocation)
sl@0
   514
	{
sl@0
   515
	TInt err = KErrNone;
sl@0
   516
	TInt udtSize;
sl@0
   517
	
sl@0
   518
	// use a copy of the target index requested by the user, so it does not get overwritten
sl@0
   519
	// when calling the APIs GetUserDataAtomSize & GetUserDataAtom
sl@0
   520
	TUint tempIndex1 = aIndex;	
sl@0
   521
	TUint tempIndex2 = aIndex;	
sl@0
   522
sl@0
   523
	err = aParse->GetUserDataAtomSize(aUdtType, aLocation, tempIndex1, udtSize);
sl@0
   524
	if (err == KErrNone)
sl@0
   525
		{
sl@0
   526
		RBuf8 buffer;	
sl@0
   527
		
sl@0
   528
		err = buffer.Create(udtSize); // Use size retrieved from GetUserDataAtomSize
sl@0
   529
		if (err == KErrNone)
sl@0
   530
			{
sl@0
   531
			err = aParse->GetUserDataAtom(aUdtType, aLocation, buffer, tempIndex2);
sl@0
   532
			if (err == KErrNone && tempIndex1 != tempIndex2)
sl@0
   533
				{
sl@0
   534
				ERR_PRINTF1(_L("C3GPLibParser_base::CallUDTApi - Highest Index returned is different when calling GetUserDataAtomSize vs GetUserDataAtom"));	
sl@0
   535
				err = KErrGeneral;
sl@0
   536
				}
sl@0
   537
			}
sl@0
   538
		else
sl@0
   539
			{
sl@0
   540
			ERR_PRINTF2(_L("buffer.Create(size) failed with %d"), err);
sl@0
   541
			}
sl@0
   542
		buffer.Close();		
sl@0
   543
		}
sl@0
   544
	
sl@0
   545
	if (err == KErrNone)
sl@0
   546
		{
sl@0
   547
		// return the highest index found
sl@0
   548
		aIndex = tempIndex1;
sl@0
   549
		}
sl@0
   550
	
sl@0
   551
	return err;
sl@0
   552
	}
sl@0
   553
sl@0
   554
void C3GPLibParser_base::DoGetVideoAudioAttributesL(C3GPParse* aParser)
sl@0
   555
	{
sl@0
   556
	// Retrieve video & audio stream attributes
sl@0
   557
	T3GPVideoType videoType;
sl@0
   558
	TUint length; 
sl@0
   559
	TReal frameRate;
sl@0
   560
	TUint avgBitRate;
sl@0
   561
	TSize videoSize;
sl@0
   562
	TUint timeScale;
sl@0
   563
	
sl@0
   564
	TInt err = aParser->GetVideoProperties(videoType, length, frameRate, avgBitRate, videoSize, timeScale);
sl@0
   565
	User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetVideoProperties()")));
sl@0
   566
	
sl@0
   567
	T3GPAudioType audioType;
sl@0
   568
	TInt framesPerSample;
sl@0
   569
	err = aParser->GetAudioProperties(audioType, length, framesPerSample, avgBitRate, timeScale);
sl@0
   570
	User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetAudioProperties()")));
sl@0
   571
	
sl@0
   572
	err = ParserGetDecoderInfo(aParser);
sl@0
   573
	User::LeaveIfError(CheckError(err, KErrNone, _L("ParserGetDecoderInfo(aParser)")));
sl@0
   574
	
sl@0
   575
	TUint numVideoFrames;
sl@0
   576
	err = aParser->GetNumberOfVideoFrames(numVideoFrames);
sl@0
   577
	User::LeaveIfError(CheckError(err, KErrNone, _L("parse->GetNumberOfVideoFrames")));
sl@0
   578
	
sl@0
   579
	TUint startIndex = 0;
sl@0
   580
	RArray<T3GPFrameInfoParameters> array;
sl@0
   581
	err = aParser->GetVideoFrameProperties(startIndex, numVideoFrames, array);	
sl@0
   582
	array.Close();
sl@0
   583
	User::LeaveIfError(CheckError(err, KErrNone, _L("parse->GetVideoFrameProperties")));
sl@0
   584
	}
sl@0
   585
sl@0
   586
TInt C3GPLibParser_base::DoReadFrame(C3GPParse* aParse)
sl@0
   587
	{
sl@0
   588
	TInt numBufferedBytes;
sl@0
   589
	TInt err = aParse->GetNumBufferedBytes(numBufferedBytes);
sl@0
   590
	if (err != KErrNone && numBufferedBytes != 0)
sl@0
   591
		{
sl@0
   592
		// when GetNumBufferedBytes returns error, numBufferedBytes is set to zero.
sl@0
   593
		return err;		
sl@0
   594
		}
sl@0
   595
	err = CheckError(err, KErrNotSupported, _L("parse->GetNumBufferedBytes()"));	
sl@0
   596
	if (err == KErrNone)
sl@0
   597
		{
sl@0
   598
		// read audio frame
sl@0
   599
		err = ReadAudioVideoFrame(aParse, ETrue, ETrue);
sl@0
   600
		// When finishing reading all frames, it returns KErrNotFound
sl@0
   601
		err = CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParse, ETrue)"));
sl@0
   602
		
sl@0
   603
		if (err == KErrNone)
sl@0
   604
			{
sl@0
   605
			// read video frame
sl@0
   606
			err = ReadAudioVideoFrame(aParse, ETrue, EFalse);
sl@0
   607
			// When finishing reading all frames, it returns KErrNotFound
sl@0
   608
			err = CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParse, EFalse)"));			
sl@0
   609
			}
sl@0
   610
		
sl@0
   611
		// After finishing reading all frame, the next video time stamp should return with KErrEof
sl@0
   612
		TUint timeStampInMs;
sl@0
   613
		TUint timeStampInTimescale;
sl@0
   614
		err = aParse->GetVideoTimestamp(timeStampInMs, timeStampInTimescale);
sl@0
   615
		err = CheckError(err, KErrEof, _L("GetVideoTimestamp()"));			
sl@0
   616
		}
sl@0
   617
		
sl@0
   618
	return err;
sl@0
   619
	}
sl@0
   620
sl@0
   621
void C3GPLibParser_base::DoSeekTestL(C3GPParse* aParser)
sl@0
   622
	{
sl@0
   623
	// testclip_h263_qcif_15fps_armnb_8khz_onlyvideo.3GP with some key frame
sl@0
   624
	TUint num; 
sl@0
   625
	TUint audioPos;
sl@0
   626
	TUint videoPos;
sl@0
   627
	TUint timeStampInMs = 0; // for key frame
sl@0
   628
	TUint timeStampInTimescale = 0;  // for key frame
sl@0
   629
	TUint timeStampInMs1 = 0;  // for non key frame immediately after key frame
sl@0
   630
	TUint timeStampInTimescale1 = 0;  // for non-key frame immediately after key frame
sl@0
   631
	TUint keyFrameIndex = 0;
sl@0
   632
	TBool keyFrame;
sl@0
   633
	TInt err = aParser->GetNumberOfVideoFrames(num);
sl@0
   634
	if (err == KErrNone)
sl@0
   635
		{
sl@0
   636
		for (TInt i = 0; i < num; i++)
sl@0
   637
			{			
sl@0
   638
			err = aParser->GetVideoFrameKeyType(i, keyFrame);
sl@0
   639
			if (err == KErrNone && keyFrame)
sl@0
   640
				{
sl@0
   641
				keyFrameIndex = i;
sl@0
   642
				err = aParser->GetVideoFrameStartTime(keyFrameIndex, timeStampInMs, timeStampInTimescale);
sl@0
   643
				}
sl@0
   644
			if (err == KErrNone && !keyFrame && keyFrameIndex > 0)
sl@0
   645
				{
sl@0
   646
				keyFrameIndex = i;
sl@0
   647
				err = aParser->GetVideoFrameStartTime(keyFrameIndex, timeStampInMs1, timeStampInTimescale1);
sl@0
   648
				break;
sl@0
   649
				}
sl@0
   650
			if (err != KErrNone)
sl@0
   651
				{
sl@0
   652
				ERR_PRINTF3(_L("aParser->GetVideoFrameKeyType() failed with %d at i %d"), err, i);
sl@0
   653
				User::Leave(err);
sl@0
   654
				}
sl@0
   655
			}
sl@0
   656
		}
sl@0
   657
	else
sl@0
   658
		{
sl@0
   659
		ERR_PRINTF2(_L("aParser->GetNumberOfVideoFrames() failed with %d"), err);
sl@0
   660
		User::Leave(err);
sl@0
   661
		}
sl@0
   662
	err = aParser->Seek(timeStampInMs, ETrue, audioPos, videoPos);
sl@0
   663
	if (err != KErrNone || timeStampInMs != videoPos)
sl@0
   664
		{
sl@0
   665
		ERR_PRINTF4(_L("aParser->Seek() return %d, timeStampInMs %d, videoPos %d"), err, timeStampInMs, videoPos);
sl@0
   666
		}
sl@0
   667
	if (err == KErrNone && timeStampInMs != videoPos)
sl@0
   668
		{
sl@0
   669
		User::LeaveIfError(KErrGeneral);
sl@0
   670
		}
sl@0
   671
	User::LeaveIfError(err);
sl@0
   672
	
sl@0
   673
	err = aParser->Seek(timeStampInMs1, EFalse, audioPos, videoPos);
sl@0
   674
	if (err != KErrNone || timeStampInMs1 != videoPos)
sl@0
   675
		{
sl@0
   676
		ERR_PRINTF4(_L("aParser->Seek() return %d, timeStampInMs1 %d, videoPos %d"), err, timeStampInMs1, videoPos);
sl@0
   677
		}
sl@0
   678
	if (err == KErrNone && timeStampInMs1 != videoPos)
sl@0
   679
		{
sl@0
   680
		User::LeaveIfError(KErrGeneral);
sl@0
   681
		}
sl@0
   682
	User::LeaveIfError(err);
sl@0
   683
	}
sl@0
   684
sl@0
   685
void C3GPLibParser_base::ReadFrameBufferModeL(C3GPParse* aParser)
sl@0
   686
	{
sl@0
   687
	ParserOpenL(aParser);
sl@0
   688
sl@0
   689
	TInt errReadAudio = KErrNone;
sl@0
   690
	TInt errReadVideo = KErrNone;
sl@0
   691
	// Insert 1K data into the library
sl@0
   692
	TInt pos = 0;
sl@0
   693
	TInt bufferSize = 1000;
sl@0
   694
	
sl@0
   695
	InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
   696
	errReadAudio = ReadAudioVideoFrame(aParser, ETrue, ETrue);
sl@0
   697
	errReadVideo = ReadAudioVideoFrame(aParser, ETrue, EFalse);
sl@0
   698
sl@0
   699
	while (errReadAudio == KErr3gpLibMoreDataRequired || errReadVideo == KErr3gpLibMoreDataRequired)
sl@0
   700
		{
sl@0
   701
		pos = pos + bufferSize;
sl@0
   702
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
   703
		if (errReadAudio == KErr3gpLibMoreDataRequired)
sl@0
   704
			{
sl@0
   705
			errReadAudio = ReadAudioVideoFrame(aParser, ETrue, ETrue);
sl@0
   706
			}
sl@0
   707
sl@0
   708
		if (errReadVideo == KErr3gpLibMoreDataRequired)
sl@0
   709
			{
sl@0
   710
			errReadVideo = ReadAudioVideoFrame(aParser, ETrue, EFalse);
sl@0
   711
			}
sl@0
   712
		}
sl@0
   713
	
sl@0
   714
	// When last frame has been read, it should return KErrNotFound
sl@0
   715
	if (errReadAudio != KErrNotFound)
sl@0
   716
		{
sl@0
   717
		ERR_PRINTF1(_L("parse->ReadAudioFrames() expects KErrNotFound. "));
sl@0
   718
		User::Leave(errReadAudio);
sl@0
   719
		}
sl@0
   720
	if (errReadVideo != KErrNotFound)
sl@0
   721
		{
sl@0
   722
		ERR_PRINTF1(_L("parse->ReadVideoFrame expects KErrNotFound. "));
sl@0
   723
		User::Leave(errReadVideo);
sl@0
   724
		}
sl@0
   725
	
sl@0
   726
	ParserCompleteL(aParser);
sl@0
   727
	}
sl@0
   728
sl@0
   729
C3GPLib_AsyncObserver::C3GPLib_AsyncObserver()
sl@0
   730
	{	
sl@0
   731
	}
sl@0
   732
sl@0
   733
TVerdict C3GPLib_AsyncObserver::doTestStepPreambleL()
sl@0
   734
	{
sl@0
   735
	C3GPLibParser_base::doTestStepPreambleL();
sl@0
   736
	
sl@0
   737
	iSchedulerWait = new (ELeave) CActiveSchedulerWait;
sl@0
   738
	if(!iSchedulerWait)
sl@0
   739
		{
sl@0
   740
		SetTestStepResult(EInconclusive);
sl@0
   741
		}
sl@0
   742
	return TestStepResult();
sl@0
   743
	}
sl@0
   744
sl@0
   745
// -----------------------------------------------------------------------------
sl@0
   746
// C3GPLib_AsyncObserver for asynchronous read
sl@0
   747
// -----------------------------------------------------------------------------
sl@0
   748
//
sl@0
   749
TVerdict C3GPLib_AsyncObserver::doTestStepPostambleL()
sl@0
   750
	{
sl@0
   751
	C3GPLibParser_base::doTestStepPostambleL();
sl@0
   752
	if ( iSchedulerWait)
sl@0
   753
		{
sl@0
   754
		if (iSchedulerWait->IsStarted())
sl@0
   755
			{
sl@0
   756
			iSchedulerWait->AsyncStop();
sl@0
   757
			}
sl@0
   758
		delete iSchedulerWait;
sl@0
   759
		iSchedulerWait = NULL;
sl@0
   760
		}	
sl@0
   761
	return TestStepResult();
sl@0
   762
	}
sl@0
   763
sl@0
   764
// Read audio or video frame(s) depending on the input parameter asynchronously
sl@0
   765
TInt C3GPLib_AsyncObserver::ReadAudioVideoFrameAsync(C3GPParse* aParse, TBool aReadAudio, TBool aCancel)
sl@0
   766
	{
sl@0
   767
	TInt err = KErrNone;
sl@0
   768
	TUint size;	
sl@0
   769
	
sl@0
   770
	while (err == KErrNone)
sl@0
   771
		{
sl@0
   772
		if (aReadAudio)
sl@0
   773
			{
sl@0
   774
			err = aParse->GetAudioFramesSize(size);
sl@0
   775
			}
sl@0
   776
		else
sl@0
   777
			{
sl@0
   778
			err = aParse->GetVideoFrameSize(size);
sl@0
   779
			}
sl@0
   780
		
sl@0
   781
		RBuf8 buffer;
sl@0
   782
		if (err == KErrNone)
sl@0
   783
			{
sl@0
   784
			err = buffer.Create(size);				
sl@0
   785
			}
sl@0
   786
		else
sl@0
   787
			{
sl@0
   788
			err = buffer.Create(KBufferSize);	
sl@0
   789
			}
sl@0
   790
		
sl@0
   791
		if (err != KErrNone)
sl@0
   792
			{
sl@0
   793
			ERR_PRINTF2(_L("buffer.Create(KBufferSize) failed with %d"), err);
sl@0
   794
			buffer.Close();
sl@0
   795
			return err;
sl@0
   796
			}
sl@0
   797
			
sl@0
   798
		iWaitForNotification = ETrue;
sl@0
   799
		if (aReadAudio)
sl@0
   800
			{				
sl@0
   801
			aParse->ReadAudioFrames(*this, buffer);
sl@0
   802
			}
sl@0
   803
		else 
sl@0
   804
			{
sl@0
   805
			aParse->ReadVideoFrame(*this, buffer);
sl@0
   806
			}
sl@0
   807
		
sl@0
   808
		if (aCancel && iAsyncError == KErrNone)
sl@0
   809
			{
sl@0
   810
			aParse->CancelReadFrame();
sl@0
   811
			// Calling cancel again won't have effects
sl@0
   812
			aParse->CancelReadFrame();
sl@0
   813
			
sl@0
   814
			// Do read frame again
sl@0
   815
			if (aReadAudio)
sl@0
   816
				{				
sl@0
   817
				aParse->ReadAudioFrames(*this, buffer);
sl@0
   818
				}
sl@0
   819
			else 
sl@0
   820
				{
sl@0
   821
				aParse->ReadVideoFrame(*this, buffer);
sl@0
   822
				}
sl@0
   823
			}
sl@0
   824
		
sl@0
   825
		if (iWaitForNotification)
sl@0
   826
		    {
sl@0
   827
			iSchedulerWait->Start();
sl@0
   828
		    }
sl@0
   829
		
sl@0
   830
		err = iAsyncError; 
sl@0
   831
		buffer.Close(); 
sl@0
   832
		} 
sl@0
   833
	
sl@0
   834
	if ( iSchedulerWait->IsStarted() )
sl@0
   835
        {
sl@0
   836
        iSchedulerWait->AsyncStop();
sl@0
   837
	    }
sl@0
   838
			
sl@0
   839
	if (err != KErrNone && err != KErrNotFound)
sl@0
   840
		{
sl@0
   841
		if (!ShouldRunOOMTest())
sl@0
   842
			{
sl@0
   843
			ERR_PRINTF2(_L("ReadAudioVideoFrameAsync failed with %d;"), err);
sl@0
   844
			}
sl@0
   845
		}
sl@0
   846
	else
sl@0
   847
		{
sl@0
   848
		err = KErrNone;
sl@0
   849
		}
sl@0
   850
	
sl@0
   851
	return err;
sl@0
   852
	}
sl@0
   853
sl@0
   854
void C3GPLib_AsyncObserver::AudioFramesAvailable(TInt aError, TUint aReturnedFrames, 
sl@0
   855
			TUint aTimeStampInMs, TUint aTimeStampInTimescale)
sl@0
   856
	{
sl@0
   857
	iWaitForNotification = EFalse;
sl@0
   858
	iAsyncLastNotificationFromAudio = EFalse;
sl@0
   859
	iAsyncError = aError;
sl@0
   860
	iAsyncAudioTimeStampInMs = aTimeStampInMs; 
sl@0
   861
	iAsyncAudioReturnedFrames = aReturnedFrames;
sl@0
   862
	iAsyncAudioTimestampInTimescale = aTimeStampInTimescale;
sl@0
   863
	if (iSchedulerWait->IsStarted())
sl@0
   864
		{
sl@0
   865
		iSchedulerWait->AsyncStop();
sl@0
   866
		}
sl@0
   867
sl@0
   868
	}
sl@0
   869
sl@0
   870
void C3GPLib_AsyncObserver::VideoFrameAvailable(TInt aError, TBool aKeyFrame, TUint 
sl@0
   871
			aTimeStampInMs, TUint aTimeStampInTimescale)
sl@0
   872
	{
sl@0
   873
	iWaitForNotification = EFalse;
sl@0
   874
	iAsyncLastNotificationFromAudio = EFalse;
sl@0
   875
	iAsyncError = aError;
sl@0
   876
	iAsyncVideoTimeStampInMs = aTimeStampInMs; 
sl@0
   877
	iAsyncVideoKeyFrame = aKeyFrame;
sl@0
   878
	iAsyncVideoTimestampInTimescale = aTimeStampInTimescale;
sl@0
   879
	
sl@0
   880
	if (iSchedulerWait->IsStarted())
sl@0
   881
		{
sl@0
   882
		iSchedulerWait->AsyncStop();
sl@0
   883
		}
sl@0
   884
sl@0
   885
	}
sl@0
   886
sl@0
   887
sl@0
   888
sl@0
   889
// -----------------------------------------------------------------------------
sl@0
   890
// Setup parser to read file by file path.
sl@0
   891
// -----------------------------------------------------------------------------
sl@0
   892
//
sl@0
   893
C3GPLibParser_0001::C3GPLibParser_0001()
sl@0
   894
	{
sl@0
   895
	}
sl@0
   896
sl@0
   897
TVerdict C3GPLibParser_0001::doTestStepL()
sl@0
   898
	{
sl@0
   899
	if(TestStepResult() == EPass)
sl@0
   900
		{
sl@0
   901
		C3GPParse* parser = C3GPParse::NewL();
sl@0
   902
		CleanupStack::PushL(parser);
sl@0
   903
		
sl@0
   904
		OpenCompleteL(parser);
sl@0
   905
	
sl@0
   906
		CleanupStack::PopAndDestroy(parser);
sl@0
   907
		}
sl@0
   908
	return TestStepResult();
sl@0
   909
	}
sl@0
   910
sl@0
   911
void C3GPLibParser_0001::OpenCompleteL(C3GPParse* aParser)
sl@0
   912
	{
sl@0
   913
	// Test open and complete with default file access mode
sl@0
   914
	ParserOpenFileL(aParser);
sl@0
   915
	ParserCompleteL(aParser);
sl@0
   916
	
sl@0
   917
	FileOpenL();
sl@0
   918
    ParserOpenFileL(aParser);
sl@0
   919
	ParserCompleteL(aParser);
sl@0
   920
	ParserCompleteL(aParser); // Should not fail when calling complete twice
sl@0
   921
	FileClose();
sl@0
   922
	
sl@0
   923
	//Open the source file passing in the file server session handle, source 
sl@0
   924
    //file path and file access mode (read-write)
sl@0
   925
	FileOpenL(EFileShareReadersOrWriters | EFileWrite);
sl@0
   926
    ParserOpenFileL(aParser);
sl@0
   927
	ParserCompleteL(aParser);
sl@0
   928
	ParserCompleteL(aParser);
sl@0
   929
	FileClose();
sl@0
   930
	
sl@0
   931
	//Open the source file passing in the file server session handle, source 
sl@0
   932
    //file path and file access mode (read-write)
sl@0
   933
	FileOpenL(EFileShareReadersOrWriters | EFileRead);
sl@0
   934
    ParserOpenFileL(aParser);
sl@0
   935
	ParserCompleteL(aParser);
sl@0
   936
	FileClose();
sl@0
   937
	
sl@0
   938
	//Open the source file passing in the file server session handle, source 
sl@0
   939
    //file path and file access mode (read-write)
sl@0
   940
	FileOpenL(EFileShareAny  | EFileWrite);
sl@0
   941
    ParserOpenFileL(aParser);
sl@0
   942
	ParserCompleteL(aParser);
sl@0
   943
	FileClose();
sl@0
   944
	
sl@0
   945
	//Open the source file passing in the file server session handle, source 
sl@0
   946
    //file path and file access mode (read-write)
sl@0
   947
	FileOpenL(EFileShareAny | EFileRead);
sl@0
   948
    ParserOpenFileL(aParser);
sl@0
   949
	ParserCompleteL(aParser);
sl@0
   950
	FileClose();
sl@0
   951
	}
sl@0
   952
sl@0
   953
// -----------------------------------------------------------------------------
sl@0
   954
// Setup parser to read file by buffer mode.
sl@0
   955
// -----------------------------------------------------------------------------
sl@0
   956
//
sl@0
   957
C3GPLibParser_0002::C3GPLibParser_0002()
sl@0
   958
	{
sl@0
   959
	}
sl@0
   960
sl@0
   961
TVerdict C3GPLibParser_0002::doTestStepL()
sl@0
   962
	{	
sl@0
   963
	if(TestStepResult() == EPass)
sl@0
   964
		{
sl@0
   965
		C3GPParse* parser = C3GPParse::NewL();
sl@0
   966
		CleanupStack::PushL(parser);
sl@0
   967
		
sl@0
   968
		OpenCompleteBufferModeL(parser);
sl@0
   969
		
sl@0
   970
		CleanupStack::PopAndDestroy(parser);
sl@0
   971
		}
sl@0
   972
	return TestStepResult();
sl@0
   973
	}
sl@0
   974
sl@0
   975
void C3GPLibParser_0002::OpenCompleteBufferModeL(C3GPParse* aParser)
sl@0
   976
	{
sl@0
   977
	// buffer mode
sl@0
   978
	FileOpenL();
sl@0
   979
	ParserOpenL(aParser);
sl@0
   980
	
sl@0
   981
	ParserCompleteL(aParser);
sl@0
   982
	FileClose();
sl@0
   983
	}
sl@0
   984
sl@0
   985
// -----------------------------------------------------------------------------
sl@0
   986
// Setup parser to read file by file handle.
sl@0
   987
// -----------------------------------------------------------------------------
sl@0
   988
//
sl@0
   989
C3GPLibParser_0003::C3GPLibParser_0003()
sl@0
   990
	{	
sl@0
   991
	}
sl@0
   992
sl@0
   993
TVerdict C3GPLibParser_0003::doTestStepL()
sl@0
   994
	{
sl@0
   995
	if(TestStepResult() == EPass)
sl@0
   996
		{
sl@0
   997
		C3GPParse* parser = C3GPParse::NewL();
sl@0
   998
		CleanupStack::PushL(parser);
sl@0
   999
		
sl@0
  1000
		OpenCompleteFileHandleL(parser);
sl@0
  1001
		
sl@0
  1002
		CleanupStack::PopAndDestroy(parser);
sl@0
  1003
		}
sl@0
  1004
	return TestStepResult();
sl@0
  1005
	}
sl@0
  1006
sl@0
  1007
void C3GPLibParser_0003::OpenCompleteFileHandleL(C3GPParse* aParser)
sl@0
  1008
	{
sl@0
  1009
	ParserOpenFileHandleL(aParser);
sl@0
  1010
	ParserCompleteHandleL(aParser);
sl@0
  1011
	
sl@0
  1012
    //Open the source file passing in the file server session handle, source 
sl@0
  1013
    //file path and file access mode (read-only)
sl@0
  1014
	ParserOpenFileHandleL(aParser, EFileRead | EFileShareReadersOnly);
sl@0
  1015
	ParserCompleteHandleL(aParser);
sl@0
  1016
	
sl@0
  1017
	//Open the source file passing in the file server session handle, source 
sl@0
  1018
    //file path and file access mode (read-only)
sl@0
  1019
	ParserOpenFileHandleL(aParser, EFileShareReadersOrWriters | EFileWrite);
sl@0
  1020
	ParserCompleteHandleL(aParser);
sl@0
  1021
	
sl@0
  1022
	//Open the source file passing in the file server session handle, source 
sl@0
  1023
    //file path and file access mode (read-only)
sl@0
  1024
	ParserOpenFileHandleL(aParser, EFileShareReadersOrWriters | EFileRead);
sl@0
  1025
	ParserCompleteHandleL(aParser);
sl@0
  1026
	
sl@0
  1027
	//Open the source file passing in the file server session handle, source 
sl@0
  1028
    //file path and file access mode (read-only)
sl@0
  1029
	ParserOpenFileHandleL(aParser, EFileShareAny  | EFileWrite);
sl@0
  1030
	ParserCompleteHandleL(aParser);
sl@0
  1031
    
sl@0
  1032
	//Open the source file passing in the file server session handle, source 
sl@0
  1033
    //file path and file access mode (read-only)
sl@0
  1034
	ParserOpenFileHandleL(aParser, EFileShareAny | EFileRead);
sl@0
  1035
	ParserCompleteHandleL(aParser);
sl@0
  1036
	}
sl@0
  1037
sl@0
  1038
// -----------------------------------------------------------------------------
sl@0
  1039
// Setup parser to read file by CAF.
sl@0
  1040
// -----------------------------------------------------------------------------
sl@0
  1041
//
sl@0
  1042
C3GPLibParser_0004::C3GPLibParser_0004()
sl@0
  1043
	{	
sl@0
  1044
	}
sl@0
  1045
sl@0
  1046
TVerdict C3GPLibParser_0004::doTestStepL()
sl@0
  1047
	{
sl@0
  1048
	if(TestStepResult() == EPass)
sl@0
  1049
		{
sl@0
  1050
		CContent* content = CContent::NewLC(iInputFile, EContentShareReadWrite);	
sl@0
  1051
		
sl@0
  1052
		CData* data = content->OpenContentL(EPeek);			
sl@0
  1053
		CleanupStack::PushL(data);
sl@0
  1054
		
sl@0
  1055
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1056
		CleanupStack::PushL(parser);
sl@0
  1057
		
sl@0
  1058
		TInt err = parser->Open(*data);
sl@0
  1059
sl@0
  1060
		if (err != KErrNone)
sl@0
  1061
			{
sl@0
  1062
			SetTestStepResult(EFail);
sl@0
  1063
			CleanupStack::PopAndDestroy(parser);
sl@0
  1064
			CleanupStack::PopAndDestroy(2); // content, data
sl@0
  1065
			return TestStepResult();
sl@0
  1066
			}
sl@0
  1067
		
sl@0
  1068
		err = parser->Complete();
sl@0
  1069
		if (err != KErrNone)
sl@0
  1070
			{
sl@0
  1071
			SetTestStepResult(EFail);
sl@0
  1072
			}
sl@0
  1073
		
sl@0
  1074
		CleanupStack::PopAndDestroy(parser);
sl@0
  1075
		CleanupStack::PopAndDestroy(2); // content, data
sl@0
  1076
		}
sl@0
  1077
	return TestStepResult();
sl@0
  1078
	}
sl@0
  1079
sl@0
  1080
// -----------------------------------------------------------------------------
sl@0
  1081
// Retrieve video & audio stream attributes from a mp4/3gp/3g2 file with supported 
sl@0
  1082
// video and audio streams using file mode - file path / file handle and CAF object.
sl@0
  1083
// -----------------------------------------------------------------------------
sl@0
  1084
//
sl@0
  1085
C3GPLibParser_0005::C3GPLibParser_0005()
sl@0
  1086
	{	
sl@0
  1087
	}
sl@0
  1088
sl@0
  1089
TVerdict C3GPLibParser_0005::doTestStepL()
sl@0
  1090
	{
sl@0
  1091
	if(TestStepResult() == EPass)
sl@0
  1092
		{
sl@0
  1093
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1094
		CleanupStack::PushL(parser);
sl@0
  1095
		
sl@0
  1096
		TRAPD(err, GetVideoAudioAttributesL(parser));
sl@0
  1097
		if (err != KErrNone)
sl@0
  1098
			{
sl@0
  1099
			SetTestStepResult(EFail);
sl@0
  1100
			}
sl@0
  1101
		
sl@0
  1102
		CleanupStack::PopAndDestroy(parser);
sl@0
  1103
		}
sl@0
  1104
	return TestStepResult();
sl@0
  1105
	}
sl@0
  1106
sl@0
  1107
void C3GPLibParser_0005::GetVideoAudioAttributesL(C3GPParse* aParser)
sl@0
  1108
	{
sl@0
  1109
	// Open parser in File path
sl@0
  1110
	ParserOpenFileL(aParser);
sl@0
  1111
	DoGetVideoAudioAttributesL(aParser);
sl@0
  1112
	ParserCompleteL(aParser);
sl@0
  1113
	
sl@0
  1114
	// open parser in file handle
sl@0
  1115
	ParserOpenFileHandleL(aParser);
sl@0
  1116
	DoGetVideoAudioAttributesL(aParser);
sl@0
  1117
	ParserCompleteHandleL(aParser);
sl@0
  1118
	
sl@0
  1119
	// Open parser in CAF
sl@0
  1120
	ParserOpenCafLC(aParser);
sl@0
  1121
	DoGetVideoAudioAttributesL(aParser);
sl@0
  1122
	ParserCompleteCafL(aParser);
sl@0
  1123
	}
sl@0
  1124
sl@0
  1125
// -----------------------------------------------------------------------------
sl@0
  1126
// Retrieve video & audio stream attributes from a mp4/3gp/3g2 file 
sl@0
  1127
// with supported video and audio streams using buffer mode.
sl@0
  1128
// -----------------------------------------------------------------------------
sl@0
  1129
//
sl@0
  1130
C3GPLibParser_0006::C3GPLibParser_0006()
sl@0
  1131
	{	
sl@0
  1132
	}
sl@0
  1133
sl@0
  1134
TVerdict C3GPLibParser_0006::doTestStepL()
sl@0
  1135
	{
sl@0
  1136
	if(TestStepResult() == EPass)
sl@0
  1137
		{
sl@0
  1138
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1139
		CleanupStack::PushL(parser);
sl@0
  1140
		
sl@0
  1141
		TRAPD(err, VideoAudioAttributesBufferModeL(parser));
sl@0
  1142
		if (err != KErrNone)
sl@0
  1143
			{
sl@0
  1144
			SetTestStepResult(EFail);
sl@0
  1145
			FileClose();
sl@0
  1146
			}
sl@0
  1147
		
sl@0
  1148
		CleanupStack::PopAndDestroy(parser);
sl@0
  1149
		}
sl@0
  1150
	return TestStepResult();
sl@0
  1151
	}
sl@0
  1152
sl@0
  1153
void C3GPLibParser_0006::VideoAudioAttributesBufferModeL(C3GPParse* aParser)
sl@0
  1154
	{
sl@0
  1155
	// buffer mode
sl@0
  1156
	FileOpenL();
sl@0
  1157
	ParserOpenL(aParser);
sl@0
  1158
sl@0
  1159
	TInt err = KErrNone;
sl@0
  1160
	// Retrieve number of buffered bytes before and after data is supplied to the parser.
sl@0
  1161
	err = GetVideoAudioAttributes(aParser, ENumBufferedBytes);
sl@0
  1162
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, ENumBufferedBytes)")));
sl@0
  1163
	
sl@0
  1164
	ParserCompleteL(aParser);
sl@0
  1165
	FileClose();
sl@0
  1166
	
sl@0
  1167
	// Open the parser again
sl@0
  1168
	FileOpenL();
sl@0
  1169
	ParserOpenL(aParser);
sl@0
  1170
	
sl@0
  1171
	// Retrieve video and audio descriptions before and after data is supplied to the parser.
sl@0
  1172
	err = GetVideoAudioAttributes(aParser, EClipProperties);
sl@0
  1173
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EClipProperties)")));
sl@0
  1174
	
sl@0
  1175
	ParserCompleteL(aParser);
sl@0
  1176
	FileClose();
sl@0
  1177
	
sl@0
  1178
	// Open the parser again
sl@0
  1179
	FileOpenL();
sl@0
  1180
	ParserOpenL(aParser);
sl@0
  1181
	
sl@0
  1182
	// Retrieve video and audio decoder before and after data is supplied to the parser.
sl@0
  1183
	err = GetVideoAudioAttributes(aParser, EDecoderInfo);
sl@0
  1184
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EDecoderInfo)")));
sl@0
  1185
	
sl@0
  1186
	ParserCompleteL(aParser);
sl@0
  1187
	FileClose();
sl@0
  1188
	
sl@0
  1189
	// Open the parser again
sl@0
  1190
	FileOpenL();
sl@0
  1191
	ParserOpenL(aParser);
sl@0
  1192
	
sl@0
  1193
	
sl@0
  1194
	// Retrieve video frame properties and number of frames before and after data is supplied to the parser.
sl@0
  1195
sl@0
  1196
	err = GetVideoAudioAttributes(aParser, EVideoFrameProp);
sl@0
  1197
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EVideoFrameProp)")));
sl@0
  1198
	
sl@0
  1199
	ParserCompleteL(aParser);
sl@0
  1200
	FileClose();
sl@0
  1201
	}
sl@0
  1202
sl@0
  1203
TInt C3GPLibParser_0006::CallTest(C3GPParse* aParser, TBufferModeTest aTest, TInt aExpectedNumBuffered)
sl@0
  1204
	{
sl@0
  1205
	TInt err = KErrNone;
sl@0
  1206
	TInt numBufferedBytes;
sl@0
  1207
sl@0
  1208
	// Before insert any data. Retrieving video and audio attributes should fail
sl@0
  1209
	switch (aTest)
sl@0
  1210
		{
sl@0
  1211
		case (ENumBufferedBytes):
sl@0
  1212
			err = aParser->GetNumBufferedBytes(numBufferedBytes);
sl@0
  1213
			if (err == KErrNone && numBufferedBytes != aExpectedNumBuffered)
sl@0
  1214
				{
sl@0
  1215
				err = KErrGeneral;
sl@0
  1216
				}
sl@0
  1217
		break;
sl@0
  1218
		case (EClipProperties):
sl@0
  1219
			TInt videoError;
sl@0
  1220
			TUint videoLength;
sl@0
  1221
			TUint audioLength;
sl@0
  1222
			err = GetClipProperties(aParser, videoError, videoLength, audioLength);
sl@0
  1223
			if ((videoError != KErrNone && videoError != KErr3gpLibMoreDataRequired) || 
sl@0
  1224
					(err != KErrNone && err != KErr3gpLibMoreDataRequired))
sl@0
  1225
				{
sl@0
  1226
				err = KErrGeneral;
sl@0
  1227
				}
sl@0
  1228
		break;
sl@0
  1229
		case (EDecoderInfo):
sl@0
  1230
			err = ParserGetDecoderInfo(aParser);
sl@0
  1231
		break;
sl@0
  1232
		case (EVideoFrameProp):
sl@0
  1233
			if (aExpectedNumBuffered == 0)
sl@0
  1234
				{
sl@0
  1235
				err = GetVideoFramePropAndNumVideoFrame(aParser, EFalse);
sl@0
  1236
				}
sl@0
  1237
			else
sl@0
  1238
				{
sl@0
  1239
				err = GetVideoFramePropAndNumVideoFrame(aParser, ETrue);
sl@0
  1240
				}
sl@0
  1241
		break;
sl@0
  1242
		default:
sl@0
  1243
		break;
sl@0
  1244
		}
sl@0
  1245
	return err;
sl@0
  1246
	}
sl@0
  1247
sl@0
  1248
TInt C3GPLibParser_0006::GetVideoAudioAttributes(C3GPParse* aParser, TBufferModeTest aTest)
sl@0
  1249
	{
sl@0
  1250
	TInt err = KErrNone;
sl@0
  1251
	
sl@0
  1252
	// Before insert any data. Retrieving video and audio attributes should fail
sl@0
  1253
	err = CallTest(aParser, aTest, 0);
sl@0
  1254
	if (aTest != ENumBufferedBytes)
sl@0
  1255
		{
sl@0
  1256
		err = CheckError(err, KErr3gpLibMoreDataRequired, _L("CallTest(aParser, aTest, 0)"));
sl@0
  1257
		}
sl@0
  1258
	else
sl@0
  1259
		{
sl@0
  1260
		err = CheckError(err, KErrNone, _L("CallTest()"));
sl@0
  1261
		}
sl@0
  1262
	
sl@0
  1263
	if (err != KErrNone)
sl@0
  1264
		{
sl@0
  1265
		ERR_PRINTF2(_L("GetVideoAudioAttributes failed with %d; "), err);
sl@0
  1266
		return KErrGeneral;
sl@0
  1267
		}
sl@0
  1268
	
sl@0
  1269
	// Insert 1K data to buffer	
sl@0
  1270
	TInt bufferSize = 0;
sl@0
  1271
	TInt pos = 0; // from begining of the file
sl@0
  1272
	err = KErr3gpLibMoreDataRequired;
sl@0
  1273
	// Insert data until enough data has been inserted
sl@0
  1274
	while (err == KErr3gpLibMoreDataRequired)
sl@0
  1275
		{
sl@0
  1276
		// Insert more data to buffer	
sl@0
  1277
		pos = bufferSize + pos;
sl@0
  1278
		bufferSize = KBufferSize;
sl@0
  1279
		RBuf8 buffer;
sl@0
  1280
		err = buffer.Create(bufferSize);
sl@0
  1281
		if (err == KErrNone)
sl@0
  1282
			{
sl@0
  1283
			err = iSourceFile.Read(pos, buffer); 
sl@0
  1284
			if (err == KErrNone)
sl@0
  1285
				{
sl@0
  1286
				err = aParser->InsertData(buffer);
sl@0
  1287
				if ( err == KErrNone )
sl@0
  1288
					{
sl@0
  1289
					err = CallTest(aParser, aTest, (bufferSize + pos));
sl@0
  1290
					}
sl@0
  1291
				}
sl@0
  1292
			}
sl@0
  1293
		buffer.Close();
sl@0
  1294
		}
sl@0
  1295
	
sl@0
  1296
	err = CheckError(err, KErrNone, _L("CallTest()"));
sl@0
  1297
	return err;
sl@0
  1298
	}
sl@0
  1299
sl@0
  1300
TInt C3GPLibParser_0006::GetVideoFramePropAndNumVideoFrame(C3GPParse* aParse, TBool aExpectPass)
sl@0
  1301
	{
sl@0
  1302
	TInt err = KErrNone;
sl@0
  1303
	TUint numVideoFrames;
sl@0
  1304
	err = aParse->GetNumberOfVideoFrames(numVideoFrames);
sl@0
  1305
	if (aExpectPass)
sl@0
  1306
		{
sl@0
  1307
		if ( err == KErrNone )
sl@0
  1308
			{
sl@0
  1309
			// Only when GetNumberOfVideoFrames returns KErrNone, the method GetVideoFrameProperties
sl@0
  1310
			// can be called
sl@0
  1311
			TUint startIndex = 0;
sl@0
  1312
			RArray<T3GPFrameInfoParameters> array;
sl@0
  1313
			err = aParse->GetVideoFrameProperties(startIndex, numVideoFrames, array);
sl@0
  1314
			array.Close();
sl@0
  1315
			}		
sl@0
  1316
		}
sl@0
  1317
	else
sl@0
  1318
		{
sl@0
  1319
		// When there is no data in the handler, GetNumberOfVideoFrames will fail with KErrGeneral, 
sl@0
  1320
		// not the KErr3gpLibMoreDataRequired
sl@0
  1321
		if ( err == KErr3gpLibMoreDataRequired || err == KErrGeneral)
sl@0
  1322
			{
sl@0
  1323
			if (!ShouldRunOOMTest())
sl@0
  1324
				{
sl@0
  1325
				INFO_PRINTF2(_L("Expect parse->GetNumberOfVideoFrames() failed with %d"), err);
sl@0
  1326
				}
sl@0
  1327
			err = KErr3gpLibMoreDataRequired;
sl@0
  1328
			}
sl@0
  1329
		// expected failure, but get KErrNone.
sl@0
  1330
		if (err == KErrNone)
sl@0
  1331
			{
sl@0
  1332
			INFO_PRINTF1(_L("parse->GetNumberOfVideoFrames() should fail due to buffer too small"));
sl@0
  1333
			err = KErrGeneral;
sl@0
  1334
			}
sl@0
  1335
		}
sl@0
  1336
	
sl@0
  1337
	return err;
sl@0
  1338
	}
sl@0
  1339
sl@0
  1340
// -----------------------------------------------------------------------------
sl@0
  1341
// Check if the clip is streamable in file mode from a mp4/3gp/3g2 file 
sl@0
  1342
// -----------------------------------------------------------------------------
sl@0
  1343
//
sl@0
  1344
C3GPLibParser_0007::C3GPLibParser_0007()
sl@0
  1345
	{	
sl@0
  1346
	}
sl@0
  1347
sl@0
  1348
TVerdict C3GPLibParser_0007::doTestStepL()
sl@0
  1349
	{
sl@0
  1350
	if(TestStepResult() == EPass)
sl@0
  1351
		{
sl@0
  1352
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1353
		CleanupStack::PushL(parser);
sl@0
  1354
		
sl@0
  1355
		TRAPD(err, GetstreamableL(parser));
sl@0
  1356
		if (err != KErrNone)
sl@0
  1357
			{
sl@0
  1358
			SetTestStepResult(EFail);
sl@0
  1359
			}
sl@0
  1360
		
sl@0
  1361
		CleanupStack::PopAndDestroy(parser);
sl@0
  1362
		}
sl@0
  1363
	return TestStepResult();
sl@0
  1364
	}
sl@0
  1365
sl@0
  1366
void C3GPLibParser_0007::GetstreamableL(C3GPParse* aParser)
sl@0
  1367
	{
sl@0
  1368
	// Open parser in File mode
sl@0
  1369
	ParserOpenFileL(aParser);
sl@0
  1370
	
sl@0
  1371
	// Check if the file is streamable
sl@0
  1372
	TBool streamable;
sl@0
  1373
	TInt err = aParser->GetStreamable(streamable);
sl@0
  1374
	if (err != KErrNone)
sl@0
  1375
		{
sl@0
  1376
		SetTestStepError(err);
sl@0
  1377
		}
sl@0
  1378
	else if (!streamable)
sl@0
  1379
		{
sl@0
  1380
		INFO_PRINTF2(_L("aParser->GetStreamable() returns %d"), streamable);
sl@0
  1381
		SetTestStepError(KErrNotSupported);
sl@0
  1382
		}
sl@0
  1383
	
sl@0
  1384
	ParserCompleteL(aParser);
sl@0
  1385
	}
sl@0
  1386
sl@0
  1387
// -----------------------------------------------------------------------------
sl@0
  1388
// Check if the clip is streamable in buffer mode from a mp4/3gp/3g2 file 
sl@0
  1389
// -----------------------------------------------------------------------------
sl@0
  1390
//
sl@0
  1391
C3GPLibParser_0008::C3GPLibParser_0008()
sl@0
  1392
	{	
sl@0
  1393
	}
sl@0
  1394
sl@0
  1395
TVerdict C3GPLibParser_0008::doTestStepL()
sl@0
  1396
	{
sl@0
  1397
	if(TestStepResult() == EPass)
sl@0
  1398
		{
sl@0
  1399
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1400
		CleanupStack::PushL(parser);
sl@0
  1401
		
sl@0
  1402
		TRAPD(err, GetstreamableL(parser));
sl@0
  1403
		if (err != KErrNone)
sl@0
  1404
			{
sl@0
  1405
			SetTestStepResult(EFail);
sl@0
  1406
			}
sl@0
  1407
		
sl@0
  1408
		CleanupStack::PopAndDestroy(parser);
sl@0
  1409
		}
sl@0
  1410
	return TestStepResult();
sl@0
  1411
	}
sl@0
  1412
sl@0
  1413
void C3GPLibParser_0008::GetstreamableL(C3GPParse* aParser)
sl@0
  1414
	{
sl@0
  1415
	// buffer mode
sl@0
  1416
	FileOpenL();
sl@0
  1417
	ParserOpenL(aParser);
sl@0
  1418
sl@0
  1419
	// Check if the file is streamable before the data is inserted
sl@0
  1420
	TBool streamable;
sl@0
  1421
	TInt err = aParser->GetStreamable(streamable);
sl@0
  1422
	
sl@0
  1423
	// Insert 1K data to buffer	
sl@0
  1424
	TInt bufferSize = 0;
sl@0
  1425
	TInt pos = 0; // from begining of the file
sl@0
  1426
sl@0
  1427
	// Insert data until enough data has been inserted
sl@0
  1428
	while (err == KErr3gpLibMoreDataRequired)
sl@0
  1429
		{
sl@0
  1430
		// Insert more data to buffer	
sl@0
  1431
		pos = bufferSize + pos;
sl@0
  1432
		bufferSize = KBufferSize;
sl@0
  1433
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1434
		
sl@0
  1435
		err = aParser->GetStreamable(streamable);
sl@0
  1436
		}
sl@0
  1437
	
sl@0
  1438
	if (err != KErrNone)
sl@0
  1439
		{
sl@0
  1440
		if (!ShouldRunOOMTest())
sl@0
  1441
			{
sl@0
  1442
			ERR_PRINTF2(_L("aParser->GetStreamable() returns %d"), err);
sl@0
  1443
			}
sl@0
  1444
		SetTestStepError(err);
sl@0
  1445
		}
sl@0
  1446
	
sl@0
  1447
	ParserCompleteL(aParser);
sl@0
  1448
	FileClose();
sl@0
  1449
	}
sl@0
  1450
sl@0
  1451
// -----------------------------------------------------------------------------
sl@0
  1452
// Retrieve buffered bytes, and video & audio frames synchronously in file mode
sl@0
  1453
// -----------------------------------------------------------------------------
sl@0
  1454
//
sl@0
  1455
C3GPLibParser_0011::C3GPLibParser_0011()
sl@0
  1456
	{	
sl@0
  1457
	}
sl@0
  1458
sl@0
  1459
TVerdict C3GPLibParser_0011::doTestStepL()
sl@0
  1460
	{
sl@0
  1461
	if(TestStepResult() == EPass)
sl@0
  1462
		{
sl@0
  1463
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1464
		CleanupStack::PushL(parser);
sl@0
  1465
		
sl@0
  1466
		TRAPD(err, ReadFrameL(parser));
sl@0
  1467
		if (err != KErrNone)
sl@0
  1468
			{
sl@0
  1469
			SetTestStepResult(EFail);
sl@0
  1470
			}
sl@0
  1471
		
sl@0
  1472
		CleanupStack::PopAndDestroy(parser);
sl@0
  1473
		}
sl@0
  1474
	return TestStepResult();
sl@0
  1475
	}
sl@0
  1476
sl@0
  1477
void C3GPLibParser_0011::ReadFrameL(C3GPParse* aParse)
sl@0
  1478
	{
sl@0
  1479
	// Parser open using File path 
sl@0
  1480
	ParserOpenFileL(aParse);
sl@0
  1481
	User::LeaveIfError(DoReadFrame(aParse));
sl@0
  1482
	ParserCompleteL(aParse);
sl@0
  1483
	
sl@0
  1484
	// Parser open using file handler
sl@0
  1485
	ParserOpenFileHandleL(aParse);
sl@0
  1486
	User::LeaveIfError(DoReadFrame(aParse));
sl@0
  1487
	ParserCompleteHandleL(aParse);
sl@0
  1488
    
sl@0
  1489
	// Parser open using CAF
sl@0
  1490
	ParserOpenCafLC(aParse);
sl@0
  1491
	User::LeaveIfError(DoReadFrame(aParse));
sl@0
  1492
	ParserCompleteCafL(aParse);
sl@0
  1493
	}
sl@0
  1494
sl@0
  1495
// -----------------------------------------------------------------------------
sl@0
  1496
// Parse video & audio frames from a mp4/3gp file asynchronously in file mode
sl@0
  1497
// -----------------------------------------------------------------------------
sl@0
  1498
//
sl@0
  1499
C3GPLibParser_0014::C3GPLibParser_0014()
sl@0
  1500
	{	
sl@0
  1501
	}
sl@0
  1502
sl@0
  1503
TVerdict C3GPLibParser_0014::doTestStepPreambleL()
sl@0
  1504
	{
sl@0
  1505
	C3GPLib_AsyncObserver::doTestStepPreambleL();	
sl@0
  1506
	if (TestStepResult() == EPass)
sl@0
  1507
		{
sl@0
  1508
		iScheduler = new (ELeave) CActiveScheduler;
sl@0
  1509
		CActiveScheduler::Install(iScheduler);
sl@0
  1510
		}
sl@0
  1511
	return TestStepResult();
sl@0
  1512
	}
sl@0
  1513
sl@0
  1514
TVerdict C3GPLibParser_0014::doTestStepPostambleL()
sl@0
  1515
	{
sl@0
  1516
	C3GPLib_AsyncObserver::doTestStepPostambleL();
sl@0
  1517
	if( iScheduler )
sl@0
  1518
		{
sl@0
  1519
		INFO_PRINTF1(_L("delete iScheduler"));
sl@0
  1520
		CActiveScheduler::Install(NULL);
sl@0
  1521
		delete iScheduler;
sl@0
  1522
		iScheduler = NULL;
sl@0
  1523
		}
sl@0
  1524
sl@0
  1525
	return TestStepResult();
sl@0
  1526
	}
sl@0
  1527
sl@0
  1528
TVerdict C3GPLibParser_0014::doTestStepL()
sl@0
  1529
	{
sl@0
  1530
	if(TestStepResult() == EPass)
sl@0
  1531
		{
sl@0
  1532
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1533
		CleanupStack::PushL(parser);
sl@0
  1534
		
sl@0
  1535
		TRAPD(err, ReadFrameAsyncL(parser));
sl@0
  1536
		if (err != KErrNone)
sl@0
  1537
			{
sl@0
  1538
			SetTestStepResult(EFail);
sl@0
  1539
			}
sl@0
  1540
		
sl@0
  1541
		CleanupStack::PopAndDestroy(parser);
sl@0
  1542
		}
sl@0
  1543
	return TestStepResult();
sl@0
  1544
	}
sl@0
  1545
sl@0
  1546
void C3GPLibParser_0014::ReadFrameAsyncL(C3GPParse* aParser)
sl@0
  1547
	{
sl@0
  1548
	ParserOpenFileL(aParser);
sl@0
  1549
	User::LeaveIfError(DoReadFrameAsync(aParser));
sl@0
  1550
	if (!ShouldRunOOMTest())
sl@0
  1551
		{
sl@0
  1552
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL()"));
sl@0
  1553
		}
sl@0
  1554
	ParserCompleteL(aParser);
sl@0
  1555
sl@0
  1556
	ParserOpenFileL(aParser);
sl@0
  1557
	User::LeaveIfError(DoReadFrameAsync(aParser, ETrue));
sl@0
  1558
	if (!ShouldRunOOMTest())
sl@0
  1559
		{
sl@0
  1560
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL(), then cancel the read"));
sl@0
  1561
		}
sl@0
  1562
	ParserCompleteL(aParser);
sl@0
  1563
	
sl@0
  1564
	ParserOpenFileHandleL(aParser);
sl@0
  1565
	User::LeaveIfError(DoReadFrameAsync(aParser));
sl@0
  1566
	if (!ShouldRunOOMTest())
sl@0
  1567
		{
sl@0
  1568
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using file handler"));
sl@0
  1569
		}
sl@0
  1570
	ParserCompleteHandleL(aParser);
sl@0
  1571
sl@0
  1572
	ParserOpenCafLC(aParser);
sl@0
  1573
	User::LeaveIfError(DoReadFrameAsync(aParser));
sl@0
  1574
	if (!ShouldRunOOMTest())
sl@0
  1575
		{
sl@0
  1576
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using CAF"));
sl@0
  1577
		}
sl@0
  1578
	ParserCompleteCafL(aParser);
sl@0
  1579
	}
sl@0
  1580
sl@0
  1581
TInt C3GPLibParser_0014::DoReadFrameAsync(C3GPParse* aParser, TBool aCancel)
sl@0
  1582
	{    
sl@0
  1583
    TInt err = KErrNone;
sl@0
  1584
    
sl@0
  1585
    if (!aCancel)
sl@0
  1586
    	{
sl@0
  1587
    	err = ReadAudioVideoFrameAsync(aParser, ETrue);
sl@0
  1588
    	if (err == KErrNone)
sl@0
  1589
    		{
sl@0
  1590
    		err = ReadAudioVideoFrameAsync(aParser, EFalse);
sl@0
  1591
    		} 
sl@0
  1592
    	}
sl@0
  1593
    else
sl@0
  1594
    	{
sl@0
  1595
    	err = ReadAudioVideoFrameAsync(aParser, EFalse, ETrue);
sl@0
  1596
    	}
sl@0
  1597
 
sl@0
  1598
    return err;
sl@0
  1599
    }
sl@0
  1600
sl@0
  1601
// -----------------------------------------------------------------------------
sl@0
  1602
// Parse video & audio frames from a mp4/3gp file synchronously
sl@0
  1603
// -----------------------------------------------------------------------------
sl@0
  1604
//
sl@0
  1605
C3GPLibParser_0015::C3GPLibParser_0015()
sl@0
  1606
	{	
sl@0
  1607
	}
sl@0
  1608
sl@0
  1609
TVerdict C3GPLibParser_0015::doTestStepL()
sl@0
  1610
	{
sl@0
  1611
	if(TestStepResult() == EPass)
sl@0
  1612
		{
sl@0
  1613
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1614
		CleanupStack::PushL(parser);
sl@0
  1615
		
sl@0
  1616
		TRAPD(err, ReadFrameL(parser));
sl@0
  1617
		if (err != KErrNone)
sl@0
  1618
			{
sl@0
  1619
			SetTestStepResult(EFail);
sl@0
  1620
			}
sl@0
  1621
		
sl@0
  1622
		CleanupStack::PopAndDestroy(parser);
sl@0
  1623
		}
sl@0
  1624
	return TestStepResult();
sl@0
  1625
	}
sl@0
  1626
sl@0
  1627
void C3GPLibParser_0015::ReadFrameL(C3GPParse* aParser)
sl@0
  1628
	{
sl@0
  1629
	FileOpenL();
sl@0
  1630
	ReadFrameBufferModeL(aParser);
sl@0
  1631
	FileClose();
sl@0
  1632
	}
sl@0
  1633
sl@0
  1634
// -----------------------------------------------------------------------------
sl@0
  1635
// Get frame type using file path
sl@0
  1636
// -----------------------------------------------------------------------------
sl@0
  1637
//
sl@0
  1638
C3GPLibParser_0016::C3GPLibParser_0016()
sl@0
  1639
	{	
sl@0
  1640
	}
sl@0
  1641
sl@0
  1642
sl@0
  1643
TVerdict C3GPLibParser_0016::doTestStepL()
sl@0
  1644
	{
sl@0
  1645
	if(TestStepResult() == EPass)
sl@0
  1646
		{
sl@0
  1647
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1648
		CleanupStack::PushL(parser);
sl@0
  1649
		
sl@0
  1650
		TRAPD(err, GetFrameTypeL(parser));
sl@0
  1651
		if (err != KErrNone)
sl@0
  1652
			{
sl@0
  1653
			SetTestStepResult(EFail);
sl@0
  1654
			}
sl@0
  1655
		
sl@0
  1656
		CleanupStack::PopAndDestroy(parser);
sl@0
  1657
		}
sl@0
  1658
	return TestStepResult();
sl@0
  1659
	}
sl@0
  1660
sl@0
  1661
void C3GPLibParser_0016::GetFrameTypeL(C3GPParse* aParser)
sl@0
  1662
	{
sl@0
  1663
	ParserOpenFileL(aParser);
sl@0
  1664
	
sl@0
  1665
	T3GPFrameType type;
sl@0
  1666
	TInt err = aParser->GetFrameType(type);
sl@0
  1667
	if (err == KErrNone)
sl@0
  1668
		{
sl@0
  1669
		TUint num;
sl@0
  1670
		err = aParser->GetNumberOfVideoFrames(num);
sl@0
  1671
		if (err == KErrNone)
sl@0
  1672
			{
sl@0
  1673
			// There is number of video in the file. Calling GetFrameType num+1 time won't affect 
sl@0
  1674
			//the parser’s current position. It should return the same results
sl@0
  1675
			for (TInt i = 0; i < num; i++)
sl@0
  1676
				{
sl@0
  1677
				err = aParser->GetFrameType(type);
sl@0
  1678
				User::LeaveIfError(err);
sl@0
  1679
				}
sl@0
  1680
			err = aParser->GetFrameType(type);
sl@0
  1681
			User::LeaveIfError(err);
sl@0
  1682
			}
sl@0
  1683
sl@0
  1684
		if (!ShouldRunOOMTest())
sl@0
  1685
			{
sl@0
  1686
			INFO_PRINTF2(_L("GetFrameType return type %d. "), type);
sl@0
  1687
			}
sl@0
  1688
		if (type == E3GPAudio)
sl@0
  1689
			{
sl@0
  1690
			// read 1 audio frame		
sl@0
  1691
			err = ReadAudioVideoFrame(aParser, EFalse, ETrue);
sl@0
  1692
			User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame")));
sl@0
  1693
sl@0
  1694
			err = aParser->GetFrameType(type);
sl@0
  1695
			if (!ShouldRunOOMTest())
sl@0
  1696
				{
sl@0
  1697
				INFO_PRINTF3(_L("After read 1 audio frame, GetFrameType return err %d; type %d. "), err, type);
sl@0
  1698
				}
sl@0
  1699
			SetTestStepError(err);
sl@0
  1700
			}
sl@0
  1701
		if (err == KErrNone && type == E3GPVideo)
sl@0
  1702
			{
sl@0
  1703
			// read 1 video frame
sl@0
  1704
			err = ReadAudioVideoFrame(aParser, EFalse, EFalse);
sl@0
  1705
			User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame")));
sl@0
  1706
			
sl@0
  1707
			err = aParser->GetFrameType(type);
sl@0
  1708
			SetTestStepError(err);
sl@0
  1709
			}
sl@0
  1710
		}
sl@0
  1711
	else
sl@0
  1712
		{
sl@0
  1713
		SetTestStepError(err);
sl@0
  1714
		}
sl@0
  1715
	ParserCompleteL(aParser);
sl@0
  1716
	}
sl@0
  1717
sl@0
  1718
// -----------------------------------------------------------------------------
sl@0
  1719
// Get the QCELP storage mode in file path and buffer mode
sl@0
  1720
// -----------------------------------------------------------------------------
sl@0
  1721
//
sl@0
  1722
C3GPLibParser_0017::C3GPLibParser_0017()
sl@0
  1723
	{	
sl@0
  1724
	}
sl@0
  1725
sl@0
  1726
TVerdict C3GPLibParser_0017::doTestStepL()
sl@0
  1727
	{
sl@0
  1728
	if(TestStepResult() == EPass)
sl@0
  1729
		{
sl@0
  1730
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1731
		CleanupStack::PushL(parser);
sl@0
  1732
		
sl@0
  1733
		TRAPD(err, GetQcelModeL(parser));
sl@0
  1734
		if (err != KErrNone)
sl@0
  1735
			{
sl@0
  1736
			SetTestStepResult(EFail);
sl@0
  1737
			}
sl@0
  1738
		
sl@0
  1739
		CleanupStack::PopAndDestroy(parser);
sl@0
  1740
		}
sl@0
  1741
	return TestStepResult();
sl@0
  1742
	}
sl@0
  1743
sl@0
  1744
void C3GPLibParser_0017::GetQcelModeL(C3GPParse* aParser)
sl@0
  1745
	{
sl@0
  1746
	// file mode
sl@0
  1747
	ParserOpenFileL(aParser);
sl@0
  1748
	TInt err = KErrNone;
sl@0
  1749
	T3GPQcelpStorageMode mode;
sl@0
  1750
	err = aParser->GetQcelpStorageMode(mode);
sl@0
  1751
	if (err != KErrNone)
sl@0
  1752
		{
sl@0
  1753
		if (!ShouldRunOOMTest())
sl@0
  1754
			{
sl@0
  1755
			ERR_PRINTF3(_L("aParser->GetQcelpStorageMode(mode) file mode return %d; mode %d. "), err, mode);
sl@0
  1756
			}
sl@0
  1757
		SetTestStepError(err);
sl@0
  1758
		}
sl@0
  1759
sl@0
  1760
	if ((iTestSection.Compare(KEsds) == 0 && mode != E3GPQcelpSampleEntryBox ) ||
sl@0
  1761
			(iTestSection.Compare(KSqcp) == 0 && mode != E3GPMP4AudioDescriptionBox ))
sl@0
  1762
		{
sl@0
  1763
		User::Leave(KErrGeneral);
sl@0
  1764
		}
sl@0
  1765
	
sl@0
  1766
	ParserCompleteL(aParser);
sl@0
  1767
	
sl@0
  1768
	// buffer mode
sl@0
  1769
	ParserOpenL(aParser);
sl@0
  1770
	FileOpenL();
sl@0
  1771
	
sl@0
  1772
	// Insert 1K data into the library
sl@0
  1773
	TInt pos = 0;
sl@0
  1774
	TInt bufferSize = 1000;
sl@0
  1775
	
sl@0
  1776
	InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1777
	err = aParser->GetQcelpStorageMode(mode);
sl@0
  1778
	
sl@0
  1779
	while (err == KErr3gpLibMoreDataRequired )
sl@0
  1780
		{
sl@0
  1781
		pos = pos + bufferSize;
sl@0
  1782
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1783
		err = aParser->GetQcelpStorageMode(mode);
sl@0
  1784
		}
sl@0
  1785
	
sl@0
  1786
	if (err != KErrNone)
sl@0
  1787
		{
sl@0
  1788
		if (!ShouldRunOOMTest())
sl@0
  1789
			{
sl@0
  1790
			ERR_PRINTF3(_L("aParser->GetQcelpStorageMode(mode) file mode return %d; mode %d. "), err, mode);
sl@0
  1791
			}
sl@0
  1792
		SetTestStepError(err);
sl@0
  1793
		}
sl@0
  1794
	
sl@0
  1795
	if ((iTestSection.Compare(KEsds) == 0 && mode != E3GPQcelpSampleEntryBox ) ||
sl@0
  1796
			(iTestSection.Compare(KSqcp) == 0 && mode != E3GPMP4AudioDescriptionBox ))
sl@0
  1797
		{
sl@0
  1798
		User::Leave(KErrGeneral);
sl@0
  1799
		}
sl@0
  1800
	
sl@0
  1801
	ParserCompleteL(aParser);
sl@0
  1802
	FileClose();
sl@0
  1803
	}
sl@0
  1804
sl@0
  1805
// -----------------------------------------------------------------------------
sl@0
  1806
// Get H263 video leve in file path and buffer mode.
sl@0
  1807
// -----------------------------------------------------------------------------
sl@0
  1808
//
sl@0
  1809
C3GPLibParser_0021::C3GPLibParser_0021()
sl@0
  1810
	{	
sl@0
  1811
	}
sl@0
  1812
sl@0
  1813
TVerdict C3GPLibParser_0021::doTestStepL()
sl@0
  1814
	{
sl@0
  1815
	if(TestStepResult() == EPass)
sl@0
  1816
		{
sl@0
  1817
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1818
		CleanupStack::PushL(parser);
sl@0
  1819
		
sl@0
  1820
		TRAPD(err, GetH263LevelL(parser));
sl@0
  1821
		if (err != KErrNone)
sl@0
  1822
			{
sl@0
  1823
			SetTestStepResult(EFail);
sl@0
  1824
			}
sl@0
  1825
		
sl@0
  1826
		CleanupStack::PopAndDestroy(parser);
sl@0
  1827
		}
sl@0
  1828
	return TestStepResult();
sl@0
  1829
	}
sl@0
  1830
sl@0
  1831
void C3GPLibParser_0021::GetH263LevelL(C3GPParse* aParser)
sl@0
  1832
	{
sl@0
  1833
	// file mode
sl@0
  1834
	ParserOpenFileL(aParser);
sl@0
  1835
	TInt err = KErrNone;
sl@0
  1836
	TInt level;
sl@0
  1837
	err = aParser->GetH263VideoLevel(level);
sl@0
  1838
	if (err != KErrNone)
sl@0
  1839
		{
sl@0
  1840
		if (!ShouldRunOOMTest())
sl@0
  1841
			{
sl@0
  1842
			ERR_PRINTF3(_L("aParser->GetH263VideoLevel() file mode return %d; level %d. "), err, level);
sl@0
  1843
			}
sl@0
  1844
		SetTestStepError(err);
sl@0
  1845
		}
sl@0
  1846
	
sl@0
  1847
	ParserCompleteL(aParser);
sl@0
  1848
	
sl@0
  1849
	// buffer mode
sl@0
  1850
	ParserOpenL(aParser);
sl@0
  1851
	FileOpenL();
sl@0
  1852
	
sl@0
  1853
	// Insert 1K data into the library
sl@0
  1854
	TInt pos = 0;
sl@0
  1855
	TInt bufferSize = KBufferSize;
sl@0
  1856
	
sl@0
  1857
	InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1858
	err = aParser->GetH263VideoLevel(level);;
sl@0
  1859
	
sl@0
  1860
	while (err == KErr3gpLibMoreDataRequired )
sl@0
  1861
		{
sl@0
  1862
		pos = pos + bufferSize;
sl@0
  1863
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1864
		err = aParser->GetH263VideoLevel(level);;
sl@0
  1865
		}
sl@0
  1866
	
sl@0
  1867
	if (err != KErrNone)
sl@0
  1868
		{
sl@0
  1869
		if (!ShouldRunOOMTest())
sl@0
  1870
			{
sl@0
  1871
			ERR_PRINTF3(_L("aParser->GetH263VideoLevel() file mode return %d; level %d. "), err, level);
sl@0
  1872
			}
sl@0
  1873
		SetTestStepError(err);
sl@0
  1874
		}
sl@0
  1875
	
sl@0
  1876
	ParserCompleteL(aParser);
sl@0
  1877
	FileClose();
sl@0
  1878
	}
sl@0
  1879
sl@0
  1880
// -----------------------------------------------------------------------------
sl@0
  1881
// Read Video and audio Decoder Info size and info in file path and buffer mode.
sl@0
  1882
// -----------------------------------------------------------------------------
sl@0
  1883
//
sl@0
  1884
C3GPLibParser_0023::C3GPLibParser_0023()
sl@0
  1885
	{	
sl@0
  1886
	}
sl@0
  1887
sl@0
  1888
TVerdict C3GPLibParser_0023::doTestStepL()
sl@0
  1889
	{
sl@0
  1890
	if(TestStepResult() == EPass)
sl@0
  1891
		{
sl@0
  1892
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1893
		CleanupStack::PushL(parser);
sl@0
  1894
		
sl@0
  1895
		TRAPD(err, GetDecoderInfoL(parser));
sl@0
  1896
		if (err != KErrNone)
sl@0
  1897
			{
sl@0
  1898
			SetTestStepResult(EFail);
sl@0
  1899
			}
sl@0
  1900
		
sl@0
  1901
		CleanupStack::PopAndDestroy(parser);
sl@0
  1902
		}
sl@0
  1903
	return TestStepResult();
sl@0
  1904
	}
sl@0
  1905
sl@0
  1906
void C3GPLibParser_0023::GetDecoderInfoL(C3GPParse* aParser)
sl@0
  1907
	{
sl@0
  1908
	// file mode
sl@0
  1909
	ParserOpenFileL(aParser);
sl@0
  1910
sl@0
  1911
	TInt errReadAudio = KErrNone;
sl@0
  1912
	TInt errReadVideo = KErrNone;
sl@0
  1913
	// Retrieve the info with buffer size = 0. Should fail with KErrOverflow
sl@0
  1914
	RBuf8 dsiBuffer;
sl@0
  1915
	CleanupClosePushL(dsiBuffer);
sl@0
  1916
	dsiBuffer.CreateL(0);
sl@0
  1917
	errReadAudio = aParser->GetAudioDecoderSpecificInfo(dsiBuffer);
sl@0
  1918
	errReadVideo = aParser->GetVideoDecoderSpecificInfo(dsiBuffer);
sl@0
  1919
	
sl@0
  1920
	if (errReadAudio == KErrOverflow && errReadVideo == KErrOverflow)
sl@0
  1921
		{
sl@0
  1922
		errReadAudio = ParserGetDecoderInfo(aParser);
sl@0
  1923
		
sl@0
  1924
		if (errReadAudio != KErrNone)
sl@0
  1925
			{
sl@0
  1926
			ERR_PRINTF2(_L("ParserGetDecoderInfo file mode return %d; "), errReadAudio);
sl@0
  1927
			User::Leave(errReadAudio);
sl@0
  1928
			}
sl@0
  1929
		}
sl@0
  1930
	else
sl@0
  1931
		{
sl@0
  1932
		ERR_PRINTF2(_L("ParserGetDecoderInfo file mode expected KErrOverflow, but return %d; "), errReadAudio);
sl@0
  1933
		User::Leave(errReadAudio);
sl@0
  1934
		}
sl@0
  1935
	
sl@0
  1936
	ParserCompleteL(aParser);
sl@0
  1937
	
sl@0
  1938
	// buffer mode
sl@0
  1939
	ParserOpenL(aParser);
sl@0
  1940
	FileOpenL();
sl@0
  1941
	
sl@0
  1942
	// Insert 1K data into the library
sl@0
  1943
	TInt pos = 0;
sl@0
  1944
	TInt bufferSize = KBufferSize;
sl@0
  1945
	
sl@0
  1946
	InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1947
	
sl@0
  1948
	// Retrieve the info with buffer size = 0. Should fail with KErrOverflow
sl@0
  1949
	dsiBuffer.Close();
sl@0
  1950
	dsiBuffer.CreateL(0);
sl@0
  1951
	errReadAudio = aParser->GetAudioDecoderSpecificInfo(dsiBuffer);
sl@0
  1952
	errReadVideo = aParser->GetVideoDecoderSpecificInfo(dsiBuffer);
sl@0
  1953
	CleanupStack::PopAndDestroy(&dsiBuffer);
sl@0
  1954
	
sl@0
  1955
	if (errReadAudio != KErrOverflow || errReadVideo != KErrOverflow)
sl@0
  1956
		{
sl@0
  1957
		ERR_PRINTF2(_L("ParserGetDecoderInfo buffer mode expected KErrOverflow, but return %d; "), errReadAudio);
sl@0
  1958
		User::Leave(errReadAudio);
sl@0
  1959
		}
sl@0
  1960
	errReadAudio = ParserGetDecoderInfo(aParser);
sl@0
  1961
	
sl@0
  1962
	while (errReadAudio == KErr3gpLibMoreDataRequired )
sl@0
  1963
		{
sl@0
  1964
		pos = pos + bufferSize;
sl@0
  1965
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  1966
		errReadAudio = ParserGetDecoderInfo(aParser);
sl@0
  1967
		}
sl@0
  1968
	if (!ShouldRunOOMTest())
sl@0
  1969
		{
sl@0
  1970
		INFO_PRINTF2(_L("ParserGetDecoderInfo(aParser) buffer mode return %d. "), errReadAudio);
sl@0
  1971
		}
sl@0
  1972
	ParserCompleteL(aParser);
sl@0
  1973
	FileClose();
sl@0
  1974
	}
sl@0
  1975
sl@0
  1976
// -----------------------------------------------------------------------------
sl@0
  1977
// Seek different position of a video/audio file
sl@0
  1978
// -----------------------------------------------------------------------------
sl@0
  1979
//
sl@0
  1980
C3GPLibParser_0027::C3GPLibParser_0027()
sl@0
  1981
	{
sl@0
  1982
	}
sl@0
  1983
sl@0
  1984
TVerdict C3GPLibParser_0027::doTestStepL()
sl@0
  1985
	{
sl@0
  1986
	if(TestStepResult() == EPass)
sl@0
  1987
		{
sl@0
  1988
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  1989
		CleanupStack::PushL(parser);
sl@0
  1990
		
sl@0
  1991
		TRAPD(err, SeekTestL(parser));
sl@0
  1992
		if (err != KErrNone)
sl@0
  1993
			{
sl@0
  1994
			SetTestStepResult(EFail);
sl@0
  1995
			}
sl@0
  1996
		
sl@0
  1997
		CleanupStack::PopAndDestroy(parser);
sl@0
  1998
		}
sl@0
  1999
	return TestStepResult();
sl@0
  2000
	}
sl@0
  2001
sl@0
  2002
void C3GPLibParser_0027::SeekTestL(C3GPParse* aParse)
sl@0
  2003
	{	
sl@0
  2004
	// file mode
sl@0
  2005
	ParserOpenFileL(aParse);
sl@0
  2006
	
sl@0
  2007
	TUint audioPos;
sl@0
  2008
	TUint videoPos;
sl@0
  2009
	TUint timeStampInMs = 0;
sl@0
  2010
	
sl@0
  2011
	// Seek to position 0.
sl@0
  2012
	TInt err = KErrNone; 
sl@0
  2013
	if (iTestSection.Compare(KNoAudioNoVideo) != 0)
sl@0
  2014
		{
sl@0
  2015
		// Retrieve video & audio stream length
sl@0
  2016
		TUint videoLength; 
sl@0
  2017
		TUint audioLength; 
sl@0
  2018
		TInt videoError;
sl@0
  2019
sl@0
  2020
		err = GetClipProperties(aParse, videoError, videoLength, audioLength);
sl@0
  2021
		if (iTestSection.Compare(KAudioOnly) == 0)
sl@0
  2022
			{
sl@0
  2023
			// audio only, GetVideoProperties should fail with KErrNotSupported. Set video length to 0
sl@0
  2024
			User::LeaveIfError(CheckError(videoError, KErrNotSupported, _L("GetClipProperties(aParse, videoError, videoLength, audioLength))")));
sl@0
  2025
			videoLength = 0;
sl@0
  2026
			}
sl@0
  2027
		else if (iTestSection.Compare(KVideoOnly) == 0)
sl@0
  2028
			{
sl@0
  2029
			// video only, GetAudioProperties should fail with KErrNotSupported. Set audio length to 0
sl@0
  2030
			User::LeaveIfError(CheckError(err, KErrNotSupported, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)")));
sl@0
  2031
			audioLength = 0;
sl@0
  2032
			}
sl@0
  2033
		else 
sl@0
  2034
			{
sl@0
  2035
			// All other files contains audio and video data
sl@0
  2036
			User::LeaveIfError(CheckError(videoError, KErrNone, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)")));
sl@0
  2037
			User::LeaveIfError(CheckError(err, KErrNone, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)")));
sl@0
  2038
			}
sl@0
  2039
		
sl@0
  2040
		if (audioLength >= videoLength)
sl@0
  2041
			{
sl@0
  2042
			timeStampInMs = audioLength;
sl@0
  2043
			}
sl@0
  2044
		else
sl@0
  2045
			{
sl@0
  2046
			timeStampInMs = videoLength;
sl@0
  2047
			}
sl@0
  2048
		
sl@0
  2049
		if (iTestSection.Compare(KSameLenAudioVideo) == 0 || iTestSection.Compare(KAudioOnly) == 0)
sl@0
  2050
			{
sl@0
  2051
			err = ParserSeek(aParse, timeStampInMs, audioPos, videoPos);
sl@0
  2052
			User::LeaveIfError(err);
sl@0
  2053
			}
sl@0
  2054
		
sl@0
  2055
		if (iTestSection.Compare(KAudioMore) == 0 || iTestSection.Compare(KVideoMore) == 0 )
sl@0
  2056
			{
sl@0
  2057
			timeStampInMs = (audioLength + videoLength)/2;
sl@0
  2058
			err = aParse->Seek(timeStampInMs, EFalse, audioPos, videoPos);
sl@0
  2059
			User::LeaveIfError(err);
sl@0
  2060
			}
sl@0
  2061
		}
sl@0
  2062
	
sl@0
  2063
	ParserCompleteL(aParse);
sl@0
  2064
	}
sl@0
  2065
sl@0
  2066
// Seek position 0, half the length and the length of the stream
sl@0
  2067
TInt C3GPLibParser_0027::ParserSeek(C3GPParse* aParser, TInt aLen, TUint& aAudioPos, TUint& aVideoPos)
sl@0
  2068
	{
sl@0
  2069
	TInt err = KErrNone;
sl@0
  2070
	TUint position = 0;
sl@0
  2071
	while (err == KErrNone && position <= aLen)
sl@0
  2072
		{
sl@0
  2073
		err = aParser->Seek(position, ETrue, aAudioPos, aVideoPos);
sl@0
  2074
		if (err == KErrNone)
sl@0
  2075
			{
sl@0
  2076
			err = aParser->Seek(position, EFalse, aAudioPos, aVideoPos);
sl@0
  2077
			}
sl@0
  2078
		position = position + aLen/2;
sl@0
  2079
		}
sl@0
  2080
sl@0
  2081
	if (err != KErrNone)
sl@0
  2082
		{
sl@0
  2083
		ERR_PRINTF3(_L("aParser->Seek() failed with %d when positon is %d"), err, position);
sl@0
  2084
		}
sl@0
  2085
	return err;
sl@0
  2086
	}
sl@0
  2087
sl@0
  2088
// -----------------------------------------------------------------------------
sl@0
  2089
// Seek positions after any keyframe and immediately after a non-key frame.
sl@0
  2090
// -----------------------------------------------------------------------------
sl@0
  2091
//
sl@0
  2092
C3GPLibParser_0031::C3GPLibParser_0031()
sl@0
  2093
	{	
sl@0
  2094
	}
sl@0
  2095
sl@0
  2096
TVerdict C3GPLibParser_0031::doTestStepL()
sl@0
  2097
	{
sl@0
  2098
	if(TestStepResult() == EPass)
sl@0
  2099
		{
sl@0
  2100
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2101
		CleanupStack::PushL(parser);
sl@0
  2102
		
sl@0
  2103
		TRAPD(err, SeekTestL(parser));
sl@0
  2104
		if (err != KErrNone)
sl@0
  2105
			{
sl@0
  2106
			SetTestStepResult(EFail);
sl@0
  2107
			}
sl@0
  2108
		
sl@0
  2109
		CleanupStack::PopAndDestroy(parser);
sl@0
  2110
		}
sl@0
  2111
	return TestStepResult();
sl@0
  2112
	}
sl@0
  2113
sl@0
  2114
void C3GPLibParser_0031::SeekTestL(C3GPParse* aParser)
sl@0
  2115
	{
sl@0
  2116
	// file mode
sl@0
  2117
	ParserOpenFileL(aParser);	
sl@0
  2118
	DoSeekTestL(aParser);			
sl@0
  2119
	ParserCompleteL(aParser);
sl@0
  2120
	}
sl@0
  2121
sl@0
  2122
// -----------------------------------------------------------------------------
sl@0
  2123
// Check frame availability using file path
sl@0
  2124
// -----------------------------------------------------------------------------
sl@0
  2125
//
sl@0
  2126
C3GPLibParser_0032::C3GPLibParser_0032()
sl@0
  2127
	{	
sl@0
  2128
	}
sl@0
  2129
sl@0
  2130
TVerdict C3GPLibParser_0032::doTestStepL()
sl@0
  2131
	{
sl@0
  2132
	if(TestStepResult() == EPass)
sl@0
  2133
		{
sl@0
  2134
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2135
		CleanupStack::PushL(parser);
sl@0
  2136
		
sl@0
  2137
		TRAPD(err, GetFrameAvailabilityL(parser));
sl@0
  2138
		if (err != KErrNone)
sl@0
  2139
			{
sl@0
  2140
			SetTestStepResult(EFail);
sl@0
  2141
			}
sl@0
  2142
		
sl@0
  2143
		CleanupStack::PopAndDestroy(parser);
sl@0
  2144
		}
sl@0
  2145
	return TestStepResult();
sl@0
  2146
	}
sl@0
  2147
sl@0
  2148
void C3GPLibParser_0032::GetFrameAvailabilityL(C3GPParse* aParser)
sl@0
  2149
	{
sl@0
  2150
	// file mode
sl@0
  2151
	ParserOpenFileL(aParser);
sl@0
  2152
	DoGetFrameAvailabilityL(aParser);
sl@0
  2153
	ParserCompleteL(aParser);
sl@0
  2154
	}
sl@0
  2155
sl@0
  2156
void C3GPLibParser_0032::DoGetFrameAvailabilityL(C3GPParse* aParser)
sl@0
  2157
	{
sl@0
  2158
	T3GPFrameType audioType = E3GPAudio;
sl@0
  2159
	T3GPFrameType videoType = E3GPVideo;
sl@0
  2160
	TBool audioAvailable;
sl@0
  2161
	TBool videoAvailable;
sl@0
  2162
	TUint num;
sl@0
  2163
	TInt audioErr = aParser->GetFrameAvailability(audioType, audioAvailable);
sl@0
  2164
	if (audioErr != KErrNone && audioErr != KErrNotFound)
sl@0
  2165
		{
sl@0
  2166
		SetTestStepError(audioErr);
sl@0
  2167
		User::LeaveIfError(audioErr);
sl@0
  2168
		}
sl@0
  2169
	
sl@0
  2170
	TInt videoErr = aParser->GetFrameAvailability(videoType, videoAvailable);
sl@0
  2171
	if (videoErr != KErrNone && videoErr != KErrNotFound)
sl@0
  2172
		{
sl@0
  2173
		SetTestStepError(videoErr);
sl@0
  2174
		User::LeaveIfError(videoErr);
sl@0
  2175
		}
sl@0
  2176
	
sl@0
  2177
	TInt err = aParser->GetNumberOfVideoFrames(num);
sl@0
  2178
	if (err != KErrNone && err != KErrNotSupported)
sl@0
  2179
		{
sl@0
  2180
		SetTestStepError(err);
sl@0
  2181
		User::LeaveIfError(err);
sl@0
  2182
		}
sl@0
  2183
	
sl@0
  2184
	if (iTestSection.Compare(KNoAudioNoVideo) == 0)
sl@0
  2185
		{
sl@0
  2186
		if (audioErr != KErrNotFound || videoErr != KErrNotFound 
sl@0
  2187
				|| audioAvailable || videoAvailable)
sl@0
  2188
			{
sl@0
  2189
			ERR_PRINTF2(_L("GetFrameAvailability() audio failed with %d, expected KErrNotFound"), audioErr);
sl@0
  2190
			ERR_PRINTF2(_L("GetFrameAvailability() expected audioAvailable returns false, actual %d "), audioAvailable);
sl@0
  2191
			ERR_PRINTF2(_L("GetFrameAvailability() video failed with %d, expected KErrNotFound;"), videoErr);
sl@0
  2192
			ERR_PRINTF2(_L("GetFrameAvailability() expected videoAvailable returns false, actual %d "), videoAvailable);
sl@0
  2193
			User::Leave(KErrGeneral);  
sl@0
  2194
			}				
sl@0
  2195
		User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser->GetNumberOfVideoFrames(num)")));
sl@0
  2196
		}
sl@0
  2197
	else if (iTestSection.Compare(KAudioOnly) == 0)
sl@0
  2198
		{
sl@0
  2199
		if (audioErr != KErrNone || videoErr != KErrNotFound 
sl@0
  2200
				|| !audioAvailable || videoAvailable)
sl@0
  2201
			{
sl@0
  2202
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNone"), audioErr);
sl@0
  2203
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns True, actual %d "), audioAvailable);
sl@0
  2204
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNotFound;"), videoErr);
sl@0
  2205
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns false, actual %d"), videoAvailable);
sl@0
  2206
			User::Leave(KErrGeneral);
sl@0
  2207
			}
sl@0
  2208
		User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser->GetNumberOfVideoFrames(num)")));
sl@0
  2209
		}
sl@0
  2210
	else if (iTestSection.Compare(KVideoOnly) == 0)
sl@0
  2211
		{
sl@0
  2212
		if (audioErr != KErrNotFound || videoErr != KErrNone 
sl@0
  2213
				|| audioAvailable || !videoAvailable)
sl@0
  2214
			{
sl@0
  2215
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNotFound"), audioErr);
sl@0
  2216
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns false, actual %d "), audioAvailable);
sl@0
  2217
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNone;"), videoErr);
sl@0
  2218
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns true, actual %d"), videoAvailable);
sl@0
  2219
			User::Leave(KErrGeneral);
sl@0
  2220
			}
sl@0
  2221
		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetNumberOfVideoFrames(num)")));
sl@0
  2222
		if (num != 265)
sl@0
  2223
			{
sl@0
  2224
			ERR_PRINTF2(_L("file h263-no-audio.MP4 has 265 video frames. Got %d instread"), num);
sl@0
  2225
			User::Leave(KErrGeneral);
sl@0
  2226
			}
sl@0
  2227
		}
sl@0
  2228
	else // File contains both valid audio and video data
sl@0
  2229
		{
sl@0
  2230
		// If file contains avc profile main or extended, videoErr could be KErrNotFound
sl@0
  2231
		if (audioErr != KErrNone || !audioAvailable)
sl@0
  2232
			{
sl@0
  2233
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNone"), audioErr);
sl@0
  2234
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns True, actual %d "), audioAvailable);
sl@0
  2235
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNone;"), videoErr);
sl@0
  2236
			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns True, actual %d"), videoAvailable);
sl@0
  2237
			User::Leave(KErrGeneral);
sl@0
  2238
			}
sl@0
  2239
		if (videoErr != KErrNone)
sl@0
  2240
			{
sl@0
  2241
			SetTestStepError(videoErr);
sl@0
  2242
			}
sl@0
  2243
		else
sl@0
  2244
			{
sl@0
  2245
			User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetNumberOfVideoFrames(num)")));
sl@0
  2246
			}
sl@0
  2247
		}
sl@0
  2248
	}
sl@0
  2249
sl@0
  2250
// -----------------------------------------------------------------------------
sl@0
  2251
// Retrieve video frame size & start time without parsing the content file frame 
sl@0
  2252
// by frame in file mode
sl@0
  2253
// -----------------------------------------------------------------------------
sl@0
  2254
//
sl@0
  2255
C3GPLibParser_0033::C3GPLibParser_0033()
sl@0
  2256
	{	
sl@0
  2257
	}
sl@0
  2258
sl@0
  2259
TVerdict C3GPLibParser_0033::doTestStepL()
sl@0
  2260
	{
sl@0
  2261
	if(TestStepResult() == EPass)
sl@0
  2262
		{
sl@0
  2263
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2264
		CleanupStack::PushL(parser);
sl@0
  2265
		
sl@0
  2266
		TRAPD(err, VideoInfoL(parser));
sl@0
  2267
		if (err != KErrNone)
sl@0
  2268
			{
sl@0
  2269
			SetTestStepResult(EFail);
sl@0
  2270
			}
sl@0
  2271
		
sl@0
  2272
		CleanupStack::PopAndDestroy(parser);
sl@0
  2273
		}
sl@0
  2274
	return TestStepResult();
sl@0
  2275
	}
sl@0
  2276
sl@0
  2277
void C3GPLibParser_0033::VideoInfoL(C3GPParse* aParser)
sl@0
  2278
	{
sl@0
  2279
	// file mode
sl@0
  2280
	ParserOpenFileL(aParser);
sl@0
  2281
	
sl@0
  2282
	TUint num; 
sl@0
  2283
	TInt num1 = 0;
sl@0
  2284
	TUint timeStampInMs = 0; 
sl@0
  2285
	TUint timeStampInTimescale = 0; 
sl@0
  2286
	TUint timeStampInMs1 = 0; 
sl@0
  2287
	TUint timeStampInTimescale1 = 0; 
sl@0
  2288
	TUint frameIndex;
sl@0
  2289
	TUint frameSize;
sl@0
  2290
	TBool keyFrame;
sl@0
  2291
	User::LeaveIfError(aParser->GetNumberOfVideoFrames(num));
sl@0
  2292
	
sl@0
  2293
	RBuf8 buffer;
sl@0
  2294
	CleanupClosePushL(buffer);
sl@0
  2295
	buffer.CreateL(0);
sl@0
  2296
	TInt err = aParser->ReadVideoFrame(buffer, keyFrame, timeStampInMs, timeStampInTimescale);
sl@0
  2297
	if (err != KErrOverflow)
sl@0
  2298
		{
sl@0
  2299
		ERR_PRINTF2(_L("aParser->ReadVideoFrame() expected KErrOverflow, actual %d"), err);
sl@0
  2300
		User::Leave(err);
sl@0
  2301
		}
sl@0
  2302
	User::LeaveIfError(aParser->GetVideoSampleEntryIndex(frameIndex));
sl@0
  2303
	CleanupStack::PopAndDestroy(&buffer);
sl@0
  2304
	
sl@0
  2305
	
sl@0
  2306
	err = KErrNone;
sl@0
  2307
	while (err == KErrNone)
sl@0
  2308
		{
sl@0
  2309
		timeStampInMs = 0; 
sl@0
  2310
		timeStampInTimescale = 0; 
sl@0
  2311
		timeStampInMs1 = 0; 
sl@0
  2312
		timeStampInTimescale1 = 0; 
sl@0
  2313
sl@0
  2314
		if (num1 < num)
sl@0
  2315
			{
sl@0
  2316
			User::LeaveIfError(aParser->GetVideoFrameSize(num1, frameSize));
sl@0
  2317
			User::LeaveIfError(aParser->GetVideoFrameStartTime(num1, timeStampInMs, timeStampInTimescale));
sl@0
  2318
			}
sl@0
  2319
		else
sl@0
  2320
			{
sl@0
  2321
			err = aParser->GetVideoFrameStartTime(num1, timeStampInMs, timeStampInTimescale);
sl@0
  2322
			err = aParser->GetVideoFrameSize(num1, frameSize);
sl@0
  2323
			}
sl@0
  2324
		RBuf8 buffer1;
sl@0
  2325
		CleanupClosePushL(buffer1);
sl@0
  2326
		buffer1.CreateL(frameSize);
sl@0
  2327
		err = aParser->ReadVideoFrame(buffer1, keyFrame, timeStampInMs1, timeStampInTimescale1);
sl@0
  2328
		
sl@0
  2329
		if (timeStampInMs != timeStampInMs1)
sl@0
  2330
			{
sl@0
  2331
			ERR_PRINTF3(_L("Two timestamps should be the same. timeStampInMs %d, timeStampInMs1 %d"), timeStampInMs, timeStampInMs1);
sl@0
  2332
			User::Leave(KErrGeneral);
sl@0
  2333
			}
sl@0
  2334
		CleanupStack::PopAndDestroy(&buffer1);
sl@0
  2335
		num1++;
sl@0
  2336
		}
sl@0
  2337
	
sl@0
  2338
	if (err != KErrNotFound)
sl@0
  2339
		{
sl@0
  2340
		ERR_PRINTF2(_L("expected KErrNotFound when finishing reading video frames. Actual err %d"), err);
sl@0
  2341
		User::Leave(KErrGeneral);
sl@0
  2342
		}
sl@0
  2343
	
sl@0
  2344
	if ((num1 - 1) != num)
sl@0
  2345
		{
sl@0
  2346
		ERR_PRINTF3(_L("Two numOfFrame should be the same. num %d, num1 %d"), num, num1);
sl@0
  2347
		User::Leave(KErrGeneral);
sl@0
  2348
		}
sl@0
  2349
	
sl@0
  2350
	// use an invalid index to attempt retrieving video frame size & start time.  Both should failed with error.
sl@0
  2351
	err = aParser->GetVideoFrameSize((num + 100), frameSize);
sl@0
  2352
	User::LeaveIfError(CheckError(err, KErrGeneral, _L("GetVideoFrameSize")));
sl@0
  2353
	
sl@0
  2354
	err = aParser->GetVideoFrameStartTime((num + 5), timeStampInMs, timeStampInTimescale);
sl@0
  2355
	User::LeaveIfError(CheckError(err, KErrGeneral, _L("GetVideoFrameStartTime")));
sl@0
  2356
	
sl@0
  2357
	ParserCompleteL(aParser);
sl@0
  2358
	}
sl@0
  2359
sl@0
  2360
// -----------------------------------------------------------------------------
sl@0
  2361
// Retrieve video frame size & start time without parsing the content file frame 
sl@0
  2362
// by frame in buffe mode
sl@0
  2363
// -----------------------------------------------------------------------------
sl@0
  2364
//
sl@0
  2365
C3GPLibParser_0034::C3GPLibParser_0034()
sl@0
  2366
	{	
sl@0
  2367
	}
sl@0
  2368
sl@0
  2369
TVerdict C3GPLibParser_0034::doTestStepL()
sl@0
  2370
	{
sl@0
  2371
	if(TestStepResult() == EPass)
sl@0
  2372
		{
sl@0
  2373
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2374
		CleanupStack::PushL(parser);
sl@0
  2375
		
sl@0
  2376
		TRAPD(err, VideoInfoBufferModeL(parser));
sl@0
  2377
		if (err != KErrNone)
sl@0
  2378
			{
sl@0
  2379
			SetTestStepResult(EFail);
sl@0
  2380
			}
sl@0
  2381
		
sl@0
  2382
		CleanupStack::PopAndDestroy(parser);
sl@0
  2383
		}
sl@0
  2384
	return TestStepResult();
sl@0
  2385
	}
sl@0
  2386
sl@0
  2387
void C3GPLibParser_0034::VideoInfoBufferModeL(C3GPParse* aParser)
sl@0
  2388
	{
sl@0
  2389
	// buffer mode
sl@0
  2390
	ParserOpenL(aParser);
sl@0
  2391
	FileOpenL();
sl@0
  2392
	
sl@0
  2393
	TUint num; 
sl@0
  2394
	TUint timeStampInMs = 0; 
sl@0
  2395
	TUint timeStampInTimescale = 0; 
sl@0
  2396
	TUint frameSize;
sl@0
  2397
	
sl@0
  2398
	// Insert 1K data into the library
sl@0
  2399
	TInt pos = 0;
sl@0
  2400
	TInt bufferSize = KBufferSize;
sl@0
  2401
	InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  2402
	TInt err = aParser->GetNumberOfVideoFrames(num);
sl@0
  2403
	if (err != KErrNone && err != KErrNotSupported && err != KErr3gpLibMoreDataRequired)
sl@0
  2404
		{
sl@0
  2405
		SetTestStepError(err);
sl@0
  2406
		User::LeaveIfError(err);
sl@0
  2407
		}
sl@0
  2408
	
sl@0
  2409
	while (err == KErr3gpLibMoreDataRequired )
sl@0
  2410
		{
sl@0
  2411
		pos = pos + bufferSize;
sl@0
  2412
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  2413
		err = aParser->GetNumberOfVideoFrames(num);
sl@0
  2414
		}
sl@0
  2415
sl@0
  2416
	if (err != KErrNone)
sl@0
  2417
		{
sl@0
  2418
		SetTestStepError(err);
sl@0
  2419
		}
sl@0
  2420
	else 
sl@0
  2421
		{
sl@0
  2422
		for (TUint i = 0; i < num; i++)
sl@0
  2423
			{
sl@0
  2424
			User::LeaveIfError(aParser->GetVideoFrameSize(i, frameSize));
sl@0
  2425
			User::LeaveIfError(aParser->GetVideoFrameStartTime(i, timeStampInMs, timeStampInTimescale));	
sl@0
  2426
			}
sl@0
  2427
		}
sl@0
  2428
	
sl@0
  2429
	ParserCompleteL(aParser);
sl@0
  2430
	FileClose();
sl@0
  2431
	}
sl@0
  2432
sl@0
  2433
// -----------------------------------------------------------------------------
sl@0
  2434
// Retrieve user atoms in all the possible locations 
sl@0
  2435
// -----------------------------------------------------------------------------
sl@0
  2436
//
sl@0
  2437
C3GPLibParser_0035::C3GPLibParser_0035()
sl@0
  2438
	{	
sl@0
  2439
	}
sl@0
  2440
sl@0
  2441
TVerdict C3GPLibParser_0035::doTestStepL()
sl@0
  2442
	{
sl@0
  2443
	if(TestStepResult() == EPass)
sl@0
  2444
		{
sl@0
  2445
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2446
		CleanupStack::PushL(parser);
sl@0
  2447
		
sl@0
  2448
		TRAPD(err, GetUserDataAtomL(parser));
sl@0
  2449
		if (err != KErrNone)
sl@0
  2450
			{
sl@0
  2451
			SetTestStepResult(EFail);
sl@0
  2452
			}
sl@0
  2453
		
sl@0
  2454
		CleanupStack::PopAndDestroy(parser);
sl@0
  2455
		}
sl@0
  2456
	return TestStepResult();
sl@0
  2457
	}
sl@0
  2458
sl@0
  2459
void C3GPLibParser_0035::GetUserDataAtomL(C3GPParse* aParse)
sl@0
  2460
	{
sl@0
  2461
	// file mode
sl@0
  2462
	ParserOpenFileL(aParse);
sl@0
  2463
sl@0
  2464
	TUint32 udtType = 0x6d657461;  // The udt type of test files is 'meta'
sl@0
  2465
	T3GPUdtaLocation location = E3GPUdtaAudioTrak;
sl@0
  2466
	TUint indexMoov = 0;
sl@0
  2467
	TUint indexAudio = 0;
sl@0
  2468
	TUint indexVideo = 0;
sl@0
  2469
	
sl@0
  2470
	TInt err = CallUDTApi(aParse, udtType, indexAudio, location); 
sl@0
  2471
	if (err == KErrNone)
sl@0
  2472
		{
sl@0
  2473
		location = E3GPUdtaMoov;
sl@0
  2474
		err = CallUDTApi(aParse, udtType, indexMoov, location); 
sl@0
  2475
		
sl@0
  2476
		if (err == KErrNone)
sl@0
  2477
			{
sl@0
  2478
			// By default, the location is video track
sl@0
  2479
			err = CallUDTApi(aParse, udtType, indexVideo); 
sl@0
  2480
			}
sl@0
  2481
		if (err == KErrNone)
sl@0
  2482
			{
sl@0
  2483
			// Test file KMultiUdta contains 1 udta at E3GPUdtaMoov, 5 udta at E3GPUdtaAudioTrak and 
sl@0
  2484
			// 3 udta at E3GPUdtaVideoTrak			
sl@0
  2485
			if (iTestSection.Compare(KMultiUdta) == 0 && (indexMoov != 0 || indexAudio != 4 || indexVideo != 2))
sl@0
  2486
				{
sl@0
  2487
				SetTestStepError(KErrNotFound);
sl@0
  2488
				}
sl@0
  2489
			}
sl@0
  2490
		}
sl@0
  2491
sl@0
  2492
	SetTestStepError(err);
sl@0
  2493
	
sl@0
  2494
	ParserCompleteL(aParse);
sl@0
  2495
	}
sl@0
  2496
sl@0
  2497
// -----------------------------------------------------------------------------
sl@0
  2498
// Retrieve user atoms from a valid mp4/3gp file containing multiple entries of 
sl@0
  2499
// the same user atom type within a user atom
sl@0
  2500
// -----------------------------------------------------------------------------
sl@0
  2501
//
sl@0
  2502
C3GPLibParser_0036::C3GPLibParser_0036()
sl@0
  2503
	{	
sl@0
  2504
	}
sl@0
  2505
sl@0
  2506
TVerdict C3GPLibParser_0036::doTestStepL()
sl@0
  2507
	{
sl@0
  2508
	if(TestStepResult() == EPass)
sl@0
  2509
		{
sl@0
  2510
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2511
		CleanupStack::PushL(parser);
sl@0
  2512
		
sl@0
  2513
		TRAPD(err, GetUserDataAtomL(parser));
sl@0
  2514
		if (err != KErrNone)
sl@0
  2515
			{
sl@0
  2516
			SetTestStepResult(EFail);
sl@0
  2517
			}
sl@0
  2518
		
sl@0
  2519
		CleanupStack::PopAndDestroy(parser);
sl@0
  2520
		}
sl@0
  2521
	return TestStepResult();
sl@0
  2522
	}
sl@0
  2523
sl@0
  2524
void C3GPLibParser_0036::GetUserDataAtomL(C3GPParse* aParse)
sl@0
  2525
	{
sl@0
  2526
	// file mode
sl@0
  2527
	ParserOpenFileL(aParse);
sl@0
  2528
	
sl@0
  2529
	TUint index;
sl@0
  2530
	TUint32 udtType = 0x6d657461;  // The udt type of test files could be 'meta'
sl@0
  2531
	T3GPUdtaLocation location = E3GPUdtaMoov; // The test files should not contain udta in audio trak
sl@0
  2532
	
sl@0
  2533
	// First read user data atom with empty buffer. It should return KErrOverflow
sl@0
  2534
	RBuf8 buffer;	
sl@0
  2535
	CleanupClosePushL(buffer);
sl@0
  2536
	buffer.CreateL(0);	
sl@0
  2537
	TInt err = aParse->GetUserDataAtom(udtType, location, buffer, index);
sl@0
  2538
	buffer.Close();
sl@0
  2539
	CleanupStack::PopAndDestroy(&buffer);
sl@0
  2540
	
sl@0
  2541
	if (err != KErrOverflow)
sl@0
  2542
		{
sl@0
  2543
		ERR_PRINTF2(_L("GetUserDataAtom with empty buffer should return KErrOverflow, failed with err %d"), err);
sl@0
  2544
		User::Leave(err);
sl@0
  2545
		}
sl@0
  2546
	
sl@0
  2547
	err = CallUDTApi(aParse, udtType, index); 	// By default, the location is videoTrack
sl@0
  2548
	
sl@0
  2549
	if (err == KErrNotFound || err == KErrNone)
sl@0
  2550
		{
sl@0
  2551
		err = CallUDTApi(aParse, udtType, index, location);
sl@0
  2552
		
sl@0
  2553
		if (err == KErrNotFound || err == KErrNone)
sl@0
  2554
			{
sl@0
  2555
			location = E3GPUdtaAudioTrak;
sl@0
  2556
			err = CallUDTApi(aParse, udtType, index, location); 
sl@0
  2557
			}
sl@0
  2558
		}
sl@0
  2559
sl@0
  2560
	SetTestStepError(err);
sl@0
  2561
	
sl@0
  2562
	ParserCompleteL(aParse);
sl@0
  2563
	}
sl@0
  2564
sl@0
  2565
// -----------------------------------------------------------------------------
sl@0
  2566
// Retrieve video frame dependencies  
sl@0
  2567
// -----------------------------------------------------------------------------
sl@0
  2568
//
sl@0
  2569
C3GPLibParser_0037::C3GPLibParser_0037()
sl@0
  2570
	{	
sl@0
  2571
	}
sl@0
  2572
sl@0
  2573
TVerdict C3GPLibParser_0037::doTestStepL()
sl@0
  2574
	{
sl@0
  2575
	if(TestStepResult() == EPass)
sl@0
  2576
		{
sl@0
  2577
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2578
		CleanupStack::PushL(parser);
sl@0
  2579
		
sl@0
  2580
		TRAPD(err, VideoDependencyL(parser));
sl@0
  2581
		if (err != KErrNone)
sl@0
  2582
			{
sl@0
  2583
			SetTestStepResult(EFail);
sl@0
  2584
			}
sl@0
  2585
		
sl@0
  2586
		CleanupStack::PopAndDestroy(parser);
sl@0
  2587
		}
sl@0
  2588
	return TestStepResult();
sl@0
  2589
	}
sl@0
  2590
sl@0
  2591
void C3GPLibParser_0037::VideoDependencyL(C3GPParse* aParser)
sl@0
  2592
	{
sl@0
  2593
	// file mode
sl@0
  2594
	ParserOpenFileL(aParser);
sl@0
  2595
	
sl@0
  2596
	TUint num; 
sl@0
  2597
	User::LeaveIfError(aParser->GetNumberOfVideoFrames(num));
sl@0
  2598
	
sl@0
  2599
	TInt err = KErrNone;
sl@0
  2600
	T3GPFrameDependencies dependencies;
sl@0
  2601
	for (TInt i = 0; i < num; i++)
sl@0
  2602
		{
sl@0
  2603
		err = aParser->GetVideoFrameDependencies(dependencies);
sl@0
  2604
		if (err != KErrNone)
sl@0
  2605
			{
sl@0
  2606
			ERR_PRINTF2(_L("GetVideoFrameDependencies failed with %d"), err);
sl@0
  2607
			SetTestStepError(err);
sl@0
  2608
			break;
sl@0
  2609
			}
sl@0
  2610
		}
sl@0
  2611
	ParserCompleteL(aParser);
sl@0
  2612
	}
sl@0
  2613
sl@0
  2614
// -----------------------------------------------------------------------------
sl@0
  2615
// Get Video Frame Properties 
sl@0
  2616
// -----------------------------------------------------------------------------
sl@0
  2617
//
sl@0
  2618
C3GPLibParser_0038::C3GPLibParser_0038()
sl@0
  2619
	{	
sl@0
  2620
	}
sl@0
  2621
sl@0
  2622
TVerdict C3GPLibParser_0038::doTestStepL()
sl@0
  2623
	{
sl@0
  2624
	if(TestStepResult() == EPass)
sl@0
  2625
		{
sl@0
  2626
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2627
		CleanupStack::PushL(parser);
sl@0
  2628
		
sl@0
  2629
		TRAPD(err, VideoInfoL(parser));
sl@0
  2630
		if (err != KErrNone)
sl@0
  2631
			{
sl@0
  2632
			SetTestStepResult(EFail);
sl@0
  2633
			}
sl@0
  2634
		
sl@0
  2635
		CleanupStack::PopAndDestroy(parser);
sl@0
  2636
		}
sl@0
  2637
	return TestStepResult();
sl@0
  2638
	}
sl@0
  2639
sl@0
  2640
void C3GPLibParser_0038::VideoInfoL(C3GPParse* aParser)
sl@0
  2641
	{
sl@0
  2642
	// file mode
sl@0
  2643
	ParserOpenFileL(aParser);
sl@0
  2644
	
sl@0
  2645
	TUint num; 
sl@0
  2646
	TUint timeStampInMs = 0; 
sl@0
  2647
	TUint timeStampInTimescale = 0; 
sl@0
  2648
	TUint frameIndex;
sl@0
  2649
	TBool keyFrame;
sl@0
  2650
	User::LeaveIfError(aParser->GetNumberOfVideoFrames(num));
sl@0
  2651
	User::LeaveIfError(aParser->GetVideoSampleEntryIndex(frameIndex));
sl@0
  2652
	
sl@0
  2653
	TInt err = KErrNone;
sl@0
  2654
	for (TInt i = 0; i < num; i++)
sl@0
  2655
		{
sl@0
  2656
		err = aParser->GetVideoFrameKeyType(i, keyFrame);
sl@0
  2657
		User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameKeyType()")));
sl@0
  2658
		
sl@0
  2659
		err = aParser->GetVideoFrameStartTime(i, timeStampInMs, timeStampInTimescale);
sl@0
  2660
		User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameStartTime()")));	
sl@0
  2661
		}
sl@0
  2662
	
sl@0
  2663
	TUint startIndex = 0;
sl@0
  2664
	RArray<T3GPFrameInfoParameters> array;
sl@0
  2665
	CleanupClosePushL(array);
sl@0
  2666
	
sl@0
  2667
	err = aParser->GetVideoFrameProperties(startIndex, num, array);
sl@0
  2668
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameProperties")));
sl@0
  2669
	if (!ShouldRunOOMTest())
sl@0
  2670
		{
sl@0
  2671
		INFO_PRINTF1(_L("aParser->GetVideoFrameProperties passed."));
sl@0
  2672
		}
sl@0
  2673
	
sl@0
  2674
	RArray<T3GPFrameInfoParameters> array1;
sl@0
  2675
	CleanupClosePushL(array1);
sl@0
  2676
	
sl@0
  2677
	// Filled in array with some data, say array with size 3
sl@0
  2678
	TInt arraySize = 3;
sl@0
  2679
	T3GPFrameInfoParameters fip;
sl@0
  2680
	for (TInt i = 0; i < arraySize; i++)
sl@0
  2681
		{
sl@0
  2682
		fip.iSize = i;
sl@0
  2683
		fip.iStartTime = 1000;
sl@0
  2684
		fip.iIsRandomAccessPoint = ETrue;
sl@0
  2685
		array1.AppendL(fip);
sl@0
  2686
		}
sl@0
  2687
	
sl@0
  2688
	if (!ShouldRunOOMTest())
sl@0
  2689
		{
sl@0
  2690
		INFO_PRINTF1(_L("Filled in array with some junk data and call aParser->GetVideoFrameProperties() ago."));
sl@0
  2691
		}
sl@0
  2692
	
sl@0
  2693
	err = aParser->GetVideoFrameProperties(startIndex, num, array1);
sl@0
  2694
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameProperties")));
sl@0
  2695
	
sl@0
  2696
	// Check two arrays are the same
sl@0
  2697
	if (array.Count() != array1.Count())
sl@0
  2698
		{
sl@0
  2699
		ERR_PRINTF3(_L("array1.Count() is %d; expected array.Count() is %d."), array1.Count(), array.Count());
sl@0
  2700
		User::Leave(KErrGeneral);
sl@0
  2701
		}
sl@0
  2702
	for (TInt j = 0; j < array.Count(); j++)
sl@0
  2703
		{
sl@0
  2704
		if (array1[j].iSize != array[j].iSize || array1[j].iStartTime != array1[j].iStartTime ||
sl@0
  2705
				array1[j].iIsRandomAccessPoint != array1[j].iIsRandomAccessPoint)
sl@0
  2706
			{
sl@0
  2707
			ERR_PRINTF1(_L("Two array are not the same."));
sl@0
  2708
			User::Leave(KErrGeneral);
sl@0
  2709
			}
sl@0
  2710
		}
sl@0
  2711
	
sl@0
  2712
	if (!ShouldRunOOMTest())
sl@0
  2713
		{
sl@0
  2714
		INFO_PRINTF1(_L("Two arrays are the same."));	
sl@0
  2715
		}
sl@0
  2716
	CleanupStack::PopAndDestroy(&array1);
sl@0
  2717
	CleanupStack::PopAndDestroy(&array);
sl@0
  2718
	
sl@0
  2719
	ParserCompleteL(aParser);
sl@0
  2720
	}
sl@0
  2721
sl@0
  2722
// -----------------------------------------------------------------------------
sl@0
  2723
// Read a audio and a video frame into a buffer of filled with junk content and 
sl@0
  2724
// ensure the buffer gets properly reset when retrieve video / audio frame data.
sl@0
  2725
// -----------------------------------------------------------------------------
sl@0
  2726
//
sl@0
  2727
C3GPLibParser_0039::C3GPLibParser_0039()
sl@0
  2728
	{	
sl@0
  2729
	}
sl@0
  2730
sl@0
  2731
TVerdict C3GPLibParser_0039::doTestStepL()
sl@0
  2732
	{
sl@0
  2733
	if(TestStepResult() == EPass)
sl@0
  2734
		{
sl@0
  2735
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2736
		CleanupStack::PushL(parser);
sl@0
  2737
		
sl@0
  2738
		TRAPD(err, AudioAndVideoFrameL(parser));
sl@0
  2739
		if (err != KErrNone)
sl@0
  2740
			{
sl@0
  2741
			SetTestStepResult(EFail);
sl@0
  2742
			}
sl@0
  2743
		
sl@0
  2744
		CleanupStack::PopAndDestroy(parser);
sl@0
  2745
		}
sl@0
  2746
	return TestStepResult();
sl@0
  2747
	}
sl@0
  2748
sl@0
  2749
void C3GPLibParser_0039::AudioAndVideoFrameL(C3GPParse* aParser)
sl@0
  2750
	{
sl@0
  2751
	// file mode
sl@0
  2752
	ParserOpenFileL(aParser);
sl@0
  2753
	
sl@0
  2754
	TUint size;	
sl@0
  2755
	TInt err = aParser->GetVideoFrameSize(size);
sl@0
  2756
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameSize")));
sl@0
  2757
		
sl@0
  2758
	RBuf8 buffer;
sl@0
  2759
	CleanupClosePushL(buffer);
sl@0
  2760
	buffer.CreateL(size + 15); // Create a buffer bigger than the size returned by GetVideoFrameSize
sl@0
  2761
	// Filled in junk data into the buffer
sl@0
  2762
	TChar c = 'a';
sl@0
  2763
	buffer.AppendFill(c, (size + 15));
sl@0
  2764
	
sl@0
  2765
	TBool keyFrame;
sl@0
  2766
	TUint timeStampInMs; 
sl@0
  2767
	TUint timeStampInTimescale;
sl@0
  2768
	err = aParser->ReadVideoFrame(buffer, keyFrame, timeStampInMs, timeStampInTimescale);
sl@0
  2769
	User::LeaveIfError(CheckError(err, KErrNone, _L("ReadVideoFrame")));
sl@0
  2770
	// Check the buffer size is the same as size returned by GetVideoFrameSize
sl@0
  2771
	if (buffer.Length() != size)
sl@0
  2772
		{
sl@0
  2773
		ERR_PRINTF3(_L("buffer size is %d; expected size is %d."), buffer.Length(), size);
sl@0
  2774
		User::Leave(KErrGeneral);
sl@0
  2775
		}
sl@0
  2776
	CleanupStack::PopAndDestroy(&buffer);
sl@0
  2777
	
sl@0
  2778
	err = aParser->GetAudioFramesSize(size);
sl@0
  2779
	User::LeaveIfError(CheckError(err, KErrNone, _L("GetAudioFramesSize")));
sl@0
  2780
			
sl@0
  2781
	RBuf8 bufferBig;
sl@0
  2782
	CleanupClosePushL(bufferBig);
sl@0
  2783
	bufferBig.CreateL(size + 10); // Create a buffer bigger than the size returned by GetVideoFrameSize
sl@0
  2784
	// Filled in junk data into the buffer
sl@0
  2785
	bufferBig.AppendFill(c, (size + 10));
sl@0
  2786
	
sl@0
  2787
	TInt returnedFrames;
sl@0
  2788
	err = aParser->ReadAudioFrames(bufferBig, returnedFrames, timeStampInMs, timeStampInTimescale);
sl@0
  2789
	User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioFrames")));
sl@0
  2790
	// Check the buffer size is the same as size returned by GetVideoFrameSize
sl@0
  2791
	if (bufferBig.Length() != size)
sl@0
  2792
		{
sl@0
  2793
		ERR_PRINTF3(_L("buffer size is %d; expected size is %d."), buffer.Length(), size);
sl@0
  2794
		User::Leave(KErrGeneral);
sl@0
  2795
		}
sl@0
  2796
	
sl@0
  2797
	CleanupStack::PopAndDestroy(&bufferBig);
sl@0
  2798
	
sl@0
  2799
	ParserCompleteL(aParser);
sl@0
  2800
	}
sl@0
  2801
sl@0
  2802
// -----------------------------------------------------------------------------
sl@0
  2803
// Multiple parser working simultaneously. 
sl@0
  2804
// -----------------------------------------------------------------------------
sl@0
  2805
//
sl@0
  2806
C3GPLibParser_0041::C3GPLibParser_0041()
sl@0
  2807
	{
sl@0
  2808
	}
sl@0
  2809
sl@0
  2810
TVerdict C3GPLibParser_0041::doTestStepPreambleL()
sl@0
  2811
	{
sl@0
  2812
	// Add the names of the new files to the following file list array.
sl@0
  2813
	TInt numOfFiles = 2; // This is the array number. Should be the same as the number of the array.
sl@0
  2814
	const TText* SelectedFiles[] = 
sl@0
  2815
		{
sl@0
  2816
		_S("mpeg4-aac.3gp"), // File with both audio and video
sl@0
  2817
		_S("arm-nb-acelp-only.3gp")  // File with audio only
sl@0
  2818
		};
sl@0
  2819
sl@0
  2820
	for (TInt index = 0; index < numOfFiles; index++)
sl@0
  2821
		{
sl@0
  2822
		// Create a zero terminated version of the file name
sl@0
  2823
		TFileName inputFile(K3GPLibTestFilePath);
sl@0
  2824
		inputFile += TPtrC(SelectedFiles[index]);
sl@0
  2825
		inputFile.ZeroTerminate();
sl@0
  2826
		
sl@0
  2827
		if (index == 0)
sl@0
  2828
			{
sl@0
  2829
			User::LeaveIfError(iInputFile1.Create(inputFile.Length() + 1));
sl@0
  2830
			iInputFile1.Copy(inputFile);	
sl@0
  2831
			}
sl@0
  2832
		else
sl@0
  2833
			{
sl@0
  2834
			User::LeaveIfError(iInputFile2.Create(inputFile.Length() + 1));
sl@0
  2835
			iInputFile2.Copy(inputFile);	
sl@0
  2836
			}
sl@0
  2837
		}
sl@0
  2838
	return TestStepResult();
sl@0
  2839
	}
sl@0
  2840
sl@0
  2841
TVerdict C3GPLibParser_0041::doTestStepPostambleL()
sl@0
  2842
	{
sl@0
  2843
	iInputFile1.Close();
sl@0
  2844
	iInputFile2.Close();
sl@0
  2845
	return TestStepResult();
sl@0
  2846
	}
sl@0
  2847
sl@0
  2848
TVerdict C3GPLibParser_0041::doTestStepL()
sl@0
  2849
	{
sl@0
  2850
	if(TestStepResult() == EPass)
sl@0
  2851
		{
sl@0
  2852
		C3GPParse* parser1 = C3GPParse::NewL();
sl@0
  2853
		CleanupStack::PushL(parser1);
sl@0
  2854
		
sl@0
  2855
		TInt err = parser1->Open(iInputFile1);
sl@0
  2856
		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser1->Open")));
sl@0
  2857
		
sl@0
  2858
		C3GPParse* parser2 = C3GPParse::NewL();
sl@0
  2859
		CleanupStack::PushL(parser2);
sl@0
  2860
		
sl@0
  2861
		err = parser2->Open(iInputFile1);
sl@0
  2862
		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser2->Open")));
sl@0
  2863
		
sl@0
  2864
		C3GPParse* parser3 = C3GPParse::NewL();
sl@0
  2865
		CleanupStack::PushL(parser3);
sl@0
  2866
		
sl@0
  2867
		err = parser3->Open(iInputFile2);
sl@0
  2868
		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser3->Open")));
sl@0
  2869
		
sl@0
  2870
		TRAP(err, MultipleParserL(parser1, parser2, parser3));
sl@0
  2871
		if (err != KErrNone)
sl@0
  2872
			{
sl@0
  2873
			SetTestStepResult(EFail);
sl@0
  2874
			}
sl@0
  2875
		
sl@0
  2876
		ParserCompleteL(parser1);
sl@0
  2877
		ParserCompleteL(parser2);
sl@0
  2878
		ParserCompleteL(parser3);
sl@0
  2879
		
sl@0
  2880
		CleanupStack::PopAndDestroy(parser3);
sl@0
  2881
		CleanupStack::PopAndDestroy(parser2);
sl@0
  2882
		CleanupStack::PopAndDestroy(parser1);
sl@0
  2883
		}
sl@0
  2884
	return TestStepResult();
sl@0
  2885
	}
sl@0
  2886
sl@0
  2887
void C3GPLibParser_0041::MultipleParserL(C3GPParse* aParser1, C3GPParse* aParser2, C3GPParse* aParser3)
sl@0
  2888
	{
sl@0
  2889
	TInt err = ReadAudioVideoFrame(aParser1);
sl@0
  2890
	User::LeaveIfError(CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParser1)")));
sl@0
  2891
	
sl@0
  2892
	// Read one video frame with parser2
sl@0
  2893
	err = ReadAudioVideoFrame(aParser2, EFalse, EFalse);
sl@0
  2894
	User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame(aParser2)")));
sl@0
  2895
	
sl@0
  2896
	// Read video properties with parser3. Expected failed with KErrNotSupported
sl@0
  2897
	T3GPVideoType videoType;
sl@0
  2898
	TUint length; 
sl@0
  2899
	TReal frameRate;
sl@0
  2900
	TUint avgBitRate;
sl@0
  2901
	TSize videoSize;
sl@0
  2902
	TUint timeScale;
sl@0
  2903
	
sl@0
  2904
	err = aParser3->GetVideoProperties(videoType, length, frameRate, avgBitRate, videoSize, timeScale);
sl@0
  2905
	User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser3->GetVideoProperties")));
sl@0
  2906
	}
sl@0
  2907
sl@0
  2908
// -----------------------------------------------------------------------------
sl@0
  2909
// Seek position in buffer mode
sl@0
  2910
// -----------------------------------------------------------------------------
sl@0
  2911
//
sl@0
  2912
C3GPLibParser_0043::C3GPLibParser_0043()
sl@0
  2913
	{
sl@0
  2914
	}
sl@0
  2915
sl@0
  2916
TVerdict C3GPLibParser_0043::doTestStepL()
sl@0
  2917
	{
sl@0
  2918
	if(TestStepResult() == EPass)
sl@0
  2919
		{
sl@0
  2920
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  2921
		CleanupStack::PushL(parser);
sl@0
  2922
		
sl@0
  2923
		TRAPD(err, SeekBufferModeL(parser));
sl@0
  2924
		if (err != KErrNone)
sl@0
  2925
			{
sl@0
  2926
			SetTestStepResult(EFail);
sl@0
  2927
			}
sl@0
  2928
		
sl@0
  2929
		CleanupStack::PopAndDestroy(parser);
sl@0
  2930
		}
sl@0
  2931
	return TestStepResult();
sl@0
  2932
	}
sl@0
  2933
sl@0
  2934
void C3GPLibParser_0043::SeekBufferModeL(C3GPParse* aParser)
sl@0
  2935
	{
sl@0
  2936
	// buffer mode
sl@0
  2937
	ParserOpenL(aParser);
sl@0
  2938
	FileOpenL();
sl@0
  2939
	
sl@0
  2940
	// Insert buffer data into the library
sl@0
  2941
	TInt pos = 0;
sl@0
  2942
	TInt bufferSize = KBufferSize;
sl@0
  2943
	InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  2944
	
sl@0
  2945
	TUint audioPos; 
sl@0
  2946
	TUint videoPos;
sl@0
  2947
	TUint timeStampInMs = 0; 
sl@0
  2948
	
sl@0
  2949
	// Seek the position
sl@0
  2950
	TInt err = aParser->Seek(timeStampInMs, EFalse, audioPos, videoPos);
sl@0
  2951
	while (err == KErr3gpLibMoreDataRequired)
sl@0
  2952
		{
sl@0
  2953
		pos = pos + bufferSize;
sl@0
  2954
		InsertDataL(aParser, iSourceFile, bufferSize, pos);
sl@0
  2955
		err = aParser->Seek(timeStampInMs, EFalse, audioPos, videoPos);
sl@0
  2956
		}
sl@0
  2957
	
sl@0
  2958
	if (err != KErrNone)
sl@0
  2959
		{
sl@0
  2960
		SetTestStepError(err);
sl@0
  2961
		}
sl@0
  2962
	ParserCompleteL(aParser);
sl@0
  2963
	FileClose();
sl@0
  2964
	}
sl@0
  2965
sl@0
  2966
// -----------------------------------------------------------------------------
sl@0
  2967
// Test C3GPParse with large file (>2GB)
sl@0
  2968
// -----------------------------------------------------------------------------
sl@0
  2969
//
sl@0
  2970
C3GPLibParser_0045::C3GPLibParser_0045()
sl@0
  2971
	{
sl@0
  2972
	}
sl@0
  2973
sl@0
  2974
TVerdict C3GPLibParser_0045::doTestStepPreambleL()
sl@0
  2975
	{
sl@0
  2976
	C3GPLib_AsyncObserver::doTestStepPreambleL();	
sl@0
  2977
	if (TestStepResult() == EPass)
sl@0
  2978
		{
sl@0
  2979
		iScheduler = new (ELeave) CActiveScheduler;
sl@0
  2980
		CActiveScheduler::Install(iScheduler);
sl@0
  2981
		}
sl@0
  2982
	return TestStepResult();
sl@0
  2983
	}
sl@0
  2984
sl@0
  2985
TVerdict C3GPLibParser_0045::doTestStepPostambleL()
sl@0
  2986
	{
sl@0
  2987
	C3GPLib_AsyncObserver::doTestStepPostambleL();
sl@0
  2988
	if( iScheduler )
sl@0
  2989
		{
sl@0
  2990
		INFO_PRINTF1(_L("delete iScheduler"));
sl@0
  2991
		CActiveScheduler::Install(NULL);
sl@0
  2992
		delete iScheduler;
sl@0
  2993
		iScheduler = NULL;
sl@0
  2994
		}
sl@0
  2995
sl@0
  2996
	return TestStepResult();
sl@0
  2997
	}
sl@0
  2998
sl@0
  2999
TVerdict C3GPLibParser_0045::doTestStepL()
sl@0
  3000
	{
sl@0
  3001
	if(TestStepResult() == EPass)
sl@0
  3002
		{
sl@0
  3003
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  3004
		CleanupStack::PushL(parser);
sl@0
  3005
		
sl@0
  3006
		TRAPD(err, TestParserWithLargeFileL(parser));
sl@0
  3007
		if (err != KErrNone)
sl@0
  3008
			{
sl@0
  3009
			SetTestStepResult(EFail);
sl@0
  3010
			}
sl@0
  3011
		
sl@0
  3012
		CleanupStack::PopAndDestroy(parser);
sl@0
  3013
		}
sl@0
  3014
	return TestStepResult();
sl@0
  3015
	}
sl@0
  3016
sl@0
  3017
void C3GPLibParser_0045::TestParserWithLargeFileL(C3GPParse* aParser)
sl@0
  3018
	{
sl@0
  3019
	INFO_PRINTF1(_L("Test Parser With Large File (>2GB)"));
sl@0
  3020
	INFO_PRINTF1(_L("Open and complete parser with 64 bit file handle"));
sl@0
  3021
sl@0
  3022
	ParserOpenFileHandle64L(aParser);
sl@0
  3023
	ParserCompleteHandle64L(aParser);
sl@0
  3024
	
sl@0
  3025
	ParserOpenFileHandle64L(aParser, EFileRead | EFileShareReadersOnly);
sl@0
  3026
	ParserCompleteHandle64L(aParser);
sl@0
  3027
	
sl@0
  3028
	ParserOpenFileHandle64L(aParser, EFileShareReadersOrWriters | EFileWrite);
sl@0
  3029
	ParserCompleteHandle64L(aParser);
sl@0
  3030
	
sl@0
  3031
	ParserOpenFileHandle64L(aParser, EFileShareReadersOrWriters | EFileRead);
sl@0
  3032
	ParserCompleteHandle64L(aParser);
sl@0
  3033
	
sl@0
  3034
	ParserOpenFileHandle64L(aParser, EFileShareAny  | EFileWrite);
sl@0
  3035
	ParserCompleteHandle64L(aParser);
sl@0
  3036
    
sl@0
  3037
	ParserOpenFileHandle64L(aParser, EFileShareAny | EFileRead);
sl@0
  3038
	ParserCompleteHandle64L(aParser);
sl@0
  3039
sl@0
  3040
	INFO_PRINTF1(_L("Test parser with 64 bit file handle"));
sl@0
  3041
sl@0
  3042
	// Read audio/video attributes
sl@0
  3043
	ParserOpenFileHandle64L(aParser);
sl@0
  3044
	DoGetVideoAudioAttributesL(aParser);
sl@0
  3045
	ParserCompleteHandle64L(aParser);
sl@0
  3046
sl@0
  3047
	// Read audio/video frames
sl@0
  3048
	ParserOpenFileHandle64L(aParser);
sl@0
  3049
	User::LeaveIfError(DoReadFrame(aParser));
sl@0
  3050
	ParserCompleteHandle64L(aParser);
sl@0
  3051
sl@0
  3052
	// Asynchronous Read of audio/video frames
sl@0
  3053
	ParserOpenFileHandle64L(aParser);
sl@0
  3054
	User::LeaveIfError(DoReadFrameAsync(aParser));
sl@0
  3055
	if (!ShouldRunOOMTest())
sl@0
  3056
		{
sl@0
  3057
		INFO_PRINTF1(_L("C3GPLibParser_0045::ReadFrameAsyncL() using 64 bit file handle"));
sl@0
  3058
		}
sl@0
  3059
	ParserCompleteHandle64L(aParser);
sl@0
  3060
	
sl@0
  3061
	// Seek positions after any keyframe and immediately after a non-key frame
sl@0
  3062
	ParserOpenFileHandle64L(aParser);
sl@0
  3063
	DoSeekTestL(aParser);
sl@0
  3064
	ParserCompleteHandle64L(aParser);	
sl@0
  3065
sl@0
  3066
	INFO_PRINTF1(_L("Test parser in File path"));
sl@0
  3067
sl@0
  3068
	// Read audio/video attributes
sl@0
  3069
	ParserOpenFileL(aParser);
sl@0
  3070
	DoGetVideoAudioAttributesL(aParser);
sl@0
  3071
	ParserCompleteL(aParser);
sl@0
  3072
	
sl@0
  3073
	// Read audio/video frames
sl@0
  3074
	ParserOpenFileL(aParser);
sl@0
  3075
	User::LeaveIfError(DoReadFrame(aParser));
sl@0
  3076
	ParserCompleteL(aParser);
sl@0
  3077
	
sl@0
  3078
	// Asynchronous Read of audio/video frames
sl@0
  3079
	ParserOpenFileL(aParser);
sl@0
  3080
	User::LeaveIfError(DoReadFrameAsync(aParser));
sl@0
  3081
	if (!ShouldRunOOMTest())
sl@0
  3082
		{
sl@0
  3083
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL()"));
sl@0
  3084
		}
sl@0
  3085
	ParserCompleteL(aParser);
sl@0
  3086
sl@0
  3087
	ParserOpenFileL(aParser);
sl@0
  3088
	User::LeaveIfError(DoReadFrameAsync(aParser, ETrue));
sl@0
  3089
	if (!ShouldRunOOMTest())
sl@0
  3090
		{
sl@0
  3091
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL(), then cancel the read"));
sl@0
  3092
		}
sl@0
  3093
	ParserCompleteL(aParser);
sl@0
  3094
sl@0
  3095
	INFO_PRINTF1(_L("Test parser in CAF"));
sl@0
  3096
	
sl@0
  3097
	// Read audio/video attributes
sl@0
  3098
	ParserOpenCafLC(aParser);
sl@0
  3099
	DoGetVideoAudioAttributesL(aParser);
sl@0
  3100
	ParserCompleteCafL(aParser);
sl@0
  3101
		    
sl@0
  3102
	// Read audio/video frames
sl@0
  3103
	ParserOpenCafLC(aParser);
sl@0
  3104
	User::LeaveIfError(DoReadFrame(aParser));
sl@0
  3105
	ParserCompleteCafL(aParser);
sl@0
  3106
	
sl@0
  3107
	// Asynchronous Read of audio/video frames
sl@0
  3108
	ParserOpenCafLC(aParser);
sl@0
  3109
	User::LeaveIfError(DoReadFrameAsync(aParser));
sl@0
  3110
	if (!ShouldRunOOMTest())
sl@0
  3111
		{
sl@0
  3112
		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using CAF"));
sl@0
  3113
		}
sl@0
  3114
	ParserCompleteCafL(aParser);	
sl@0
  3115
	}
sl@0
  3116
sl@0
  3117
TInt C3GPLibParser_0045::DoReadFrameAsync(C3GPParse* aParser, TBool aCancel)
sl@0
  3118
	{    
sl@0
  3119
    TInt err = KErrNone;
sl@0
  3120
    
sl@0
  3121
    if (!aCancel)
sl@0
  3122
    	{
sl@0
  3123
    	err = ReadAudioVideoFrameAsync(aParser, ETrue);
sl@0
  3124
    	if (err == KErrNone)
sl@0
  3125
    		{
sl@0
  3126
    		err = ReadAudioVideoFrameAsync(aParser, EFalse);
sl@0
  3127
    		} 
sl@0
  3128
    	}
sl@0
  3129
    else
sl@0
  3130
    	{
sl@0
  3131
    	err = ReadAudioVideoFrameAsync(aParser, EFalse, ETrue);
sl@0
  3132
    	}
sl@0
  3133
 
sl@0
  3134
    return err;
sl@0
  3135
    }
sl@0
  3136
sl@0
  3137
// -----------------------------------------------------------------------------
sl@0
  3138
// Parse video & audio frames from >2GB file synchronously in buffer mode
sl@0
  3139
// -----------------------------------------------------------------------------
sl@0
  3140
//
sl@0
  3141
C3GPLibParser_0047::C3GPLibParser_0047()
sl@0
  3142
	{	
sl@0
  3143
	}
sl@0
  3144
sl@0
  3145
TVerdict C3GPLibParser_0047::doTestStepL()
sl@0
  3146
	{
sl@0
  3147
	if(TestStepResult() == EPass)
sl@0
  3148
		{
sl@0
  3149
		C3GPParse* parser = C3GPParse::NewL();
sl@0
  3150
		CleanupStack::PushL(parser);
sl@0
  3151
		
sl@0
  3152
		TRAPD(err, ReadFrameL(parser));
sl@0
  3153
		if (err != KErrNone)
sl@0
  3154
			{
sl@0
  3155
			SetTestStepResult(EFail);
sl@0
  3156
			}
sl@0
  3157
		
sl@0
  3158
		CleanupStack::PopAndDestroy(parser);
sl@0
  3159
		}
sl@0
  3160
	return TestStepResult();
sl@0
  3161
	}
sl@0
  3162
sl@0
  3163
void C3GPLibParser_0047::ReadFrameL(C3GPParse* aParser)
sl@0
  3164
	{
sl@0
  3165
	FileOpen64L();
sl@0
  3166
	ReadFrameBufferModeL(aParser);
sl@0
  3167
	FileClose64();
sl@0
  3168
	}
sl@0
  3169
	
sl@0
  3170
// -----------------------------------------------------------------------------
sl@0
  3171
// Retrieve User Data Atoms with Multiple atoms
sl@0
  3172
// -----------------------------------------------------------------------------
sl@0
  3173
//
sl@0
  3174
_LIT(KAtomFileNamePrefix, "AtomFile");
sl@0
  3175
sl@0
  3176
C3GPUserDataAtomRetrieval::C3GPUserDataAtomRetrieval()
sl@0
  3177
	{		
sl@0
  3178
	}
sl@0
  3179
		
sl@0
  3180
TVerdict C3GPUserDataAtomRetrieval::doTestStepL()
sl@0
  3181
	{
sl@0
  3182
	// ensure test step error & result reset before each test
sl@0
  3183
	if (TestStepResult() != EPass)
sl@0
  3184
		{
sl@0
  3185
		return TestStepResult();
sl@0
  3186
		}
sl@0
  3187
	SetTestStepError(KErrNone);
sl@0
  3188
		
sl@0
  3189
	C3GPParse* parser = C3GPParse::NewL();
sl@0
  3190
	CleanupStack::PushL(parser);
sl@0
  3191
sl@0
  3192
	if (iLargeFile)
sl@0
  3193
		{
sl@0
  3194
		User::LeaveIfError(parser->Open(iInputFile64));		
sl@0
  3195
		}
sl@0
  3196
	else
sl@0
  3197
		{
sl@0
  3198
		User::LeaveIfError(parser->Open(iInputFile));		
sl@0
  3199
		}
sl@0
  3200
	
sl@0
  3201
	TBool keepLooking = ETrue;
sl@0
  3202
	TInt atomFound = 0;
sl@0
  3203
	TInt atomSize = 0;
sl@0
  3204
	TUint atomIndex = 0;
sl@0
  3205
	TUint atomHighestIndex1 = 0;
sl@0
  3206
	TUint atomHighestIndex2 = 0;
sl@0
  3207
	TInt err = KErrNone;
sl@0
  3208
	RFile atomFile;
sl@0
  3209
	RBuf8 atomContent;
sl@0
  3210
	RBuf8 fileContent;
sl@0
  3211
	CleanupClosePushL(fileContent);	
sl@0
  3212
	CleanupClosePushL(atomFile);
sl@0
  3213
	CleanupClosePushL(atomContent);		
sl@0
  3214
	
sl@0
  3215
	while(keepLooking && err == KErrNone)
sl@0
  3216
		{
sl@0
  3217
		TInt atomIndexInput = atomIndex;
sl@0
  3218
		err = parser->GetUserDataAtomSize(iAtomType, iAtomLocation, atomIndex, atomSize);
sl@0
  3219
		if (err == KErrNone)
sl@0
  3220
			{
sl@0
  3221
			atomHighestIndex1 = atomIndex;
sl@0
  3222
			atomIndex = atomIndexInput;
sl@0
  3223
			atomContent.CreateL(atomSize);
sl@0
  3224
			
sl@0
  3225
			err = parser->GetUserDataAtom(iAtomType, iAtomLocation, atomContent, atomIndex);
sl@0
  3226
			if (err == KErrNone)
sl@0
  3227
				{
sl@0
  3228
				if (atomFound == 0)
sl@0
  3229
					{
sl@0
  3230
					// remember the highest atom index found during first run
sl@0
  3231
					atomHighestIndex2 = atomIndex;
sl@0
  3232
					if (atomHighestIndex1 != atomHighestIndex2)
sl@0
  3233
						{
sl@0
  3234
						if (!ShouldRunOOMTest())
sl@0
  3235
							{
sl@0
  3236
							ERR_PRINTF1(_L("Highest Atom Index returned is different when calling GetUserDataAtomSize vs GetUserDataAtom"));							
sl@0
  3237
							}
sl@0
  3238
						}
sl@0
  3239
					}
sl@0
  3240
				atomFound++;
sl@0
  3241
				
sl@0
  3242
				User::LeaveIfError(atomFile.Open(iFs, (*iAtomFileArray)[atomIndexInput], EFileRead | EFileStream));
sl@0
  3243
				TInt fileSize = 0;
sl@0
  3244
				User::LeaveIfError(atomFile.Size(fileSize));
sl@0
  3245
				if (atomContent.Size() != fileSize)
sl@0
  3246
					{
sl@0
  3247
					if (!ShouldRunOOMTest())
sl@0
  3248
						{
sl@0
  3249
						ERR_PRINTF4(_L("Atom %d retrieved is of different size as expected.  Expected=%d Retrieved=%d"), atomIndexInput, fileSize, atomContent.Size());							
sl@0
  3250
						}
sl@0
  3251
					SetTestStepResult(EFail);			
sl@0
  3252
					keepLooking = EFalse;					
sl@0
  3253
					}
sl@0
  3254
				else
sl@0
  3255
					{
sl@0
  3256
					fileContent.CreateL(fileSize);
sl@0
  3257
					User::LeaveIfError(atomFile.Read(fileContent));
sl@0
  3258
					if (fileContent != atomContent)	
sl@0
  3259
						{
sl@0
  3260
						if (!ShouldRunOOMTest())
sl@0
  3261
							{						
sl@0
  3262
							ERR_PRINTF4(_L("Atom %d retrieved is of different content.  Expected=%S Retrieved=%S"), atomIndexInput, &fileContent, &atomContent);						
sl@0
  3263
							}
sl@0
  3264
						SetTestStepResult(EFail);			
sl@0
  3265
						keepLooking = EFalse;
sl@0
  3266
						}
sl@0
  3267
					else
sl@0
  3268
						{
sl@0
  3269
						if (atomIndex != atomHighestIndex2)	
sl@0
  3270
							{
sl@0
  3271
							// seems like there's an error occurred, as the highest index for this atom
sl@0
  3272
							// type should stay the same throughout
sl@0
  3273
							keepLooking = EFalse;
sl@0
  3274
							if (!ShouldRunOOMTest())
sl@0
  3275
								{							
sl@0
  3276
								ERR_PRINTF3(_L("Previous highest atom index is %d but now it is %d.  Data inconsistency."), atomHighestIndex2, atomIndex);
sl@0
  3277
								}
sl@0
  3278
							SetTestStepResult(EFail);
sl@0
  3279
							}
sl@0
  3280
						else
sl@0
  3281
							{
sl@0
  3282
							// look for the next atom of the same type now	
sl@0
  3283
							atomIndex = atomIndexInput + 1;
sl@0
  3284
							}	
sl@0
  3285
						} 
sl@0
  3286
					fileContent.Close();	
sl@0
  3287
					}	
sl@0
  3288
				atomFile.Close();	
sl@0
  3289
				}
sl@0
  3290
			else
sl@0
  3291
				{
sl@0
  3292
				if (!ShouldRunOOMTest())
sl@0
  3293
					{				
sl@0
  3294
					ERR_PRINTF4(_L("Fail to get user atom: index = %d, location = %d, type = %d"), atomIndex, iAtomLocation, iAtomType);
sl@0
  3295
					}
sl@0
  3296
				User::Leave(err);
sl@0
  3297
				}	
sl@0
  3298
				
sl@0
  3299
			atomContent.Close();					
sl@0
  3300
			}			
sl@0
  3301
		}
sl@0
  3302
	if (TestStepResult() == EPass && atomFound != iExpectedNumAtom && atomFound == (atomHighestIndex2 + 1))	
sl@0
  3303
		{
sl@0
  3304
		if (!ShouldRunOOMTest())
sl@0
  3305
			{		
sl@0
  3306
			ERR_PRINTF3(_L("Number of atoms found (%d) does not match expected # of atoms (%d)."), atomFound, iExpectedNumAtom);
sl@0
  3307
			}
sl@0
  3308
		SetTestStepResult(EFail);	
sl@0
  3309
		}	
sl@0
  3310
		
sl@0
  3311
	CleanupStack::PopAndDestroy(&atomContent);
sl@0
  3312
	CleanupStack::PopAndDestroy(&atomFile);
sl@0
  3313
	CleanupStack::PopAndDestroy(&fileContent);
sl@0
  3314
	
sl@0
  3315
	parser->Complete();
sl@0
  3316
		
sl@0
  3317
	CleanupStack::PopAndDestroy(parser);				
sl@0
  3318
	return TestStepResult();
sl@0
  3319
	}
sl@0
  3320
	
sl@0
  3321
TVerdict C3GPUserDataAtomRetrieval::doTestStepPreambleL()
sl@0
  3322
	{	
sl@0
  3323
	SetTestStepResult(ETestSuiteError);					
sl@0
  3324
sl@0
  3325
 	#ifdef __WINSCW__
sl@0
  3326
 	_LIT(KFileToParse, "FileToParseEmu");
sl@0
  3327
 	#else
sl@0
  3328
 	_LIT(KFileToParse, "FileToParseHw");
sl@0
  3329
 	#endif		
sl@0
  3330
	
sl@0
  3331
	TPtrC inputFilename;
sl@0
  3332
	if (!GetStringFromConfig(ConfigSection(), KFileToParse, inputFilename))
sl@0
  3333
		{
sl@0
  3334
		// file need to be specified
sl@0
  3335
		ERR_PRINTF1(_L("Specify the file to be parsed."));
sl@0
  3336
		return TestStepResult();
sl@0
  3337
		}
sl@0
  3338
	
sl@0
  3339
	if (!GetBoolFromConfig(ConfigSection(), _L("largeFile"), iLargeFile))
sl@0
  3340
		{
sl@0
  3341
		ERR_PRINTF1(_L("Specify whether the file is larger than 2GB."));
sl@0
  3342
		return TestStepResult();
sl@0
  3343
		}
sl@0
  3344
		
sl@0
  3345
	User::LeaveIfError(iFs.Connect());			
sl@0
  3346
	if (iLargeFile)
sl@0
  3347
		{
sl@0
  3348
		User::LeaveIfError(iInputFile64.Open(iFs, inputFilename, EFileRead | EFileStream | EFileShareReadersOnly));
sl@0
  3349
		}
sl@0
  3350
	else
sl@0
  3351
		{
sl@0
  3352
		User::LeaveIfError(iInputFile.Open(iFs, inputFilename, EFileRead | EFileStream | EFileShareReadersOnly));		
sl@0
  3353
		}
sl@0
  3354
	
sl@0
  3355
	if (!GetIntFromConfig(ConfigSection(), _L("ExpectedNumOfAtom"), iExpectedNumAtom))
sl@0
  3356
		{
sl@0
  3357
		// Number of expected number of atoms needs to be specified
sl@0
  3358
		ERR_PRINTF1(_L("Specify the number of atoms to be expected."));
sl@0
  3359
		return TestStepResult();
sl@0
  3360
		}
sl@0
  3361
	
sl@0
  3362
	iAtomFileArray = new CDesCArrayFlat(4);	
sl@0
  3363
	TInt temp;
sl@0
  3364
	if (!GetIntFromConfig(ConfigSection(), _L("AtomType"), temp))
sl@0
  3365
		{
sl@0
  3366
		// atom type to retrieve needs to be specified
sl@0
  3367
		ERR_PRINTF1(_L("Specify the atoms type to be retrieved."));
sl@0
  3368
		return TestStepResult();
sl@0
  3369
		}
sl@0
  3370
	else
sl@0
  3371
		{
sl@0
  3372
		iAtomType = (TUint32) temp;	
sl@0
  3373
		}
sl@0
  3374
		
sl@0
  3375
	if (!GetIntFromConfig(ConfigSection(), _L("AtomLocation"), temp))		
sl@0
  3376
		{
sl@0
  3377
		// atom location to retrieve needs to be specified
sl@0
  3378
		ERR_PRINTF1(_L("Specify the atoms location for the atoms to be retrieved."));
sl@0
  3379
		return TestStepResult();
sl@0
  3380
		}
sl@0
  3381
	else
sl@0
  3382
		{
sl@0
  3383
		iAtomLocation = (T3GPUdtaLocation) temp;					
sl@0
  3384
		}
sl@0
  3385
sl@0
  3386
	if (iExpectedNumAtom > 0)
sl@0
  3387
		{
sl@0
  3388
		TBuf<50> keyName;	
sl@0
  3389
		TPtrC fileName;		
sl@0
  3390
		for (TInt i = 1; i <= iExpectedNumAtom; i++)	
sl@0
  3391
			{
sl@0
  3392
			keyName.Zero();
sl@0
  3393
			keyName.AppendFormat(_L("%S%d"), &KAtomFileNamePrefix, i);			
sl@0
  3394
sl@0
  3395
			if (!GetStringFromConfig(ConfigSection(), keyName, fileName))
sl@0
  3396
				{
sl@0
  3397
				// atom content file needs to be specified
sl@0
  3398
				ERR_PRINTF1(_L("Specify the file name that contents the matching atom content."));
sl@0
  3399
				return TestStepResult();					
sl@0
  3400
				}
sl@0
  3401
			
sl@0
  3402
			iAtomFileArray->AppendL(fileName);
sl@0
  3403
			}		
sl@0
  3404
		}
sl@0
  3405
		
sl@0
  3406
	SetTestStepResult(EPass);							
sl@0
  3407
	return TestStepResult();
sl@0
  3408
	}
sl@0
  3409
		
sl@0
  3410
TVerdict C3GPUserDataAtomRetrieval::doTestStepPostambleL()
sl@0
  3411
	{
sl@0
  3412
	if (iAtomFileArray)
sl@0
  3413
		{
sl@0
  3414
		iAtomFileArray->Reset();
sl@0
  3415
		delete iAtomFileArray;			
sl@0
  3416
		}
sl@0
  3417
	
sl@0
  3418
	if (iLargeFile)
sl@0
  3419
		{	
sl@0
  3420
		iInputFile64.Close();		
sl@0
  3421
		}
sl@0
  3422
	else
sl@0
  3423
		{
sl@0
  3424
		iInputFile.Close();		
sl@0
  3425
		}
sl@0
  3426
	iFs.Close();
sl@0
  3427
	
sl@0
  3428
	return TestStepResult();
sl@0
  3429
	}