os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestDevVideoPlugins/encoder.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "encoder.h"
sl@0
    17
#include "../TestDevVideoPlayTestData.h"
sl@0
    18
sl@0
    19
_LIT(KDevVideoEncoderPanicCategory, "DevVideoEncoder");
sl@0
    20
void DevVideoEncoderPanic(TInt aReason)
sl@0
    21
	{
sl@0
    22
	User::Panic(KDevVideoEncoderPanicCategory, aReason);
sl@0
    23
	}
sl@0
    24
sl@0
    25
CMMFVideoEncodeHwDevice* CMMFTestVideoEncodeHwDevice::NewL(TAny* /*aInitParams*/)
sl@0
    26
	{
sl@0
    27
	CMMFTestVideoEncodeHwDevice* s = new(ELeave) CMMFTestVideoEncodeHwDevice;
sl@0
    28
	return (STATIC_CAST(CMMFVideoEncodeHwDevice*, s));
sl@0
    29
	}
sl@0
    30
sl@0
    31
CMMFTestVideoEncodeHwDevice::CMMFTestVideoEncodeHwDevice()
sl@0
    32
	{
sl@0
    33
	}
sl@0
    34
sl@0
    35
CMMFTestVideoEncodeHwDevice::~CMMFTestVideoEncodeHwDevice()
sl@0
    36
	{
sl@0
    37
	iDataBuffers.Reset();
sl@0
    38
	iDataBuffers.Close();
sl@0
    39
sl@0
    40
	// destroy objects in RArray
sl@0
    41
	for (TInt i = 0; i < iOutputVidFormats.Count(); i++)
sl@0
    42
		{
sl@0
    43
		delete iOutputVidFormats[i];
sl@0
    44
		}
sl@0
    45
sl@0
    46
	iOutputVidFormats.Reset();
sl@0
    47
	iOutputVidFormats.Close();
sl@0
    48
sl@0
    49
	iInputVidFormats.Reset();
sl@0
    50
	iInputVidFormats.Close();
sl@0
    51
sl@0
    52
	iPictureRates.Reset();
sl@0
    53
	iPictureRates.Close();
sl@0
    54
	}
sl@0
    55
sl@0
    56
TAny* CMMFTestVideoEncodeHwDevice::CustomInterface(TUid aInterface)
sl@0
    57
	{
sl@0
    58
	if (aInterface == KUidCustomInterfaceThree)
sl@0
    59
		{
sl@0
    60
		return this;//just want to return something non-null!
sl@0
    61
		}
sl@0
    62
	else
sl@0
    63
		{
sl@0
    64
		return NULL;
sl@0
    65
		}
sl@0
    66
	}
sl@0
    67
sl@0
    68
CPreProcessorInfo* CMMFTestVideoEncodeHwDevice::PreProcessorInfoLC()
sl@0
    69
	{
sl@0
    70
	return NULL;
sl@0
    71
	}
sl@0
    72
sl@0
    73
void CMMFTestVideoEncodeHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize)
sl@0
    74
	{
sl@0
    75
	TSize testSize(KTestInputSize1X, KTestInputSize1Y);
sl@0
    76
sl@0
    77
	if (!(aFormat == KTestVidFormat1) || !(aPictureSize == testSize))
sl@0
    78
		User::Leave(KErrCorrupt);
sl@0
    79
	}
sl@0
    80
sl@0
    81
void CMMFTestVideoEncodeHwDevice::SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate)
sl@0
    82
	{
sl@0
    83
	if (aCameraHandle == KTestCamHandleFatal)
sl@0
    84
		iProxy->MdvrpFatalError(this, KErrDied);
sl@0
    85
	else if ((KTestCamHandleEnc != aCameraHandle) || (KTestPictureRate != aPictureRate))
sl@0
    86
		User::Leave(KErrCorrupt);
sl@0
    87
	}
sl@0
    88
sl@0
    89
void CMMFTestVideoEncodeHwDevice::SetSourceMemoryL(TReal /*aMaxPictureRate*/, TBool /*aConstantPictureRate*/, TBool /*aProcessRealtime*/)
sl@0
    90
	{
sl@0
    91
	DevVideoEncoderPanic(EEncoderPanicSourceMem);
sl@0
    92
	}
sl@0
    93
sl@0
    94
void CMMFTestVideoEncodeHwDevice::SetClockSource(MMMFClockSource* aClock) 
sl@0
    95
	{
sl@0
    96
	__ASSERT_ALWAYS(aClock, DevVideoEncoderPanic(EEncoderPanicClockSource)); 
sl@0
    97
sl@0
    98
	// call Time() to check that clock can be used
sl@0
    99
	TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
sl@0
   100
	currTime = aClock->Time();
sl@0
   101
	}
sl@0
   102
sl@0
   103
void CMMFTestVideoEncodeHwDevice::SetPreProcessTypesL(TUint32 aPreProcessTypes)
sl@0
   104
	{
sl@0
   105
	if (!(aPreProcessTypes == KTestProcessType1))
sl@0
   106
		User::Leave(KErrCorrupt);
sl@0
   107
	}
sl@0
   108
sl@0
   109
void CMMFTestVideoEncodeHwDevice::SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat)
sl@0
   110
	{
sl@0
   111
	// check against test data
sl@0
   112
	if ((aRange != KTestRgbRange1) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat1) )
sl@0
   113
		User::Leave(KErrCorrupt);
sl@0
   114
	}
sl@0
   115
sl@0
   116
void CMMFTestVideoEncodeHwDevice::SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat)
sl@0
   117
	{
sl@0
   118
	if (!CompareYuvFormats(aInputFormat, KTestYuvFormat1) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat2) )
sl@0
   119
		User::Leave(KErrCorrupt);
sl@0
   120
	}
sl@0
   121
sl@0
   122
void CMMFTestVideoEncodeHwDevice::SetRotateOptionsL(TRotationType aRotationType)
sl@0
   123
	{
sl@0
   124
	if (!(aRotationType == KTestRotate1))
sl@0
   125
		User::Leave(KErrCorrupt);
sl@0
   126
	}
sl@0
   127
sl@0
   128
void CMMFTestVideoEncodeHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
sl@0
   129
	{
sl@0
   130
	TSize testScale(KTestScaleX, KTestScaleY);
sl@0
   131
	if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
sl@0
   132
		User::Leave(KErrCorrupt);
sl@0
   133
	}
sl@0
   134
sl@0
   135
void CMMFTestVideoEncodeHwDevice::SetInputCropOptionsL(const TRect& aRect)
sl@0
   136
	{
sl@0
   137
	TRect testRect(KTestInputCropRectA, KTestInputCropRectB, KTestInputCropRectC, KTestInputCropRectD);
sl@0
   138
	if (!(aRect == testRect))
sl@0
   139
		User::Leave(KErrCorrupt);
sl@0
   140
	}
sl@0
   141
sl@0
   142
void CMMFTestVideoEncodeHwDevice::SetOutputCropOptionsL(const TRect& aRect)
sl@0
   143
	{
sl@0
   144
	TRect testRect(KTestOutputCropRectA, KTestOutputCropRectB, KTestOutputCropRectC, KTestOutputCropRectD);
sl@0
   145
	if (!(aRect == testRect))
sl@0
   146
		User::Leave(KErrCorrupt);
sl@0
   147
	}
sl@0
   148
sl@0
   149
void CMMFTestVideoEncodeHwDevice::SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos)
sl@0
   150
	{
sl@0
   151
	TSize testPad(KTestPadX, KTestPadY);
sl@0
   152
	TPoint testPoint(KTestPadPointX, KTestPadPointY);
sl@0
   153
sl@0
   154
	if (!(testPad == aOutputSize) || !(testPoint == aPicturePos))
sl@0
   155
		User::Leave(KErrCorrupt);
sl@0
   156
	}
sl@0
   157
sl@0
   158
void CMMFTestVideoEncodeHwDevice::SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions)
sl@0
   159
	{
sl@0
   160
	if (!CompareColorEnhancements(aOptions, KTestColorEnhance1))
sl@0
   161
		User::Leave(KErrCorrupt);
sl@0
   162
	}
sl@0
   163
sl@0
   164
void CMMFTestVideoEncodeHwDevice::SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation)
sl@0
   165
	{
sl@0
   166
	TSize testSize(KTestScaleX, KTestScaleY);
sl@0
   167
	if (!(aOutputSize == testSize) || !aFrameStabilisation)
sl@0
   168
		User::Leave(KErrCorrupt);
sl@0
   169
	}
sl@0
   170
sl@0
   171
void CMMFTestVideoEncodeHwDevice::SetCustomPreProcessOptionsL(const TDesC8& aOptions)
sl@0
   172
	{
sl@0
   173
	if (!(aOptions == KTestCustomPreProc1))
sl@0
   174
		User::Leave(KErrCorrupt);
sl@0
   175
	}
sl@0
   176
sl@0
   177
void CMMFTestVideoEncodeHwDevice::Initialize()
sl@0
   178
	{
sl@0
   179
	iProxy->MdvrpInitializeComplete(this, KErrNone);
sl@0
   180
	}
sl@0
   181
sl@0
   182
void CMMFTestVideoEncodeHwDevice::WritePictureL(TVideoPicture* aPicture)
sl@0
   183
	{
sl@0
   184
	// change the timestamp to the encoder timestamp
sl@0
   185
	aPicture->iTimestamp = KTestEncPictureTimestamp;
sl@0
   186
sl@0
   187
	iProxy->MdvrpReturnPicture(aPicture);
sl@0
   188
	}
sl@0
   189
sl@0
   190
void CMMFTestVideoEncodeHwDevice::InputEnd()
sl@0
   191
	{
sl@0
   192
	iProxy->MdvrpStreamEnd();
sl@0
   193
	}
sl@0
   194
sl@0
   195
void CMMFTestVideoEncodeHwDevice::Start()
sl@0
   196
	{
sl@0
   197
	iRecPosition = KTestRecTimeStartEnc;
sl@0
   198
	iIsRecording = ETrue;
sl@0
   199
sl@0
   200
	// if we're doing the buffer tests, start sending buffers to DevVideo
sl@0
   201
	if (iDataBuffers.Count() > 0)
sl@0
   202
		{
sl@0
   203
		iProxy->MdvrpNewBuffer(&(iDataBuffers[0]));
sl@0
   204
		}
sl@0
   205
	}
sl@0
   206
sl@0
   207
void CMMFTestVideoEncodeHwDevice::Stop()
sl@0
   208
	{
sl@0
   209
	iRecPosition = KTestRecTimeStop;
sl@0
   210
	iIsRecording = EFalse;
sl@0
   211
	}
sl@0
   212
sl@0
   213
void CMMFTestVideoEncodeHwDevice::Pause()
sl@0
   214
	{
sl@0
   215
	iRecPosition = KTestRecTimePauseEnc;
sl@0
   216
	iIsRecording = EFalse;
sl@0
   217
	}
sl@0
   218
sl@0
   219
void CMMFTestVideoEncodeHwDevice::Resume()
sl@0
   220
	{
sl@0
   221
	iRecPosition = KTestRecTimeResumeEnc;
sl@0
   222
	iIsRecording = ETrue;
sl@0
   223
	}
sl@0
   224
sl@0
   225
void CMMFTestVideoEncodeHwDevice::Freeze()
sl@0
   226
	{
sl@0
   227
	}
sl@0
   228
sl@0
   229
void CMMFTestVideoEncodeHwDevice::ReleaseFreeze()
sl@0
   230
	{
sl@0
   231
	}
sl@0
   232
sl@0
   233
TTimeIntervalMicroSeconds CMMFTestVideoEncodeHwDevice::RecordingPosition()
sl@0
   234
	{
sl@0
   235
	return iRecPosition;
sl@0
   236
	}
sl@0
   237
sl@0
   238
void CMMFTestVideoEncodeHwDevice::GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters)
sl@0
   239
	{	
sl@0
   240
	CMMFDevVideoRecord::TPictureCounters pic = GetTestEncPictureCounters(); 
sl@0
   241
	
sl@0
   242
	// adjust picture counters to differentiate encoder from preproc
sl@0
   243
	pic.iInputPictures = KTestEncInputPictures;
sl@0
   244
	aCounters = pic;
sl@0
   245
	}
sl@0
   246
sl@0
   247
void CMMFTestVideoEncodeHwDevice::GetFrameStabilisationOutput(TRect& aRect)
sl@0
   248
	{
sl@0
   249
	aRect = TRect(KTestFrameStableX1, KTestFrameStableY1, KTestFrameStableX2, KTestFrameStableY2);
sl@0
   250
	}
sl@0
   251
sl@0
   252
TUint CMMFTestVideoEncodeHwDevice::NumComplexityLevels()
sl@0
   253
	{
sl@0
   254
	return KTestNumComplexityLevels1;
sl@0
   255
	}
sl@0
   256
sl@0
   257
void CMMFTestVideoEncodeHwDevice::SetComplexityLevel(TUint aLevel)
sl@0
   258
	{
sl@0
   259
	__ASSERT_ALWAYS(aLevel == KTestComplexityLevel1, DevVideoEncoderPanic(EEncoderPanicComplexityLevel));
sl@0
   260
	}
sl@0
   261
sl@0
   262
CVideoEncoderInfo* CMMFTestVideoEncodeHwDevice::VideoEncoderInfoLC()
sl@0
   263
	{
sl@0
   264
	// construct array of test types
sl@0
   265
	for (TUint i = 0; i < KTestEncoderInfoCount; i++)
sl@0
   266
		{
sl@0
   267
		// construct the video types for iOutputVidTypes
sl@0
   268
		// use the same test data as for the decoder
sl@0
   269
		CCompressedVideoFormat* vidCV = NULL;
sl@0
   270
		TPtrC8 mimeType = KTestDecoderInfoMimeArray[i];
sl@0
   271
		vidCV = GetTestCVFormatL(mimeType);
sl@0
   272
		CleanupStack::PushL(vidCV);
sl@0
   273
		User::LeaveIfError(iOutputVidFormats.Append(vidCV));
sl@0
   274
		CleanupStack::Pop(vidCV);	// CCompressedVideo object is destroyed in destructor
sl@0
   275
sl@0
   276
		// append the uncompressed video formats
sl@0
   277
		TUncompressedVideoFormat vidUC = KTestPostProcInfoFormatArray[i];
sl@0
   278
		User::LeaveIfError(iInputVidFormats.Append(vidUC));
sl@0
   279
sl@0
   280
		// append the max picture rates
sl@0
   281
		TPictureRateAndSize rate;
sl@0
   282
		GetTestEncoderInfoRate(i, rate);
sl@0
   283
		User::LeaveIfError(iPictureRates.Append(rate));
sl@0
   284
		}
sl@0
   285
	
sl@0
   286
	// construct the video Encoder info object
sl@0
   287
	CVideoEncoderInfo* vInfo = CVideoEncoderInfo::NewL(
sl@0
   288
		KUidDevVideoTestEncodeHwDevice,
sl@0
   289
		KTestEncoderInfoManufacturer,
sl@0
   290
		KTestEncoderInfoIdentifier,
sl@0
   291
		TVersion(KTestEncoderInfoVersionMaj, KTestEncoderInfoVersionMin, KTestEncoderInfoVersionBuild),
sl@0
   292
		ETrue, // accelerated
sl@0
   293
		ETrue, // supports direct capture
sl@0
   294
		iInputVidFormats.Array(),
sl@0
   295
		iOutputVidFormats.Array(),
sl@0
   296
		TSize(KTestEncoderInfoMaxSizeX, KTestEncoderInfoMaxSizeY),
sl@0
   297
		KTestUnitType1,
sl@0
   298
		KTestEncapType1,
sl@0
   299
		KTestNumBitrateLayers,
sl@0
   300
		ETrue, // supports supplemental enhancement info
sl@0
   301
		KTestEncoderInfoMaxUEPLevels,
sl@0
   302
		KTestEncoderInfoMaxBitrate,
sl@0
   303
		iPictureRates.Array(),
sl@0
   304
		KTestEncoderInfoMaxILSSteps,
sl@0
   305
		KTestEncoderInfoPictureOptions,
sl@0
   306
		EFalse, // aSupportsPictureLoss,
sl@0
   307
		ETrue, // aSupportsSliceLoss,
sl@0
   308
		KTestEncoderInfoCSInfo,
sl@0
   309
		KTestEncoderInfoISInfo );
sl@0
   310
		
sl@0
   311
sl@0
   312
	CleanupStack::PushL(vInfo);
sl@0
   313
	return vInfo;
sl@0
   314
	}
sl@0
   315
sl@0
   316
void CMMFTestVideoEncodeHwDevice::SetOutputFormatL(const CCompressedVideoFormat& aFormat, 
sl@0
   317
					  TVideoDataUnitType aDataUnitType, 					
sl@0
   318
					  TVideoDataUnitEncapsulation aDataEncapsulation,
sl@0
   319
					  TBool aSegmentationAllowed)
sl@0
   320
	{
sl@0
   321
	// check expected parameters - TClasses first
sl@0
   322
	if (!((aDataUnitType == KTestUnitType1) && (aDataEncapsulation == KTestEncapType1) && aSegmentationAllowed))
sl@0
   323
		User::Leave(KErrCorrupt);
sl@0
   324
	
sl@0
   325
	// construct a temporary compressed video class	[will leave on error]
sl@0
   326
	CCompressedVideoFormat *compVideo = GetTestCVFormatL(KTestMimeType1);
sl@0
   327
	CleanupStack::PushL(compVideo);
sl@0
   328
sl@0
   329
	// compare to received class
sl@0
   330
	if (!(aFormat == *compVideo))
sl@0
   331
		User::Leave(KErrCorrupt);
sl@0
   332
sl@0
   333
	// destroy temporary class
sl@0
   334
	CleanupStack::PopAndDestroy(compVideo);
sl@0
   335
	}
sl@0
   336
sl@0
   337
void CMMFTestVideoEncodeHwDevice::SetOutputRectL(const TRect& aRect)
sl@0
   338
	{
sl@0
   339
	TRect testRect1(KTestInputCropRectA, KTestInputCropRectB, KTestInputCropRectC, KTestInputCropRectD);
sl@0
   340
sl@0
   341
	if (!(aRect == testRect1))
sl@0
   342
		User::Leave(KErrCorrupt);
sl@0
   343
	}
sl@0
   344
sl@0
   345
void CMMFTestVideoEncodeHwDevice::SetInputDevice(CMMFVideoPreProcHwDevice* /*aDevice*/)
sl@0
   346
	{
sl@0
   347
	}
sl@0
   348
sl@0
   349
void CMMFTestVideoEncodeHwDevice::SetErrorsExpected(TBool aBitErrors, TBool aPacketLosses)
sl@0
   350
	{
sl@0
   351
	__ASSERT_ALWAYS(aBitErrors && !aPacketLosses, DevVideoEncoderPanic(EEncoderPanicErrorsExpected)); 
sl@0
   352
	}
sl@0
   353
sl@0
   354
void CMMFTestVideoEncodeHwDevice::SetMinRandomAccessRate(TReal aRate)
sl@0
   355
	{
sl@0
   356
	__ASSERT_ALWAYS(aRate == KTestRandomAccessRate, DevVideoEncoderPanic(EEncoderPanicRandomAccessRate)); 
sl@0
   357
	}
sl@0
   358
sl@0
   359
void CMMFTestVideoEncodeHwDevice::SetNumBitrateLayersL(TUint aNumLayers)
sl@0
   360
	{
sl@0
   361
	if (aNumLayers != KTestNumBitrateLayers)
sl@0
   362
		User::Leave(KErrCorrupt);
sl@0
   363
	}
sl@0
   364
sl@0
   365
void CMMFTestVideoEncodeHwDevice::SetScalabilityLayerTypeL(TUint aLayer, TScalabilityType aScalabilityType)
sl@0
   366
	{
sl@0
   367
	if ((aLayer != KTestLayer) || (aScalabilityType != KTestScaleType))
sl@0
   368
		User::Leave(KErrCorrupt);
sl@0
   369
	}
sl@0
   370
sl@0
   371
void CMMFTestVideoEncodeHwDevice::SetGlobalReferenceOptions(TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay)
sl@0
   372
	{
sl@0
   373
	__ASSERT_ALWAYS((aMaxReferencePictures == KTestMaxRefPics) && (aMaxPictureOrderDelay == KTestMaxPicDelay), DevVideoEncoderPanic(EEncoderPanicRandomAccessRate)); 
sl@0
   374
	}
sl@0
   375
sl@0
   376
void CMMFTestVideoEncodeHwDevice::SetLayerReferenceOptions(TUint aLayer, TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay)
sl@0
   377
	{
sl@0
   378
	__ASSERT_ALWAYS((aMaxReferencePictures == KTestMaxRefPics) && (aMaxPictureOrderDelay == KTestMaxPicDelay) && (aLayer == KTestLayer), DevVideoEncoderPanic(EEncoderPanicRandomAccessRate)); 
sl@0
   379
	}
sl@0
   380
sl@0
   381
void CMMFTestVideoEncodeHwDevice::SetBufferOptionsL(const TEncoderBufferOptions& aOptions)
sl@0
   382
	{
sl@0
   383
	if ( !CompareEncBufferOptions(aOptions, GetTestEncBufferOptions()) )
sl@0
   384
		User::Leave(KErrCorrupt);
sl@0
   385
	}
sl@0
   386
sl@0
   387
void CMMFTestVideoEncodeHwDevice::SetCodingStandardSpecificOptionsL(const TDesC8& aOptions)
sl@0
   388
	{
sl@0
   389
	if (!(aOptions == KTestCSEncoderOptions))
sl@0
   390
		User::Leave(KErrCorrupt);
sl@0
   391
	}
sl@0
   392
sl@0
   393
void CMMFTestVideoEncodeHwDevice::SetImplementationSpecificEncoderOptionsL(const TDesC8& aOptions)
sl@0
   394
	{
sl@0
   395
	if (aOptions == KTestISEncoderOptions)
sl@0
   396
		{
sl@0
   397
		// running standard test
sl@0
   398
		}
sl@0
   399
	else if (aOptions == KTestISEncBuffers)
sl@0
   400
		{
sl@0
   401
		// Special test plugin feature: we're being told to start outputting
sl@0
   402
		// video buffers up to DevVideo.
sl@0
   403
		// Create 10 video buffers
sl@0
   404
		iDataBuffers.Reset();
sl@0
   405
		for (TInt i = 0; i < 10; i++)
sl@0
   406
			{
sl@0
   407
			// Create a video output buffer that only has a valid timestamp
sl@0
   408
			TVideoOutputBuffer buf;
sl@0
   409
			buf.iCaptureTimestamp = TTimeIntervalMicroSeconds(i);
sl@0
   410
			buf.iImplementationSpecificData.Set(KTestISEncBufferData);
sl@0
   411
			User::LeaveIfError(iDataBuffers.Append(buf));
sl@0
   412
			}
sl@0
   413
		}
sl@0
   414
	else
sl@0
   415
		{
sl@0
   416
		User::Leave(KErrCorrupt);
sl@0
   417
		}
sl@0
   418
	}
sl@0
   419
sl@0
   420
HBufC8* CMMFTestVideoEncodeHwDevice::CodingStandardSpecificInitOutputLC()
sl@0
   421
	{
sl@0
   422
	HBufC8* bob = KTestCSInitOutput().AllocL();
sl@0
   423
	CleanupStack::PushL(bob);
sl@0
   424
sl@0
   425
	return bob;
sl@0
   426
	}
sl@0
   427
sl@0
   428
HBufC8* CMMFTestVideoEncodeHwDevice::ImplementationSpecificInitOutputLC()
sl@0
   429
	{
sl@0
   430
	HBufC8* fred = KTestISInitOutput().AllocL();
sl@0
   431
	CleanupStack::PushL(fred);
sl@0
   432
sl@0
   433
	return fred;
sl@0
   434
	}
sl@0
   435
sl@0
   436
void CMMFTestVideoEncodeHwDevice::SetErrorProtectionLevelsL(TUint aNumLevels, TBool aSeparateBuffers)
sl@0
   437
	{
sl@0
   438
	if ((aNumLevels != KTestProtectLevels) || !aSeparateBuffers)
sl@0
   439
		User::Leave(KErrCorrupt);
sl@0
   440
	}
sl@0
   441
sl@0
   442
void CMMFTestVideoEncodeHwDevice::SetErrorProtectionLevelL(TUint aLevel, TUint aBitrate, TUint aStrength)
sl@0
   443
	{
sl@0
   444
	if ((aLevel != KTestLevel) || (aBitrate != KTestBitrate) || (aStrength != KTestStrength))
sl@0
   445
		User::Leave(KErrCorrupt);
sl@0
   446
	}
sl@0
   447
sl@0
   448
void CMMFTestVideoEncodeHwDevice::SetChannelPacketLossRate(TUint aLevel, 
sl@0
   449
							  TReal aLossRate, 
sl@0
   450
							  TTimeIntervalMicroSeconds32 aLossBurstLength)
sl@0
   451
	{
sl@0
   452
	__ASSERT_ALWAYS((aLevel == KTestLevel) && (aLossRate == KTestLossRate) && (aLossBurstLength == TTimeIntervalMicroSeconds32(KTestLossBurstLength)), DevVideoEncoderPanic(EEncoderPanicPacketLossRate)); 
sl@0
   453
	}
sl@0
   454
sl@0
   455
void CMMFTestVideoEncodeHwDevice::SetChannelBitErrorRate(TUint aLevel, TReal aErrorRate, TReal aStdDeviation)
sl@0
   456
	{
sl@0
   457
	__ASSERT_ALWAYS((aLevel == KTestLevel) && (aErrorRate == KTestErrorRate) && (aStdDeviation == KTestStdDeviation), DevVideoEncoderPanic(EEncoderPanicBitErrorRate));	
sl@0
   458
	}
sl@0
   459
sl@0
   460
void CMMFTestVideoEncodeHwDevice::SetSegmentTargetSize(TUint aLayer, TUint aSizeBytes, TUint aSizeMacroblocks)
sl@0
   461
	{
sl@0
   462
	__ASSERT_ALWAYS((aLayer == KTestLayer) && (aSizeBytes == KTestSizeBytes) && (aSizeMacroblocks == KTestSizeMacroblocks), DevVideoEncoderPanic(EEncoderPanicSegmentTargetSize));	
sl@0
   463
	}
sl@0
   464
sl@0
   465
void CMMFTestVideoEncodeHwDevice::SetRateControlOptions(TUint aLayer, const TRateControlOptions& aOptions)
sl@0
   466
	{
sl@0
   467
	__ASSERT_ALWAYS(CompareRateControlOptions(aOptions, GetTestRateControlOptions()) && (aLayer == KTestLayer), DevVideoEncoderPanic(EEncoderPanicRateControlOptions)); 
sl@0
   468
	}
sl@0
   469
sl@0
   470
void CMMFTestVideoEncodeHwDevice::SetInLayerScalabilityL(TUint aLayer, TUint aNumSteps,
sl@0
   471
							TInLayerScalabilityType aScalabilityType,
sl@0
   472
							const TArray<TUint>& aBitrateShare,
sl@0
   473
							const TArray<TUint>& aPictureShare)
sl@0
   474
	{
sl@0
   475
	// check the non-array classes first
sl@0
   476
	if ((aLayer != KTestLayer) || (aNumSteps != KTestNumSteps) || (aScalabilityType != KTestLayerScaleType) )
sl@0
   477
		User::Leave(KErrCorrupt);
sl@0
   478
sl@0
   479
	TBool successBit = EFalse;
sl@0
   480
	TBool successPic = EFalse;
sl@0
   481
sl@0
   482
	// bitrateShare array
sl@0
   483
	if (aBitrateShare.Count() == 2)
sl@0
   484
		{
sl@0
   485
		if ((aBitrateShare[0] == KTestBitrateShare1) && (aBitrateShare[1] == KTestBitrateShare2))
sl@0
   486
			{
sl@0
   487
			successBit = ETrue;
sl@0
   488
			}
sl@0
   489
		}
sl@0
   490
sl@0
   491
	// pictureShare array
sl@0
   492
	if (aPictureShare.Count() == 2)
sl@0
   493
		{
sl@0
   494
		if ((aPictureShare[0] == KTestPictureShare1) && (aPictureShare[1] == KTestPictureShare2))
sl@0
   495
			{
sl@0
   496
			successPic = ETrue;
sl@0
   497
			}
sl@0
   498
		}
sl@0
   499
sl@0
   500
	if (!successBit || !successPic)
sl@0
   501
		User::Leave(KErrCorrupt);
sl@0
   502
	}
sl@0
   503
sl@0
   504
void CMMFTestVideoEncodeHwDevice::SetLayerPromotionPointPeriod(TUint aLayer, TUint aPeriod)
sl@0
   505
	{
sl@0
   506
	__ASSERT_ALWAYS((aLayer == KTestLayer) && (aPeriod == KTestPointPeriod), DevVideoEncoderPanic(EEncoderPanicPointPromPeriod)); 
sl@0
   507
	}
sl@0
   508
sl@0
   509
HBufC8* CMMFTestVideoEncodeHwDevice::CodingStandardSpecificSettingsOutputLC()
sl@0
   510
	{
sl@0
   511
	HBufC8* chaz = KTestCSSettingsOutput().AllocL();
sl@0
   512
	CleanupStack::PushL(chaz);
sl@0
   513
sl@0
   514
	return chaz;
sl@0
   515
	}
sl@0
   516
sl@0
   517
HBufC8* CMMFTestVideoEncodeHwDevice::ImplementationSpecificSettingsOutputLC()
sl@0
   518
	{
sl@0
   519
	HBufC8* dave = KTestISSettingsOutput().AllocL();
sl@0
   520
	CleanupStack::PushL(dave);
sl@0
   521
sl@0
   522
	return dave;
sl@0
   523
	}
sl@0
   524
sl@0
   525
void CMMFTestVideoEncodeHwDevice::SendSupplementalInfoL(const TDesC8& aData)
sl@0
   526
	{
sl@0
   527
	if (!(aData == KTestSuppInfo))
sl@0
   528
		User::Leave(KErrCorrupt);
sl@0
   529
sl@0
   530
	iProxy->MdvrpSupplementalInfoSent();	
sl@0
   531
	}
sl@0
   532
sl@0
   533
void CMMFTestVideoEncodeHwDevice::SendSupplementalInfoL(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp)
sl@0
   534
	{
sl@0
   535
	if (!(aData == KTestSuppInfo))
sl@0
   536
		User::Leave(KErrCorrupt);
sl@0
   537
sl@0
   538
	TTimeIntervalMicroSeconds suppTime(KTestSuppTime);
sl@0
   539
	TTimeIntervalMicroSeconds suppTimeCancel(KTestSuppTimeCancel);
sl@0
   540
sl@0
   541
	// check time stamp
sl@0
   542
	if (!(aTimestamp == TTimeIntervalMicroSeconds(suppTime)) && 
sl@0
   543
		!(aTimestamp == TTimeIntervalMicroSeconds(suppTimeCancel) ))
sl@0
   544
		User::Leave(KErrCorrupt);
sl@0
   545
sl@0
   546
	iSuppTime = ETrue;
sl@0
   547
sl@0
   548
	// don't send callback if cancel supp time requested
sl@0
   549
	if (aTimestamp == suppTime)
sl@0
   550
		iProxy->MdvrpSupplementalInfoSent();
sl@0
   551
	}
sl@0
   552
sl@0
   553
void CMMFTestVideoEncodeHwDevice::CancelSupplementalInfo()
sl@0
   554
	{
sl@0
   555
	if (iSuppTime)
sl@0
   556
		iProxy->MdvrpSupplementalInfoSent();
sl@0
   557
	
sl@0
   558
	iSuppTime = EFalse;
sl@0
   559
	}
sl@0
   560
sl@0
   561
void CMMFTestVideoEncodeHwDevice::GetOutputBufferStatus(TUint& aNumFreeBuffers, TUint& aTotalFreeBytes)
sl@0
   562
	{
sl@0
   563
	aNumFreeBuffers = KTestFreeBuffers;
sl@0
   564
	aTotalFreeBytes = KTestFreeBytes;
sl@0
   565
	}
sl@0
   566
sl@0
   567
void CMMFTestVideoEncodeHwDevice::ReturnBuffer(TVideoOutputBuffer* /*aBuffer*/)
sl@0
   568
	{
sl@0
   569
	switch (iCurrentBuffer)
sl@0
   570
		{
sl@0
   571
	case 0:
sl@0
   572
		// Send two more buffers
sl@0
   573
		iCurrentBuffer = 1;
sl@0
   574
		iProxy->MdvrpNewBuffer(&(iDataBuffers[1]));
sl@0
   575
		iCurrentBuffer = 2;
sl@0
   576
		iProxy->MdvrpNewBuffer(&(iDataBuffers[2]));
sl@0
   577
		break;
sl@0
   578
	case 2:
sl@0
   579
		// Send three more buffers
sl@0
   580
		iCurrentBuffer = 3;
sl@0
   581
		iProxy->MdvrpNewBuffer(&(iDataBuffers[3]));
sl@0
   582
		iCurrentBuffer = 4;
sl@0
   583
		iProxy->MdvrpNewBuffer(&(iDataBuffers[4]));
sl@0
   584
		iCurrentBuffer = 5;
sl@0
   585
		iProxy->MdvrpNewBuffer(&(iDataBuffers[5]));
sl@0
   586
		break;
sl@0
   587
	case 5:
sl@0
   588
		// Send the rest of the buffers
sl@0
   589
		iCurrentBuffer = 6;
sl@0
   590
		iProxy->MdvrpNewBuffer(&(iDataBuffers[6]));
sl@0
   591
		iCurrentBuffer = 7;
sl@0
   592
		iProxy->MdvrpNewBuffer(&(iDataBuffers[7]));
sl@0
   593
		iCurrentBuffer = 8;
sl@0
   594
		iProxy->MdvrpNewBuffer(&(iDataBuffers[8]));
sl@0
   595
		iCurrentBuffer = 9;
sl@0
   596
		iProxy->MdvrpNewBuffer(&(iDataBuffers[9]));
sl@0
   597
		break;
sl@0
   598
	default:
sl@0
   599
		break;
sl@0
   600
		};
sl@0
   601
	}
sl@0
   602
sl@0
   603
void CMMFTestVideoEncodeHwDevice::PictureLoss()
sl@0
   604
	{
sl@0
   605
	}
sl@0
   606
sl@0
   607
void CMMFTestVideoEncodeHwDevice::PictureLoss(const TArray<TPictureId>& aPictures)
sl@0
   608
	{
sl@0
   609
	TBool success = EFalse;
sl@0
   610
sl@0
   611
	if (aPictures.Count() == 3)
sl@0
   612
		{
sl@0
   613
		if (ComparePictureIDs(aPictures[0], KTestPictureId1) &&
sl@0
   614
			ComparePictureIDs(aPictures[1], KTestPictureId2) &&
sl@0
   615
			ComparePictureIDs(aPictures[2], KTestPictureId3) )
sl@0
   616
			{
sl@0
   617
			success = ETrue;
sl@0
   618
			}
sl@0
   619
		}
sl@0
   620
sl@0
   621
	__ASSERT_ALWAYS(success, DevVideoEncoderPanic(EEncoderPanicPictureLossSpec)); 
sl@0
   622
	}
sl@0
   623
sl@0
   624
void CMMFTestVideoEncodeHwDevice::SliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture)
sl@0
   625
	{
sl@0
   626
	__ASSERT_ALWAYS((aFirstMacroblock == KTestFirstMacroblock) && 
sl@0
   627
					(aNumMacroblocks == KTestNumMacroblocks) && 
sl@0
   628
					ComparePictureIDs(aPicture, KTestPictureId1), DevVideoEncoderPanic(EEncoderPanicSliceLoss)); 
sl@0
   629
	}
sl@0
   630
sl@0
   631
void CMMFTestVideoEncodeHwDevice::ReferencePictureSelection(const TDesC8& aSelectionData)
sl@0
   632
	{
sl@0
   633
	__ASSERT_ALWAYS((aSelectionData == KTestRefPictureInfo), DevVideoEncoderPanic(EEncoderPanicRefPictureInfo));
sl@0
   634
	}
sl@0
   635
sl@0
   636
void CMMFTestVideoEncodeHwDevice::CommitL()
sl@0
   637
	{
sl@0
   638
	}
sl@0
   639
sl@0
   640
void CMMFTestVideoEncodeHwDevice::Revert()
sl@0
   641
	{
sl@0
   642
	}
sl@0
   643
sl@0
   644
void CMMFTestVideoEncodeHwDevice::SetProxy(MMMFDevVideoRecordProxy& aProxy)
sl@0
   645
	{
sl@0
   646
	ASSERT(iProxy == NULL);
sl@0
   647
	iProxy = &aProxy;
sl@0
   648
	}
sl@0
   649