os/mm/mmdevicefw/mdfunittest/codecapi/video/src/videoplayfile_cov.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <mmf/devvideo/videoplayhwdevice.h>
    17 #include <mmf/server/mmfdatabuffer.h>
    18 #include "videoplayfile_cov.h"
    19 
    20 #include "../../PU/video/src/Plugin/VideoTestDecoderPU/videotestdecoderpu.hrh"
    21 #include "../../PU/video/src/Plugin/VideoTestEncoderPU/videotestencoderpu.hrh"
    22 
    23 const TInt KInputBufferSize = 8192;
    24 const TInt KFilePositionZero = 0;
    25 const TInt KTBufSize = 256;
    26 const TInt KTRegionFixSize = 1;
    27 const TInt64 KInterval=2184;
    28 const TInt KVideoDecoderMaxDataBufferSize = 0x40000;
    29 const TUint KMinInputBuffers=2;
    30 _LIT8(KMime,"video/x-symbiantest");
    31 _LIT8(KBlank,"");
    32 
    33 
    34 // **************************************************
    35 // instructs the Hw Device Adapter to play a file	
    36 // **************************************************
    37 CPlayVideoFileCov::CPlayVideoFileCov(RTestStepVideoCodecs* aParent) : 
    38 	CActive(EPriorityNormal),
    39 	iState(EHwDeviceInit),
    40 	iParent(aParent)
    41 	{
    42 	}
    43 
    44 void  CPlayVideoFileCov::ConstructL()
    45 	{
    46 	CActiveScheduler::Add(this);
    47 	User::LeaveIfError(RFbsSession::Connect());
    48 
    49 	TInt err = KErrNone;
    50 	TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(_L(""),EColor16MA));
    51 	if (err == KErrNotSupported)
    52 		{
    53 		TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(_L(""),EColor16M));
    54 		}
    55 	if (err == KErrNotSupported)
    56 		{
    57 		TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(_L(""),EColor64K));
    58 		}
    59 	if (err == KErrNotSupported)
    60 		{
    61 		TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(_L(""),EColor4K));
    62 		}
    63 	if (err == KErrNotSupported)
    64 		{
    65 		TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(_L(""),EColor256));
    66 		}
    67 	if (err == KErrNotSupported)
    68 		{
    69 		iScreenDevice = CFbsScreenDevice::NewL(_L(""),EColor16MAP);
    70 		}	
    71 	else
    72 		{
    73 		User::LeaveIfError(err);		
    74 		}
    75 	}
    76 
    77 CPlayVideoFileCov* CPlayVideoFileCov::NewL(RTestStepVideoCodecs* aParent)
    78 	{
    79 	CPlayVideoFileCov* self = new (ELeave) CPlayVideoFileCov(aParent);
    80 	CleanupStack::PushL(self);
    81 	self->ConstructL();
    82 	CleanupStack::Pop(self);
    83 	return self;
    84 	}
    85 	
    86 	
    87 void CPlayVideoFileCov::DoCancel()
    88 	{
    89 	}
    90 
    91 CPlayVideoFileCov::~CPlayVideoFileCov()
    92 	{
    93 	iFile.Close();
    94 	iFs.Close();
    95 	
    96 	delete iVideoHwDevice;
    97 	delete iScreenDevice;
    98 	RFbsSession::Disconnect();
    99 	}
   100 	
   101 	
   102 void CPlayVideoFileCov::LoadCodecL()	
   103 	{
   104 	iParent->InfoMessage(_L("Loading Hw Device Adapter and PU Codec"));
   105 
   106 	RImplInfoPtrArray array;
   107 	REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), array);
   108 	TBool found = EFalse;
   109 	CImplementationInformation* info = NULL;
   110 	for (TInt i=0;i<array.Count() && !found;i++)
   111 		{
   112 		info = array[i];
   113 		if (info->ImplementationUid() == TUid::Uid(KUidVideoTestDecoderPu))
   114 			{
   115 			found = ETrue;
   116 			}
   117 		}
   118 	TInt err = KErrNotFound;
   119 	if (found)
   120 		{
   121 		TRAP(err, iVideoHwDevice = CMMFVideoDecodeHwDevice::NewPuAdapterL(*info,*this));
   122 		}
   123 	else
   124 		{
   125 		err = KErrNotFound;
   126 		}
   127 	CVideoDecoderInfo* vInfo=NULL;
   128 	iParent->InfoMessage(_L("VideoDecoderInfoLC"));
   129 	TRAP(iError, vInfo=iVideoHwDevice->VideoDecoderInfoLC(); CleanupStack::Pop(vInfo) );
   130 	if (iError!=KErrNone)
   131 		{
   132 		iParent->InfoMessage(_L("VideoDecoderInfoLC Failed"));
   133 		SetState(EHwDeviceError);
   134 		}
   135 	delete vInfo;
   136 	CCompressedVideoFormat* format=CCompressedVideoFormat::NewL(KMime);
   137 	TVideoDataUnitType dataUnitType=EDuCodedPicture;
   138 	TVideoDataUnitEncapsulation encapsulation=EDuElementaryStream;
   139 	TBool dataInOrder=ETrue;
   140 	iParent->InfoMessage(_L("SetInputFormatL"));
   141 	TRAP(iError, iVideoHwDevice->SetInputFormatL(*format,dataUnitType,encapsulation,dataInOrder));
   142 	if (iError!=KErrNone)
   143 		{
   144 		iParent->InfoMessage(_L("SetInputFormatL Failed"));
   145 		SetState(EHwDeviceError);
   146 		}
   147 	//Negative test case for  SetInputFormatL
   148 	CCompressedVideoFormat* format2=CCompressedVideoFormat::NewL(KBlank);
   149 	TRAP(iError, iVideoHwDevice->SetInputFormatL(*format2,dataUnitType,encapsulation,dataInOrder));
   150 	if (iError!=KErrNotSupported)
   151 		{
   152 		iParent->InfoMessage(_L("SetInputFormatL Failed"));
   153 		SetState(EHwDeviceError);
   154 		}
   155 	delete format2;
   156 	//Negative test case for SetInputFormatL
   157 	dataUnitType=EDuVideoSegment;
   158 	TRAP(iError, iVideoHwDevice->SetInputFormatL(*format,dataUnitType,encapsulation,dataInOrder));
   159 	if (iError!=KErrNotSupported)
   160 		{
   161 		iParent->InfoMessage(_L("SetInputFormatL Failed"));
   162 		SetState(EHwDeviceError);
   163 		}
   164 	//Negative test case for SetInputFormatL
   165 	dataUnitType=EDuCodedPicture;
   166 	encapsulation=EDuGenericPayload;
   167 	TRAP(iError, iVideoHwDevice->SetInputFormatL(*format,dataUnitType,encapsulation,dataInOrder));
   168 	if (iError!=KErrNotSupported)
   169 		{
   170 		iParent->InfoMessage(_L("SetInputFormatL Failed"));
   171 		SetState(EHwDeviceError);
   172 		}
   173 	//Negative test case for SetInputFormatL
   174 	encapsulation=EDuElementaryStream;
   175 	dataInOrder=EFalse;
   176 	TRAP(iError, iVideoHwDevice->SetInputFormatL(*format,dataUnitType,encapsulation,dataInOrder));
   177 	if (iError!=KErrNotSupported)
   178 		{
   179 		iParent->InfoMessage(_L("SetInputFormatL Failed"));
   180 		SetState(EHwDeviceError);
   181 		}
   182 	delete format;
   183 	array.ResetAndDestroy();
   184 	User::LeaveIfError(err);
   185 
   186 	}
   187 	
   188 void CPlayVideoFileCov::SetDSA(TBool aUseDSA)	
   189 	{
   190 	// Need new version of this to load from a PU based uid
   191 	iUseDSA = aUseDSA;
   192 	}
   193 	
   194 void CPlayVideoFileCov::StartPlaybackL()	
   195 	{
   196 	OpenTestFileL();
   197 	SetState(EHwDeviceInit);
   198 	CActiveScheduler::Start();
   199 	}
   200 
   201 void CPlayVideoFileCov::SetState(TPlayVideoFileState aState)
   202 	{
   203 	iState = aState;
   204 	SetActive();	
   205 	TRequestStatus* status = &iStatus;
   206 	User::RequestComplete(status, KErrNone);	
   207 	}
   208 
   209 void CPlayVideoFileCov::OpenTestFileL()
   210 	{
   211 	TBuf<KTBufSize> buf;
   212 	buf.Format(_L("Opening test input file %S"), &KTestPlaybackFile);
   213 	iParent->InfoMessage(buf);
   214 	User::LeaveIfError(iFs.Connect());
   215 	User::LeaveIfError(iFile.Open(iFs, KTestPlaybackFile, EFileRead));
   216 	}
   217 
   218 void CPlayVideoFileCov::RunL()
   219  	{
   220 	switch (iState)
   221 		{
   222 		case EHwDeviceInit:
   223 			{
   224 			iParent->InfoMessage(_L("State: EHwDeviceInit"));
   225 			TRAPD(err, InitializeL());
   226 			if (err != KErrNone)
   227 				{
   228 				CleanupAndSetDeviceError(_L("Cannot intialize HwDevice"));
   229 				break;
   230 				}
   231 			break;
   232 			}
   233 		case EHwDeviceStartDecode:
   234 			{
   235 			// if we are playing a file, first we have to open the file
   236 			iParent->InfoMessage(_L("State: EHwDeviceStartDecode"));
   237 			TRAPD(err, StartDecodeL());
   238 			if (err != KErrNone)
   239 				{
   240 				CleanupAndSetDeviceError(_L("Cannot start decoding"));
   241 				break;
   242 				}
   243 			break;
   244 			}
   245 		case EHwDeviceAllowToComplete:
   246 			iParent->InfoMessage(_L("State: EHwDeviceAllowToComplete"));
   247 			break;
   248 		case EHwDeviceDone:
   249 			{
   250 			iParent->InfoMessage(_L("State: EHwDeviceDeviceDone"));
   251 			Cancel();
   252 			CActiveScheduler::Stop();
   253 			break;
   254 			}				
   255 		case EHwDeviceError:
   256 			{
   257 			TBuf<KTBufSize> buf;
   258 			buf.Format(_L("State: EHwDeviceDeviceError %d"), iError);
   259 			iParent->SetVerdict(buf, EFail);
   260 			
   261 			CActiveScheduler::Stop();
   262 			break;
   263 			}
   264 		default:
   265 			{
   266 			CleanupAndSetDeviceError(_L("Unknown CPlayVideoFileCov iState"));
   267 			break;
   268 			}
   269 		}
   270 	}
   271 	
   272 	
   273 void CPlayVideoFileCov::InitializeL()
   274 	{
   275 	iParent->InfoMessage(_L("InitializeL()"));
   276 
   277 	CMMFDevVideoPlay::TBufferOptions bufferOptions;
   278 	bufferOptions.iMaxInputBufferSize=0x40000;
   279 	iVideoHwDevice->SetBufferOptionsL(bufferOptions);
   280 	
   281 	TTimeIntervalMicroSeconds Interval(KInterval);
   282 	iVideoHwDevice->SetPosition(Interval);
   283 	
   284 	CMMFDevVideoPlay::TBitstreamCounters bitstreamCounters;
   285 	iVideoHwDevice->GetBitstreamCounters(bitstreamCounters);
   286 
   287 	CMMFDevVideoPlay::TBufferOptions Options;
   288 	Options.iMaxInputBufferSize=0x40000;
   289 	iVideoHwDevice->SetBufferOptionsL(Options);
   290 	
   291 	CMMFDevVideoPlay::TBitstreamCounters Counters;
   292 	iVideoHwDevice->GetBitstreamCounters(Counters);
   293 	
   294 	TUint complexityLevel=1;
   295 	iParent->InfoMessage(_L("SetComplexityLevel"));
   296 	TRAP(iError, iVideoHwDevice->SetComplexityLevel(complexityLevel) );
   297 	if (iError!=KErrNone)
   298 		{
   299 		iParent->InfoMessage(_L("SetComplexityLevel Failed"));
   300 		SetState(EHwDeviceError);
   301 		}
   302 	THrdVbvSpecification HrdVbvSpec=EHrdVbvNone;
   303 	iParent->InfoMessage(_L("SetHrdVbvSpec"));
   304 	TRAP(iError, iVideoHwDevice->SetHrdVbvSpec(HrdVbvSpec,KBlank) );
   305 	if (iError!=KErrNone)
   306 		{
   307 		iParent->InfoMessage(_L("SetHrdVbvSpec Failed"));
   308 		SetState(EHwDeviceError);
   309 		}
   310 	TRect rect;
   311 	iParent->InfoMessage(_L("SetInputCropOptionsL"));
   312 	TRAP(iError, iVideoHwDevice->SetInputCropOptionsL(rect) );
   313 	if (iError!=KErrNotSupported)
   314 		{
   315 		iParent->InfoMessage(_L("SetInputCropOptionsL Failed"));
   316 		SetState(EHwDeviceError);
   317 		}
   318 	iParent->InfoMessage(_L("SetOutputCropOptionsL"));
   319 	TRAP(iError, iVideoHwDevice->SetOutputCropOptionsL(rect) );
   320 	if (iError!=KErrNotSupported)
   321 		{
   322 		iParent->InfoMessage(_L("SetOutputCropOptionsL Failed"));
   323 		SetState(EHwDeviceError);
   324 		}
   325 	iParent->InfoMessage(_L("SetPauseOnClipFail"));
   326 	TRAP(iError, iVideoHwDevice->SetPauseOnClipFail(ETrue) );
   327 	if (iError!=KErrNone)
   328 		{
   329 		iParent->InfoMessage(_L("SetPauseOnClipFail Failed"));
   330 		SetState(EHwDeviceError);
   331 		}
   332 	iParent->InfoMessage(_L("SetPostProcessTypesL"));
   333 	TRAP(iError, iVideoHwDevice->SetPostProcessTypesL(ETrue) );
   334 	if (iError!=KErrNotSupported)
   335 		{
   336 		iParent->InfoMessage(_L("SetPostProcessTypesL Failed"));
   337 		SetState(EHwDeviceError);
   338 		}
   339 	iParent->InfoMessage(_L("SetPostProcSpecificOptionsL"));
   340 	TRAP(iError, iVideoHwDevice->SetPostProcSpecificOptionsL(KBlank) );
   341 	if (iError!=KErrNotSupported)
   342 		{
   343 		iParent->InfoMessage(_L("SetPostProcSpecificOptionsL Failed"));
   344 		SetState(EHwDeviceError);
   345 		}
   346 	TRotationType rotType=ERotate90Clockwise;
   347 	iParent->InfoMessage(_L("SetRotateOptionsL"));
   348 	TRAP(iError, iVideoHwDevice->SetRotateOptionsL(rotType) );
   349 	if (iError!=KErrNotSupported)
   350 		{
   351 		iParent->InfoMessage(_L("SetRotateOptionsL Failed"));
   352 		SetState(EHwDeviceError);
   353 		}
   354 	TSize size(12,30);
   355 	iParent->InfoMessage(_L("SetScaleOptionsL"));
   356 	TRAP(iError, iVideoHwDevice->SetScaleOptionsL(size,ETrue) );
   357 	if (iError!=KErrNotSupported)
   358 		{
   359 		iParent->InfoMessage(_L("SetScaleOptionsL Failed"));
   360 		SetState(EHwDeviceError);
   361 		}
   362 	TYuvToRgbOptions YuvOption;
   363 	
   364 	iParent->InfoMessage(_L("SetYuvToRgbOptionsL"));
   365 	TRAP(iError, iVideoHwDevice->SetYuvToRgbOptionsL(YuvOption) );
   366 	if (iError!=KErrNotSupported)
   367 		{
   368 		iParent->InfoMessage(_L("SetYuvToRgbOptionsL Failed"));
   369 		SetState(EHwDeviceError);
   370 		}
   371 	TYuvFormat YuvFormat;
   372 	TRgbFormat RgbFormat=ERgb16bit444;
   373 	iParent->InfoMessage(_L("SetYuvToRgbOptionsL"));
   374 	TRAP(iError, iVideoHwDevice->SetYuvToRgbOptionsL(YuvOption,YuvFormat,RgbFormat) );
   375 	if (iError!=KErrNotSupported)
   376 		{
   377 		iParent->InfoMessage(_L("SetYuvToRgbOptionsL Failed"));
   378 		SetState(EHwDeviceError);
   379 		}
   380 	CMMFVideoPostProcHwDevice *outDevice = NULL;
   381 	iParent->InfoMessage(_L("SetOutputDevice"));
   382 	TRAP(iError, iVideoHwDevice->SetOutputDevice(outDevice) );
   383 	if (iError!=KErrNone)
   384 		{
   385 		iParent->InfoMessage(_L("SetOutputDevice Failed"));
   386 		SetState(EHwDeviceError);
   387 		}
   388 	
   389 	TVideoPictureHeader  videoPictureHeader;
   390 	iParent->InfoMessage(_L("ConfigureDecoderL"));
   391 	TRAP(iError, iVideoHwDevice->ConfigureDecoderL(videoPictureHeader) );
   392 	if (iError!=KErrNotSupported)
   393 		{
   394 		iParent->InfoMessage(_L("ConfigureDecoderL Failed"));
   395 		SetState(EHwDeviceError);
   396 		}
   397 	TUncompressedVideoFormat reqFormat;
   398 		
   399 	reqFormat.iDataFormat = ERgbFbsBitmap;
   400 	reqFormat.iRgbFormat = EFbsBitmapColor16M;
   401 	
   402 	RArray<TUncompressedVideoFormat> decodeFormats;
   403 	iVideoHwDevice->GetOutputFormatListL(decodeFormats);
   404 	CleanupClosePushL(decodeFormats);
   405 	User::LeaveIfError(decodeFormats.Find(reqFormat));
   406 
   407 	iParent->InfoMessage(_L("Call VideoHwDevice->SetOutputFormat()"));
   408 	iVideoHwDevice->SetOutputFormatL(reqFormat);
   409 	CleanupStack::PopAndDestroy(&decodeFormats);	
   410 	
   411 	CMMFDescriptorBuffer* buffer = CMMFDescriptorBuffer::NewL(KInputBufferSize);
   412 	CleanupStack::PushL(buffer);
   413 	TVideoInputBuffer inputBuffer;
   414 	
   415 	TDes8& des = buffer->Data();
   416 	// read header data from file
   417 	User::LeaveIfError(iFile.Read(des));
   418 	TInt pos = KFilePositionZero;
   419 	// seek back to start
   420 	User::LeaveIfError(iFile.Seek(ESeekStart, pos));
   421 
   422 	TBuf<KTBufSize> buf;
   423 	buf.Format(_L("Read header of size %d"),inputBuffer.iData.Length());
   424 	iParent->InfoMessage(buf);
   425 	
   426 	if (des.Length()>0)
   427 		{
   428 		// Set the pointer
   429 		inputBuffer.iData.Set(&des[0],des.Length(),des.MaxLength());
   430 		
   431 		iParent->InfoMessage(_L("Call VideoHwDevice GetHeaderInformationL()"));
   432 		TVideoPictureHeader* header = iVideoHwDevice->GetHeaderInformationL(EDuArbitraryStreamSection, 
   433 												EDuElementaryStream,
   434 												&inputBuffer);
   435 		TVideoPictureHeader* header2 =NULL;
   436 		//Call ReturnHeader for negative test
   437 		iVideoHwDevice->ReturnHeader(header2);
   438 		iFrameSize = header->iSizeInMemory;
   439 		iVideoHwDevice->ReturnHeader(header);
   440 		}
   441 	else
   442 		{
   443 		// Cannot read any data from file, so no point in continuing
   444 		User::Leave(KErrCorrupt);
   445 		}
   446 		
   447 	CleanupStack::PopAndDestroy(buffer);	
   448 	
   449 	iParent->InfoMessage(_L("Call VideoHwDevice SetVideoDestScreenL()"));
   450 	iVideoHwDevice->SetVideoDestScreenL(iUseDSA);
   451 	
   452 	iParent->InfoMessage(_L("Call VideoHwDevice->Initialize()"));
   453 	iVideoHwDevice->Initialize();
   454 	}
   455 	
   456 	
   457 void CPlayVideoFileCov::StartDecodeL()
   458 	{
   459 	iParent->InfoMessage(_L("SynchronizeDecoding"));
   460 	TRAP(iError, iVideoHwDevice->SynchronizeDecoding(ETrue) );
   461 	if (iError!=KErrNone)
   462 		{
   463 		iParent->InfoMessage(_L("SynchronizeDecoding Failed"));
   464 		SetState(EHwDeviceError);
   465 		}
   466 	iParent->InfoMessage(_L("StartDecodeL()"));
   467 
   468 	if (iUseDSA)
   469 		{
   470 		StartDirectScreenAccessL();
   471 		}
   472 	// tell the HwDeviceAdapter to play the file
   473 	iParent->InfoMessage(_L("Call VideoHwDevice->Start()"));
   474 	iVideoHwDevice->Start();
   475 	CSystemClockSource *time1= NULL;
   476 	
   477 	iParent->InfoMessage(_L("SetClockSource"));
   478 	TRAP(iError, iVideoHwDevice->SetClockSource(time1) );
   479 	if (iError!=KErrNone)
   480 		{
   481 		iParent->InfoMessage(_L("SetClockSource Failed"));
   482 		SetState(EHwDeviceError);
   483 		}
   484 	
   485 	delete time1;
   486 	iVideoHwDevice->PictureBufferBytes();
   487 	CMMFDevVideoPlay::TComplexityLevelInfo aInfo;
   488 	iVideoHwDevice->GetComplexityLevelInfo(0,aInfo);
   489 	//Call GetComplexityLevelInfo for False condition coverage
   490 	iVideoHwDevice->GetComplexityLevelInfo(1,aInfo);
   491 	iVideoHwDevice->IsPlaying();
   492 	CMMFDevVideoPlay::TPictureCounters PictureCounters;
   493 	iParent->InfoMessage(_L("GetPictureCounters"));
   494 	TRAP(iError, iVideoHwDevice->GetPictureCounters(PictureCounters) );
   495 	if (iError!=KErrNone)
   496 		{
   497 		iParent->InfoMessage(_L("GetPictureCounters Failed"));
   498 		SetState(EHwDeviceError);
   499 		}
   500 	TPictureData PictureData;
   501 	TUncompressedVideoFormat UncomprossedVideoFormat;
   502 	iParent->InfoMessage(_L("GetSnapshotL"));
   503 	TRAP(iError, iVideoHwDevice->GetSnapshotL(PictureData,UncomprossedVideoFormat) );
   504 	if (iError!=KErrNotSupported)
   505 		{
   506 		iParent->InfoMessage(_L("GetSnapshotL Failed"));
   507 		SetState(EHwDeviceError);
   508 		}
   509 	CMMFDevVideoPlay::TBufferOptions bufferOptions;
   510 	iVideoHwDevice->GetBufferOptions(bufferOptions);
   511 	iVideoHwDevice->NumComplexityLevels();
   512 
   513 	iParent->InfoMessage(_L("NumFreeBuffers"));
   514 	TRAP(iError, iVideoHwDevice->NumFreeBuffers() );
   515 	if (iError!=KErrNone)
   516 		{
   517 		iParent->InfoMessage(_L("NumFreeBuffers Failed"));
   518 		SetState(EHwDeviceError);
   519 		}
   520 	iParent->InfoMessage(_L("PlaybackPosition"));
   521 	TRAP(iError, iVideoHwDevice->PlaybackPosition() );
   522 	if (iError!=KErrNone)
   523 		{
   524 		iParent->InfoMessage(_L("PlaybackPosition Failed"));
   525 		SetState(EHwDeviceError);
   526 		}
   527 	iParent->InfoMessage(_L("DecodingPosition"));
   528 	TRAP(iError, iVideoHwDevice->DecodingPosition() );
   529 	if (iError!=KErrNone)
   530 		{
   531 		iParent->InfoMessage(_L("DecodingPosition Failed"));
   532 		SetState(EHwDeviceError);
   533 		}
   534 	iParent->InfoMessage(_L("Redraw"));
   535 	TRAP(iError, iVideoHwDevice->Redraw() );
   536 	if (iError!=KErrNone)
   537 		{
   538 		iParent->InfoMessage(_L("Redraw Failed"));
   539 		SetState(EHwDeviceError);
   540 		}
   541 	iParent->InfoMessage(_L("AbortDirectScreenAccess"));
   542 	TRAP(iError, iVideoHwDevice->AbortDirectScreenAccess() );
   543 	if (iError!=KErrNone)
   544 		{
   545 		iParent->InfoMessage(_L("AbortDirectScreenAccess Failed"));
   546 		SetState(EHwDeviceError);
   547 		}
   548 	iParent->InfoMessage(_L("CommitL"));
   549 	TRAP(iError, iVideoHwDevice->CommitL() );
   550 	if (iError!=KErrNotSupported)
   551 		{
   552 		iParent->InfoMessage(_L("CommitL Failed"));
   553 		SetState(EHwDeviceError);
   554 		}
   555 	TTimeIntervalMicroSeconds Timestamp;
   556 	iParent->InfoMessage(_L("FreezePicture"));
   557 	TRAP(iError, iVideoHwDevice->FreezePicture(Timestamp) );
   558 	if (iError!=KErrNone)
   559 		{
   560 		iParent->InfoMessage(_L("FreezePicture Failed"));
   561 		SetState(EHwDeviceError);
   562 		}
   563 	iParent->InfoMessage(_L("PostProcessorInfoLC"));
   564 	TRAP(iError, iVideoHwDevice->PostProcessorInfoLC() );
   565 	if (iError!=KErrNone)
   566 		{
   567 		iParent->InfoMessage(_L("PostProcessorInfoLC Failed"));
   568 		SetState(EHwDeviceError);
   569 		}
   570 	iParent->InfoMessage(_L("PreDecoderBufferBytes"));
   571 	TRAP(iError, iVideoHwDevice->PreDecoderBufferBytes() );
   572 	if (iError!=KErrNone)
   573 		{
   574 		iParent->InfoMessage(_L("PreDecoderBufferBytes Failed"));
   575 		SetState(EHwDeviceError);
   576 		}
   577 	iParent->InfoMessage(_L("ReleaseFreeze"));
   578 	TRAP(iError, iVideoHwDevice->ReleaseFreeze(Timestamp) );
   579 	if (iError!=KErrNone)
   580 		{
   581 		iParent->InfoMessage(_L("ReleaseFreeze Failed"));
   582 		SetState(EHwDeviceError);
   583 		}
   584 	iParent->InfoMessage(_L("Revert"));
   585 	TRAP(iError, iVideoHwDevice->Revert() );
   586 	if (iError!=KErrNone)
   587 		{
   588 		iParent->InfoMessage(_L("Revert Failed"));
   589 		SetState(EHwDeviceError);
   590 		}
   591 	iParent->InfoMessage(_L("Redraw"));
   592 	TRAP(iError, iVideoHwDevice->Redraw() );
   593 	if (iError!=KErrNone)
   594 		{
   595 		iParent->InfoMessage(_L("Redraw Failed"));
   596 		SetState(EHwDeviceError);
   597 		}
   598 	
   599 	}
   600 	
   601 
   602 	
   603 void CPlayVideoFileCov::ReadNextBufferL()
   604 	{
   605 	// check that we aren't waiting for the input buffer to be returned
   606 	iParent->InfoMessage(_L("ReadNextBufferL()"));
   607 	TVideoInputBuffer* inputBuffer = iVideoHwDevice->GetBufferL(KInputBufferSize);	
   608 	CMMFDevVideoPlay::TBufferOptions aOptions;
   609 	iVideoHwDevice->GetBufferOptions(aOptions);
   610 	iVideoHwDevice->NumComplexityLevels();
   611 	
   612 	
   613 	if (inputBuffer)
   614 		{
   615 		TBuf<KTBufSize> buf;
   616 		buf.Format(_L("inputBuffer size %d"),inputBuffer->iData.Length());
   617 		iParent->InfoMessage(buf);
   618 		User::LeaveIfError(iFile.Read(inputBuffer->iData));
   619 		buf.Format(_L("Read from file %d bytes"),inputBuffer->iData.Length());
   620 		iParent->InfoMessage(buf);
   621 		if (inputBuffer->iData.Length()>0)
   622 			{
   623 			iParent->InfoMessage(_L("Call HwDevice->WriteCodedData()"));
   624 			
   625 			iVideoHwDevice->WriteCodedDataL(inputBuffer);
   626 			}
   627 		else
   628 			{
   629 			iParent->InfoMessage(_L("End of input stream"));
   630 			iParent->InfoMessage(_L("Call HwDevice->InputEnd()"));
   631 			iVideoHwDevice->InputEnd();
   632 			}
   633 		}
   634 	}
   635 		
   636 void CPlayVideoFileCov::CleanupAndSetDeviceError(TPtrC16 aText)
   637 	{
   638 	iParent->SetVerdict(aText, EFail);
   639 	delete iVideoHwDevice;
   640 	SetState(EHwDeviceError);
   641 	}
   642 	
   643 void CPlayVideoFileCov::MdvppNewPicture(TVideoPicture* aPicture)
   644 	{
   645 	iParent->InfoMessage(_L("MdvppNewPicture - Received Frame"));
   646 	iVideoHwDevice->ReturnPicture(aPicture);
   647 	iParent->InfoMessage(_L("MdvppNewPicture - finished returning Frame"));
   648 	}
   649 
   650 void CPlayVideoFileCov::MdvppNewBuffers()
   651 	{
   652 	iParent->InfoMessage(_L("MdvppNewBuffers()"));
   653 	TRAP(iError, ReadNextBufferL());
   654 	if (iError != KErrNone)
   655 		{
   656 		iParent->SetVerdict(_L("Error reading next buffer"),EFail);		
   657 		iVideoHwDevice->Stop();
   658 		SetState(EHwDeviceError);
   659 		}
   660 	}
   661 
   662 void CPlayVideoFileCov::MdvppReturnPicture(TVideoPicture* /*aPicture*/)
   663 	{
   664 	iParent->InfoMessage(_L("MdvppReturnPicture()"));
   665 	}
   666 	
   667 void CPlayVideoFileCov::MdvppSupplementalInformation(const TDesC8& /*aData*/, 
   668 	const TTimeIntervalMicroSeconds& /*aTimestamp*/, const TPictureId& /*aPictureId*/)
   669 	{
   670 	}
   671 	
   672 void CPlayVideoFileCov::MdvppPictureLoss()
   673 	{
   674 	iParent->InfoMessage(_L("MdvppPictureLoss()"));
   675 	}
   676 	
   677 void CPlayVideoFileCov::MdvppPictureLoss(const TArray<TPictureId>& /*aPictures*/)
   678 	{
   679 	iParent->InfoMessage(_L("MdvppPictureLoss()"));
   680 	}
   681 	
   682 void CPlayVideoFileCov::MdvppSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
   683 	{
   684 	iParent->InfoMessage(_L("MdvppSliceLoss()"));
   685 	}
   686 	
   687 void CPlayVideoFileCov::MdvppReferencePictureSelection(const TDesC8& /*aSelectionData*/)
   688 	{
   689 	}
   690 	
   691 void CPlayVideoFileCov::MdvppTimedSnapshotComplete(TInt /*aError*/, TPictureData* /*aPictureData*/, 
   692 	const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/, const TPictureId& /*aPictureId*/)
   693 	{
   694 	}
   695 	
   696 void CPlayVideoFileCov::MdvppFatalError(CMMFVideoHwDevice* /*aDevice*/, TInt aError)
   697 	{
   698 	iError = aError;
   699 	iParent->InfoMessage(_L("MdvppFatalError()"));
   700 	SetState(EHwDeviceError);
   701 	}
   702 	
   703 void CPlayVideoFileCov::MdvppInitializeComplete(CMMFVideoHwDevice* /*aDevice*/, TInt aError)
   704 	{
   705 	iParent->InfoMessage(_L("MdvppInitializeComplete()"));
   706 	iError = aError;
   707 	if (iError == KErrNone)
   708 		{
   709 		iParent->InfoMessage(_L("The Hw Device Adapter initialised correctly"));
   710 		SetState(EHwDeviceStartDecode);
   711 		}
   712 	else
   713 		{
   714 		iParent->InfoMessage(_L("Failure intialising the hw device adapter"));
   715 		SetState(EHwDeviceError);
   716 		}
   717 	}
   718 	
   719 void CPlayVideoFileCov::MdvppStreamEnd()
   720 	{
   721 	iParent->InfoMessage(_L("MdvppStreamEnd()"));
   722 	SetState(EHwDeviceDone);
   723 	}
   724 
   725 void CPlayVideoFileCov::StartDirectScreenAccessL()
   726 	{
   727 	TRegionFix<KTRegionFixSize> reg;
   728 	TRect pos(iFrameSize);
   729 	reg.AddRect(pos);
   730 	iVideoHwDevice->StartDirectScreenAccessL(pos, *iScreenDevice, reg);
   731 	iParent->InfoMessage(_L("Pause"));
   732 	TRAP(iError, iVideoHwDevice->Pause() );
   733 	if (iError!=KErrNone)
   734 		{
   735 		iParent->InfoMessage(_L("Pause Failed"));
   736 		SetState(EHwDeviceError);
   737 		}
   738 	iParent->InfoMessage(_L("Resume"));
   739 	TRAP(iError, iVideoHwDevice->Resume() );
   740 	if (iError!=KErrNone)
   741 		{
   742 		iParent->InfoMessage(_L("Resume Failed"));
   743 		SetState(EHwDeviceError);
   744 		}
   745 	RRegion region;
   746 	iParent->InfoMessage(_L("SetScreenClipRegion"));
   747 	TRAP(iError, iVideoHwDevice->SetScreenClipRegion(region) );
   748 	if (iError!=KErrNone)
   749 		{
   750 		iParent->InfoMessage(_L("SetScreenClipRegion Failed"));
   751 		SetState(EHwDeviceError);
   752 		}
   753 	}
   754 void CPlayVideoFileCov::CancelTimedSnapshot()
   755 	{
   756 iParent->InfoMessage(_L("CancelTimedSnapshot"));
   757 TRAP(iError, iVideoHwDevice->CancelTimedSnapshot() );
   758 if (iError!=KErrNone)
   759 	{
   760 	iParent->InfoMessage(_L("CancelTimedSnapshot Failed"));
   761 	SetState(EHwDeviceError);
   762 	}
   763 }
   764 
   765 void CPlayVideoFileCov::GetTimedSnapshot1()
   766 	{
   767 TPictureData* pictureData=NULL;
   768 TUncompressedVideoFormat format;
   769 TTimeIntervalMicroSeconds presentationTimestamp;
   770 iParent->InfoMessage(_L("GetTimedSnapshotL"));
   771 TRAP(iError, iVideoHwDevice->GetTimedSnapshotL(pictureData,format,presentationTimestamp) );
   772 if (iError!=KErrNone)
   773 		{
   774 		iParent->InfoMessage(_L("GetTimedSnapshotL Failed"));
   775 		SetState(EHwDeviceError);
   776 		}
   777 
   778 	}
   779 
   780 void CPlayVideoFileCov::GetTimedSnapshot2()
   781 	{
   782 TPictureData* pictureData=NULL;
   783 TUncompressedVideoFormat format;
   784 TPictureId pictureId;
   785 iParent->InfoMessage(_L("GetTimedSnapshotL"));
   786 TRAP(iError, iVideoHwDevice->GetTimedSnapshotL(pictureData,format,pictureId) );
   787 if (iError!=KErrNone)
   788 		{
   789 		iParent->InfoMessage(_L("GetTimedSnapshotL Failed"));
   790 		SetState(EHwDeviceError);
   791 		}
   792 
   793 	}
   794 
   795 void CPlayVideoFileCov::GetSupportedSnapshotFormats()
   796 	{
   797 RArray<TUncompressedVideoFormat> formats;
   798 iParent->InfoMessage(_L("GetSupportedSnapshotFormatsL"));
   799 TRAP(iError, iVideoHwDevice->GetSupportedSnapshotFormatsL(formats) );
   800 if (iError!=KErrNone)
   801 		{
   802 		iParent->InfoMessage(_L("GetSupportedSnapshotFormatsL Failed"));
   803 		SetState(EHwDeviceError);
   804 		}
   805 
   806 	}
   807 
   808 
   809 
   810 void CPlayVideoFileCov::NegTests()
   811 	{
   812 	//call PlayBackPosition Before initializing iFrameRate
   813 	TRAP(iError, iVideoHwDevice->PlaybackPosition() );
   814 	if (iError!=KErrNone)
   815 		{
   816 		iParent->InfoMessage(_L("PlaybackPosition Failed"));
   817 		
   818 		}
   819 	//call DecodingPosition Before initializing iFrameRate
   820 	TRAP(iError, iVideoHwDevice->DecodingPosition() );
   821 	if (iError!=KErrNone)
   822 		{
   823 		iParent->InfoMessage(_L("DecodingPosition Failed"));
   824 		
   825 		}
   826 	
   827 	//call StartDirectScreenAccess before DSA is enabled
   828 	TRegionFix<KTRegionFixSize> reg;
   829 	TRect pos(iFrameSize);
   830 	reg.AddRect(pos);
   831 	
   832 	TRAP(iError, iVideoHwDevice->StartDirectScreenAccessL(pos, *iScreenDevice, reg) );
   833 	if (iError!=KErrNotReady)
   834 		{
   835 		iParent->InfoMessage(_L("StartDirectScreenAccessL Failed"));
   836 		
   837 		}
   838 	TUncompressedVideoFormat reqFormat;
   839 	reqFormat.iDataFormat = ERgbFbsBitmap;
   840 	reqFormat.iRgbFormat = EFbsBitmapColor16M;
   841 	
   842 	
   843 	
   844 	iParent->InfoMessage(_L("Call VideoHwDevice->SetOutputFormat()"));
   845 	
   846 	TRAP(iError, iVideoHwDevice->SetOutputFormatL(reqFormat) );
   847 	if (iError!=KErrNotReady)
   848 		{
   849 		iParent->InfoMessage(_L("SetOutputFormatL Failed"));
   850 		
   851 		}
   852 	
   853 	
   854 	
   855 
   856 	//Call initialize without settting output format
   857 	//Negative Test to improve code coverage
   858 	iVideoHwDevice->Initialize();
   859 	iVideoHwDevice->IsPlaying();
   860 	Cancel(); //Cancel pending requests
   861 	
   862 	
   863 	
   864 
   865 	}
   866 
   867 void CPlayVideoFileCov::InitializeCov1()
   868 	{
   869 	
   870 	
   871 	//Negative test for Buffer Options
   872 	CMMFDevVideoPlay::TBufferOptions bufferOptions;
   873 	bufferOptions.iMaxInputBufferSize=0x40000;
   874 	bufferOptions.iPreDecoderBufferPeriod=1;
   875 	TRAP(iError, iVideoHwDevice->SetBufferOptionsL(bufferOptions); );
   876 	if (iError!=KErrNotSupported)
   877 		{
   878 		iParent->InfoMessage(_L("SetBufferOptionsL Failed"));
   879 		
   880 		}
   881 	bufferOptions.iPreDecoderBufferPeriod=0;
   882 	bufferOptions.iMaxPostDecodeBufferSize=1;
   883 	TRAP(iError, iVideoHwDevice->SetBufferOptionsL(bufferOptions); );
   884 	if (iError!=KErrNotSupported)
   885 		{
   886 		iParent->InfoMessage(_L("SetBufferOptionsL Failed"));
   887 		
   888 		}
   889 	bufferOptions.iMaxPostDecodeBufferSize=0;
   890 	bufferOptions.iPostDecoderBufferPeriod=1;
   891 	TRAP(iError, iVideoHwDevice->SetBufferOptionsL(bufferOptions); );
   892 	if (iError!=KErrNotSupported)
   893 		{
   894 		iParent->InfoMessage(_L("SetBufferOptionsL Failed"));
   895 		
   896 		}
   897 	bufferOptions.iPostDecoderBufferPeriod=0;
   898 	bufferOptions.iMaxInputBufferSize=KVideoDecoderMaxDataBufferSize+1;
   899 	TRAP(iError, iVideoHwDevice->SetBufferOptionsL(bufferOptions); );
   900 	if (iError!=KErrNotSupported)
   901 		{
   902 		iParent->InfoMessage(_L("SetBufferOptionsL Failed"));
   903 		
   904 		}
   905 	bufferOptions.iMaxInputBufferSize=0;
   906 	bufferOptions.iMinNumInputBuffers=KMinInputBuffers;
   907 	TRAP(iError, iVideoHwDevice->SetBufferOptionsL(bufferOptions); );
   908 	if (iError!=KErrNotSupported)
   909 		{
   910 		iParent->InfoMessage(_L("SetBufferOptionsL Failed"));
   911 		
   912 		}
   913 	//Call SetVideoDest before iFormat has been set
   914 	iParent->InfoMessage(_L("Call VideoHwDevice SetVideoDestScreenL()"));
   915 	TRAP(iError, iVideoHwDevice->SetVideoDestScreenL(ETrue); );
   916 	if (iError!=KErrNotReady)
   917 		{
   918 		iParent->InfoMessage(_L("SetVideoDestScreenL Failed"));
   919 		
   920 		}
   921 	
   922 	
   923 	//SetOutputFormat which is not supported
   924 	TUncompressedVideoFormat reqFormat;
   925 	reqFormat.iDataFormat = ERgbRawData;
   926 	reqFormat.iRgbFormat = EFbsBitmapColor16M;
   927 
   928 	RArray<TUncompressedVideoFormat> decodeFormats;
   929 	TRAP(iError,iVideoHwDevice->GetOutputFormatListL(decodeFormats));
   930 	CleanupClosePushL(decodeFormats);
   931 	User::LeaveIfError(decodeFormats.Find(reqFormat));
   932 
   933 	iParent->InfoMessage(_L("Call VideoHwDevice->SetOutputFormat()"));
   934 	TRAP(iError, iVideoHwDevice->SetOutputFormatL(reqFormat) );
   935 	if (iError!=KErrNotReady)
   936 		{
   937 		iParent->InfoMessage(_L("SetOutputFormatL Failed"));
   938 		
   939 		}
   940 	//Call WriteCodedDataL with a NULL buffer
   941 	TVideoInputBuffer* inputBuffer=NULL;
   942 	iParent->InfoMessage(_L("Call VideoHwDevice->WriteCodedDataL()"));
   943 	TRAP(iError, iVideoHwDevice->WriteCodedDataL(inputBuffer) );
   944 	if (iError!=KErrArgument)
   945 		{
   946 		iParent->InfoMessage(_L("WriteCodedDataL Failed"));
   947 		
   948 		}
   949 	CleanupStack::PopAndDestroy(&decodeFormats);	
   950 	
   951 	iVideoHwDevice->Initialize();
   952 	
   953 	Cancel();
   954 
   955 	}
   956 
   957 void CPlayVideoFileCov::InitializeCov2()
   958 	{
   959 	
   960 	
   961 	
   962 	TUncompressedVideoFormat reqFormat;
   963 	reqFormat.iDataFormat = ERgbRawData;
   964 	reqFormat.iRgbFormat = EFbsBitmapColor16M;
   965 	
   966 	RArray<TUncompressedVideoFormat> decodeFormats;
   967 	TRAP(iError,iVideoHwDevice->GetOutputFormatListL(decodeFormats));
   968 	CleanupClosePushL(decodeFormats);
   969 	User::LeaveIfError(decodeFormats.Find(reqFormat));
   970 
   971 	iParent->InfoMessage(_L("Call VideoHwDevice->SetOutputFormat()"));
   972 	iVideoHwDevice->SetOutputFormatL(reqFormat);
   973 	CleanupStack::PopAndDestroy(&decodeFormats);	
   974 	
   975 	iVideoHwDevice->Initialize();
   976 
   977 	}
   978 	
   979 
   980