os/mm/mmplugins/lib3gpunittest/src/parserapi.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmplugins/lib3gpunittest/src/parserapi.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,3429 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <mmf/common/mmferrors.h>
    1.20 +#include <caf/caf.h>
    1.21 +#include "tsu3gplibraryapi.h"
    1.22 +
    1.23 +using namespace ContentAccess;
    1.24 +
    1.25 +// --------------------------
    1.26 +// C3GPLibParser_base 
    1.27 +// --------------------------
    1.28 +//
    1.29 +TVerdict C3GPLibParser_base::doTestStepPreambleL()
    1.30 +	{
    1.31 +	SetTestStepResult(EPass);
    1.32 +	SetTestStepError(KErrNone);
    1.33 +	
    1.34 +	TPtrC testSection = ConfigSection();
    1.35 +	
    1.36 +	TInt err = iTestSection.Create(testSection.Length());
    1.37 +	if( err != KErrNone )
    1.38 +		{
    1.39 +		ERR_PRINTF2(_L("Cannot create buffer for inputFilename. err = %d"), err);
    1.40 +		SetTestStepResult(EInconclusive);
    1.41 +		return TestStepResult();
    1.42 +		}
    1.43 +	iTestSection += testSection;
    1.44 +	
    1.45 +	TBuf<20> testFolderName;
    1.46 +	testFolderName.Zero();
    1.47 +	if (ConfigSection().Compare(_L("3GP-H264-MP4-LARGE")) == 0)
    1.48 +		{
    1.49 + 		#ifdef __WINSCW__
    1.50 + 		testFolderName.Append(_L("inputFileEmu"));
    1.51 + 		#else
    1.52 + 		testFolderName.Append(_L("inputFileHw"));
    1.53 + 		#endif		
    1.54 +		}
    1.55 +	else	
    1.56 +		{
    1.57 + 		testFolderName.Append(_L("inputFile"));
    1.58 +		}
    1.59 +	
    1.60 +	TPtrC inputFile;
    1.61 +	if(!GetStringFromConfig(ConfigSection(), testFolderName, inputFile))
    1.62 +		{
    1.63 +		ERR_PRINTF1(_L("Cannot read inputFile from ini file."));
    1.64 +		SetTestStepResult(ETestSuiteError);
    1.65 +		return TestStepResult();
    1.66 +		}
    1.67 +	err = iInputFile.Create(inputFile.Length() + 1);
    1.68 +	if( err != KErrNone )
    1.69 +		{
    1.70 +		ERR_PRINTF2(_L("Cannot create buffer for inputFilename. err = %d"), err);
    1.71 +		SetTestStepResult(EInconclusive);
    1.72 +		return TestStepResult();
    1.73 +		}
    1.74 +	iInputFile += inputFile;
    1.75 +	iInputFile.ZeroTerminate();
    1.76 +	
    1.77 +	return TestStepResult();
    1.78 +	}
    1.79 +
    1.80 +TVerdict C3GPLibParser_base::doTestStepPostambleL()
    1.81 +	{
    1.82 +	iInputFile.Close();
    1.83 +	iTestSection.Close();
    1.84 +	
    1.85 +	// Close file
    1.86 +	iSourceFile.Close();
    1.87 +	iSourceFile64.Close();
    1.88 +
    1.89 +    //Close the file server session
    1.90 +    iFsSession.Close();
    1.91 +    
    1.92 +	return TestStepResult();
    1.93 +	}
    1.94 +
    1.95 +TInt C3GPLibParser_base::CheckError(TInt aError, TInt aExpectError, const TDesC& aFunction)
    1.96 +	{
    1.97 +	if (aError != aExpectError)
    1.98 +		{
    1.99 +		ERR_PRINTF4(_L("%S expected %d, but returns %d; "), &aFunction, aExpectError, aError);
   1.100 +		if (aError != KErrNone)
   1.101 +			{
   1.102 +			return aError;
   1.103 +			}
   1.104 +		// expected an error, but return KErrNone
   1.105 +		return KErrGeneral;
   1.106 +		}
   1.107 +	return KErrNone;
   1.108 +	}
   1.109 +
   1.110 +void C3GPLibParser_base::ParserOpenL(C3GPParse* aParser, TInt aExpectedError)
   1.111 +	{
   1.112 +	ASSERT(aParser);
   1.113 +	
   1.114 +	TInt err = aParser->Open();
   1.115 +	if (aExpectedError == KErrInUse && err == KErrNone)
   1.116 +		{
   1.117 +		err = aParser->Open();
   1.118 +		}
   1.119 +
   1.120 +	if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError)
   1.121 +		{
   1.122 +		INFO_PRINTF2(_L("Parser open using buffer mode (OOM), returns %d"), err);
   1.123 +		User::Leave(err);
   1.124 +		}
   1.125 +
   1.126 +	if (!ShouldRunOOMTest())
   1.127 +		{
   1.128 +		INFO_PRINTF2(_L("Parser open using buffer mode, returns %d"), err);
   1.129 +		}
   1.130 +
   1.131 +	User::LeaveIfError(CheckError(err, aExpectedError, _L("aParser->Open() buffer mode")));
   1.132 +	}
   1.133 +
   1.134 +void C3GPLibParser_base::ParserOpenFileL(C3GPParse* aParser, TInt aExpectedError)
   1.135 +	{
   1.136 +	ASSERT(aParser);
   1.137 +	
   1.138 +	TInt err = aParser->Open(iInputFile);
   1.139 +	if (aExpectedError == KErrInUse && err == KErrNone)
   1.140 +		{
   1.141 +		err = aParser->Open(iInputFile);
   1.142 +		}
   1.143 +
   1.144 +	if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError)
   1.145 +		{
   1.146 +		INFO_PRINTF2(_L("Parser open using file path (OOM), returns %d"), err);
   1.147 +		User::Leave(err);
   1.148 +		}
   1.149 +
   1.150 +	if (!ShouldRunOOMTest())
   1.151 +		{
   1.152 +		INFO_PRINTF2(_L("Parser open using file path, returns %d"), err);
   1.153 +		}
   1.154 +	
   1.155 +	User::LeaveIfError(CheckError(err, aExpectedError, _L("aParser->Open() file path")));
   1.156 +	}
   1.157 +
   1.158 +void C3GPLibParser_base::ParserCompleteL(C3GPParse* aParser)
   1.159 +	{
   1.160 +	ASSERT(aParser);
   1.161 +	
   1.162 +	TInt err = aParser->Complete();
   1.163 +	User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->Complete()")));
   1.164 +	}
   1.165 +	
   1.166 +void C3GPLibParser_base::FileOpenL(TUint aFileMode)	
   1.167 +	{
   1.168 +	iSourceFile.Close();
   1.169 +	//Create a connection to the file server    
   1.170 +    User::LeaveIfError(iFsSession.Connect());
   1.171 +    
   1.172 +    //Open the source file passing in the file server session handle, source 
   1.173 +    //file path and file access mode 
   1.174 +    User::LeaveIfError(iSourceFile.Open(iFsSession, iInputFile, aFileMode ));
   1.175 +	}
   1.176 +
   1.177 +void C3GPLibParser_base::FileClose()	
   1.178 +	{
   1.179 +	// Close file
   1.180 +	iSourceFile.Close();
   1.181 +
   1.182 +    //Close the file server session
   1.183 +    iFsSession.Close();
   1.184 +	}
   1.185 +
   1.186 +void C3GPLibParser_base::FileOpen64L(TUint aFileMode)	
   1.187 +	{
   1.188 +	iSourceFile64.Close();
   1.189 +	//Create a connection to the file server    
   1.190 +    User::LeaveIfError(iFsSession.Connect());
   1.191 +    
   1.192 +    //Open the source file passing in the file server session handle, source 
   1.193 +    //file path and file access mode 
   1.194 +    User::LeaveIfError(iSourceFile64.Open(iFsSession, iInputFile, aFileMode ));
   1.195 +	}
   1.196 +
   1.197 +void C3GPLibParser_base::FileClose64()	
   1.198 +	{
   1.199 +	// Close file
   1.200 +	iSourceFile64.Close();
   1.201 +
   1.202 +    //Close the file server session
   1.203 +    iFsSession.Close();
   1.204 +	}
   1.205 +
   1.206 +void C3GPLibParser_base::ParserOpenFileHandleL(C3GPParse* aParser, TUint aFileMode, TInt aExpectedError)
   1.207 +	{
   1.208 +	ASSERT(aParser);
   1.209 +   
   1.210 +	FileOpenL(aFileMode);
   1.211 +    TInt err = aParser->Open(iSourceFile);	
   1.212 +    if (aExpectedError == KErrInUse && err == KErrNone)
   1.213 +		{
   1.214 +		err = aParser->Open(iSourceFile);
   1.215 +		}
   1.216 +
   1.217 +	if (err != KErrNone && err != aExpectedError)
   1.218 +		{
   1.219 +		FileClose();
   1.220 +
   1.221 +		if (ShouldRunOOMTest())
   1.222 +			{
   1.223 +			INFO_PRINTF2(_L("Parser open using file handle (OOM), returns %d"), err);
   1.224 +			User::Leave(err);
   1.225 +			}
   1.226 +		}
   1.227 +
   1.228 +	if (!ShouldRunOOMTest())
   1.229 +		{
   1.230 +		INFO_PRINTF2(_L("Parser open using file handle, returns %d"), err);		
   1.231 +		}
   1.232 +
   1.233 +	if (err == aExpectedError ) 
   1.234 +		{
   1.235 +		err = KErrNone;
   1.236 +		}
   1.237 +	User::LeaveIfError(err);
   1.238 +	}
   1.239 +
   1.240 +void C3GPLibParser_base::ParserCompleteHandleL(C3GPParse* aParser)
   1.241 +	{
   1.242 +	ASSERT(aParser);
   1.243 +	
   1.244 +	TInt err = aParser->Complete();
   1.245 +	if (err != KErrNone)
   1.246 +		{
   1.247 +		ERR_PRINTF2(_L("aParser->Complete() file handle failed with %d"), err);
   1.248 +		}
   1.249 +	
   1.250 +	FileClose();
   1.251 +    User::LeaveIfError(err);
   1.252 +	}
   1.253 +
   1.254 +void C3GPLibParser_base::ParserOpenFileHandle64L(C3GPParse* aParser, TUint aFileMode, TInt aExpectedError)
   1.255 +	{
   1.256 +	ASSERT(aParser);
   1.257 +   
   1.258 +	FileOpen64L(aFileMode);
   1.259 +    TInt err = aParser->Open(iSourceFile64);	
   1.260 +    if (aExpectedError == KErrInUse && err == KErrNone)
   1.261 +		{
   1.262 +		err = aParser->Open(iSourceFile64);
   1.263 +		}
   1.264 +
   1.265 +	if (err != KErrNone && err != aExpectedError)
   1.266 +		{
   1.267 +		FileClose();
   1.268 +
   1.269 +		if (ShouldRunOOMTest())
   1.270 +			{
   1.271 +			INFO_PRINTF2(_L("Parser open using 64bit file handle (OOM), returns %d"), err);
   1.272 +			User::Leave(err);
   1.273 +			}
   1.274 +		}
   1.275 +
   1.276 +	if (!ShouldRunOOMTest())
   1.277 +		{
   1.278 +		INFO_PRINTF2(_L("Parser open using 64bit file handle, returns %d"), err);		
   1.279 +		}
   1.280 +
   1.281 +	if (err == aExpectedError ) 
   1.282 +		{
   1.283 +		err = KErrNone;
   1.284 +		}
   1.285 +	User::LeaveIfError(err);
   1.286 +	}
   1.287 +
   1.288 +void C3GPLibParser_base::ParserCompleteHandle64L(C3GPParse* aParser)
   1.289 +	{
   1.290 +	ASSERT(aParser);
   1.291 +	
   1.292 +	TInt err = aParser->Complete();
   1.293 +	if (err != KErrNone)
   1.294 +		{
   1.295 +		ERR_PRINTF2(_L("aParser->Complete() 64bit file handle failed with %d"), err);
   1.296 +		}
   1.297 +	
   1.298 +	FileClose64();
   1.299 +    User::LeaveIfError(err);
   1.300 +	}
   1.301 +
   1.302 +void C3GPLibParser_base::ParserOpenCafLC(C3GPParse* aParser, TInt aExpectedError)
   1.303 +	{
   1.304 +	ASSERT(aParser);
   1.305 +	CContent* content = CContent::NewLC(iInputFile, EContentShareReadWrite);	
   1.306 +	CData* data = content->OpenContentL(EPeek);	
   1.307 +	
   1.308 +	CleanupStack::PushL(data);
   1.309 +
   1.310 +	TInt err = aParser->Open(*data);
   1.311 +	if (aExpectedError == KErrInUse && err == KErrNone)
   1.312 +		{
   1.313 +		err = aParser->Open(*data);
   1.314 +		}
   1.315 +
   1.316 +	if (ShouldRunOOMTest() && err != KErrNone && err != aExpectedError)
   1.317 +		{
   1.318 +		INFO_PRINTF2(_L("Parser open using CAF (OOM), returns %d"), err);
   1.319 +		User::Leave(err);	
   1.320 +		}
   1.321 +
   1.322 +	if (!ShouldRunOOMTest())
   1.323 +		{
   1.324 +		INFO_PRINTF2(_L("Parser open using CAF, returns %d"), err);
   1.325 +		}
   1.326 +
   1.327 +	if (err == aExpectedError)
   1.328 +		{
   1.329 +		err = KErrNone;
   1.330 +		}
   1.331 +	User::LeaveIfError(err);
   1.332 +	}
   1.333 +
   1.334 +void C3GPLibParser_base::ParserCompleteCafL(C3GPParse* aParser)
   1.335 +	{
   1.336 +	ASSERT(aParser);
   1.337 +	TInt err = aParser->Complete();
   1.338 +	if ( err != KErrNone )
   1.339 +		{
   1.340 +		ERR_PRINTF2(_L("parse->Complete() CAF failed with %d."), err);
   1.341 +		}
   1.342 +
   1.343 +	CleanupStack::PopAndDestroy(2); // content, data
   1.344 +	User::LeaveIfError(err);
   1.345 +	}
   1.346 +
   1.347 +// Retrieve both video & audio stream properties
   1.348 +TInt C3GPLibParser_base::GetClipProperties(C3GPParse* aParse, TInt& aVideoError, TUint& aVideoLength, TUint& aAudioLength)
   1.349 +	{
   1.350 +	TInt err = KErrCorrupt;
   1.351 +	T3GPVideoType videoType;
   1.352 +	TReal frameRate;
   1.353 +	TUint avgBitRate;
   1.354 +	TSize videoSize;
   1.355 +	TUint timeScale;
   1.356 +	
   1.357 +	aVideoError = aParse->GetVideoProperties(videoType, aVideoLength, frameRate, avgBitRate, videoSize, timeScale);
   1.358 +	
   1.359 +	if (aVideoError == KErrNone || aVideoError == KErrNotSupported || aVideoError == KErr3gpLibMoreDataRequired)
   1.360 +		{
   1.361 +		T3GPAudioType audioType;
   1.362 +		TInt framesPerSample;
   1.363 +		err = aParse->GetAudioProperties(audioType, aAudioLength, framesPerSample, avgBitRate, timeScale);
   1.364 +		}	
   1.365 +	return err;
   1.366 +	}
   1.367 +
   1.368 +// Get both audio and video decorder information
   1.369 +TInt C3GPLibParser_base::ParserGetDecoderInfo(C3GPParse* aParser)
   1.370 +	{
   1.371 +	TInt dsiSize;
   1.372 +	RBuf8 dsiBuffer;
   1.373 +	
   1.374 +	TInt err = aParser->GetAudioDecoderSpecificInfoSize(dsiSize);
   1.375 +	if ( err == KErrNone )
   1.376 +		{		
   1.377 +		err = dsiBuffer.Create(dsiSize);
   1.378 +		if ( err != KErrNone )
   1.379 +			{
   1.380 +			ERR_PRINTF2(_L("dsiBuffer.Create failed with %d"), err);
   1.381 +			dsiBuffer.Close();
   1.382 +			return err;
   1.383 +			}
   1.384 +		
   1.385 +		err = aParser->GetAudioDecoderSpecificInfo(dsiBuffer);
   1.386 +		}
   1.387 +	if ( err != KErrNone )
   1.388 +		{
   1.389 +		if (!ShouldRunOOMTest())
   1.390 +			{
   1.391 +			ERR_PRINTF3(_L("GetAudioDecoderSpecificInfo/Size() failed with %d, size %d"), err, dsiSize);
   1.392 +			}
   1.393 +		dsiBuffer.Close();
   1.394 +		return err;
   1.395 +		}
   1.396 +	
   1.397 +	err = aParser->GetVideoDecoderSpecificInfoSize(dsiSize);
   1.398 +	if ( err != KErrNone && err != KErrNotSupported)
   1.399 +		{
   1.400 +		dsiBuffer.Close();
   1.401 +		ERR_PRINTF2(_L("parse->GetVideoDecoderSpecificInfoSize() failed with %d"), err);
   1.402 +		return err;
   1.403 +		}
   1.404 +	if (err != KErrNotSupported)
   1.405 +		{
   1.406 +		dsiBuffer.Close();
   1.407 +		err = dsiBuffer.Create(dsiSize);	
   1.408 +		if ( err != KErrNone )
   1.409 +			{
   1.410 +			ERR_PRINTF2(_L("dsiBuffer.Create failed with %d"), err);
   1.411 +			dsiBuffer.Close();
   1.412 +			return err;
   1.413 +			}
   1.414 +		
   1.415 +		err = aParser->GetVideoDecoderSpecificInfo(dsiBuffer);
   1.416 +		if ( err != KErrNone )
   1.417 +			{
   1.418 +			ERR_PRINTF2(_L("VideoDecoderSpecificInfo() failed with %d"), err);
   1.419 +			}
   1.420 +		}
   1.421 +	dsiBuffer.Close();
   1.422 +	return err;
   1.423 +	}
   1.424 +
   1.425 +// Read data from file and insert it to the buffer
   1.426 +void C3GPLibParser_base::InsertDataL(C3GPParse* aParse, RFile aFile, TInt aBufferSize, TInt aPos)
   1.427 +	{
   1.428 +	TInt err = KErrNone;
   1.429 +	RBuf8 buffer;
   1.430 +	CleanupClosePushL(buffer);
   1.431 +	buffer.CreateL(aBufferSize);
   1.432 +	err = aFile.Read(aPos, buffer); 
   1.433 +	if (err == KErrNone)
   1.434 +		{
   1.435 +		err = aParse->InsertData(buffer);
   1.436 +		if ( err != KErrNone )
   1.437 +			{
   1.438 +			ERR_PRINTF2(_L("parse->InsertData() failed with %d"), err);
   1.439 +			}
   1.440 +		}
   1.441 +	else
   1.442 +		{
   1.443 +		ERR_PRINTF2(_L("aFile.Read(aPos, buffer) failed with %d"), err);
   1.444 +		}
   1.445 +	buffer.Close();
   1.446 +	CleanupStack::PopAndDestroy(&buffer);
   1.447 +	User::LeaveIfError(err);
   1.448 +	}
   1.449 +
   1.450 +// Read audio or video frame(s) depending on the input parameter synchronously
   1.451 +TInt C3GPLibParser_base::ReadAudioVideoFrame(C3GPParse* aParse, TBool aRepeat, TBool aReadAudio)
   1.452 +	{
   1.453 +	TInt err = KErrNone;
   1.454 +	// If repeat, read all frames; otherwise, read only one frame
   1.455 +	while (err == KErrNone)
   1.456 +		{
   1.457 +		TUint size;		
   1.458 +		if (aReadAudio)
   1.459 +			{
   1.460 +			err = aParse->GetAudioFramesSize(size);
   1.461 +			}
   1.462 +		else
   1.463 +			{
   1.464 +			err = aParse->GetVideoFrameSize(size);
   1.465 +			}
   1.466 +		
   1.467 +		if (err == KErrNone)
   1.468 +			{
   1.469 +			TUint timeStampInMs;
   1.470 +			TUint timeStampInTimescale;
   1.471 +			RBuf8 buffer;
   1.472 +			err = buffer.Create(size);				
   1.473 +			if (err != KErrNone)
   1.474 +				{
   1.475 +				ERR_PRINTF2(_L("buffer.Create(size) failed with %d"), err);
   1.476 +				buffer.Close();
   1.477 +				return err;
   1.478 +				}
   1.479 +			
   1.480 +			if (aReadAudio)
   1.481 +				{				
   1.482 +				TInt returnedFrames;
   1.483 +				err = aParse->ReadAudioFrames(buffer, returnedFrames, timeStampInMs, timeStampInTimescale);
   1.484 +				}
   1.485 +			else
   1.486 +				{
   1.487 +				TBool keyframe;
   1.488 +				err = aParse->ReadVideoFrame(buffer, keyframe, timeStampInMs, timeStampInTimescale);
   1.489 +				}
   1.490 +			
   1.491 +			if (err != KErrNone && err != KErrNotFound && err != KErr3gpLibMoreDataRequired)
   1.492 +				{
   1.493 +				if (aReadAudio)
   1.494 +					{
   1.495 +					ERR_PRINTF3(_L("parse->GetAudioFrames() failed with %d; frame size: %d"), err, size);
   1.496 +					}
   1.497 +				else
   1.498 +					{
   1.499 +					ERR_PRINTF3(_L("parse->GetVideoFrame() failed with %d; frame size: %d"), err, size);
   1.500 +					}
   1.501 +				buffer.Close();
   1.502 +				return err;
   1.503 +				}
   1.504 +			buffer.Close();
   1.505 +			}
   1.506 +		
   1.507 +		if (!aRepeat)
   1.508 +			{
   1.509 +			break;
   1.510 +			}
   1.511 +		}
   1.512 +	return err;
   1.513 +	}
   1.514 +
   1.515 +// Retrieve user data atom.
   1.516 +TInt C3GPLibParser_base::CallUDTApi(C3GPParse* aParse, TUint32 aUdtType, TUint& aIndex, T3GPUdtaLocation aLocation)
   1.517 +	{
   1.518 +	TInt err = KErrNone;
   1.519 +	TInt udtSize;
   1.520 +	
   1.521 +	// use a copy of the target index requested by the user, so it does not get overwritten
   1.522 +	// when calling the APIs GetUserDataAtomSize & GetUserDataAtom
   1.523 +	TUint tempIndex1 = aIndex;	
   1.524 +	TUint tempIndex2 = aIndex;	
   1.525 +
   1.526 +	err = aParse->GetUserDataAtomSize(aUdtType, aLocation, tempIndex1, udtSize);
   1.527 +	if (err == KErrNone)
   1.528 +		{
   1.529 +		RBuf8 buffer;	
   1.530 +		
   1.531 +		err = buffer.Create(udtSize); // Use size retrieved from GetUserDataAtomSize
   1.532 +		if (err == KErrNone)
   1.533 +			{
   1.534 +			err = aParse->GetUserDataAtom(aUdtType, aLocation, buffer, tempIndex2);
   1.535 +			if (err == KErrNone && tempIndex1 != tempIndex2)
   1.536 +				{
   1.537 +				ERR_PRINTF1(_L("C3GPLibParser_base::CallUDTApi - Highest Index returned is different when calling GetUserDataAtomSize vs GetUserDataAtom"));	
   1.538 +				err = KErrGeneral;
   1.539 +				}
   1.540 +			}
   1.541 +		else
   1.542 +			{
   1.543 +			ERR_PRINTF2(_L("buffer.Create(size) failed with %d"), err);
   1.544 +			}
   1.545 +		buffer.Close();		
   1.546 +		}
   1.547 +	
   1.548 +	if (err == KErrNone)
   1.549 +		{
   1.550 +		// return the highest index found
   1.551 +		aIndex = tempIndex1;
   1.552 +		}
   1.553 +	
   1.554 +	return err;
   1.555 +	}
   1.556 +
   1.557 +void C3GPLibParser_base::DoGetVideoAudioAttributesL(C3GPParse* aParser)
   1.558 +	{
   1.559 +	// Retrieve video & audio stream attributes
   1.560 +	T3GPVideoType videoType;
   1.561 +	TUint length; 
   1.562 +	TReal frameRate;
   1.563 +	TUint avgBitRate;
   1.564 +	TSize videoSize;
   1.565 +	TUint timeScale;
   1.566 +	
   1.567 +	TInt err = aParser->GetVideoProperties(videoType, length, frameRate, avgBitRate, videoSize, timeScale);
   1.568 +	User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetVideoProperties()")));
   1.569 +	
   1.570 +	T3GPAudioType audioType;
   1.571 +	TInt framesPerSample;
   1.572 +	err = aParser->GetAudioProperties(audioType, length, framesPerSample, avgBitRate, timeScale);
   1.573 +	User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetAudioProperties()")));
   1.574 +	
   1.575 +	err = ParserGetDecoderInfo(aParser);
   1.576 +	User::LeaveIfError(CheckError(err, KErrNone, _L("ParserGetDecoderInfo(aParser)")));
   1.577 +	
   1.578 +	TUint numVideoFrames;
   1.579 +	err = aParser->GetNumberOfVideoFrames(numVideoFrames);
   1.580 +	User::LeaveIfError(CheckError(err, KErrNone, _L("parse->GetNumberOfVideoFrames")));
   1.581 +	
   1.582 +	TUint startIndex = 0;
   1.583 +	RArray<T3GPFrameInfoParameters> array;
   1.584 +	err = aParser->GetVideoFrameProperties(startIndex, numVideoFrames, array);	
   1.585 +	array.Close();
   1.586 +	User::LeaveIfError(CheckError(err, KErrNone, _L("parse->GetVideoFrameProperties")));
   1.587 +	}
   1.588 +
   1.589 +TInt C3GPLibParser_base::DoReadFrame(C3GPParse* aParse)
   1.590 +	{
   1.591 +	TInt numBufferedBytes;
   1.592 +	TInt err = aParse->GetNumBufferedBytes(numBufferedBytes);
   1.593 +	if (err != KErrNone && numBufferedBytes != 0)
   1.594 +		{
   1.595 +		// when GetNumBufferedBytes returns error, numBufferedBytes is set to zero.
   1.596 +		return err;		
   1.597 +		}
   1.598 +	err = CheckError(err, KErrNotSupported, _L("parse->GetNumBufferedBytes()"));	
   1.599 +	if (err == KErrNone)
   1.600 +		{
   1.601 +		// read audio frame
   1.602 +		err = ReadAudioVideoFrame(aParse, ETrue, ETrue);
   1.603 +		// When finishing reading all frames, it returns KErrNotFound
   1.604 +		err = CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParse, ETrue)"));
   1.605 +		
   1.606 +		if (err == KErrNone)
   1.607 +			{
   1.608 +			// read video frame
   1.609 +			err = ReadAudioVideoFrame(aParse, ETrue, EFalse);
   1.610 +			// When finishing reading all frames, it returns KErrNotFound
   1.611 +			err = CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParse, EFalse)"));			
   1.612 +			}
   1.613 +		
   1.614 +		// After finishing reading all frame, the next video time stamp should return with KErrEof
   1.615 +		TUint timeStampInMs;
   1.616 +		TUint timeStampInTimescale;
   1.617 +		err = aParse->GetVideoTimestamp(timeStampInMs, timeStampInTimescale);
   1.618 +		err = CheckError(err, KErrEof, _L("GetVideoTimestamp()"));			
   1.619 +		}
   1.620 +		
   1.621 +	return err;
   1.622 +	}
   1.623 +
   1.624 +void C3GPLibParser_base::DoSeekTestL(C3GPParse* aParser)
   1.625 +	{
   1.626 +	// testclip_h263_qcif_15fps_armnb_8khz_onlyvideo.3GP with some key frame
   1.627 +	TUint num; 
   1.628 +	TUint audioPos;
   1.629 +	TUint videoPos;
   1.630 +	TUint timeStampInMs = 0; // for key frame
   1.631 +	TUint timeStampInTimescale = 0;  // for key frame
   1.632 +	TUint timeStampInMs1 = 0;  // for non key frame immediately after key frame
   1.633 +	TUint timeStampInTimescale1 = 0;  // for non-key frame immediately after key frame
   1.634 +	TUint keyFrameIndex = 0;
   1.635 +	TBool keyFrame;
   1.636 +	TInt err = aParser->GetNumberOfVideoFrames(num);
   1.637 +	if (err == KErrNone)
   1.638 +		{
   1.639 +		for (TInt i = 0; i < num; i++)
   1.640 +			{			
   1.641 +			err = aParser->GetVideoFrameKeyType(i, keyFrame);
   1.642 +			if (err == KErrNone && keyFrame)
   1.643 +				{
   1.644 +				keyFrameIndex = i;
   1.645 +				err = aParser->GetVideoFrameStartTime(keyFrameIndex, timeStampInMs, timeStampInTimescale);
   1.646 +				}
   1.647 +			if (err == KErrNone && !keyFrame && keyFrameIndex > 0)
   1.648 +				{
   1.649 +				keyFrameIndex = i;
   1.650 +				err = aParser->GetVideoFrameStartTime(keyFrameIndex, timeStampInMs1, timeStampInTimescale1);
   1.651 +				break;
   1.652 +				}
   1.653 +			if (err != KErrNone)
   1.654 +				{
   1.655 +				ERR_PRINTF3(_L("aParser->GetVideoFrameKeyType() failed with %d at i %d"), err, i);
   1.656 +				User::Leave(err);
   1.657 +				}
   1.658 +			}
   1.659 +		}
   1.660 +	else
   1.661 +		{
   1.662 +		ERR_PRINTF2(_L("aParser->GetNumberOfVideoFrames() failed with %d"), err);
   1.663 +		User::Leave(err);
   1.664 +		}
   1.665 +	err = aParser->Seek(timeStampInMs, ETrue, audioPos, videoPos);
   1.666 +	if (err != KErrNone || timeStampInMs != videoPos)
   1.667 +		{
   1.668 +		ERR_PRINTF4(_L("aParser->Seek() return %d, timeStampInMs %d, videoPos %d"), err, timeStampInMs, videoPos);
   1.669 +		}
   1.670 +	if (err == KErrNone && timeStampInMs != videoPos)
   1.671 +		{
   1.672 +		User::LeaveIfError(KErrGeneral);
   1.673 +		}
   1.674 +	User::LeaveIfError(err);
   1.675 +	
   1.676 +	err = aParser->Seek(timeStampInMs1, EFalse, audioPos, videoPos);
   1.677 +	if (err != KErrNone || timeStampInMs1 != videoPos)
   1.678 +		{
   1.679 +		ERR_PRINTF4(_L("aParser->Seek() return %d, timeStampInMs1 %d, videoPos %d"), err, timeStampInMs1, videoPos);
   1.680 +		}
   1.681 +	if (err == KErrNone && timeStampInMs1 != videoPos)
   1.682 +		{
   1.683 +		User::LeaveIfError(KErrGeneral);
   1.684 +		}
   1.685 +	User::LeaveIfError(err);
   1.686 +	}
   1.687 +
   1.688 +void C3GPLibParser_base::ReadFrameBufferModeL(C3GPParse* aParser)
   1.689 +	{
   1.690 +	ParserOpenL(aParser);
   1.691 +
   1.692 +	TInt errReadAudio = KErrNone;
   1.693 +	TInt errReadVideo = KErrNone;
   1.694 +	// Insert 1K data into the library
   1.695 +	TInt pos = 0;
   1.696 +	TInt bufferSize = 1000;
   1.697 +	
   1.698 +	InsertDataL(aParser, iSourceFile, bufferSize, pos);
   1.699 +	errReadAudio = ReadAudioVideoFrame(aParser, ETrue, ETrue);
   1.700 +	errReadVideo = ReadAudioVideoFrame(aParser, ETrue, EFalse);
   1.701 +
   1.702 +	while (errReadAudio == KErr3gpLibMoreDataRequired || errReadVideo == KErr3gpLibMoreDataRequired)
   1.703 +		{
   1.704 +		pos = pos + bufferSize;
   1.705 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
   1.706 +		if (errReadAudio == KErr3gpLibMoreDataRequired)
   1.707 +			{
   1.708 +			errReadAudio = ReadAudioVideoFrame(aParser, ETrue, ETrue);
   1.709 +			}
   1.710 +
   1.711 +		if (errReadVideo == KErr3gpLibMoreDataRequired)
   1.712 +			{
   1.713 +			errReadVideo = ReadAudioVideoFrame(aParser, ETrue, EFalse);
   1.714 +			}
   1.715 +		}
   1.716 +	
   1.717 +	// When last frame has been read, it should return KErrNotFound
   1.718 +	if (errReadAudio != KErrNotFound)
   1.719 +		{
   1.720 +		ERR_PRINTF1(_L("parse->ReadAudioFrames() expects KErrNotFound. "));
   1.721 +		User::Leave(errReadAudio);
   1.722 +		}
   1.723 +	if (errReadVideo != KErrNotFound)
   1.724 +		{
   1.725 +		ERR_PRINTF1(_L("parse->ReadVideoFrame expects KErrNotFound. "));
   1.726 +		User::Leave(errReadVideo);
   1.727 +		}
   1.728 +	
   1.729 +	ParserCompleteL(aParser);
   1.730 +	}
   1.731 +
   1.732 +C3GPLib_AsyncObserver::C3GPLib_AsyncObserver()
   1.733 +	{	
   1.734 +	}
   1.735 +
   1.736 +TVerdict C3GPLib_AsyncObserver::doTestStepPreambleL()
   1.737 +	{
   1.738 +	C3GPLibParser_base::doTestStepPreambleL();
   1.739 +	
   1.740 +	iSchedulerWait = new (ELeave) CActiveSchedulerWait;
   1.741 +	if(!iSchedulerWait)
   1.742 +		{
   1.743 +		SetTestStepResult(EInconclusive);
   1.744 +		}
   1.745 +	return TestStepResult();
   1.746 +	}
   1.747 +
   1.748 +// -----------------------------------------------------------------------------
   1.749 +// C3GPLib_AsyncObserver for asynchronous read
   1.750 +// -----------------------------------------------------------------------------
   1.751 +//
   1.752 +TVerdict C3GPLib_AsyncObserver::doTestStepPostambleL()
   1.753 +	{
   1.754 +	C3GPLibParser_base::doTestStepPostambleL();
   1.755 +	if ( iSchedulerWait)
   1.756 +		{
   1.757 +		if (iSchedulerWait->IsStarted())
   1.758 +			{
   1.759 +			iSchedulerWait->AsyncStop();
   1.760 +			}
   1.761 +		delete iSchedulerWait;
   1.762 +		iSchedulerWait = NULL;
   1.763 +		}	
   1.764 +	return TestStepResult();
   1.765 +	}
   1.766 +
   1.767 +// Read audio or video frame(s) depending on the input parameter asynchronously
   1.768 +TInt C3GPLib_AsyncObserver::ReadAudioVideoFrameAsync(C3GPParse* aParse, TBool aReadAudio, TBool aCancel)
   1.769 +	{
   1.770 +	TInt err = KErrNone;
   1.771 +	TUint size;	
   1.772 +	
   1.773 +	while (err == KErrNone)
   1.774 +		{
   1.775 +		if (aReadAudio)
   1.776 +			{
   1.777 +			err = aParse->GetAudioFramesSize(size);
   1.778 +			}
   1.779 +		else
   1.780 +			{
   1.781 +			err = aParse->GetVideoFrameSize(size);
   1.782 +			}
   1.783 +		
   1.784 +		RBuf8 buffer;
   1.785 +		if (err == KErrNone)
   1.786 +			{
   1.787 +			err = buffer.Create(size);				
   1.788 +			}
   1.789 +		else
   1.790 +			{
   1.791 +			err = buffer.Create(KBufferSize);	
   1.792 +			}
   1.793 +		
   1.794 +		if (err != KErrNone)
   1.795 +			{
   1.796 +			ERR_PRINTF2(_L("buffer.Create(KBufferSize) failed with %d"), err);
   1.797 +			buffer.Close();
   1.798 +			return err;
   1.799 +			}
   1.800 +			
   1.801 +		iWaitForNotification = ETrue;
   1.802 +		if (aReadAudio)
   1.803 +			{				
   1.804 +			aParse->ReadAudioFrames(*this, buffer);
   1.805 +			}
   1.806 +		else 
   1.807 +			{
   1.808 +			aParse->ReadVideoFrame(*this, buffer);
   1.809 +			}
   1.810 +		
   1.811 +		if (aCancel && iAsyncError == KErrNone)
   1.812 +			{
   1.813 +			aParse->CancelReadFrame();
   1.814 +			// Calling cancel again won't have effects
   1.815 +			aParse->CancelReadFrame();
   1.816 +			
   1.817 +			// Do read frame again
   1.818 +			if (aReadAudio)
   1.819 +				{				
   1.820 +				aParse->ReadAudioFrames(*this, buffer);
   1.821 +				}
   1.822 +			else 
   1.823 +				{
   1.824 +				aParse->ReadVideoFrame(*this, buffer);
   1.825 +				}
   1.826 +			}
   1.827 +		
   1.828 +		if (iWaitForNotification)
   1.829 +		    {
   1.830 +			iSchedulerWait->Start();
   1.831 +		    }
   1.832 +		
   1.833 +		err = iAsyncError; 
   1.834 +		buffer.Close(); 
   1.835 +		} 
   1.836 +	
   1.837 +	if ( iSchedulerWait->IsStarted() )
   1.838 +        {
   1.839 +        iSchedulerWait->AsyncStop();
   1.840 +	    }
   1.841 +			
   1.842 +	if (err != KErrNone && err != KErrNotFound)
   1.843 +		{
   1.844 +		if (!ShouldRunOOMTest())
   1.845 +			{
   1.846 +			ERR_PRINTF2(_L("ReadAudioVideoFrameAsync failed with %d;"), err);
   1.847 +			}
   1.848 +		}
   1.849 +	else
   1.850 +		{
   1.851 +		err = KErrNone;
   1.852 +		}
   1.853 +	
   1.854 +	return err;
   1.855 +	}
   1.856 +
   1.857 +void C3GPLib_AsyncObserver::AudioFramesAvailable(TInt aError, TUint aReturnedFrames, 
   1.858 +			TUint aTimeStampInMs, TUint aTimeStampInTimescale)
   1.859 +	{
   1.860 +	iWaitForNotification = EFalse;
   1.861 +	iAsyncLastNotificationFromAudio = EFalse;
   1.862 +	iAsyncError = aError;
   1.863 +	iAsyncAudioTimeStampInMs = aTimeStampInMs; 
   1.864 +	iAsyncAudioReturnedFrames = aReturnedFrames;
   1.865 +	iAsyncAudioTimestampInTimescale = aTimeStampInTimescale;
   1.866 +	if (iSchedulerWait->IsStarted())
   1.867 +		{
   1.868 +		iSchedulerWait->AsyncStop();
   1.869 +		}
   1.870 +
   1.871 +	}
   1.872 +
   1.873 +void C3GPLib_AsyncObserver::VideoFrameAvailable(TInt aError, TBool aKeyFrame, TUint 
   1.874 +			aTimeStampInMs, TUint aTimeStampInTimescale)
   1.875 +	{
   1.876 +	iWaitForNotification = EFalse;
   1.877 +	iAsyncLastNotificationFromAudio = EFalse;
   1.878 +	iAsyncError = aError;
   1.879 +	iAsyncVideoTimeStampInMs = aTimeStampInMs; 
   1.880 +	iAsyncVideoKeyFrame = aKeyFrame;
   1.881 +	iAsyncVideoTimestampInTimescale = aTimeStampInTimescale;
   1.882 +	
   1.883 +	if (iSchedulerWait->IsStarted())
   1.884 +		{
   1.885 +		iSchedulerWait->AsyncStop();
   1.886 +		}
   1.887 +
   1.888 +	}
   1.889 +
   1.890 +
   1.891 +
   1.892 +// -----------------------------------------------------------------------------
   1.893 +// Setup parser to read file by file path.
   1.894 +// -----------------------------------------------------------------------------
   1.895 +//
   1.896 +C3GPLibParser_0001::C3GPLibParser_0001()
   1.897 +	{
   1.898 +	}
   1.899 +
   1.900 +TVerdict C3GPLibParser_0001::doTestStepL()
   1.901 +	{
   1.902 +	if(TestStepResult() == EPass)
   1.903 +		{
   1.904 +		C3GPParse* parser = C3GPParse::NewL();
   1.905 +		CleanupStack::PushL(parser);
   1.906 +		
   1.907 +		OpenCompleteL(parser);
   1.908 +	
   1.909 +		CleanupStack::PopAndDestroy(parser);
   1.910 +		}
   1.911 +	return TestStepResult();
   1.912 +	}
   1.913 +
   1.914 +void C3GPLibParser_0001::OpenCompleteL(C3GPParse* aParser)
   1.915 +	{
   1.916 +	// Test open and complete with default file access mode
   1.917 +	ParserOpenFileL(aParser);
   1.918 +	ParserCompleteL(aParser);
   1.919 +	
   1.920 +	FileOpenL();
   1.921 +    ParserOpenFileL(aParser);
   1.922 +	ParserCompleteL(aParser);
   1.923 +	ParserCompleteL(aParser); // Should not fail when calling complete twice
   1.924 +	FileClose();
   1.925 +	
   1.926 +	//Open the source file passing in the file server session handle, source 
   1.927 +    //file path and file access mode (read-write)
   1.928 +	FileOpenL(EFileShareReadersOrWriters | EFileWrite);
   1.929 +    ParserOpenFileL(aParser);
   1.930 +	ParserCompleteL(aParser);
   1.931 +	ParserCompleteL(aParser);
   1.932 +	FileClose();
   1.933 +	
   1.934 +	//Open the source file passing in the file server session handle, source 
   1.935 +    //file path and file access mode (read-write)
   1.936 +	FileOpenL(EFileShareReadersOrWriters | EFileRead);
   1.937 +    ParserOpenFileL(aParser);
   1.938 +	ParserCompleteL(aParser);
   1.939 +	FileClose();
   1.940 +	
   1.941 +	//Open the source file passing in the file server session handle, source 
   1.942 +    //file path and file access mode (read-write)
   1.943 +	FileOpenL(EFileShareAny  | EFileWrite);
   1.944 +    ParserOpenFileL(aParser);
   1.945 +	ParserCompleteL(aParser);
   1.946 +	FileClose();
   1.947 +	
   1.948 +	//Open the source file passing in the file server session handle, source 
   1.949 +    //file path and file access mode (read-write)
   1.950 +	FileOpenL(EFileShareAny | EFileRead);
   1.951 +    ParserOpenFileL(aParser);
   1.952 +	ParserCompleteL(aParser);
   1.953 +	FileClose();
   1.954 +	}
   1.955 +
   1.956 +// -----------------------------------------------------------------------------
   1.957 +// Setup parser to read file by buffer mode.
   1.958 +// -----------------------------------------------------------------------------
   1.959 +//
   1.960 +C3GPLibParser_0002::C3GPLibParser_0002()
   1.961 +	{
   1.962 +	}
   1.963 +
   1.964 +TVerdict C3GPLibParser_0002::doTestStepL()
   1.965 +	{	
   1.966 +	if(TestStepResult() == EPass)
   1.967 +		{
   1.968 +		C3GPParse* parser = C3GPParse::NewL();
   1.969 +		CleanupStack::PushL(parser);
   1.970 +		
   1.971 +		OpenCompleteBufferModeL(parser);
   1.972 +		
   1.973 +		CleanupStack::PopAndDestroy(parser);
   1.974 +		}
   1.975 +	return TestStepResult();
   1.976 +	}
   1.977 +
   1.978 +void C3GPLibParser_0002::OpenCompleteBufferModeL(C3GPParse* aParser)
   1.979 +	{
   1.980 +	// buffer mode
   1.981 +	FileOpenL();
   1.982 +	ParserOpenL(aParser);
   1.983 +	
   1.984 +	ParserCompleteL(aParser);
   1.985 +	FileClose();
   1.986 +	}
   1.987 +
   1.988 +// -----------------------------------------------------------------------------
   1.989 +// Setup parser to read file by file handle.
   1.990 +// -----------------------------------------------------------------------------
   1.991 +//
   1.992 +C3GPLibParser_0003::C3GPLibParser_0003()
   1.993 +	{	
   1.994 +	}
   1.995 +
   1.996 +TVerdict C3GPLibParser_0003::doTestStepL()
   1.997 +	{
   1.998 +	if(TestStepResult() == EPass)
   1.999 +		{
  1.1000 +		C3GPParse* parser = C3GPParse::NewL();
  1.1001 +		CleanupStack::PushL(parser);
  1.1002 +		
  1.1003 +		OpenCompleteFileHandleL(parser);
  1.1004 +		
  1.1005 +		CleanupStack::PopAndDestroy(parser);
  1.1006 +		}
  1.1007 +	return TestStepResult();
  1.1008 +	}
  1.1009 +
  1.1010 +void C3GPLibParser_0003::OpenCompleteFileHandleL(C3GPParse* aParser)
  1.1011 +	{
  1.1012 +	ParserOpenFileHandleL(aParser);
  1.1013 +	ParserCompleteHandleL(aParser);
  1.1014 +	
  1.1015 +    //Open the source file passing in the file server session handle, source 
  1.1016 +    //file path and file access mode (read-only)
  1.1017 +	ParserOpenFileHandleL(aParser, EFileRead | EFileShareReadersOnly);
  1.1018 +	ParserCompleteHandleL(aParser);
  1.1019 +	
  1.1020 +	//Open the source file passing in the file server session handle, source 
  1.1021 +    //file path and file access mode (read-only)
  1.1022 +	ParserOpenFileHandleL(aParser, EFileShareReadersOrWriters | EFileWrite);
  1.1023 +	ParserCompleteHandleL(aParser);
  1.1024 +	
  1.1025 +	//Open the source file passing in the file server session handle, source 
  1.1026 +    //file path and file access mode (read-only)
  1.1027 +	ParserOpenFileHandleL(aParser, EFileShareReadersOrWriters | EFileRead);
  1.1028 +	ParserCompleteHandleL(aParser);
  1.1029 +	
  1.1030 +	//Open the source file passing in the file server session handle, source 
  1.1031 +    //file path and file access mode (read-only)
  1.1032 +	ParserOpenFileHandleL(aParser, EFileShareAny  | EFileWrite);
  1.1033 +	ParserCompleteHandleL(aParser);
  1.1034 +    
  1.1035 +	//Open the source file passing in the file server session handle, source 
  1.1036 +    //file path and file access mode (read-only)
  1.1037 +	ParserOpenFileHandleL(aParser, EFileShareAny | EFileRead);
  1.1038 +	ParserCompleteHandleL(aParser);
  1.1039 +	}
  1.1040 +
  1.1041 +// -----------------------------------------------------------------------------
  1.1042 +// Setup parser to read file by CAF.
  1.1043 +// -----------------------------------------------------------------------------
  1.1044 +//
  1.1045 +C3GPLibParser_0004::C3GPLibParser_0004()
  1.1046 +	{	
  1.1047 +	}
  1.1048 +
  1.1049 +TVerdict C3GPLibParser_0004::doTestStepL()
  1.1050 +	{
  1.1051 +	if(TestStepResult() == EPass)
  1.1052 +		{
  1.1053 +		CContent* content = CContent::NewLC(iInputFile, EContentShareReadWrite);	
  1.1054 +		
  1.1055 +		CData* data = content->OpenContentL(EPeek);			
  1.1056 +		CleanupStack::PushL(data);
  1.1057 +		
  1.1058 +		C3GPParse* parser = C3GPParse::NewL();
  1.1059 +		CleanupStack::PushL(parser);
  1.1060 +		
  1.1061 +		TInt err = parser->Open(*data);
  1.1062 +
  1.1063 +		if (err != KErrNone)
  1.1064 +			{
  1.1065 +			SetTestStepResult(EFail);
  1.1066 +			CleanupStack::PopAndDestroy(parser);
  1.1067 +			CleanupStack::PopAndDestroy(2); // content, data
  1.1068 +			return TestStepResult();
  1.1069 +			}
  1.1070 +		
  1.1071 +		err = parser->Complete();
  1.1072 +		if (err != KErrNone)
  1.1073 +			{
  1.1074 +			SetTestStepResult(EFail);
  1.1075 +			}
  1.1076 +		
  1.1077 +		CleanupStack::PopAndDestroy(parser);
  1.1078 +		CleanupStack::PopAndDestroy(2); // content, data
  1.1079 +		}
  1.1080 +	return TestStepResult();
  1.1081 +	}
  1.1082 +
  1.1083 +// -----------------------------------------------------------------------------
  1.1084 +// Retrieve video & audio stream attributes from a mp4/3gp/3g2 file with supported 
  1.1085 +// video and audio streams using file mode - file path / file handle and CAF object.
  1.1086 +// -----------------------------------------------------------------------------
  1.1087 +//
  1.1088 +C3GPLibParser_0005::C3GPLibParser_0005()
  1.1089 +	{	
  1.1090 +	}
  1.1091 +
  1.1092 +TVerdict C3GPLibParser_0005::doTestStepL()
  1.1093 +	{
  1.1094 +	if(TestStepResult() == EPass)
  1.1095 +		{
  1.1096 +		C3GPParse* parser = C3GPParse::NewL();
  1.1097 +		CleanupStack::PushL(parser);
  1.1098 +		
  1.1099 +		TRAPD(err, GetVideoAudioAttributesL(parser));
  1.1100 +		if (err != KErrNone)
  1.1101 +			{
  1.1102 +			SetTestStepResult(EFail);
  1.1103 +			}
  1.1104 +		
  1.1105 +		CleanupStack::PopAndDestroy(parser);
  1.1106 +		}
  1.1107 +	return TestStepResult();
  1.1108 +	}
  1.1109 +
  1.1110 +void C3GPLibParser_0005::GetVideoAudioAttributesL(C3GPParse* aParser)
  1.1111 +	{
  1.1112 +	// Open parser in File path
  1.1113 +	ParserOpenFileL(aParser);
  1.1114 +	DoGetVideoAudioAttributesL(aParser);
  1.1115 +	ParserCompleteL(aParser);
  1.1116 +	
  1.1117 +	// open parser in file handle
  1.1118 +	ParserOpenFileHandleL(aParser);
  1.1119 +	DoGetVideoAudioAttributesL(aParser);
  1.1120 +	ParserCompleteHandleL(aParser);
  1.1121 +	
  1.1122 +	// Open parser in CAF
  1.1123 +	ParserOpenCafLC(aParser);
  1.1124 +	DoGetVideoAudioAttributesL(aParser);
  1.1125 +	ParserCompleteCafL(aParser);
  1.1126 +	}
  1.1127 +
  1.1128 +// -----------------------------------------------------------------------------
  1.1129 +// Retrieve video & audio stream attributes from a mp4/3gp/3g2 file 
  1.1130 +// with supported video and audio streams using buffer mode.
  1.1131 +// -----------------------------------------------------------------------------
  1.1132 +//
  1.1133 +C3GPLibParser_0006::C3GPLibParser_0006()
  1.1134 +	{	
  1.1135 +	}
  1.1136 +
  1.1137 +TVerdict C3GPLibParser_0006::doTestStepL()
  1.1138 +	{
  1.1139 +	if(TestStepResult() == EPass)
  1.1140 +		{
  1.1141 +		C3GPParse* parser = C3GPParse::NewL();
  1.1142 +		CleanupStack::PushL(parser);
  1.1143 +		
  1.1144 +		TRAPD(err, VideoAudioAttributesBufferModeL(parser));
  1.1145 +		if (err != KErrNone)
  1.1146 +			{
  1.1147 +			SetTestStepResult(EFail);
  1.1148 +			FileClose();
  1.1149 +			}
  1.1150 +		
  1.1151 +		CleanupStack::PopAndDestroy(parser);
  1.1152 +		}
  1.1153 +	return TestStepResult();
  1.1154 +	}
  1.1155 +
  1.1156 +void C3GPLibParser_0006::VideoAudioAttributesBufferModeL(C3GPParse* aParser)
  1.1157 +	{
  1.1158 +	// buffer mode
  1.1159 +	FileOpenL();
  1.1160 +	ParserOpenL(aParser);
  1.1161 +
  1.1162 +	TInt err = KErrNone;
  1.1163 +	// Retrieve number of buffered bytes before and after data is supplied to the parser.
  1.1164 +	err = GetVideoAudioAttributes(aParser, ENumBufferedBytes);
  1.1165 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, ENumBufferedBytes)")));
  1.1166 +	
  1.1167 +	ParserCompleteL(aParser);
  1.1168 +	FileClose();
  1.1169 +	
  1.1170 +	// Open the parser again
  1.1171 +	FileOpenL();
  1.1172 +	ParserOpenL(aParser);
  1.1173 +	
  1.1174 +	// Retrieve video and audio descriptions before and after data is supplied to the parser.
  1.1175 +	err = GetVideoAudioAttributes(aParser, EClipProperties);
  1.1176 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EClipProperties)")));
  1.1177 +	
  1.1178 +	ParserCompleteL(aParser);
  1.1179 +	FileClose();
  1.1180 +	
  1.1181 +	// Open the parser again
  1.1182 +	FileOpenL();
  1.1183 +	ParserOpenL(aParser);
  1.1184 +	
  1.1185 +	// Retrieve video and audio decoder before and after data is supplied to the parser.
  1.1186 +	err = GetVideoAudioAttributes(aParser, EDecoderInfo);
  1.1187 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EDecoderInfo)")));
  1.1188 +	
  1.1189 +	ParserCompleteL(aParser);
  1.1190 +	FileClose();
  1.1191 +	
  1.1192 +	// Open the parser again
  1.1193 +	FileOpenL();
  1.1194 +	ParserOpenL(aParser);
  1.1195 +	
  1.1196 +	
  1.1197 +	// Retrieve video frame properties and number of frames before and after data is supplied to the parser.
  1.1198 +
  1.1199 +	err = GetVideoAudioAttributes(aParser, EVideoFrameProp);
  1.1200 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoAudioAttributes(aParser, EVideoFrameProp)")));
  1.1201 +	
  1.1202 +	ParserCompleteL(aParser);
  1.1203 +	FileClose();
  1.1204 +	}
  1.1205 +
  1.1206 +TInt C3GPLibParser_0006::CallTest(C3GPParse* aParser, TBufferModeTest aTest, TInt aExpectedNumBuffered)
  1.1207 +	{
  1.1208 +	TInt err = KErrNone;
  1.1209 +	TInt numBufferedBytes;
  1.1210 +
  1.1211 +	// Before insert any data. Retrieving video and audio attributes should fail
  1.1212 +	switch (aTest)
  1.1213 +		{
  1.1214 +		case (ENumBufferedBytes):
  1.1215 +			err = aParser->GetNumBufferedBytes(numBufferedBytes);
  1.1216 +			if (err == KErrNone && numBufferedBytes != aExpectedNumBuffered)
  1.1217 +				{
  1.1218 +				err = KErrGeneral;
  1.1219 +				}
  1.1220 +		break;
  1.1221 +		case (EClipProperties):
  1.1222 +			TInt videoError;
  1.1223 +			TUint videoLength;
  1.1224 +			TUint audioLength;
  1.1225 +			err = GetClipProperties(aParser, videoError, videoLength, audioLength);
  1.1226 +			if ((videoError != KErrNone && videoError != KErr3gpLibMoreDataRequired) || 
  1.1227 +					(err != KErrNone && err != KErr3gpLibMoreDataRequired))
  1.1228 +				{
  1.1229 +				err = KErrGeneral;
  1.1230 +				}
  1.1231 +		break;
  1.1232 +		case (EDecoderInfo):
  1.1233 +			err = ParserGetDecoderInfo(aParser);
  1.1234 +		break;
  1.1235 +		case (EVideoFrameProp):
  1.1236 +			if (aExpectedNumBuffered == 0)
  1.1237 +				{
  1.1238 +				err = GetVideoFramePropAndNumVideoFrame(aParser, EFalse);
  1.1239 +				}
  1.1240 +			else
  1.1241 +				{
  1.1242 +				err = GetVideoFramePropAndNumVideoFrame(aParser, ETrue);
  1.1243 +				}
  1.1244 +		break;
  1.1245 +		default:
  1.1246 +		break;
  1.1247 +		}
  1.1248 +	return err;
  1.1249 +	}
  1.1250 +
  1.1251 +TInt C3GPLibParser_0006::GetVideoAudioAttributes(C3GPParse* aParser, TBufferModeTest aTest)
  1.1252 +	{
  1.1253 +	TInt err = KErrNone;
  1.1254 +	
  1.1255 +	// Before insert any data. Retrieving video and audio attributes should fail
  1.1256 +	err = CallTest(aParser, aTest, 0);
  1.1257 +	if (aTest != ENumBufferedBytes)
  1.1258 +		{
  1.1259 +		err = CheckError(err, KErr3gpLibMoreDataRequired, _L("CallTest(aParser, aTest, 0)"));
  1.1260 +		}
  1.1261 +	else
  1.1262 +		{
  1.1263 +		err = CheckError(err, KErrNone, _L("CallTest()"));
  1.1264 +		}
  1.1265 +	
  1.1266 +	if (err != KErrNone)
  1.1267 +		{
  1.1268 +		ERR_PRINTF2(_L("GetVideoAudioAttributes failed with %d; "), err);
  1.1269 +		return KErrGeneral;
  1.1270 +		}
  1.1271 +	
  1.1272 +	// Insert 1K data to buffer	
  1.1273 +	TInt bufferSize = 0;
  1.1274 +	TInt pos = 0; // from begining of the file
  1.1275 +	err = KErr3gpLibMoreDataRequired;
  1.1276 +	// Insert data until enough data has been inserted
  1.1277 +	while (err == KErr3gpLibMoreDataRequired)
  1.1278 +		{
  1.1279 +		// Insert more data to buffer	
  1.1280 +		pos = bufferSize + pos;
  1.1281 +		bufferSize = KBufferSize;
  1.1282 +		RBuf8 buffer;
  1.1283 +		err = buffer.Create(bufferSize);
  1.1284 +		if (err == KErrNone)
  1.1285 +			{
  1.1286 +			err = iSourceFile.Read(pos, buffer); 
  1.1287 +			if (err == KErrNone)
  1.1288 +				{
  1.1289 +				err = aParser->InsertData(buffer);
  1.1290 +				if ( err == KErrNone )
  1.1291 +					{
  1.1292 +					err = CallTest(aParser, aTest, (bufferSize + pos));
  1.1293 +					}
  1.1294 +				}
  1.1295 +			}
  1.1296 +		buffer.Close();
  1.1297 +		}
  1.1298 +	
  1.1299 +	err = CheckError(err, KErrNone, _L("CallTest()"));
  1.1300 +	return err;
  1.1301 +	}
  1.1302 +
  1.1303 +TInt C3GPLibParser_0006::GetVideoFramePropAndNumVideoFrame(C3GPParse* aParse, TBool aExpectPass)
  1.1304 +	{
  1.1305 +	TInt err = KErrNone;
  1.1306 +	TUint numVideoFrames;
  1.1307 +	err = aParse->GetNumberOfVideoFrames(numVideoFrames);
  1.1308 +	if (aExpectPass)
  1.1309 +		{
  1.1310 +		if ( err == KErrNone )
  1.1311 +			{
  1.1312 +			// Only when GetNumberOfVideoFrames returns KErrNone, the method GetVideoFrameProperties
  1.1313 +			// can be called
  1.1314 +			TUint startIndex = 0;
  1.1315 +			RArray<T3GPFrameInfoParameters> array;
  1.1316 +			err = aParse->GetVideoFrameProperties(startIndex, numVideoFrames, array);
  1.1317 +			array.Close();
  1.1318 +			}		
  1.1319 +		}
  1.1320 +	else
  1.1321 +		{
  1.1322 +		// When there is no data in the handler, GetNumberOfVideoFrames will fail with KErrGeneral, 
  1.1323 +		// not the KErr3gpLibMoreDataRequired
  1.1324 +		if ( err == KErr3gpLibMoreDataRequired || err == KErrGeneral)
  1.1325 +			{
  1.1326 +			if (!ShouldRunOOMTest())
  1.1327 +				{
  1.1328 +				INFO_PRINTF2(_L("Expect parse->GetNumberOfVideoFrames() failed with %d"), err);
  1.1329 +				}
  1.1330 +			err = KErr3gpLibMoreDataRequired;
  1.1331 +			}
  1.1332 +		// expected failure, but get KErrNone.
  1.1333 +		if (err == KErrNone)
  1.1334 +			{
  1.1335 +			INFO_PRINTF1(_L("parse->GetNumberOfVideoFrames() should fail due to buffer too small"));
  1.1336 +			err = KErrGeneral;
  1.1337 +			}
  1.1338 +		}
  1.1339 +	
  1.1340 +	return err;
  1.1341 +	}
  1.1342 +
  1.1343 +// -----------------------------------------------------------------------------
  1.1344 +// Check if the clip is streamable in file mode from a mp4/3gp/3g2 file 
  1.1345 +// -----------------------------------------------------------------------------
  1.1346 +//
  1.1347 +C3GPLibParser_0007::C3GPLibParser_0007()
  1.1348 +	{	
  1.1349 +	}
  1.1350 +
  1.1351 +TVerdict C3GPLibParser_0007::doTestStepL()
  1.1352 +	{
  1.1353 +	if(TestStepResult() == EPass)
  1.1354 +		{
  1.1355 +		C3GPParse* parser = C3GPParse::NewL();
  1.1356 +		CleanupStack::PushL(parser);
  1.1357 +		
  1.1358 +		TRAPD(err, GetstreamableL(parser));
  1.1359 +		if (err != KErrNone)
  1.1360 +			{
  1.1361 +			SetTestStepResult(EFail);
  1.1362 +			}
  1.1363 +		
  1.1364 +		CleanupStack::PopAndDestroy(parser);
  1.1365 +		}
  1.1366 +	return TestStepResult();
  1.1367 +	}
  1.1368 +
  1.1369 +void C3GPLibParser_0007::GetstreamableL(C3GPParse* aParser)
  1.1370 +	{
  1.1371 +	// Open parser in File mode
  1.1372 +	ParserOpenFileL(aParser);
  1.1373 +	
  1.1374 +	// Check if the file is streamable
  1.1375 +	TBool streamable;
  1.1376 +	TInt err = aParser->GetStreamable(streamable);
  1.1377 +	if (err != KErrNone)
  1.1378 +		{
  1.1379 +		SetTestStepError(err);
  1.1380 +		}
  1.1381 +	else if (!streamable)
  1.1382 +		{
  1.1383 +		INFO_PRINTF2(_L("aParser->GetStreamable() returns %d"), streamable);
  1.1384 +		SetTestStepError(KErrNotSupported);
  1.1385 +		}
  1.1386 +	
  1.1387 +	ParserCompleteL(aParser);
  1.1388 +	}
  1.1389 +
  1.1390 +// -----------------------------------------------------------------------------
  1.1391 +// Check if the clip is streamable in buffer mode from a mp4/3gp/3g2 file 
  1.1392 +// -----------------------------------------------------------------------------
  1.1393 +//
  1.1394 +C3GPLibParser_0008::C3GPLibParser_0008()
  1.1395 +	{	
  1.1396 +	}
  1.1397 +
  1.1398 +TVerdict C3GPLibParser_0008::doTestStepL()
  1.1399 +	{
  1.1400 +	if(TestStepResult() == EPass)
  1.1401 +		{
  1.1402 +		C3GPParse* parser = C3GPParse::NewL();
  1.1403 +		CleanupStack::PushL(parser);
  1.1404 +		
  1.1405 +		TRAPD(err, GetstreamableL(parser));
  1.1406 +		if (err != KErrNone)
  1.1407 +			{
  1.1408 +			SetTestStepResult(EFail);
  1.1409 +			}
  1.1410 +		
  1.1411 +		CleanupStack::PopAndDestroy(parser);
  1.1412 +		}
  1.1413 +	return TestStepResult();
  1.1414 +	}
  1.1415 +
  1.1416 +void C3GPLibParser_0008::GetstreamableL(C3GPParse* aParser)
  1.1417 +	{
  1.1418 +	// buffer mode
  1.1419 +	FileOpenL();
  1.1420 +	ParserOpenL(aParser);
  1.1421 +
  1.1422 +	// Check if the file is streamable before the data is inserted
  1.1423 +	TBool streamable;
  1.1424 +	TInt err = aParser->GetStreamable(streamable);
  1.1425 +	
  1.1426 +	// Insert 1K data to buffer	
  1.1427 +	TInt bufferSize = 0;
  1.1428 +	TInt pos = 0; // from begining of the file
  1.1429 +
  1.1430 +	// Insert data until enough data has been inserted
  1.1431 +	while (err == KErr3gpLibMoreDataRequired)
  1.1432 +		{
  1.1433 +		// Insert more data to buffer	
  1.1434 +		pos = bufferSize + pos;
  1.1435 +		bufferSize = KBufferSize;
  1.1436 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1437 +		
  1.1438 +		err = aParser->GetStreamable(streamable);
  1.1439 +		}
  1.1440 +	
  1.1441 +	if (err != KErrNone)
  1.1442 +		{
  1.1443 +		if (!ShouldRunOOMTest())
  1.1444 +			{
  1.1445 +			ERR_PRINTF2(_L("aParser->GetStreamable() returns %d"), err);
  1.1446 +			}
  1.1447 +		SetTestStepError(err);
  1.1448 +		}
  1.1449 +	
  1.1450 +	ParserCompleteL(aParser);
  1.1451 +	FileClose();
  1.1452 +	}
  1.1453 +
  1.1454 +// -----------------------------------------------------------------------------
  1.1455 +// Retrieve buffered bytes, and video & audio frames synchronously in file mode
  1.1456 +// -----------------------------------------------------------------------------
  1.1457 +//
  1.1458 +C3GPLibParser_0011::C3GPLibParser_0011()
  1.1459 +	{	
  1.1460 +	}
  1.1461 +
  1.1462 +TVerdict C3GPLibParser_0011::doTestStepL()
  1.1463 +	{
  1.1464 +	if(TestStepResult() == EPass)
  1.1465 +		{
  1.1466 +		C3GPParse* parser = C3GPParse::NewL();
  1.1467 +		CleanupStack::PushL(parser);
  1.1468 +		
  1.1469 +		TRAPD(err, ReadFrameL(parser));
  1.1470 +		if (err != KErrNone)
  1.1471 +			{
  1.1472 +			SetTestStepResult(EFail);
  1.1473 +			}
  1.1474 +		
  1.1475 +		CleanupStack::PopAndDestroy(parser);
  1.1476 +		}
  1.1477 +	return TestStepResult();
  1.1478 +	}
  1.1479 +
  1.1480 +void C3GPLibParser_0011::ReadFrameL(C3GPParse* aParse)
  1.1481 +	{
  1.1482 +	// Parser open using File path 
  1.1483 +	ParserOpenFileL(aParse);
  1.1484 +	User::LeaveIfError(DoReadFrame(aParse));
  1.1485 +	ParserCompleteL(aParse);
  1.1486 +	
  1.1487 +	// Parser open using file handler
  1.1488 +	ParserOpenFileHandleL(aParse);
  1.1489 +	User::LeaveIfError(DoReadFrame(aParse));
  1.1490 +	ParserCompleteHandleL(aParse);
  1.1491 +    
  1.1492 +	// Parser open using CAF
  1.1493 +	ParserOpenCafLC(aParse);
  1.1494 +	User::LeaveIfError(DoReadFrame(aParse));
  1.1495 +	ParserCompleteCafL(aParse);
  1.1496 +	}
  1.1497 +
  1.1498 +// -----------------------------------------------------------------------------
  1.1499 +// Parse video & audio frames from a mp4/3gp file asynchronously in file mode
  1.1500 +// -----------------------------------------------------------------------------
  1.1501 +//
  1.1502 +C3GPLibParser_0014::C3GPLibParser_0014()
  1.1503 +	{	
  1.1504 +	}
  1.1505 +
  1.1506 +TVerdict C3GPLibParser_0014::doTestStepPreambleL()
  1.1507 +	{
  1.1508 +	C3GPLib_AsyncObserver::doTestStepPreambleL();	
  1.1509 +	if (TestStepResult() == EPass)
  1.1510 +		{
  1.1511 +		iScheduler = new (ELeave) CActiveScheduler;
  1.1512 +		CActiveScheduler::Install(iScheduler);
  1.1513 +		}
  1.1514 +	return TestStepResult();
  1.1515 +	}
  1.1516 +
  1.1517 +TVerdict C3GPLibParser_0014::doTestStepPostambleL()
  1.1518 +	{
  1.1519 +	C3GPLib_AsyncObserver::doTestStepPostambleL();
  1.1520 +	if( iScheduler )
  1.1521 +		{
  1.1522 +		INFO_PRINTF1(_L("delete iScheduler"));
  1.1523 +		CActiveScheduler::Install(NULL);
  1.1524 +		delete iScheduler;
  1.1525 +		iScheduler = NULL;
  1.1526 +		}
  1.1527 +
  1.1528 +	return TestStepResult();
  1.1529 +	}
  1.1530 +
  1.1531 +TVerdict C3GPLibParser_0014::doTestStepL()
  1.1532 +	{
  1.1533 +	if(TestStepResult() == EPass)
  1.1534 +		{
  1.1535 +		C3GPParse* parser = C3GPParse::NewL();
  1.1536 +		CleanupStack::PushL(parser);
  1.1537 +		
  1.1538 +		TRAPD(err, ReadFrameAsyncL(parser));
  1.1539 +		if (err != KErrNone)
  1.1540 +			{
  1.1541 +			SetTestStepResult(EFail);
  1.1542 +			}
  1.1543 +		
  1.1544 +		CleanupStack::PopAndDestroy(parser);
  1.1545 +		}
  1.1546 +	return TestStepResult();
  1.1547 +	}
  1.1548 +
  1.1549 +void C3GPLibParser_0014::ReadFrameAsyncL(C3GPParse* aParser)
  1.1550 +	{
  1.1551 +	ParserOpenFileL(aParser);
  1.1552 +	User::LeaveIfError(DoReadFrameAsync(aParser));
  1.1553 +	if (!ShouldRunOOMTest())
  1.1554 +		{
  1.1555 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL()"));
  1.1556 +		}
  1.1557 +	ParserCompleteL(aParser);
  1.1558 +
  1.1559 +	ParserOpenFileL(aParser);
  1.1560 +	User::LeaveIfError(DoReadFrameAsync(aParser, ETrue));
  1.1561 +	if (!ShouldRunOOMTest())
  1.1562 +		{
  1.1563 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL(), then cancel the read"));
  1.1564 +		}
  1.1565 +	ParserCompleteL(aParser);
  1.1566 +	
  1.1567 +	ParserOpenFileHandleL(aParser);
  1.1568 +	User::LeaveIfError(DoReadFrameAsync(aParser));
  1.1569 +	if (!ShouldRunOOMTest())
  1.1570 +		{
  1.1571 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using file handler"));
  1.1572 +		}
  1.1573 +	ParserCompleteHandleL(aParser);
  1.1574 +
  1.1575 +	ParserOpenCafLC(aParser);
  1.1576 +	User::LeaveIfError(DoReadFrameAsync(aParser));
  1.1577 +	if (!ShouldRunOOMTest())
  1.1578 +		{
  1.1579 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using CAF"));
  1.1580 +		}
  1.1581 +	ParserCompleteCafL(aParser);
  1.1582 +	}
  1.1583 +
  1.1584 +TInt C3GPLibParser_0014::DoReadFrameAsync(C3GPParse* aParser, TBool aCancel)
  1.1585 +	{    
  1.1586 +    TInt err = KErrNone;
  1.1587 +    
  1.1588 +    if (!aCancel)
  1.1589 +    	{
  1.1590 +    	err = ReadAudioVideoFrameAsync(aParser, ETrue);
  1.1591 +    	if (err == KErrNone)
  1.1592 +    		{
  1.1593 +    		err = ReadAudioVideoFrameAsync(aParser, EFalse);
  1.1594 +    		} 
  1.1595 +    	}
  1.1596 +    else
  1.1597 +    	{
  1.1598 +    	err = ReadAudioVideoFrameAsync(aParser, EFalse, ETrue);
  1.1599 +    	}
  1.1600 + 
  1.1601 +    return err;
  1.1602 +    }
  1.1603 +
  1.1604 +// -----------------------------------------------------------------------------
  1.1605 +// Parse video & audio frames from a mp4/3gp file synchronously
  1.1606 +// -----------------------------------------------------------------------------
  1.1607 +//
  1.1608 +C3GPLibParser_0015::C3GPLibParser_0015()
  1.1609 +	{	
  1.1610 +	}
  1.1611 +
  1.1612 +TVerdict C3GPLibParser_0015::doTestStepL()
  1.1613 +	{
  1.1614 +	if(TestStepResult() == EPass)
  1.1615 +		{
  1.1616 +		C3GPParse* parser = C3GPParse::NewL();
  1.1617 +		CleanupStack::PushL(parser);
  1.1618 +		
  1.1619 +		TRAPD(err, ReadFrameL(parser));
  1.1620 +		if (err != KErrNone)
  1.1621 +			{
  1.1622 +			SetTestStepResult(EFail);
  1.1623 +			}
  1.1624 +		
  1.1625 +		CleanupStack::PopAndDestroy(parser);
  1.1626 +		}
  1.1627 +	return TestStepResult();
  1.1628 +	}
  1.1629 +
  1.1630 +void C3GPLibParser_0015::ReadFrameL(C3GPParse* aParser)
  1.1631 +	{
  1.1632 +	FileOpenL();
  1.1633 +	ReadFrameBufferModeL(aParser);
  1.1634 +	FileClose();
  1.1635 +	}
  1.1636 +
  1.1637 +// -----------------------------------------------------------------------------
  1.1638 +// Get frame type using file path
  1.1639 +// -----------------------------------------------------------------------------
  1.1640 +//
  1.1641 +C3GPLibParser_0016::C3GPLibParser_0016()
  1.1642 +	{	
  1.1643 +	}
  1.1644 +
  1.1645 +
  1.1646 +TVerdict C3GPLibParser_0016::doTestStepL()
  1.1647 +	{
  1.1648 +	if(TestStepResult() == EPass)
  1.1649 +		{
  1.1650 +		C3GPParse* parser = C3GPParse::NewL();
  1.1651 +		CleanupStack::PushL(parser);
  1.1652 +		
  1.1653 +		TRAPD(err, GetFrameTypeL(parser));
  1.1654 +		if (err != KErrNone)
  1.1655 +			{
  1.1656 +			SetTestStepResult(EFail);
  1.1657 +			}
  1.1658 +		
  1.1659 +		CleanupStack::PopAndDestroy(parser);
  1.1660 +		}
  1.1661 +	return TestStepResult();
  1.1662 +	}
  1.1663 +
  1.1664 +void C3GPLibParser_0016::GetFrameTypeL(C3GPParse* aParser)
  1.1665 +	{
  1.1666 +	ParserOpenFileL(aParser);
  1.1667 +	
  1.1668 +	T3GPFrameType type;
  1.1669 +	TInt err = aParser->GetFrameType(type);
  1.1670 +	if (err == KErrNone)
  1.1671 +		{
  1.1672 +		TUint num;
  1.1673 +		err = aParser->GetNumberOfVideoFrames(num);
  1.1674 +		if (err == KErrNone)
  1.1675 +			{
  1.1676 +			// There is number of video in the file. Calling GetFrameType num+1 time won't affect 
  1.1677 +			//the parser’s current position. It should return the same results
  1.1678 +			for (TInt i = 0; i < num; i++)
  1.1679 +				{
  1.1680 +				err = aParser->GetFrameType(type);
  1.1681 +				User::LeaveIfError(err);
  1.1682 +				}
  1.1683 +			err = aParser->GetFrameType(type);
  1.1684 +			User::LeaveIfError(err);
  1.1685 +			}
  1.1686 +
  1.1687 +		if (!ShouldRunOOMTest())
  1.1688 +			{
  1.1689 +			INFO_PRINTF2(_L("GetFrameType return type %d. "), type);
  1.1690 +			}
  1.1691 +		if (type == E3GPAudio)
  1.1692 +			{
  1.1693 +			// read 1 audio frame		
  1.1694 +			err = ReadAudioVideoFrame(aParser, EFalse, ETrue);
  1.1695 +			User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame")));
  1.1696 +
  1.1697 +			err = aParser->GetFrameType(type);
  1.1698 +			if (!ShouldRunOOMTest())
  1.1699 +				{
  1.1700 +				INFO_PRINTF3(_L("After read 1 audio frame, GetFrameType return err %d; type %d. "), err, type);
  1.1701 +				}
  1.1702 +			SetTestStepError(err);
  1.1703 +			}
  1.1704 +		if (err == KErrNone && type == E3GPVideo)
  1.1705 +			{
  1.1706 +			// read 1 video frame
  1.1707 +			err = ReadAudioVideoFrame(aParser, EFalse, EFalse);
  1.1708 +			User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame")));
  1.1709 +			
  1.1710 +			err = aParser->GetFrameType(type);
  1.1711 +			SetTestStepError(err);
  1.1712 +			}
  1.1713 +		}
  1.1714 +	else
  1.1715 +		{
  1.1716 +		SetTestStepError(err);
  1.1717 +		}
  1.1718 +	ParserCompleteL(aParser);
  1.1719 +	}
  1.1720 +
  1.1721 +// -----------------------------------------------------------------------------
  1.1722 +// Get the QCELP storage mode in file path and buffer mode
  1.1723 +// -----------------------------------------------------------------------------
  1.1724 +//
  1.1725 +C3GPLibParser_0017::C3GPLibParser_0017()
  1.1726 +	{	
  1.1727 +	}
  1.1728 +
  1.1729 +TVerdict C3GPLibParser_0017::doTestStepL()
  1.1730 +	{
  1.1731 +	if(TestStepResult() == EPass)
  1.1732 +		{
  1.1733 +		C3GPParse* parser = C3GPParse::NewL();
  1.1734 +		CleanupStack::PushL(parser);
  1.1735 +		
  1.1736 +		TRAPD(err, GetQcelModeL(parser));
  1.1737 +		if (err != KErrNone)
  1.1738 +			{
  1.1739 +			SetTestStepResult(EFail);
  1.1740 +			}
  1.1741 +		
  1.1742 +		CleanupStack::PopAndDestroy(parser);
  1.1743 +		}
  1.1744 +	return TestStepResult();
  1.1745 +	}
  1.1746 +
  1.1747 +void C3GPLibParser_0017::GetQcelModeL(C3GPParse* aParser)
  1.1748 +	{
  1.1749 +	// file mode
  1.1750 +	ParserOpenFileL(aParser);
  1.1751 +	TInt err = KErrNone;
  1.1752 +	T3GPQcelpStorageMode mode;
  1.1753 +	err = aParser->GetQcelpStorageMode(mode);
  1.1754 +	if (err != KErrNone)
  1.1755 +		{
  1.1756 +		if (!ShouldRunOOMTest())
  1.1757 +			{
  1.1758 +			ERR_PRINTF3(_L("aParser->GetQcelpStorageMode(mode) file mode return %d; mode %d. "), err, mode);
  1.1759 +			}
  1.1760 +		SetTestStepError(err);
  1.1761 +		}
  1.1762 +
  1.1763 +	if ((iTestSection.Compare(KEsds) == 0 && mode != E3GPQcelpSampleEntryBox ) ||
  1.1764 +			(iTestSection.Compare(KSqcp) == 0 && mode != E3GPMP4AudioDescriptionBox ))
  1.1765 +		{
  1.1766 +		User::Leave(KErrGeneral);
  1.1767 +		}
  1.1768 +	
  1.1769 +	ParserCompleteL(aParser);
  1.1770 +	
  1.1771 +	// buffer mode
  1.1772 +	ParserOpenL(aParser);
  1.1773 +	FileOpenL();
  1.1774 +	
  1.1775 +	// Insert 1K data into the library
  1.1776 +	TInt pos = 0;
  1.1777 +	TInt bufferSize = 1000;
  1.1778 +	
  1.1779 +	InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1780 +	err = aParser->GetQcelpStorageMode(mode);
  1.1781 +	
  1.1782 +	while (err == KErr3gpLibMoreDataRequired )
  1.1783 +		{
  1.1784 +		pos = pos + bufferSize;
  1.1785 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1786 +		err = aParser->GetQcelpStorageMode(mode);
  1.1787 +		}
  1.1788 +	
  1.1789 +	if (err != KErrNone)
  1.1790 +		{
  1.1791 +		if (!ShouldRunOOMTest())
  1.1792 +			{
  1.1793 +			ERR_PRINTF3(_L("aParser->GetQcelpStorageMode(mode) file mode return %d; mode %d. "), err, mode);
  1.1794 +			}
  1.1795 +		SetTestStepError(err);
  1.1796 +		}
  1.1797 +	
  1.1798 +	if ((iTestSection.Compare(KEsds) == 0 && mode != E3GPQcelpSampleEntryBox ) ||
  1.1799 +			(iTestSection.Compare(KSqcp) == 0 && mode != E3GPMP4AudioDescriptionBox ))
  1.1800 +		{
  1.1801 +		User::Leave(KErrGeneral);
  1.1802 +		}
  1.1803 +	
  1.1804 +	ParserCompleteL(aParser);
  1.1805 +	FileClose();
  1.1806 +	}
  1.1807 +
  1.1808 +// -----------------------------------------------------------------------------
  1.1809 +// Get H263 video leve in file path and buffer mode.
  1.1810 +// -----------------------------------------------------------------------------
  1.1811 +//
  1.1812 +C3GPLibParser_0021::C3GPLibParser_0021()
  1.1813 +	{	
  1.1814 +	}
  1.1815 +
  1.1816 +TVerdict C3GPLibParser_0021::doTestStepL()
  1.1817 +	{
  1.1818 +	if(TestStepResult() == EPass)
  1.1819 +		{
  1.1820 +		C3GPParse* parser = C3GPParse::NewL();
  1.1821 +		CleanupStack::PushL(parser);
  1.1822 +		
  1.1823 +		TRAPD(err, GetH263LevelL(parser));
  1.1824 +		if (err != KErrNone)
  1.1825 +			{
  1.1826 +			SetTestStepResult(EFail);
  1.1827 +			}
  1.1828 +		
  1.1829 +		CleanupStack::PopAndDestroy(parser);
  1.1830 +		}
  1.1831 +	return TestStepResult();
  1.1832 +	}
  1.1833 +
  1.1834 +void C3GPLibParser_0021::GetH263LevelL(C3GPParse* aParser)
  1.1835 +	{
  1.1836 +	// file mode
  1.1837 +	ParserOpenFileL(aParser);
  1.1838 +	TInt err = KErrNone;
  1.1839 +	TInt level;
  1.1840 +	err = aParser->GetH263VideoLevel(level);
  1.1841 +	if (err != KErrNone)
  1.1842 +		{
  1.1843 +		if (!ShouldRunOOMTest())
  1.1844 +			{
  1.1845 +			ERR_PRINTF3(_L("aParser->GetH263VideoLevel() file mode return %d; level %d. "), err, level);
  1.1846 +			}
  1.1847 +		SetTestStepError(err);
  1.1848 +		}
  1.1849 +	
  1.1850 +	ParserCompleteL(aParser);
  1.1851 +	
  1.1852 +	// buffer mode
  1.1853 +	ParserOpenL(aParser);
  1.1854 +	FileOpenL();
  1.1855 +	
  1.1856 +	// Insert 1K data into the library
  1.1857 +	TInt pos = 0;
  1.1858 +	TInt bufferSize = KBufferSize;
  1.1859 +	
  1.1860 +	InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1861 +	err = aParser->GetH263VideoLevel(level);;
  1.1862 +	
  1.1863 +	while (err == KErr3gpLibMoreDataRequired )
  1.1864 +		{
  1.1865 +		pos = pos + bufferSize;
  1.1866 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1867 +		err = aParser->GetH263VideoLevel(level);;
  1.1868 +		}
  1.1869 +	
  1.1870 +	if (err != KErrNone)
  1.1871 +		{
  1.1872 +		if (!ShouldRunOOMTest())
  1.1873 +			{
  1.1874 +			ERR_PRINTF3(_L("aParser->GetH263VideoLevel() file mode return %d; level %d. "), err, level);
  1.1875 +			}
  1.1876 +		SetTestStepError(err);
  1.1877 +		}
  1.1878 +	
  1.1879 +	ParserCompleteL(aParser);
  1.1880 +	FileClose();
  1.1881 +	}
  1.1882 +
  1.1883 +// -----------------------------------------------------------------------------
  1.1884 +// Read Video and audio Decoder Info size and info in file path and buffer mode.
  1.1885 +// -----------------------------------------------------------------------------
  1.1886 +//
  1.1887 +C3GPLibParser_0023::C3GPLibParser_0023()
  1.1888 +	{	
  1.1889 +	}
  1.1890 +
  1.1891 +TVerdict C3GPLibParser_0023::doTestStepL()
  1.1892 +	{
  1.1893 +	if(TestStepResult() == EPass)
  1.1894 +		{
  1.1895 +		C3GPParse* parser = C3GPParse::NewL();
  1.1896 +		CleanupStack::PushL(parser);
  1.1897 +		
  1.1898 +		TRAPD(err, GetDecoderInfoL(parser));
  1.1899 +		if (err != KErrNone)
  1.1900 +			{
  1.1901 +			SetTestStepResult(EFail);
  1.1902 +			}
  1.1903 +		
  1.1904 +		CleanupStack::PopAndDestroy(parser);
  1.1905 +		}
  1.1906 +	return TestStepResult();
  1.1907 +	}
  1.1908 +
  1.1909 +void C3GPLibParser_0023::GetDecoderInfoL(C3GPParse* aParser)
  1.1910 +	{
  1.1911 +	// file mode
  1.1912 +	ParserOpenFileL(aParser);
  1.1913 +
  1.1914 +	TInt errReadAudio = KErrNone;
  1.1915 +	TInt errReadVideo = KErrNone;
  1.1916 +	// Retrieve the info with buffer size = 0. Should fail with KErrOverflow
  1.1917 +	RBuf8 dsiBuffer;
  1.1918 +	CleanupClosePushL(dsiBuffer);
  1.1919 +	dsiBuffer.CreateL(0);
  1.1920 +	errReadAudio = aParser->GetAudioDecoderSpecificInfo(dsiBuffer);
  1.1921 +	errReadVideo = aParser->GetVideoDecoderSpecificInfo(dsiBuffer);
  1.1922 +	
  1.1923 +	if (errReadAudio == KErrOverflow && errReadVideo == KErrOverflow)
  1.1924 +		{
  1.1925 +		errReadAudio = ParserGetDecoderInfo(aParser);
  1.1926 +		
  1.1927 +		if (errReadAudio != KErrNone)
  1.1928 +			{
  1.1929 +			ERR_PRINTF2(_L("ParserGetDecoderInfo file mode return %d; "), errReadAudio);
  1.1930 +			User::Leave(errReadAudio);
  1.1931 +			}
  1.1932 +		}
  1.1933 +	else
  1.1934 +		{
  1.1935 +		ERR_PRINTF2(_L("ParserGetDecoderInfo file mode expected KErrOverflow, but return %d; "), errReadAudio);
  1.1936 +		User::Leave(errReadAudio);
  1.1937 +		}
  1.1938 +	
  1.1939 +	ParserCompleteL(aParser);
  1.1940 +	
  1.1941 +	// buffer mode
  1.1942 +	ParserOpenL(aParser);
  1.1943 +	FileOpenL();
  1.1944 +	
  1.1945 +	// Insert 1K data into the library
  1.1946 +	TInt pos = 0;
  1.1947 +	TInt bufferSize = KBufferSize;
  1.1948 +	
  1.1949 +	InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1950 +	
  1.1951 +	// Retrieve the info with buffer size = 0. Should fail with KErrOverflow
  1.1952 +	dsiBuffer.Close();
  1.1953 +	dsiBuffer.CreateL(0);
  1.1954 +	errReadAudio = aParser->GetAudioDecoderSpecificInfo(dsiBuffer);
  1.1955 +	errReadVideo = aParser->GetVideoDecoderSpecificInfo(dsiBuffer);
  1.1956 +	CleanupStack::PopAndDestroy(&dsiBuffer);
  1.1957 +	
  1.1958 +	if (errReadAudio != KErrOverflow || errReadVideo != KErrOverflow)
  1.1959 +		{
  1.1960 +		ERR_PRINTF2(_L("ParserGetDecoderInfo buffer mode expected KErrOverflow, but return %d; "), errReadAudio);
  1.1961 +		User::Leave(errReadAudio);
  1.1962 +		}
  1.1963 +	errReadAudio = ParserGetDecoderInfo(aParser);
  1.1964 +	
  1.1965 +	while (errReadAudio == KErr3gpLibMoreDataRequired )
  1.1966 +		{
  1.1967 +		pos = pos + bufferSize;
  1.1968 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.1969 +		errReadAudio = ParserGetDecoderInfo(aParser);
  1.1970 +		}
  1.1971 +	if (!ShouldRunOOMTest())
  1.1972 +		{
  1.1973 +		INFO_PRINTF2(_L("ParserGetDecoderInfo(aParser) buffer mode return %d. "), errReadAudio);
  1.1974 +		}
  1.1975 +	ParserCompleteL(aParser);
  1.1976 +	FileClose();
  1.1977 +	}
  1.1978 +
  1.1979 +// -----------------------------------------------------------------------------
  1.1980 +// Seek different position of a video/audio file
  1.1981 +// -----------------------------------------------------------------------------
  1.1982 +//
  1.1983 +C3GPLibParser_0027::C3GPLibParser_0027()
  1.1984 +	{
  1.1985 +	}
  1.1986 +
  1.1987 +TVerdict C3GPLibParser_0027::doTestStepL()
  1.1988 +	{
  1.1989 +	if(TestStepResult() == EPass)
  1.1990 +		{
  1.1991 +		C3GPParse* parser = C3GPParse::NewL();
  1.1992 +		CleanupStack::PushL(parser);
  1.1993 +		
  1.1994 +		TRAPD(err, SeekTestL(parser));
  1.1995 +		if (err != KErrNone)
  1.1996 +			{
  1.1997 +			SetTestStepResult(EFail);
  1.1998 +			}
  1.1999 +		
  1.2000 +		CleanupStack::PopAndDestroy(parser);
  1.2001 +		}
  1.2002 +	return TestStepResult();
  1.2003 +	}
  1.2004 +
  1.2005 +void C3GPLibParser_0027::SeekTestL(C3GPParse* aParse)
  1.2006 +	{	
  1.2007 +	// file mode
  1.2008 +	ParserOpenFileL(aParse);
  1.2009 +	
  1.2010 +	TUint audioPos;
  1.2011 +	TUint videoPos;
  1.2012 +	TUint timeStampInMs = 0;
  1.2013 +	
  1.2014 +	// Seek to position 0.
  1.2015 +	TInt err = KErrNone; 
  1.2016 +	if (iTestSection.Compare(KNoAudioNoVideo) != 0)
  1.2017 +		{
  1.2018 +		// Retrieve video & audio stream length
  1.2019 +		TUint videoLength; 
  1.2020 +		TUint audioLength; 
  1.2021 +		TInt videoError;
  1.2022 +
  1.2023 +		err = GetClipProperties(aParse, videoError, videoLength, audioLength);
  1.2024 +		if (iTestSection.Compare(KAudioOnly) == 0)
  1.2025 +			{
  1.2026 +			// audio only, GetVideoProperties should fail with KErrNotSupported. Set video length to 0
  1.2027 +			User::LeaveIfError(CheckError(videoError, KErrNotSupported, _L("GetClipProperties(aParse, videoError, videoLength, audioLength))")));
  1.2028 +			videoLength = 0;
  1.2029 +			}
  1.2030 +		else if (iTestSection.Compare(KVideoOnly) == 0)
  1.2031 +			{
  1.2032 +			// video only, GetAudioProperties should fail with KErrNotSupported. Set audio length to 0
  1.2033 +			User::LeaveIfError(CheckError(err, KErrNotSupported, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)")));
  1.2034 +			audioLength = 0;
  1.2035 +			}
  1.2036 +		else 
  1.2037 +			{
  1.2038 +			// All other files contains audio and video data
  1.2039 +			User::LeaveIfError(CheckError(videoError, KErrNone, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)")));
  1.2040 +			User::LeaveIfError(CheckError(err, KErrNone, _L("GetClipProperties(aParse, videoError, videoLength, audioLength)")));
  1.2041 +			}
  1.2042 +		
  1.2043 +		if (audioLength >= videoLength)
  1.2044 +			{
  1.2045 +			timeStampInMs = audioLength;
  1.2046 +			}
  1.2047 +		else
  1.2048 +			{
  1.2049 +			timeStampInMs = videoLength;
  1.2050 +			}
  1.2051 +		
  1.2052 +		if (iTestSection.Compare(KSameLenAudioVideo) == 0 || iTestSection.Compare(KAudioOnly) == 0)
  1.2053 +			{
  1.2054 +			err = ParserSeek(aParse, timeStampInMs, audioPos, videoPos);
  1.2055 +			User::LeaveIfError(err);
  1.2056 +			}
  1.2057 +		
  1.2058 +		if (iTestSection.Compare(KAudioMore) == 0 || iTestSection.Compare(KVideoMore) == 0 )
  1.2059 +			{
  1.2060 +			timeStampInMs = (audioLength + videoLength)/2;
  1.2061 +			err = aParse->Seek(timeStampInMs, EFalse, audioPos, videoPos);
  1.2062 +			User::LeaveIfError(err);
  1.2063 +			}
  1.2064 +		}
  1.2065 +	
  1.2066 +	ParserCompleteL(aParse);
  1.2067 +	}
  1.2068 +
  1.2069 +// Seek position 0, half the length and the length of the stream
  1.2070 +TInt C3GPLibParser_0027::ParserSeek(C3GPParse* aParser, TInt aLen, TUint& aAudioPos, TUint& aVideoPos)
  1.2071 +	{
  1.2072 +	TInt err = KErrNone;
  1.2073 +	TUint position = 0;
  1.2074 +	while (err == KErrNone && position <= aLen)
  1.2075 +		{
  1.2076 +		err = aParser->Seek(position, ETrue, aAudioPos, aVideoPos);
  1.2077 +		if (err == KErrNone)
  1.2078 +			{
  1.2079 +			err = aParser->Seek(position, EFalse, aAudioPos, aVideoPos);
  1.2080 +			}
  1.2081 +		position = position + aLen/2;
  1.2082 +		}
  1.2083 +
  1.2084 +	if (err != KErrNone)
  1.2085 +		{
  1.2086 +		ERR_PRINTF3(_L("aParser->Seek() failed with %d when positon is %d"), err, position);
  1.2087 +		}
  1.2088 +	return err;
  1.2089 +	}
  1.2090 +
  1.2091 +// -----------------------------------------------------------------------------
  1.2092 +// Seek positions after any keyframe and immediately after a non-key frame.
  1.2093 +// -----------------------------------------------------------------------------
  1.2094 +//
  1.2095 +C3GPLibParser_0031::C3GPLibParser_0031()
  1.2096 +	{	
  1.2097 +	}
  1.2098 +
  1.2099 +TVerdict C3GPLibParser_0031::doTestStepL()
  1.2100 +	{
  1.2101 +	if(TestStepResult() == EPass)
  1.2102 +		{
  1.2103 +		C3GPParse* parser = C3GPParse::NewL();
  1.2104 +		CleanupStack::PushL(parser);
  1.2105 +		
  1.2106 +		TRAPD(err, SeekTestL(parser));
  1.2107 +		if (err != KErrNone)
  1.2108 +			{
  1.2109 +			SetTestStepResult(EFail);
  1.2110 +			}
  1.2111 +		
  1.2112 +		CleanupStack::PopAndDestroy(parser);
  1.2113 +		}
  1.2114 +	return TestStepResult();
  1.2115 +	}
  1.2116 +
  1.2117 +void C3GPLibParser_0031::SeekTestL(C3GPParse* aParser)
  1.2118 +	{
  1.2119 +	// file mode
  1.2120 +	ParserOpenFileL(aParser);	
  1.2121 +	DoSeekTestL(aParser);			
  1.2122 +	ParserCompleteL(aParser);
  1.2123 +	}
  1.2124 +
  1.2125 +// -----------------------------------------------------------------------------
  1.2126 +// Check frame availability using file path
  1.2127 +// -----------------------------------------------------------------------------
  1.2128 +//
  1.2129 +C3GPLibParser_0032::C3GPLibParser_0032()
  1.2130 +	{	
  1.2131 +	}
  1.2132 +
  1.2133 +TVerdict C3GPLibParser_0032::doTestStepL()
  1.2134 +	{
  1.2135 +	if(TestStepResult() == EPass)
  1.2136 +		{
  1.2137 +		C3GPParse* parser = C3GPParse::NewL();
  1.2138 +		CleanupStack::PushL(parser);
  1.2139 +		
  1.2140 +		TRAPD(err, GetFrameAvailabilityL(parser));
  1.2141 +		if (err != KErrNone)
  1.2142 +			{
  1.2143 +			SetTestStepResult(EFail);
  1.2144 +			}
  1.2145 +		
  1.2146 +		CleanupStack::PopAndDestroy(parser);
  1.2147 +		}
  1.2148 +	return TestStepResult();
  1.2149 +	}
  1.2150 +
  1.2151 +void C3GPLibParser_0032::GetFrameAvailabilityL(C3GPParse* aParser)
  1.2152 +	{
  1.2153 +	// file mode
  1.2154 +	ParserOpenFileL(aParser);
  1.2155 +	DoGetFrameAvailabilityL(aParser);
  1.2156 +	ParserCompleteL(aParser);
  1.2157 +	}
  1.2158 +
  1.2159 +void C3GPLibParser_0032::DoGetFrameAvailabilityL(C3GPParse* aParser)
  1.2160 +	{
  1.2161 +	T3GPFrameType audioType = E3GPAudio;
  1.2162 +	T3GPFrameType videoType = E3GPVideo;
  1.2163 +	TBool audioAvailable;
  1.2164 +	TBool videoAvailable;
  1.2165 +	TUint num;
  1.2166 +	TInt audioErr = aParser->GetFrameAvailability(audioType, audioAvailable);
  1.2167 +	if (audioErr != KErrNone && audioErr != KErrNotFound)
  1.2168 +		{
  1.2169 +		SetTestStepError(audioErr);
  1.2170 +		User::LeaveIfError(audioErr);
  1.2171 +		}
  1.2172 +	
  1.2173 +	TInt videoErr = aParser->GetFrameAvailability(videoType, videoAvailable);
  1.2174 +	if (videoErr != KErrNone && videoErr != KErrNotFound)
  1.2175 +		{
  1.2176 +		SetTestStepError(videoErr);
  1.2177 +		User::LeaveIfError(videoErr);
  1.2178 +		}
  1.2179 +	
  1.2180 +	TInt err = aParser->GetNumberOfVideoFrames(num);
  1.2181 +	if (err != KErrNone && err != KErrNotSupported)
  1.2182 +		{
  1.2183 +		SetTestStepError(err);
  1.2184 +		User::LeaveIfError(err);
  1.2185 +		}
  1.2186 +	
  1.2187 +	if (iTestSection.Compare(KNoAudioNoVideo) == 0)
  1.2188 +		{
  1.2189 +		if (audioErr != KErrNotFound || videoErr != KErrNotFound 
  1.2190 +				|| audioAvailable || videoAvailable)
  1.2191 +			{
  1.2192 +			ERR_PRINTF2(_L("GetFrameAvailability() audio failed with %d, expected KErrNotFound"), audioErr);
  1.2193 +			ERR_PRINTF2(_L("GetFrameAvailability() expected audioAvailable returns false, actual %d "), audioAvailable);
  1.2194 +			ERR_PRINTF2(_L("GetFrameAvailability() video failed with %d, expected KErrNotFound;"), videoErr);
  1.2195 +			ERR_PRINTF2(_L("GetFrameAvailability() expected videoAvailable returns false, actual %d "), videoAvailable);
  1.2196 +			User::Leave(KErrGeneral);  
  1.2197 +			}				
  1.2198 +		User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser->GetNumberOfVideoFrames(num)")));
  1.2199 +		}
  1.2200 +	else if (iTestSection.Compare(KAudioOnly) == 0)
  1.2201 +		{
  1.2202 +		if (audioErr != KErrNone || videoErr != KErrNotFound 
  1.2203 +				|| !audioAvailable || videoAvailable)
  1.2204 +			{
  1.2205 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNone"), audioErr);
  1.2206 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns True, actual %d "), audioAvailable);
  1.2207 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNotFound;"), videoErr);
  1.2208 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns false, actual %d"), videoAvailable);
  1.2209 +			User::Leave(KErrGeneral);
  1.2210 +			}
  1.2211 +		User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser->GetNumberOfVideoFrames(num)")));
  1.2212 +		}
  1.2213 +	else if (iTestSection.Compare(KVideoOnly) == 0)
  1.2214 +		{
  1.2215 +		if (audioErr != KErrNotFound || videoErr != KErrNone 
  1.2216 +				|| audioAvailable || !videoAvailable)
  1.2217 +			{
  1.2218 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNotFound"), audioErr);
  1.2219 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns false, actual %d "), audioAvailable);
  1.2220 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNone;"), videoErr);
  1.2221 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns true, actual %d"), videoAvailable);
  1.2222 +			User::Leave(KErrGeneral);
  1.2223 +			}
  1.2224 +		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetNumberOfVideoFrames(num)")));
  1.2225 +		if (num != 265)
  1.2226 +			{
  1.2227 +			ERR_PRINTF2(_L("file h263-no-audio.MP4 has 265 video frames. Got %d instread"), num);
  1.2228 +			User::Leave(KErrGeneral);
  1.2229 +			}
  1.2230 +		}
  1.2231 +	else // File contains both valid audio and video data
  1.2232 +		{
  1.2233 +		// If file contains avc profile main or extended, videoErr could be KErrNotFound
  1.2234 +		if (audioErr != KErrNone || !audioAvailable)
  1.2235 +			{
  1.2236 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() audio failed with %d, expected KErrNone"), audioErr);
  1.2237 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected audioAvailable returns True, actual %d "), audioAvailable);
  1.2238 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() video failed with %d, expected KErrNone;"), videoErr);
  1.2239 +			ERR_PRINTF2(_L("aParser->GetFrameAvailability() expected videoAvailable returns True, actual %d"), videoAvailable);
  1.2240 +			User::Leave(KErrGeneral);
  1.2241 +			}
  1.2242 +		if (videoErr != KErrNone)
  1.2243 +			{
  1.2244 +			SetTestStepError(videoErr);
  1.2245 +			}
  1.2246 +		else
  1.2247 +			{
  1.2248 +			User::LeaveIfError(CheckError(err, KErrNone, _L("aParser->GetNumberOfVideoFrames(num)")));
  1.2249 +			}
  1.2250 +		}
  1.2251 +	}
  1.2252 +
  1.2253 +// -----------------------------------------------------------------------------
  1.2254 +// Retrieve video frame size & start time without parsing the content file frame 
  1.2255 +// by frame in file mode
  1.2256 +// -----------------------------------------------------------------------------
  1.2257 +//
  1.2258 +C3GPLibParser_0033::C3GPLibParser_0033()
  1.2259 +	{	
  1.2260 +	}
  1.2261 +
  1.2262 +TVerdict C3GPLibParser_0033::doTestStepL()
  1.2263 +	{
  1.2264 +	if(TestStepResult() == EPass)
  1.2265 +		{
  1.2266 +		C3GPParse* parser = C3GPParse::NewL();
  1.2267 +		CleanupStack::PushL(parser);
  1.2268 +		
  1.2269 +		TRAPD(err, VideoInfoL(parser));
  1.2270 +		if (err != KErrNone)
  1.2271 +			{
  1.2272 +			SetTestStepResult(EFail);
  1.2273 +			}
  1.2274 +		
  1.2275 +		CleanupStack::PopAndDestroy(parser);
  1.2276 +		}
  1.2277 +	return TestStepResult();
  1.2278 +	}
  1.2279 +
  1.2280 +void C3GPLibParser_0033::VideoInfoL(C3GPParse* aParser)
  1.2281 +	{
  1.2282 +	// file mode
  1.2283 +	ParserOpenFileL(aParser);
  1.2284 +	
  1.2285 +	TUint num; 
  1.2286 +	TInt num1 = 0;
  1.2287 +	TUint timeStampInMs = 0; 
  1.2288 +	TUint timeStampInTimescale = 0; 
  1.2289 +	TUint timeStampInMs1 = 0; 
  1.2290 +	TUint timeStampInTimescale1 = 0; 
  1.2291 +	TUint frameIndex;
  1.2292 +	TUint frameSize;
  1.2293 +	TBool keyFrame;
  1.2294 +	User::LeaveIfError(aParser->GetNumberOfVideoFrames(num));
  1.2295 +	
  1.2296 +	RBuf8 buffer;
  1.2297 +	CleanupClosePushL(buffer);
  1.2298 +	buffer.CreateL(0);
  1.2299 +	TInt err = aParser->ReadVideoFrame(buffer, keyFrame, timeStampInMs, timeStampInTimescale);
  1.2300 +	if (err != KErrOverflow)
  1.2301 +		{
  1.2302 +		ERR_PRINTF2(_L("aParser->ReadVideoFrame() expected KErrOverflow, actual %d"), err);
  1.2303 +		User::Leave(err);
  1.2304 +		}
  1.2305 +	User::LeaveIfError(aParser->GetVideoSampleEntryIndex(frameIndex));
  1.2306 +	CleanupStack::PopAndDestroy(&buffer);
  1.2307 +	
  1.2308 +	
  1.2309 +	err = KErrNone;
  1.2310 +	while (err == KErrNone)
  1.2311 +		{
  1.2312 +		timeStampInMs = 0; 
  1.2313 +		timeStampInTimescale = 0; 
  1.2314 +		timeStampInMs1 = 0; 
  1.2315 +		timeStampInTimescale1 = 0; 
  1.2316 +
  1.2317 +		if (num1 < num)
  1.2318 +			{
  1.2319 +			User::LeaveIfError(aParser->GetVideoFrameSize(num1, frameSize));
  1.2320 +			User::LeaveIfError(aParser->GetVideoFrameStartTime(num1, timeStampInMs, timeStampInTimescale));
  1.2321 +			}
  1.2322 +		else
  1.2323 +			{
  1.2324 +			err = aParser->GetVideoFrameStartTime(num1, timeStampInMs, timeStampInTimescale);
  1.2325 +			err = aParser->GetVideoFrameSize(num1, frameSize);
  1.2326 +			}
  1.2327 +		RBuf8 buffer1;
  1.2328 +		CleanupClosePushL(buffer1);
  1.2329 +		buffer1.CreateL(frameSize);
  1.2330 +		err = aParser->ReadVideoFrame(buffer1, keyFrame, timeStampInMs1, timeStampInTimescale1);
  1.2331 +		
  1.2332 +		if (timeStampInMs != timeStampInMs1)
  1.2333 +			{
  1.2334 +			ERR_PRINTF3(_L("Two timestamps should be the same. timeStampInMs %d, timeStampInMs1 %d"), timeStampInMs, timeStampInMs1);
  1.2335 +			User::Leave(KErrGeneral);
  1.2336 +			}
  1.2337 +		CleanupStack::PopAndDestroy(&buffer1);
  1.2338 +		num1++;
  1.2339 +		}
  1.2340 +	
  1.2341 +	if (err != KErrNotFound)
  1.2342 +		{
  1.2343 +		ERR_PRINTF2(_L("expected KErrNotFound when finishing reading video frames. Actual err %d"), err);
  1.2344 +		User::Leave(KErrGeneral);
  1.2345 +		}
  1.2346 +	
  1.2347 +	if ((num1 - 1) != num)
  1.2348 +		{
  1.2349 +		ERR_PRINTF3(_L("Two numOfFrame should be the same. num %d, num1 %d"), num, num1);
  1.2350 +		User::Leave(KErrGeneral);
  1.2351 +		}
  1.2352 +	
  1.2353 +	// use an invalid index to attempt retrieving video frame size & start time.  Both should failed with error.
  1.2354 +	err = aParser->GetVideoFrameSize((num + 100), frameSize);
  1.2355 +	User::LeaveIfError(CheckError(err, KErrGeneral, _L("GetVideoFrameSize")));
  1.2356 +	
  1.2357 +	err = aParser->GetVideoFrameStartTime((num + 5), timeStampInMs, timeStampInTimescale);
  1.2358 +	User::LeaveIfError(CheckError(err, KErrGeneral, _L("GetVideoFrameStartTime")));
  1.2359 +	
  1.2360 +	ParserCompleteL(aParser);
  1.2361 +	}
  1.2362 +
  1.2363 +// -----------------------------------------------------------------------------
  1.2364 +// Retrieve video frame size & start time without parsing the content file frame 
  1.2365 +// by frame in buffe mode
  1.2366 +// -----------------------------------------------------------------------------
  1.2367 +//
  1.2368 +C3GPLibParser_0034::C3GPLibParser_0034()
  1.2369 +	{	
  1.2370 +	}
  1.2371 +
  1.2372 +TVerdict C3GPLibParser_0034::doTestStepL()
  1.2373 +	{
  1.2374 +	if(TestStepResult() == EPass)
  1.2375 +		{
  1.2376 +		C3GPParse* parser = C3GPParse::NewL();
  1.2377 +		CleanupStack::PushL(parser);
  1.2378 +		
  1.2379 +		TRAPD(err, VideoInfoBufferModeL(parser));
  1.2380 +		if (err != KErrNone)
  1.2381 +			{
  1.2382 +			SetTestStepResult(EFail);
  1.2383 +			}
  1.2384 +		
  1.2385 +		CleanupStack::PopAndDestroy(parser);
  1.2386 +		}
  1.2387 +	return TestStepResult();
  1.2388 +	}
  1.2389 +
  1.2390 +void C3GPLibParser_0034::VideoInfoBufferModeL(C3GPParse* aParser)
  1.2391 +	{
  1.2392 +	// buffer mode
  1.2393 +	ParserOpenL(aParser);
  1.2394 +	FileOpenL();
  1.2395 +	
  1.2396 +	TUint num; 
  1.2397 +	TUint timeStampInMs = 0; 
  1.2398 +	TUint timeStampInTimescale = 0; 
  1.2399 +	TUint frameSize;
  1.2400 +	
  1.2401 +	// Insert 1K data into the library
  1.2402 +	TInt pos = 0;
  1.2403 +	TInt bufferSize = KBufferSize;
  1.2404 +	InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.2405 +	TInt err = aParser->GetNumberOfVideoFrames(num);
  1.2406 +	if (err != KErrNone && err != KErrNotSupported && err != KErr3gpLibMoreDataRequired)
  1.2407 +		{
  1.2408 +		SetTestStepError(err);
  1.2409 +		User::LeaveIfError(err);
  1.2410 +		}
  1.2411 +	
  1.2412 +	while (err == KErr3gpLibMoreDataRequired )
  1.2413 +		{
  1.2414 +		pos = pos + bufferSize;
  1.2415 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.2416 +		err = aParser->GetNumberOfVideoFrames(num);
  1.2417 +		}
  1.2418 +
  1.2419 +	if (err != KErrNone)
  1.2420 +		{
  1.2421 +		SetTestStepError(err);
  1.2422 +		}
  1.2423 +	else 
  1.2424 +		{
  1.2425 +		for (TUint i = 0; i < num; i++)
  1.2426 +			{
  1.2427 +			User::LeaveIfError(aParser->GetVideoFrameSize(i, frameSize));
  1.2428 +			User::LeaveIfError(aParser->GetVideoFrameStartTime(i, timeStampInMs, timeStampInTimescale));	
  1.2429 +			}
  1.2430 +		}
  1.2431 +	
  1.2432 +	ParserCompleteL(aParser);
  1.2433 +	FileClose();
  1.2434 +	}
  1.2435 +
  1.2436 +// -----------------------------------------------------------------------------
  1.2437 +// Retrieve user atoms in all the possible locations 
  1.2438 +// -----------------------------------------------------------------------------
  1.2439 +//
  1.2440 +C3GPLibParser_0035::C3GPLibParser_0035()
  1.2441 +	{	
  1.2442 +	}
  1.2443 +
  1.2444 +TVerdict C3GPLibParser_0035::doTestStepL()
  1.2445 +	{
  1.2446 +	if(TestStepResult() == EPass)
  1.2447 +		{
  1.2448 +		C3GPParse* parser = C3GPParse::NewL();
  1.2449 +		CleanupStack::PushL(parser);
  1.2450 +		
  1.2451 +		TRAPD(err, GetUserDataAtomL(parser));
  1.2452 +		if (err != KErrNone)
  1.2453 +			{
  1.2454 +			SetTestStepResult(EFail);
  1.2455 +			}
  1.2456 +		
  1.2457 +		CleanupStack::PopAndDestroy(parser);
  1.2458 +		}
  1.2459 +	return TestStepResult();
  1.2460 +	}
  1.2461 +
  1.2462 +void C3GPLibParser_0035::GetUserDataAtomL(C3GPParse* aParse)
  1.2463 +	{
  1.2464 +	// file mode
  1.2465 +	ParserOpenFileL(aParse);
  1.2466 +
  1.2467 +	TUint32 udtType = 0x6d657461;  // The udt type of test files is 'meta'
  1.2468 +	T3GPUdtaLocation location = E3GPUdtaAudioTrak;
  1.2469 +	TUint indexMoov = 0;
  1.2470 +	TUint indexAudio = 0;
  1.2471 +	TUint indexVideo = 0;
  1.2472 +	
  1.2473 +	TInt err = CallUDTApi(aParse, udtType, indexAudio, location); 
  1.2474 +	if (err == KErrNone)
  1.2475 +		{
  1.2476 +		location = E3GPUdtaMoov;
  1.2477 +		err = CallUDTApi(aParse, udtType, indexMoov, location); 
  1.2478 +		
  1.2479 +		if (err == KErrNone)
  1.2480 +			{
  1.2481 +			// By default, the location is video track
  1.2482 +			err = CallUDTApi(aParse, udtType, indexVideo); 
  1.2483 +			}
  1.2484 +		if (err == KErrNone)
  1.2485 +			{
  1.2486 +			// Test file KMultiUdta contains 1 udta at E3GPUdtaMoov, 5 udta at E3GPUdtaAudioTrak and 
  1.2487 +			// 3 udta at E3GPUdtaVideoTrak			
  1.2488 +			if (iTestSection.Compare(KMultiUdta) == 0 && (indexMoov != 0 || indexAudio != 4 || indexVideo != 2))
  1.2489 +				{
  1.2490 +				SetTestStepError(KErrNotFound);
  1.2491 +				}
  1.2492 +			}
  1.2493 +		}
  1.2494 +
  1.2495 +	SetTestStepError(err);
  1.2496 +	
  1.2497 +	ParserCompleteL(aParse);
  1.2498 +	}
  1.2499 +
  1.2500 +// -----------------------------------------------------------------------------
  1.2501 +// Retrieve user atoms from a valid mp4/3gp file containing multiple entries of 
  1.2502 +// the same user atom type within a user atom
  1.2503 +// -----------------------------------------------------------------------------
  1.2504 +//
  1.2505 +C3GPLibParser_0036::C3GPLibParser_0036()
  1.2506 +	{	
  1.2507 +	}
  1.2508 +
  1.2509 +TVerdict C3GPLibParser_0036::doTestStepL()
  1.2510 +	{
  1.2511 +	if(TestStepResult() == EPass)
  1.2512 +		{
  1.2513 +		C3GPParse* parser = C3GPParse::NewL();
  1.2514 +		CleanupStack::PushL(parser);
  1.2515 +		
  1.2516 +		TRAPD(err, GetUserDataAtomL(parser));
  1.2517 +		if (err != KErrNone)
  1.2518 +			{
  1.2519 +			SetTestStepResult(EFail);
  1.2520 +			}
  1.2521 +		
  1.2522 +		CleanupStack::PopAndDestroy(parser);
  1.2523 +		}
  1.2524 +	return TestStepResult();
  1.2525 +	}
  1.2526 +
  1.2527 +void C3GPLibParser_0036::GetUserDataAtomL(C3GPParse* aParse)
  1.2528 +	{
  1.2529 +	// file mode
  1.2530 +	ParserOpenFileL(aParse);
  1.2531 +	
  1.2532 +	TUint index;
  1.2533 +	TUint32 udtType = 0x6d657461;  // The udt type of test files could be 'meta'
  1.2534 +	T3GPUdtaLocation location = E3GPUdtaMoov; // The test files should not contain udta in audio trak
  1.2535 +	
  1.2536 +	// First read user data atom with empty buffer. It should return KErrOverflow
  1.2537 +	RBuf8 buffer;	
  1.2538 +	CleanupClosePushL(buffer);
  1.2539 +	buffer.CreateL(0);	
  1.2540 +	TInt err = aParse->GetUserDataAtom(udtType, location, buffer, index);
  1.2541 +	buffer.Close();
  1.2542 +	CleanupStack::PopAndDestroy(&buffer);
  1.2543 +	
  1.2544 +	if (err != KErrOverflow)
  1.2545 +		{
  1.2546 +		ERR_PRINTF2(_L("GetUserDataAtom with empty buffer should return KErrOverflow, failed with err %d"), err);
  1.2547 +		User::Leave(err);
  1.2548 +		}
  1.2549 +	
  1.2550 +	err = CallUDTApi(aParse, udtType, index); 	// By default, the location is videoTrack
  1.2551 +	
  1.2552 +	if (err == KErrNotFound || err == KErrNone)
  1.2553 +		{
  1.2554 +		err = CallUDTApi(aParse, udtType, index, location);
  1.2555 +		
  1.2556 +		if (err == KErrNotFound || err == KErrNone)
  1.2557 +			{
  1.2558 +			location = E3GPUdtaAudioTrak;
  1.2559 +			err = CallUDTApi(aParse, udtType, index, location); 
  1.2560 +			}
  1.2561 +		}
  1.2562 +
  1.2563 +	SetTestStepError(err);
  1.2564 +	
  1.2565 +	ParserCompleteL(aParse);
  1.2566 +	}
  1.2567 +
  1.2568 +// -----------------------------------------------------------------------------
  1.2569 +// Retrieve video frame dependencies  
  1.2570 +// -----------------------------------------------------------------------------
  1.2571 +//
  1.2572 +C3GPLibParser_0037::C3GPLibParser_0037()
  1.2573 +	{	
  1.2574 +	}
  1.2575 +
  1.2576 +TVerdict C3GPLibParser_0037::doTestStepL()
  1.2577 +	{
  1.2578 +	if(TestStepResult() == EPass)
  1.2579 +		{
  1.2580 +		C3GPParse* parser = C3GPParse::NewL();
  1.2581 +		CleanupStack::PushL(parser);
  1.2582 +		
  1.2583 +		TRAPD(err, VideoDependencyL(parser));
  1.2584 +		if (err != KErrNone)
  1.2585 +			{
  1.2586 +			SetTestStepResult(EFail);
  1.2587 +			}
  1.2588 +		
  1.2589 +		CleanupStack::PopAndDestroy(parser);
  1.2590 +		}
  1.2591 +	return TestStepResult();
  1.2592 +	}
  1.2593 +
  1.2594 +void C3GPLibParser_0037::VideoDependencyL(C3GPParse* aParser)
  1.2595 +	{
  1.2596 +	// file mode
  1.2597 +	ParserOpenFileL(aParser);
  1.2598 +	
  1.2599 +	TUint num; 
  1.2600 +	User::LeaveIfError(aParser->GetNumberOfVideoFrames(num));
  1.2601 +	
  1.2602 +	TInt err = KErrNone;
  1.2603 +	T3GPFrameDependencies dependencies;
  1.2604 +	for (TInt i = 0; i < num; i++)
  1.2605 +		{
  1.2606 +		err = aParser->GetVideoFrameDependencies(dependencies);
  1.2607 +		if (err != KErrNone)
  1.2608 +			{
  1.2609 +			ERR_PRINTF2(_L("GetVideoFrameDependencies failed with %d"), err);
  1.2610 +			SetTestStepError(err);
  1.2611 +			break;
  1.2612 +			}
  1.2613 +		}
  1.2614 +	ParserCompleteL(aParser);
  1.2615 +	}
  1.2616 +
  1.2617 +// -----------------------------------------------------------------------------
  1.2618 +// Get Video Frame Properties 
  1.2619 +// -----------------------------------------------------------------------------
  1.2620 +//
  1.2621 +C3GPLibParser_0038::C3GPLibParser_0038()
  1.2622 +	{	
  1.2623 +	}
  1.2624 +
  1.2625 +TVerdict C3GPLibParser_0038::doTestStepL()
  1.2626 +	{
  1.2627 +	if(TestStepResult() == EPass)
  1.2628 +		{
  1.2629 +		C3GPParse* parser = C3GPParse::NewL();
  1.2630 +		CleanupStack::PushL(parser);
  1.2631 +		
  1.2632 +		TRAPD(err, VideoInfoL(parser));
  1.2633 +		if (err != KErrNone)
  1.2634 +			{
  1.2635 +			SetTestStepResult(EFail);
  1.2636 +			}
  1.2637 +		
  1.2638 +		CleanupStack::PopAndDestroy(parser);
  1.2639 +		}
  1.2640 +	return TestStepResult();
  1.2641 +	}
  1.2642 +
  1.2643 +void C3GPLibParser_0038::VideoInfoL(C3GPParse* aParser)
  1.2644 +	{
  1.2645 +	// file mode
  1.2646 +	ParserOpenFileL(aParser);
  1.2647 +	
  1.2648 +	TUint num; 
  1.2649 +	TUint timeStampInMs = 0; 
  1.2650 +	TUint timeStampInTimescale = 0; 
  1.2651 +	TUint frameIndex;
  1.2652 +	TBool keyFrame;
  1.2653 +	User::LeaveIfError(aParser->GetNumberOfVideoFrames(num));
  1.2654 +	User::LeaveIfError(aParser->GetVideoSampleEntryIndex(frameIndex));
  1.2655 +	
  1.2656 +	TInt err = KErrNone;
  1.2657 +	for (TInt i = 0; i < num; i++)
  1.2658 +		{
  1.2659 +		err = aParser->GetVideoFrameKeyType(i, keyFrame);
  1.2660 +		User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameKeyType()")));
  1.2661 +		
  1.2662 +		err = aParser->GetVideoFrameStartTime(i, timeStampInMs, timeStampInTimescale);
  1.2663 +		User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameStartTime()")));	
  1.2664 +		}
  1.2665 +	
  1.2666 +	TUint startIndex = 0;
  1.2667 +	RArray<T3GPFrameInfoParameters> array;
  1.2668 +	CleanupClosePushL(array);
  1.2669 +	
  1.2670 +	err = aParser->GetVideoFrameProperties(startIndex, num, array);
  1.2671 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameProperties")));
  1.2672 +	if (!ShouldRunOOMTest())
  1.2673 +		{
  1.2674 +		INFO_PRINTF1(_L("aParser->GetVideoFrameProperties passed."));
  1.2675 +		}
  1.2676 +	
  1.2677 +	RArray<T3GPFrameInfoParameters> array1;
  1.2678 +	CleanupClosePushL(array1);
  1.2679 +	
  1.2680 +	// Filled in array with some data, say array with size 3
  1.2681 +	TInt arraySize = 3;
  1.2682 +	T3GPFrameInfoParameters fip;
  1.2683 +	for (TInt i = 0; i < arraySize; i++)
  1.2684 +		{
  1.2685 +		fip.iSize = i;
  1.2686 +		fip.iStartTime = 1000;
  1.2687 +		fip.iIsRandomAccessPoint = ETrue;
  1.2688 +		array1.AppendL(fip);
  1.2689 +		}
  1.2690 +	
  1.2691 +	if (!ShouldRunOOMTest())
  1.2692 +		{
  1.2693 +		INFO_PRINTF1(_L("Filled in array with some junk data and call aParser->GetVideoFrameProperties() ago."));
  1.2694 +		}
  1.2695 +	
  1.2696 +	err = aParser->GetVideoFrameProperties(startIndex, num, array1);
  1.2697 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameProperties")));
  1.2698 +	
  1.2699 +	// Check two arrays are the same
  1.2700 +	if (array.Count() != array1.Count())
  1.2701 +		{
  1.2702 +		ERR_PRINTF3(_L("array1.Count() is %d; expected array.Count() is %d."), array1.Count(), array.Count());
  1.2703 +		User::Leave(KErrGeneral);
  1.2704 +		}
  1.2705 +	for (TInt j = 0; j < array.Count(); j++)
  1.2706 +		{
  1.2707 +		if (array1[j].iSize != array[j].iSize || array1[j].iStartTime != array1[j].iStartTime ||
  1.2708 +				array1[j].iIsRandomAccessPoint != array1[j].iIsRandomAccessPoint)
  1.2709 +			{
  1.2710 +			ERR_PRINTF1(_L("Two array are not the same."));
  1.2711 +			User::Leave(KErrGeneral);
  1.2712 +			}
  1.2713 +		}
  1.2714 +	
  1.2715 +	if (!ShouldRunOOMTest())
  1.2716 +		{
  1.2717 +		INFO_PRINTF1(_L("Two arrays are the same."));	
  1.2718 +		}
  1.2719 +	CleanupStack::PopAndDestroy(&array1);
  1.2720 +	CleanupStack::PopAndDestroy(&array);
  1.2721 +	
  1.2722 +	ParserCompleteL(aParser);
  1.2723 +	}
  1.2724 +
  1.2725 +// -----------------------------------------------------------------------------
  1.2726 +// Read a audio and a video frame into a buffer of filled with junk content and 
  1.2727 +// ensure the buffer gets properly reset when retrieve video / audio frame data.
  1.2728 +// -----------------------------------------------------------------------------
  1.2729 +//
  1.2730 +C3GPLibParser_0039::C3GPLibParser_0039()
  1.2731 +	{	
  1.2732 +	}
  1.2733 +
  1.2734 +TVerdict C3GPLibParser_0039::doTestStepL()
  1.2735 +	{
  1.2736 +	if(TestStepResult() == EPass)
  1.2737 +		{
  1.2738 +		C3GPParse* parser = C3GPParse::NewL();
  1.2739 +		CleanupStack::PushL(parser);
  1.2740 +		
  1.2741 +		TRAPD(err, AudioAndVideoFrameL(parser));
  1.2742 +		if (err != KErrNone)
  1.2743 +			{
  1.2744 +			SetTestStepResult(EFail);
  1.2745 +			}
  1.2746 +		
  1.2747 +		CleanupStack::PopAndDestroy(parser);
  1.2748 +		}
  1.2749 +	return TestStepResult();
  1.2750 +	}
  1.2751 +
  1.2752 +void C3GPLibParser_0039::AudioAndVideoFrameL(C3GPParse* aParser)
  1.2753 +	{
  1.2754 +	// file mode
  1.2755 +	ParserOpenFileL(aParser);
  1.2756 +	
  1.2757 +	TUint size;	
  1.2758 +	TInt err = aParser->GetVideoFrameSize(size);
  1.2759 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetVideoFrameSize")));
  1.2760 +		
  1.2761 +	RBuf8 buffer;
  1.2762 +	CleanupClosePushL(buffer);
  1.2763 +	buffer.CreateL(size + 15); // Create a buffer bigger than the size returned by GetVideoFrameSize
  1.2764 +	// Filled in junk data into the buffer
  1.2765 +	TChar c = 'a';
  1.2766 +	buffer.AppendFill(c, (size + 15));
  1.2767 +	
  1.2768 +	TBool keyFrame;
  1.2769 +	TUint timeStampInMs; 
  1.2770 +	TUint timeStampInTimescale;
  1.2771 +	err = aParser->ReadVideoFrame(buffer, keyFrame, timeStampInMs, timeStampInTimescale);
  1.2772 +	User::LeaveIfError(CheckError(err, KErrNone, _L("ReadVideoFrame")));
  1.2773 +	// Check the buffer size is the same as size returned by GetVideoFrameSize
  1.2774 +	if (buffer.Length() != size)
  1.2775 +		{
  1.2776 +		ERR_PRINTF3(_L("buffer size is %d; expected size is %d."), buffer.Length(), size);
  1.2777 +		User::Leave(KErrGeneral);
  1.2778 +		}
  1.2779 +	CleanupStack::PopAndDestroy(&buffer);
  1.2780 +	
  1.2781 +	err = aParser->GetAudioFramesSize(size);
  1.2782 +	User::LeaveIfError(CheckError(err, KErrNone, _L("GetAudioFramesSize")));
  1.2783 +			
  1.2784 +	RBuf8 bufferBig;
  1.2785 +	CleanupClosePushL(bufferBig);
  1.2786 +	bufferBig.CreateL(size + 10); // Create a buffer bigger than the size returned by GetVideoFrameSize
  1.2787 +	// Filled in junk data into the buffer
  1.2788 +	bufferBig.AppendFill(c, (size + 10));
  1.2789 +	
  1.2790 +	TInt returnedFrames;
  1.2791 +	err = aParser->ReadAudioFrames(bufferBig, returnedFrames, timeStampInMs, timeStampInTimescale);
  1.2792 +	User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioFrames")));
  1.2793 +	// Check the buffer size is the same as size returned by GetVideoFrameSize
  1.2794 +	if (bufferBig.Length() != size)
  1.2795 +		{
  1.2796 +		ERR_PRINTF3(_L("buffer size is %d; expected size is %d."), buffer.Length(), size);
  1.2797 +		User::Leave(KErrGeneral);
  1.2798 +		}
  1.2799 +	
  1.2800 +	CleanupStack::PopAndDestroy(&bufferBig);
  1.2801 +	
  1.2802 +	ParserCompleteL(aParser);
  1.2803 +	}
  1.2804 +
  1.2805 +// -----------------------------------------------------------------------------
  1.2806 +// Multiple parser working simultaneously. 
  1.2807 +// -----------------------------------------------------------------------------
  1.2808 +//
  1.2809 +C3GPLibParser_0041::C3GPLibParser_0041()
  1.2810 +	{
  1.2811 +	}
  1.2812 +
  1.2813 +TVerdict C3GPLibParser_0041::doTestStepPreambleL()
  1.2814 +	{
  1.2815 +	// Add the names of the new files to the following file list array.
  1.2816 +	TInt numOfFiles = 2; // This is the array number. Should be the same as the number of the array.
  1.2817 +	const TText* SelectedFiles[] = 
  1.2818 +		{
  1.2819 +		_S("mpeg4-aac.3gp"), // File with both audio and video
  1.2820 +		_S("arm-nb-acelp-only.3gp")  // File with audio only
  1.2821 +		};
  1.2822 +
  1.2823 +	for (TInt index = 0; index < numOfFiles; index++)
  1.2824 +		{
  1.2825 +		// Create a zero terminated version of the file name
  1.2826 +		TFileName inputFile(K3GPLibTestFilePath);
  1.2827 +		inputFile += TPtrC(SelectedFiles[index]);
  1.2828 +		inputFile.ZeroTerminate();
  1.2829 +		
  1.2830 +		if (index == 0)
  1.2831 +			{
  1.2832 +			User::LeaveIfError(iInputFile1.Create(inputFile.Length() + 1));
  1.2833 +			iInputFile1.Copy(inputFile);	
  1.2834 +			}
  1.2835 +		else
  1.2836 +			{
  1.2837 +			User::LeaveIfError(iInputFile2.Create(inputFile.Length() + 1));
  1.2838 +			iInputFile2.Copy(inputFile);	
  1.2839 +			}
  1.2840 +		}
  1.2841 +	return TestStepResult();
  1.2842 +	}
  1.2843 +
  1.2844 +TVerdict C3GPLibParser_0041::doTestStepPostambleL()
  1.2845 +	{
  1.2846 +	iInputFile1.Close();
  1.2847 +	iInputFile2.Close();
  1.2848 +	return TestStepResult();
  1.2849 +	}
  1.2850 +
  1.2851 +TVerdict C3GPLibParser_0041::doTestStepL()
  1.2852 +	{
  1.2853 +	if(TestStepResult() == EPass)
  1.2854 +		{
  1.2855 +		C3GPParse* parser1 = C3GPParse::NewL();
  1.2856 +		CleanupStack::PushL(parser1);
  1.2857 +		
  1.2858 +		TInt err = parser1->Open(iInputFile1);
  1.2859 +		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser1->Open")));
  1.2860 +		
  1.2861 +		C3GPParse* parser2 = C3GPParse::NewL();
  1.2862 +		CleanupStack::PushL(parser2);
  1.2863 +		
  1.2864 +		err = parser2->Open(iInputFile1);
  1.2865 +		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser2->Open")));
  1.2866 +		
  1.2867 +		C3GPParse* parser3 = C3GPParse::NewL();
  1.2868 +		CleanupStack::PushL(parser3);
  1.2869 +		
  1.2870 +		err = parser3->Open(iInputFile2);
  1.2871 +		User::LeaveIfError(CheckError(err, KErrNone, _L("aParser3->Open")));
  1.2872 +		
  1.2873 +		TRAP(err, MultipleParserL(parser1, parser2, parser3));
  1.2874 +		if (err != KErrNone)
  1.2875 +			{
  1.2876 +			SetTestStepResult(EFail);
  1.2877 +			}
  1.2878 +		
  1.2879 +		ParserCompleteL(parser1);
  1.2880 +		ParserCompleteL(parser2);
  1.2881 +		ParserCompleteL(parser3);
  1.2882 +		
  1.2883 +		CleanupStack::PopAndDestroy(parser3);
  1.2884 +		CleanupStack::PopAndDestroy(parser2);
  1.2885 +		CleanupStack::PopAndDestroy(parser1);
  1.2886 +		}
  1.2887 +	return TestStepResult();
  1.2888 +	}
  1.2889 +
  1.2890 +void C3GPLibParser_0041::MultipleParserL(C3GPParse* aParser1, C3GPParse* aParser2, C3GPParse* aParser3)
  1.2891 +	{
  1.2892 +	TInt err = ReadAudioVideoFrame(aParser1);
  1.2893 +	User::LeaveIfError(CheckError(err, KErrNotFound, _L("ReadAudioVideoFrame(aParser1)")));
  1.2894 +	
  1.2895 +	// Read one video frame with parser2
  1.2896 +	err = ReadAudioVideoFrame(aParser2, EFalse, EFalse);
  1.2897 +	User::LeaveIfError(CheckError(err, KErrNone, _L("ReadAudioVideoFrame(aParser2)")));
  1.2898 +	
  1.2899 +	// Read video properties with parser3. Expected failed with KErrNotSupported
  1.2900 +	T3GPVideoType videoType;
  1.2901 +	TUint length; 
  1.2902 +	TReal frameRate;
  1.2903 +	TUint avgBitRate;
  1.2904 +	TSize videoSize;
  1.2905 +	TUint timeScale;
  1.2906 +	
  1.2907 +	err = aParser3->GetVideoProperties(videoType, length, frameRate, avgBitRate, videoSize, timeScale);
  1.2908 +	User::LeaveIfError(CheckError(err, KErrNotSupported, _L("aParser3->GetVideoProperties")));
  1.2909 +	}
  1.2910 +
  1.2911 +// -----------------------------------------------------------------------------
  1.2912 +// Seek position in buffer mode
  1.2913 +// -----------------------------------------------------------------------------
  1.2914 +//
  1.2915 +C3GPLibParser_0043::C3GPLibParser_0043()
  1.2916 +	{
  1.2917 +	}
  1.2918 +
  1.2919 +TVerdict C3GPLibParser_0043::doTestStepL()
  1.2920 +	{
  1.2921 +	if(TestStepResult() == EPass)
  1.2922 +		{
  1.2923 +		C3GPParse* parser = C3GPParse::NewL();
  1.2924 +		CleanupStack::PushL(parser);
  1.2925 +		
  1.2926 +		TRAPD(err, SeekBufferModeL(parser));
  1.2927 +		if (err != KErrNone)
  1.2928 +			{
  1.2929 +			SetTestStepResult(EFail);
  1.2930 +			}
  1.2931 +		
  1.2932 +		CleanupStack::PopAndDestroy(parser);
  1.2933 +		}
  1.2934 +	return TestStepResult();
  1.2935 +	}
  1.2936 +
  1.2937 +void C3GPLibParser_0043::SeekBufferModeL(C3GPParse* aParser)
  1.2938 +	{
  1.2939 +	// buffer mode
  1.2940 +	ParserOpenL(aParser);
  1.2941 +	FileOpenL();
  1.2942 +	
  1.2943 +	// Insert buffer data into the library
  1.2944 +	TInt pos = 0;
  1.2945 +	TInt bufferSize = KBufferSize;
  1.2946 +	InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.2947 +	
  1.2948 +	TUint audioPos; 
  1.2949 +	TUint videoPos;
  1.2950 +	TUint timeStampInMs = 0; 
  1.2951 +	
  1.2952 +	// Seek the position
  1.2953 +	TInt err = aParser->Seek(timeStampInMs, EFalse, audioPos, videoPos);
  1.2954 +	while (err == KErr3gpLibMoreDataRequired)
  1.2955 +		{
  1.2956 +		pos = pos + bufferSize;
  1.2957 +		InsertDataL(aParser, iSourceFile, bufferSize, pos);
  1.2958 +		err = aParser->Seek(timeStampInMs, EFalse, audioPos, videoPos);
  1.2959 +		}
  1.2960 +	
  1.2961 +	if (err != KErrNone)
  1.2962 +		{
  1.2963 +		SetTestStepError(err);
  1.2964 +		}
  1.2965 +	ParserCompleteL(aParser);
  1.2966 +	FileClose();
  1.2967 +	}
  1.2968 +
  1.2969 +// -----------------------------------------------------------------------------
  1.2970 +// Test C3GPParse with large file (>2GB)
  1.2971 +// -----------------------------------------------------------------------------
  1.2972 +//
  1.2973 +C3GPLibParser_0045::C3GPLibParser_0045()
  1.2974 +	{
  1.2975 +	}
  1.2976 +
  1.2977 +TVerdict C3GPLibParser_0045::doTestStepPreambleL()
  1.2978 +	{
  1.2979 +	C3GPLib_AsyncObserver::doTestStepPreambleL();	
  1.2980 +	if (TestStepResult() == EPass)
  1.2981 +		{
  1.2982 +		iScheduler = new (ELeave) CActiveScheduler;
  1.2983 +		CActiveScheduler::Install(iScheduler);
  1.2984 +		}
  1.2985 +	return TestStepResult();
  1.2986 +	}
  1.2987 +
  1.2988 +TVerdict C3GPLibParser_0045::doTestStepPostambleL()
  1.2989 +	{
  1.2990 +	C3GPLib_AsyncObserver::doTestStepPostambleL();
  1.2991 +	if( iScheduler )
  1.2992 +		{
  1.2993 +		INFO_PRINTF1(_L("delete iScheduler"));
  1.2994 +		CActiveScheduler::Install(NULL);
  1.2995 +		delete iScheduler;
  1.2996 +		iScheduler = NULL;
  1.2997 +		}
  1.2998 +
  1.2999 +	return TestStepResult();
  1.3000 +	}
  1.3001 +
  1.3002 +TVerdict C3GPLibParser_0045::doTestStepL()
  1.3003 +	{
  1.3004 +	if(TestStepResult() == EPass)
  1.3005 +		{
  1.3006 +		C3GPParse* parser = C3GPParse::NewL();
  1.3007 +		CleanupStack::PushL(parser);
  1.3008 +		
  1.3009 +		TRAPD(err, TestParserWithLargeFileL(parser));
  1.3010 +		if (err != KErrNone)
  1.3011 +			{
  1.3012 +			SetTestStepResult(EFail);
  1.3013 +			}
  1.3014 +		
  1.3015 +		CleanupStack::PopAndDestroy(parser);
  1.3016 +		}
  1.3017 +	return TestStepResult();
  1.3018 +	}
  1.3019 +
  1.3020 +void C3GPLibParser_0045::TestParserWithLargeFileL(C3GPParse* aParser)
  1.3021 +	{
  1.3022 +	INFO_PRINTF1(_L("Test Parser With Large File (>2GB)"));
  1.3023 +	INFO_PRINTF1(_L("Open and complete parser with 64 bit file handle"));
  1.3024 +
  1.3025 +	ParserOpenFileHandle64L(aParser);
  1.3026 +	ParserCompleteHandle64L(aParser);
  1.3027 +	
  1.3028 +	ParserOpenFileHandle64L(aParser, EFileRead | EFileShareReadersOnly);
  1.3029 +	ParserCompleteHandle64L(aParser);
  1.3030 +	
  1.3031 +	ParserOpenFileHandle64L(aParser, EFileShareReadersOrWriters | EFileWrite);
  1.3032 +	ParserCompleteHandle64L(aParser);
  1.3033 +	
  1.3034 +	ParserOpenFileHandle64L(aParser, EFileShareReadersOrWriters | EFileRead);
  1.3035 +	ParserCompleteHandle64L(aParser);
  1.3036 +	
  1.3037 +	ParserOpenFileHandle64L(aParser, EFileShareAny  | EFileWrite);
  1.3038 +	ParserCompleteHandle64L(aParser);
  1.3039 +    
  1.3040 +	ParserOpenFileHandle64L(aParser, EFileShareAny | EFileRead);
  1.3041 +	ParserCompleteHandle64L(aParser);
  1.3042 +
  1.3043 +	INFO_PRINTF1(_L("Test parser with 64 bit file handle"));
  1.3044 +
  1.3045 +	// Read audio/video attributes
  1.3046 +	ParserOpenFileHandle64L(aParser);
  1.3047 +	DoGetVideoAudioAttributesL(aParser);
  1.3048 +	ParserCompleteHandle64L(aParser);
  1.3049 +
  1.3050 +	// Read audio/video frames
  1.3051 +	ParserOpenFileHandle64L(aParser);
  1.3052 +	User::LeaveIfError(DoReadFrame(aParser));
  1.3053 +	ParserCompleteHandle64L(aParser);
  1.3054 +
  1.3055 +	// Asynchronous Read of audio/video frames
  1.3056 +	ParserOpenFileHandle64L(aParser);
  1.3057 +	User::LeaveIfError(DoReadFrameAsync(aParser));
  1.3058 +	if (!ShouldRunOOMTest())
  1.3059 +		{
  1.3060 +		INFO_PRINTF1(_L("C3GPLibParser_0045::ReadFrameAsyncL() using 64 bit file handle"));
  1.3061 +		}
  1.3062 +	ParserCompleteHandle64L(aParser);
  1.3063 +	
  1.3064 +	// Seek positions after any keyframe and immediately after a non-key frame
  1.3065 +	ParserOpenFileHandle64L(aParser);
  1.3066 +	DoSeekTestL(aParser);
  1.3067 +	ParserCompleteHandle64L(aParser);	
  1.3068 +
  1.3069 +	INFO_PRINTF1(_L("Test parser in File path"));
  1.3070 +
  1.3071 +	// Read audio/video attributes
  1.3072 +	ParserOpenFileL(aParser);
  1.3073 +	DoGetVideoAudioAttributesL(aParser);
  1.3074 +	ParserCompleteL(aParser);
  1.3075 +	
  1.3076 +	// Read audio/video frames
  1.3077 +	ParserOpenFileL(aParser);
  1.3078 +	User::LeaveIfError(DoReadFrame(aParser));
  1.3079 +	ParserCompleteL(aParser);
  1.3080 +	
  1.3081 +	// Asynchronous Read of audio/video frames
  1.3082 +	ParserOpenFileL(aParser);
  1.3083 +	User::LeaveIfError(DoReadFrameAsync(aParser));
  1.3084 +	if (!ShouldRunOOMTest())
  1.3085 +		{
  1.3086 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL()"));
  1.3087 +		}
  1.3088 +	ParserCompleteL(aParser);
  1.3089 +
  1.3090 +	ParserOpenFileL(aParser);
  1.3091 +	User::LeaveIfError(DoReadFrameAsync(aParser, ETrue));
  1.3092 +	if (!ShouldRunOOMTest())
  1.3093 +		{
  1.3094 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL(), then cancel the read"));
  1.3095 +		}
  1.3096 +	ParserCompleteL(aParser);
  1.3097 +
  1.3098 +	INFO_PRINTF1(_L("Test parser in CAF"));
  1.3099 +	
  1.3100 +	// Read audio/video attributes
  1.3101 +	ParserOpenCafLC(aParser);
  1.3102 +	DoGetVideoAudioAttributesL(aParser);
  1.3103 +	ParserCompleteCafL(aParser);
  1.3104 +		    
  1.3105 +	// Read audio/video frames
  1.3106 +	ParserOpenCafLC(aParser);
  1.3107 +	User::LeaveIfError(DoReadFrame(aParser));
  1.3108 +	ParserCompleteCafL(aParser);
  1.3109 +	
  1.3110 +	// Asynchronous Read of audio/video frames
  1.3111 +	ParserOpenCafLC(aParser);
  1.3112 +	User::LeaveIfError(DoReadFrameAsync(aParser));
  1.3113 +	if (!ShouldRunOOMTest())
  1.3114 +		{
  1.3115 +		INFO_PRINTF1(_L("C3GPLibParser_0014::ReadFrameAsyncL() using CAF"));
  1.3116 +		}
  1.3117 +	ParserCompleteCafL(aParser);	
  1.3118 +	}
  1.3119 +
  1.3120 +TInt C3GPLibParser_0045::DoReadFrameAsync(C3GPParse* aParser, TBool aCancel)
  1.3121 +	{    
  1.3122 +    TInt err = KErrNone;
  1.3123 +    
  1.3124 +    if (!aCancel)
  1.3125 +    	{
  1.3126 +    	err = ReadAudioVideoFrameAsync(aParser, ETrue);
  1.3127 +    	if (err == KErrNone)
  1.3128 +    		{
  1.3129 +    		err = ReadAudioVideoFrameAsync(aParser, EFalse);
  1.3130 +    		} 
  1.3131 +    	}
  1.3132 +    else
  1.3133 +    	{
  1.3134 +    	err = ReadAudioVideoFrameAsync(aParser, EFalse, ETrue);
  1.3135 +    	}
  1.3136 + 
  1.3137 +    return err;
  1.3138 +    }
  1.3139 +
  1.3140 +// -----------------------------------------------------------------------------
  1.3141 +// Parse video & audio frames from >2GB file synchronously in buffer mode
  1.3142 +// -----------------------------------------------------------------------------
  1.3143 +//
  1.3144 +C3GPLibParser_0047::C3GPLibParser_0047()
  1.3145 +	{	
  1.3146 +	}
  1.3147 +
  1.3148 +TVerdict C3GPLibParser_0047::doTestStepL()
  1.3149 +	{
  1.3150 +	if(TestStepResult() == EPass)
  1.3151 +		{
  1.3152 +		C3GPParse* parser = C3GPParse::NewL();
  1.3153 +		CleanupStack::PushL(parser);
  1.3154 +		
  1.3155 +		TRAPD(err, ReadFrameL(parser));
  1.3156 +		if (err != KErrNone)
  1.3157 +			{
  1.3158 +			SetTestStepResult(EFail);
  1.3159 +			}
  1.3160 +		
  1.3161 +		CleanupStack::PopAndDestroy(parser);
  1.3162 +		}
  1.3163 +	return TestStepResult();
  1.3164 +	}
  1.3165 +
  1.3166 +void C3GPLibParser_0047::ReadFrameL(C3GPParse* aParser)
  1.3167 +	{
  1.3168 +	FileOpen64L();
  1.3169 +	ReadFrameBufferModeL(aParser);
  1.3170 +	FileClose64();
  1.3171 +	}
  1.3172 +	
  1.3173 +// -----------------------------------------------------------------------------
  1.3174 +// Retrieve User Data Atoms with Multiple atoms
  1.3175 +// -----------------------------------------------------------------------------
  1.3176 +//
  1.3177 +_LIT(KAtomFileNamePrefix, "AtomFile");
  1.3178 +
  1.3179 +C3GPUserDataAtomRetrieval::C3GPUserDataAtomRetrieval()
  1.3180 +	{		
  1.3181 +	}
  1.3182 +		
  1.3183 +TVerdict C3GPUserDataAtomRetrieval::doTestStepL()
  1.3184 +	{
  1.3185 +	// ensure test step error & result reset before each test
  1.3186 +	if (TestStepResult() != EPass)
  1.3187 +		{
  1.3188 +		return TestStepResult();
  1.3189 +		}
  1.3190 +	SetTestStepError(KErrNone);
  1.3191 +		
  1.3192 +	C3GPParse* parser = C3GPParse::NewL();
  1.3193 +	CleanupStack::PushL(parser);
  1.3194 +
  1.3195 +	if (iLargeFile)
  1.3196 +		{
  1.3197 +		User::LeaveIfError(parser->Open(iInputFile64));		
  1.3198 +		}
  1.3199 +	else
  1.3200 +		{
  1.3201 +		User::LeaveIfError(parser->Open(iInputFile));		
  1.3202 +		}
  1.3203 +	
  1.3204 +	TBool keepLooking = ETrue;
  1.3205 +	TInt atomFound = 0;
  1.3206 +	TInt atomSize = 0;
  1.3207 +	TUint atomIndex = 0;
  1.3208 +	TUint atomHighestIndex1 = 0;
  1.3209 +	TUint atomHighestIndex2 = 0;
  1.3210 +	TInt err = KErrNone;
  1.3211 +	RFile atomFile;
  1.3212 +	RBuf8 atomContent;
  1.3213 +	RBuf8 fileContent;
  1.3214 +	CleanupClosePushL(fileContent);	
  1.3215 +	CleanupClosePushL(atomFile);
  1.3216 +	CleanupClosePushL(atomContent);		
  1.3217 +	
  1.3218 +	while(keepLooking && err == KErrNone)
  1.3219 +		{
  1.3220 +		TInt atomIndexInput = atomIndex;
  1.3221 +		err = parser->GetUserDataAtomSize(iAtomType, iAtomLocation, atomIndex, atomSize);
  1.3222 +		if (err == KErrNone)
  1.3223 +			{
  1.3224 +			atomHighestIndex1 = atomIndex;
  1.3225 +			atomIndex = atomIndexInput;
  1.3226 +			atomContent.CreateL(atomSize);
  1.3227 +			
  1.3228 +			err = parser->GetUserDataAtom(iAtomType, iAtomLocation, atomContent, atomIndex);
  1.3229 +			if (err == KErrNone)
  1.3230 +				{
  1.3231 +				if (atomFound == 0)
  1.3232 +					{
  1.3233 +					// remember the highest atom index found during first run
  1.3234 +					atomHighestIndex2 = atomIndex;
  1.3235 +					if (atomHighestIndex1 != atomHighestIndex2)
  1.3236 +						{
  1.3237 +						if (!ShouldRunOOMTest())
  1.3238 +							{
  1.3239 +							ERR_PRINTF1(_L("Highest Atom Index returned is different when calling GetUserDataAtomSize vs GetUserDataAtom"));							
  1.3240 +							}
  1.3241 +						}
  1.3242 +					}
  1.3243 +				atomFound++;
  1.3244 +				
  1.3245 +				User::LeaveIfError(atomFile.Open(iFs, (*iAtomFileArray)[atomIndexInput], EFileRead | EFileStream));
  1.3246 +				TInt fileSize = 0;
  1.3247 +				User::LeaveIfError(atomFile.Size(fileSize));
  1.3248 +				if (atomContent.Size() != fileSize)
  1.3249 +					{
  1.3250 +					if (!ShouldRunOOMTest())
  1.3251 +						{
  1.3252 +						ERR_PRINTF4(_L("Atom %d retrieved is of different size as expected.  Expected=%d Retrieved=%d"), atomIndexInput, fileSize, atomContent.Size());							
  1.3253 +						}
  1.3254 +					SetTestStepResult(EFail);			
  1.3255 +					keepLooking = EFalse;					
  1.3256 +					}
  1.3257 +				else
  1.3258 +					{
  1.3259 +					fileContent.CreateL(fileSize);
  1.3260 +					User::LeaveIfError(atomFile.Read(fileContent));
  1.3261 +					if (fileContent != atomContent)	
  1.3262 +						{
  1.3263 +						if (!ShouldRunOOMTest())
  1.3264 +							{						
  1.3265 +							ERR_PRINTF4(_L("Atom %d retrieved is of different content.  Expected=%S Retrieved=%S"), atomIndexInput, &fileContent, &atomContent);						
  1.3266 +							}
  1.3267 +						SetTestStepResult(EFail);			
  1.3268 +						keepLooking = EFalse;
  1.3269 +						}
  1.3270 +					else
  1.3271 +						{
  1.3272 +						if (atomIndex != atomHighestIndex2)	
  1.3273 +							{
  1.3274 +							// seems like there's an error occurred, as the highest index for this atom
  1.3275 +							// type should stay the same throughout
  1.3276 +							keepLooking = EFalse;
  1.3277 +							if (!ShouldRunOOMTest())
  1.3278 +								{							
  1.3279 +								ERR_PRINTF3(_L("Previous highest atom index is %d but now it is %d.  Data inconsistency."), atomHighestIndex2, atomIndex);
  1.3280 +								}
  1.3281 +							SetTestStepResult(EFail);
  1.3282 +							}
  1.3283 +						else
  1.3284 +							{
  1.3285 +							// look for the next atom of the same type now	
  1.3286 +							atomIndex = atomIndexInput + 1;
  1.3287 +							}	
  1.3288 +						} 
  1.3289 +					fileContent.Close();	
  1.3290 +					}	
  1.3291 +				atomFile.Close();	
  1.3292 +				}
  1.3293 +			else
  1.3294 +				{
  1.3295 +				if (!ShouldRunOOMTest())
  1.3296 +					{				
  1.3297 +					ERR_PRINTF4(_L("Fail to get user atom: index = %d, location = %d, type = %d"), atomIndex, iAtomLocation, iAtomType);
  1.3298 +					}
  1.3299 +				User::Leave(err);
  1.3300 +				}	
  1.3301 +				
  1.3302 +			atomContent.Close();					
  1.3303 +			}			
  1.3304 +		}
  1.3305 +	if (TestStepResult() == EPass && atomFound != iExpectedNumAtom && atomFound == (atomHighestIndex2 + 1))	
  1.3306 +		{
  1.3307 +		if (!ShouldRunOOMTest())
  1.3308 +			{		
  1.3309 +			ERR_PRINTF3(_L("Number of atoms found (%d) does not match expected # of atoms (%d)."), atomFound, iExpectedNumAtom);
  1.3310 +			}
  1.3311 +		SetTestStepResult(EFail);	
  1.3312 +		}	
  1.3313 +		
  1.3314 +	CleanupStack::PopAndDestroy(&atomContent);
  1.3315 +	CleanupStack::PopAndDestroy(&atomFile);
  1.3316 +	CleanupStack::PopAndDestroy(&fileContent);
  1.3317 +	
  1.3318 +	parser->Complete();
  1.3319 +		
  1.3320 +	CleanupStack::PopAndDestroy(parser);				
  1.3321 +	return TestStepResult();
  1.3322 +	}
  1.3323 +	
  1.3324 +TVerdict C3GPUserDataAtomRetrieval::doTestStepPreambleL()
  1.3325 +	{	
  1.3326 +	SetTestStepResult(ETestSuiteError);					
  1.3327 +
  1.3328 + 	#ifdef __WINSCW__
  1.3329 + 	_LIT(KFileToParse, "FileToParseEmu");
  1.3330 + 	#else
  1.3331 + 	_LIT(KFileToParse, "FileToParseHw");
  1.3332 + 	#endif		
  1.3333 +	
  1.3334 +	TPtrC inputFilename;
  1.3335 +	if (!GetStringFromConfig(ConfigSection(), KFileToParse, inputFilename))
  1.3336 +		{
  1.3337 +		// file need to be specified
  1.3338 +		ERR_PRINTF1(_L("Specify the file to be parsed."));
  1.3339 +		return TestStepResult();
  1.3340 +		}
  1.3341 +	
  1.3342 +	if (!GetBoolFromConfig(ConfigSection(), _L("largeFile"), iLargeFile))
  1.3343 +		{
  1.3344 +		ERR_PRINTF1(_L("Specify whether the file is larger than 2GB."));
  1.3345 +		return TestStepResult();
  1.3346 +		}
  1.3347 +		
  1.3348 +	User::LeaveIfError(iFs.Connect());			
  1.3349 +	if (iLargeFile)
  1.3350 +		{
  1.3351 +		User::LeaveIfError(iInputFile64.Open(iFs, inputFilename, EFileRead | EFileStream | EFileShareReadersOnly));
  1.3352 +		}
  1.3353 +	else
  1.3354 +		{
  1.3355 +		User::LeaveIfError(iInputFile.Open(iFs, inputFilename, EFileRead | EFileStream | EFileShareReadersOnly));		
  1.3356 +		}
  1.3357 +	
  1.3358 +	if (!GetIntFromConfig(ConfigSection(), _L("ExpectedNumOfAtom"), iExpectedNumAtom))
  1.3359 +		{
  1.3360 +		// Number of expected number of atoms needs to be specified
  1.3361 +		ERR_PRINTF1(_L("Specify the number of atoms to be expected."));
  1.3362 +		return TestStepResult();
  1.3363 +		}
  1.3364 +	
  1.3365 +	iAtomFileArray = new CDesCArrayFlat(4);	
  1.3366 +	TInt temp;
  1.3367 +	if (!GetIntFromConfig(ConfigSection(), _L("AtomType"), temp))
  1.3368 +		{
  1.3369 +		// atom type to retrieve needs to be specified
  1.3370 +		ERR_PRINTF1(_L("Specify the atoms type to be retrieved."));
  1.3371 +		return TestStepResult();
  1.3372 +		}
  1.3373 +	else
  1.3374 +		{
  1.3375 +		iAtomType = (TUint32) temp;	
  1.3376 +		}
  1.3377 +		
  1.3378 +	if (!GetIntFromConfig(ConfigSection(), _L("AtomLocation"), temp))		
  1.3379 +		{
  1.3380 +		// atom location to retrieve needs to be specified
  1.3381 +		ERR_PRINTF1(_L("Specify the atoms location for the atoms to be retrieved."));
  1.3382 +		return TestStepResult();
  1.3383 +		}
  1.3384 +	else
  1.3385 +		{
  1.3386 +		iAtomLocation = (T3GPUdtaLocation) temp;					
  1.3387 +		}
  1.3388 +
  1.3389 +	if (iExpectedNumAtom > 0)
  1.3390 +		{
  1.3391 +		TBuf<50> keyName;	
  1.3392 +		TPtrC fileName;		
  1.3393 +		for (TInt i = 1; i <= iExpectedNumAtom; i++)	
  1.3394 +			{
  1.3395 +			keyName.Zero();
  1.3396 +			keyName.AppendFormat(_L("%S%d"), &KAtomFileNamePrefix, i);			
  1.3397 +
  1.3398 +			if (!GetStringFromConfig(ConfigSection(), keyName, fileName))
  1.3399 +				{
  1.3400 +				// atom content file needs to be specified
  1.3401 +				ERR_PRINTF1(_L("Specify the file name that contents the matching atom content."));
  1.3402 +				return TestStepResult();					
  1.3403 +				}
  1.3404 +			
  1.3405 +			iAtomFileArray->AppendL(fileName);
  1.3406 +			}		
  1.3407 +		}
  1.3408 +		
  1.3409 +	SetTestStepResult(EPass);							
  1.3410 +	return TestStepResult();
  1.3411 +	}
  1.3412 +		
  1.3413 +TVerdict C3GPUserDataAtomRetrieval::doTestStepPostambleL()
  1.3414 +	{
  1.3415 +	if (iAtomFileArray)
  1.3416 +		{
  1.3417 +		iAtomFileArray->Reset();
  1.3418 +		delete iAtomFileArray;			
  1.3419 +		}
  1.3420 +	
  1.3421 +	if (iLargeFile)
  1.3422 +		{	
  1.3423 +		iInputFile64.Close();		
  1.3424 +		}
  1.3425 +	else
  1.3426 +		{
  1.3427 +		iInputFile.Close();		
  1.3428 +		}
  1.3429 +	iFs.Close();
  1.3430 +	
  1.3431 +	return TestStepResult();
  1.3432 +	}