os/mm/mmapitest/devvideohaitest/src/T_CMMFDevVideoRecordData.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmapitest/devvideohaitest/src/T_CMMFDevVideoRecordData.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1111 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "t_cmmfdevvideorecorddata.h"
    1.23 +
    1.24 +/*@{*/
    1.25 +//LIT's to identify commands
    1.26 +_LIT(KCmdNewL,						"NewL");
    1.27 +_LIT(KCmdDestructor,				"~");
    1.28 +_LIT(KCmdSelectEncoderL,			"SelectEncoderL");
    1.29 +_LIT(KCmdSetInputFormatL,			"SetInputFormatL");
    1.30 +_LIT(KCmdSetOutputFormatL,			"SetOutputFormatL");
    1.31 +_LIT(KCmdSetBufferOptionsL,			"SetBufferOptionsL");
    1.32 +_LIT(KCmdSetSourceMemoryL,			"SetSourceMemoryL");
    1.33 +_LIT(KCmdSetMinRandomAccessRate,	"SetMinRandomAccessRate");
    1.34 +_LIT(KCmdInitialize,				"Initialize");
    1.35 +_LIT(KCmdSetComplexityLevel,		"SetComplexityLevel");
    1.36 +_LIT(KCmdStart,						"Start");
    1.37 +_LIT(KCmdPause,						"Pause");
    1.38 +_LIT(KCmdResume,					"Resume");
    1.39 +_LIT(KCmdStop,						"Stop");
    1.40 +_LIT(KCmdUtilityGetEnvironment,  	"UtilityGetEnvironment");
    1.41 +_LIT(KCmdSetRateControlOptions,  	"SetRateControlOptions");
    1.42 +
    1.43 +
    1.44 +/*@}*/
    1.45 +
    1.46 +/*@{*/
    1.47 +//LIT's to get params from ini files
    1.48 +_LIT(KInputFile,			"inputfile");
    1.49 +_LIT(KOutputFile,			"outputfile");
    1.50 +_LIT(KInputPath,			"inputPath");
    1.51 +_LIT(KOutputPath,			"outputPath");
    1.52 +_LIT(KFrameRate,			"framerate");
    1.53 +_LIT(KUid,					"uid");
    1.54 +_LIT(KMimeType,				"mimeType");
    1.55 +_LIT(KDataUnitType,			"DataUnitType");
    1.56 +_LIT(KDataEncapsulation,	"DataEncapsulation");
    1.57 +_LIT(KHrdVbvSpecification,	"HrdVbvSpecification");
    1.58 +_LIT(KMaxPictureSize,		"maxPictureSize");
    1.59 +_LIT(KRandomAccessRate, 	"randomAccessRate");
    1.60 +_LIT(KComplexityLevel,		"complexityLevel");
    1.61 +_LIT(KRawPicLength , 		"rawPicLength");
    1.62 +_LIT(KPicWidth,				"picWidth");
    1.63 +_LIT(KPicHeight,			"picHeight");
    1.64 +_LIT(KHrdVbvNone, 			"EHrdVbvNone");
    1.65 +_LIT(KHrdVbvCodingStandard, "EHrdVbvCodingStandard");
    1.66 +_LIT(KHrdVbv3GPP, 			"EHrdVbv3GPP");
    1.67 +_LIT(KLayer, 			    "layer");
    1.68 +_LIT(KBitrateControlType, 	"bitrateControlType");
    1.69 +_LIT(KBitrate, 			    "bitrate");
    1.70 +_LIT(KPictureQuality, 		"pictureQuality");
    1.71 +_LIT(KPicRate, 			    "picRate");
    1.72 +_LIT(KQualityTempTradeOff, 	"qualityTempTradeOff");
    1.73 +_LIT(KLatencyQuality, 		"latencyQuality");
    1.74 +/*@{*/
    1.75 +
    1.76 +const CDataWrapperBase::TEnumEntryTable	CT_MMFDevVideoRecordData::iHrdVbvSpecification[] =
    1.77 +	{
    1.78 +	KHrdVbvNone, 			EHrdVbvNone,
    1.79 +	KHrdVbvCodingStandard, 	EHrdVbvCodingStandard,
    1.80 +	KHrdVbv3GPP, 			EHrdVbv3GPP
    1.81 +	};
    1.82 +
    1.83 +/**
    1.84 + * Two phase constructor
    1.85 + *
    1.86 + * @leave	system wide error
    1.87 + */
    1.88 +CT_MMFDevVideoRecordData* CT_MMFDevVideoRecordData::NewL()
    1.89 +	{
    1.90 +	CT_MMFDevVideoRecordData* self = new(ELeave)CT_MMFDevVideoRecordData();
    1.91 +	CleanupStack::PushL (self);
    1.92 +	self->ConstructL ();
    1.93 +	CleanupStack::Pop (self);
    1.94 +	return self;
    1.95 +	}
    1.96 +
    1.97 +/**
    1.98 + * Public destructor
    1.99 + */
   1.100 +CT_MMFDevVideoRecordData::~CT_MMFDevVideoRecordData()
   1.101 +	{
   1.102 +	INFO_PRINTF1(_L("Destroying data..."));
   1.103 +	DestroyData();
   1.104 +	INFO_PRINTF1(_L("Data destroyed"));
   1.105 +	}
   1.106 +
   1.107 +/**
   1.108 + * Protected constructor. First phase construction
   1.109 + */
   1.110 +CT_MMFDevVideoRecordData::CT_MMFDevVideoRecordData()
   1.111 +	:	
   1.112 +	iBufferCount(0),	
   1.113 +	iTimeStamp(0), 	
   1.114 +	iWrittenPictures(0), 	
   1.115 +	iReturnedPictures(0), 	
   1.116 +	iCompressedBuffers(0), 	
   1.117 +	iBufferedPictures(0),	
   1.118 +	iStopAfterAllFramesReturned(EFalse), 	
   1.119 +	iInputEnd(EFalse),	
   1.120 +	iDatabuf(),	
   1.121 +	iRequests(0),	
   1.122 +	iOutputRequests(0)
   1.123 +	{
   1.124 +	}
   1.125 +
   1.126 +
   1.127 +void CT_MMFDevVideoRecordData::ConstructL()
   1.128 +	{
   1.129 +	iFs.Connect();
   1.130 +	}
   1.131 +
   1.132 +/**
   1.133 + * Returns a pointer to the object that the data wraps
   1.134 + * @return wrapped object
   1.135 + */
   1.136 +TAny* CT_MMFDevVideoRecordData::GetObject()
   1.137 +	{
   1.138 +	return iDevvr;
   1.139 +	}
   1.140 +
   1.141 +
   1.142 +/*
   1.143 + * COMMANDS
   1.144 + */
   1.145 +
   1.146 +/**
   1.147 + * Process a command read from the ini file
   1.148 + *
   1.149 + * @param aCommand			The command to process
   1.150 + * @param aSection			The section in the ini containing data for the command
   1.151 + * @param aAsyncErrorIndex	Command index for async calls to return errors to 
   1.152 + * @return					ETrue if the command is processed *
   1.153 + * @leave					System wide error
   1.154 + */
   1.155 +TBool CT_MMFDevVideoRecordData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
   1.156 +	{
   1.157 +	TBool cmdProcessed = ETrue;
   1.158 +	if(aCommand == KCmdNewL())
   1.159 +		{
   1.160 +		DoCmdNewL(aSection);
   1.161 +		}
   1.162 +	else if(aCommand == KCmdDestructor())
   1.163 +		{
   1.164 +		DoCmdDestructor();
   1.165 +		}
   1.166 +	else if(aCommand == KCmdSelectEncoderL())
   1.167 +		{
   1.168 +		DoCmdSelectEncoderL(aSection);
   1.169 +		}
   1.170 +	else if(aCommand == KCmdSetInputFormatL())
   1.171 +		{
   1.172 +		DoCmdSetInputFormatL();
   1.173 +		}
   1.174 +	else if(aCommand == KCmdSetOutputFormatL())
   1.175 +		{
   1.176 +		DoCmdSetOutputFormatL(aSection);
   1.177 +		}
   1.178 +	else if(aCommand == KCmdSetBufferOptionsL())
   1.179 +		{
   1.180 +		DoCmdSetBufferOptionsL(aSection);
   1.181 +		}
   1.182 +	else if(aCommand == KCmdSetSourceMemoryL())
   1.183 +		{
   1.184 +		DoCmdSetSourceMemoryL();
   1.185 +		}
   1.186 +	else if(aCommand == KCmdSetMinRandomAccessRate())
   1.187 +		{
   1.188 +		DoCmdSetMinRandomAccessRate(aSection);
   1.189 +		}
   1.190 +	else if(aCommand == KCmdInitialize())
   1.191 +		{
   1.192 +		DoCmdInitialize(aAsyncErrorIndex);
   1.193 +		}
   1.194 +	else if(aCommand == KCmdSetComplexityLevel())
   1.195 +		{
   1.196 +		DoCmdSetComplexityLevel(aSection);
   1.197 +		}
   1.198 +	else if(aCommand == KCmdStart())
   1.199 +		{
   1.200 +		DoCmdStart(aAsyncErrorIndex);
   1.201 +		}
   1.202 +	else if(aCommand == KCmdPause())
   1.203 +		{
   1.204 +		DoCmdPause();
   1.205 +		}
   1.206 +	else if(aCommand == KCmdResume())
   1.207 +		{
   1.208 +		DoCmdResume();
   1.209 +		}
   1.210 +	else if(aCommand == KCmdStop())
   1.211 +		{
   1.212 +		DoCmdStop();
   1.213 +		}
   1.214 +	else if ( aCommand==KCmdUtilityGetEnvironment )
   1.215 +		{
   1.216 +		DoCmdUtilityGetEnvironmentL();
   1.217 +		}
   1.218 +	else if ( aCommand==KCmdSetRateControlOptions )
   1.219 +		{
   1.220 +		DoCmdSetRateControlOptions(aSection);
   1.221 +		}
   1.222 +	else
   1.223 +		{
   1.224 +		cmdProcessed = EFalse;
   1.225 +		}
   1.226 +
   1.227 +	return cmdProcessed;
   1.228 +	}
   1.229 +
   1.230 +/**
   1.231 + * DoCmdNewL
   1.232 + * @param aSection			The section in the ini containing data for the command
   1.233 + */
   1.234 +void CT_MMFDevVideoRecordData::DoCmdNewL(const TTEFSectionName& aSection)
   1.235 +	{
   1.236 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdNewL"));
   1.237 +	DestroyData();
   1.238 +	TRAPD(error,iDevvr = CMMFDevVideoRecord::NewL( *this ));
   1.239 +	if(error!=KErrNone)
   1.240 +		{
   1.241 +		ERR_PRINTF2(_L("Error creating CMMFDevVideoRecord %i"), error);
   1.242 +		SetError(error);
   1.243 +		}
   1.244 +	else
   1.245 +		{
   1.246 +		CreateBuffers();
   1.247 +	
   1.248 +		if(CreateFiles(aSection)!= KErrNone)
   1.249 +			{
   1.250 +			ERR_PRINTF1(_L("Error creating input/output files"));
   1.251 +			SetBlockResult(EFail);
   1.252 +			}
   1.253 +		}
   1.254 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdNewL"));
   1.255 +	}
   1.256 +
   1.257 +/**
   1.258 + * DoCmdDestructor
   1.259 + */
   1.260 +void CT_MMFDevVideoRecordData::DoCmdDestructor()
   1.261 +	{
   1.262 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdDestructor"));
   1.263 +	iInFile.Close();   
   1.264 +	iOutFile.Close();
   1.265 +	iFs.Close();
   1.266 +	REComSession::FinalClose();	
   1.267 +	DestroyData();
   1.268 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdDestructor"));
   1.269 +	}
   1.270 +
   1.271 +/**
   1.272 + *	DoCmdSelectEncoderL
   1.273 + *  Selects the video encoder to be used. This method must be called before any other video encoder related 
   1.274 + *  methods are used. The encoder can be changed by calling this method again before the system has been 
   1.275 + *  initialized with Initialize().
   1.276 + *  All video encoder settings are reset to their default values. By default no pre-processing is performed.
   1.277 + *  @param aSection			The section in the ini containing data for the command
   1.278 + */
   1.279 +void CT_MMFDevVideoRecordData::DoCmdSelectEncoderL(const TTEFSectionName& aSection)
   1.280 +	{
   1.281 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSelectEncoderL"));
   1.282 +	TInt hUid = 0;
   1.283 +
   1.284 +	if(!GetHexFromConfig(aSection, KUid(), hUid))
   1.285 +		{
   1.286 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUid());
   1.287 +		SetBlockResult(EFail);
   1.288 +		}
   1.289 +	else
   1.290 +		{
   1.291 +		TUid Uid = TUid::Uid(hUid);
   1.292 +		SetPictureTypeL(aSection);
   1.293 +		TRAPD(error,iEncHWDevId = iDevvr->SelectEncoderL(Uid));
   1.294 +		if(error!=KErrNone)
   1.295 +			{
   1.296 +			iEncHWDevId = NULL;		
   1.297 +			ERR_PRINTF2(_L("Error Selecting encoder: %i"), error);
   1.298 +			SetError(error);
   1.299 +			}
   1.300 +		}
   1.301 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSelectEncoderL"));
   1.302 +	}
   1.303 +
   1.304 +/*
   1.305 + *	Sets the input format for a hardware device. If both a pre-processor and an encoder are used, the 
   1.306 + *	pre-processor output format and the encoder input format must be the same. The input format for the 
   1.307 + *	first device in the system is the input format for video input data.
   1.308 +*/
   1.309 +void CT_MMFDevVideoRecordData::DoCmdSetInputFormatL()
   1.310 +	{
   1.311 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetInputFormatL"));
   1.312 +	TUncompressedVideoFormat unCompressedFormat;	
   1.313 +
   1.314 +	unCompressedFormat.iDataFormat = EYuvRawData; 
   1.315 +	unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
   1.316 +	unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma1;
   1.317 +	unCompressedFormat.iYuvFormat.iYuv2RgbMatrix = NULL;
   1.318 +	unCompressedFormat.iYuvFormat.iRgb2YuvMatrix = NULL;
   1.319 +	unCompressedFormat.iYuvFormat.iAspectRatioNum = 1;
   1.320 +	unCompressedFormat.iYuvFormat.iAspectRatioDenom = 1;
   1.321 +	unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
   1.322 +
   1.323 +	TRAPD(error,iDevvr->SetInputFormatL( iEncHWDevId, unCompressedFormat, iPictSize ));
   1.324 +	if(error!=KErrNone)
   1.325 +		{
   1.326 +		ERR_PRINTF2(_L("Error Setting input format: %i"), error);
   1.327 +		SetError(error);
   1.328 +		}
   1.329 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetInputFormatL"));
   1.330 +	}
   1.331 +
   1.332 +/*
   1.333 + *	Sets the output format for a hardware device to a compressed video format. Only applicable for encoder 
   1.334 + *	devices. The picture size depends on the input data format and possible scaling performed.
   1.335 + *  	@param aSection			The section in the ini containing data for the command
   1.336 + */
   1.337 +void CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL(const TTEFSectionName& aSection)
   1.338 +	{
   1.339 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL"));
   1.340 +	TBuf8<50> mimetype;		
   1.341 +	TVideoDataUnitType dataUnitType;
   1.342 +	TVideoDataUnitEncapsulation dataEncapsulation;
   1.343 +	TBool dataOk = ETrue;
   1.344 +	TInt iDataUnitType = 0;
   1.345 +	TInt iDataEncapsulation = 0;
   1.346 +		
   1.347 +	TPtrC mimeType;
   1.348 +	if(!GetStringFromConfig(aSection, KMimeType(), mimeType))
   1.349 +		{
   1.350 +		ERR_PRINTF1(_L("Mime type not retrieved, command will not be executed"));
   1.351 +		SetBlockResult(EFail);
   1.352 +		dataOk = EFalse;
   1.353 +		}
   1.354 +	if(!GetHexFromConfig(aSection, KDataUnitType(), iDataUnitType))
   1.355 +		{
   1.356 +		ERR_PRINTF2(_L("check parameter: %S"), &KDataUnitType());
   1.357 +		SetBlockResult(EFail);
   1.358 +		dataOk = EFalse;
   1.359 +		}
   1.360 +	if(!GetHexFromConfig(aSection, KDataEncapsulation(), iDataEncapsulation))
   1.361 +		{
   1.362 +		ERR_PRINTF2(_L("check parameter: %S"), &KDataEncapsulation());
   1.363 +		SetBlockResult(EFail);
   1.364 +		dataOk = EFalse;
   1.365 +		}
   1.366 +	if(dataOk)
   1.367 +		{
   1.368 +		mimetype.Append(mimeType);
   1.369 +		CCompressedVideoFormat* compressedFormat=NULL;
   1.370 +		TRAPD(cfError, compressedFormat = CCompressedVideoFormat::NewL(mimetype));
   1.371 +		CleanupStack::PushL(compressedFormat);
   1.372 +		if(cfError != KErrNone)
   1.373 +			{
   1.374 +			ERR_PRINTF2(_L("Error selecting compressed video format, check selected mimeType: %i"), cfError);
   1.375 +			SetError(cfError);
   1.376 +			}
   1.377 +		else
   1.378 +			{
   1.379 +			dataUnitType = static_cast<TVideoDataUnitType>(iDataUnitType);
   1.380 +			dataEncapsulation = static_cast<TVideoDataUnitEncapsulation>(iDataEncapsulation);
   1.381 +			
   1.382 +			TRAPD(error,iDevvr->SetOutputFormatL(iEncHWDevId, *compressedFormat, dataUnitType, dataEncapsulation, EFalse));  	
   1.383 +			if(error != KErrNone)
   1.384 +				{
   1.385 +				ERR_PRINTF2(_L("Couldn't set OutputFormat %i"), error);	
   1.386 +				delete iDevvr;
   1.387 +				iDevvr = NULL;
   1.388 +				SetError(error);
   1.389 +				}
   1.390 +			}
   1.391 +		CleanupStack::PopAndDestroy(compressedFormat);
   1.392 +		}
   1.393 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL"));
   1.394 +	}
   1.395 +
   1.396 +/*
   1.397 + *	Sets encoder buffering options.
   1.398 + *	@param aSection			The section in the ini containing data for the command
   1.399 +*/
   1.400 +void CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL(const TTEFSectionName& aSection)
   1.401 +	{
   1.402 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL"));
   1.403 +	TEncoderBufferOptions bufferOptions;
   1.404 +	TInt HrdVbvSpecification = 0;
   1.405 +	TInt maxPictureSize = 0;
   1.406 +	TBool dataOk = ETrue;
   1.407 +	if(!GetEnumFromConfig(aSection, KHrdVbvSpecification(), iHrdVbvSpecification, HrdVbvSpecification))
   1.408 +		{
   1.409 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHrdVbvSpecification());
   1.410 +		SetBlockResult(EFail);
   1.411 +		dataOk = EFalse;
   1.412 +		}
   1.413 +	if(!GetIntFromConfig(aSection, KMaxPictureSize(), maxPictureSize))
   1.414 +		{
   1.415 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMaxPictureSize());
   1.416 +		SetBlockResult(EFail);
   1.417 +		dataOk = EFalse;
   1.418 +		}	
   1.419 +	if(dataOk)
   1.420 +		{
   1.421 +		bufferOptions.iHrdVbvParams.Set(NULL, 0);
   1.422 +		bufferOptions.iHrdVbvSpec = (THrdVbvSpecification)HrdVbvSpecification;
   1.423 +		bufferOptions.iMaxPreEncoderBufferPictures = KNumPictures;
   1.424 +		bufferOptions.iMaxCodedPictureSize = maxPictureSize;
   1.425 +		bufferOptions.iMaxOutputBufferSize = maxPictureSize;      
   1.426 +		bufferOptions.iMaxCodedSegmentSize = maxPictureSize;
   1.427 +	
   1.428 +		//Not needed more that 4 input buffers for normal fileRead test cases
   1.429 +		bufferOptions.iMinNumOutputBuffers = KNumPictures - 2;
   1.430 +		TRAPD(error, iDevvr->SetBufferOptionsL( bufferOptions ));
   1.431 +		if(error!=KErrNone)
   1.432 +			{
   1.433 +			ERR_PRINTF2(_L("Error Setting buffer options: %i"), error);
   1.434 +			SetError(error);
   1.435 +			}	
   1.436 +		}
   1.437 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL"));
   1.438 +	}
   1.439 +/*
   1.440 + *	Sets the data source to be memory buffers.
   1.441 + */
   1.442 +void CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL()
   1.443 +	{
   1.444 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL"));
   1.445 +	
   1.446 +	TRAPD(error, iDevvr->SetSourceMemoryL(iFrameRate, EFalse, EFalse));	
   1.447 +	if(error != KErrNone)
   1.448 +		{
   1.449 +		ERR_PRINTF2(_L("Error Setting Source Memory: %i"), error);
   1.450 +		SetError(error);
   1.451 +		}
   1.452 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL"));
   1.453 +	}
   1.454 +
   1.455 +/*
   1.456 + *	Sets the minimum frequency (in time) for instantaneous random access points in the bitstream. 
   1.457 + *	An instantaneous random access point is such where the encoder can achieve a full output picture 
   1.458 + *	immediately by encoding data starting from the random access point. The random access point frequency
   1.459 + *	may be higher than signalled, if the sequence contains scene cuts which typically cause a coding of 
   1.460 + *	a random access point.
   1.461 + *	@param aSection			The section in the ini containing data for the command
   1.462 +*/
   1.463 +void CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate(const TTEFSectionName& aSection)
   1.464 +	{
   1.465 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate"));
   1.466 +	TReal randomAccessRate = 0; 
   1.467 +	
   1.468 +	if(!GetRealFromConfig(aSection, KRandomAccessRate(), randomAccessRate))
   1.469 +		{
   1.470 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRandomAccessRate());
   1.471 +		SetBlockResult(EFail);
   1.472 +		}
   1.473 +	else
   1.474 +		{
   1.475 +		iDevvr->SetMinRandomAccessRate( randomAccessRate );
   1.476 +		}
   1.477 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate"));
   1.478 +	}
   1.479 +
   1.480 +/*
   1.481 + * Initializes the video devices, and reserves hardware resources. This method is asynchronous, 
   1.482 + *	DevVideoRecord will call MMMFDevVideoRecordObserver::MdvroInitializeComplete() after initialization has 
   1.483 + *	completed. If direct capture is used, this method also prepares the camera API for capture by calling 
   1.484 + *	PrepareVideoCaptureL(). No DevVideoRecord method may be called while initialization is in progress, the 
   1.485 + *	initialization process can only be cancelled by destroying the DevVideoRecord object. 
   1.486 + *	@param a AsyncErrorIndex 	Command index for async calls to return errors to
   1.487 +*/
   1.488 +void CT_MMFDevVideoRecordData::DoCmdInitialize(const TInt aAsyncErrorIndex)
   1.489 +	{
   1.490 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdInitialize"));
   1.491 +	iAsyncErrorIndex = aAsyncErrorIndex;
   1.492 +	IncOutstanding();
   1.493 +	iDevvr->Initialize();	
   1.494 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdInitialize"));
   1.495 +	}
   1.496 +
   1.497 +/*
   1.498 + * Sets the complexity level to use for video processing in a hardware device. The level can be changed at 
   1.499 + * any time. 
   1.500 + * @param a AsyncErrorIndex 	Command index for async calls to return errors to
   1.501 +*/
   1.502 +void CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel(const TTEFSectionName& aSection)
   1.503 +	{
   1.504 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel"));
   1.505 +	TInt complexityLevel = 0; 
   1.506 +	
   1.507 +	INFO_PRINTF1(_L("SET COMPLEXITY LEVEL begin"));
   1.508 +	
   1.509 +	if(!GetIntFromConfig(aSection, KComplexityLevel(), complexityLevel))
   1.510 +		{
   1.511 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KComplexityLevel());
   1.512 +		SetBlockResult(EFail);
   1.513 +		}
   1.514 +	else
   1.515 +		{
   1.516 +		iDevvr->SetComplexityLevel( iEncHWDevId, complexityLevel );
   1.517 +		INFO_PRINTF1(_L("SET COMPLEXITY LEVEL stop"));	
   1.518 +		}
   1.519 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel"));
   1.520 +	}
   1.521 +
   1.522 +/*
   1.523 + *	Starts recording video. This includes capturing pictures from the camera (if direct capture is used), 
   1.524 + *	pre-processing and encoding. Recording will proceed until it is stopped or paused. Initally recording 
   1.525 + *	is stopped.
   1.526 + * 	@param a AsyncErrorIndex 	Command index for async calls to return errors to
   1.527 + */
   1.528 +void CT_MMFDevVideoRecordData::DoCmdStart(const TInt aAsyncErrorIndex)
   1.529 +	{
   1.530 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdStart"));
   1.531 +	iAsyncErrorIndex = aAsyncErrorIndex;
   1.532 +	
   1.533 +	iDevvr->Start();
   1.534 +	
   1.535 +	iRequests++;
   1.536 +	if ( FillAndSendBuffer() == 0 ) 
   1.537 +		{
   1.538 +		iStopAfterAllFramesReturned = ETrue;
   1.539 +		}
   1.540 +	IncOutstanding();
   1.541 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdStart"));
   1.542 +	}
   1.543 +
   1.544 +/*
   1.545 + * 	Pauses video recording. Recording can be resumed using Resume().
   1.546 + */
   1.547 +void CT_MMFDevVideoRecordData::DoCmdPause()
   1.548 +	{
   1.549 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdPause"));
   1.550 +	iDevvr->Pause();
   1.551 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdPause"));
   1.552 +	}
   1.553 +
   1.554 +/*
   1.555 + * 	Resumes video recording after a pause.
   1.556 + */
   1.557 +void CT_MMFDevVideoRecordData::DoCmdResume()
   1.558 +	{
   1.559 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdResume"));
   1.560 +	iDevvr->Resume();
   1.561 +	HandleReturnedPicture();
   1.562 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdResume"));
   1.563 +	}
   1.564 +
   1.565 +/**
   1.566 + * Stops recording video. No new pictures will be captured, pre-processed, or encoded.
   1.567 + */
   1.568 +void CT_MMFDevVideoRecordData::DoCmdStop()
   1.569 +	{
   1.570 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdStop"));
   1.571 +	iDevvr->Stop();
   1.572 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdStop"));	
   1.573 +	}
   1.574 +
   1.575 +/*
   1.576 + * CALLBACKS
   1.577 + */
   1.578 +
   1.579 +/**
   1.580 + * Returns a used input video picture back to the caller. The picture memory can be re-used or freed. 
   1.581 + * 
   1.582 + * @param aPicture	the picture to return
   1.583 + */
   1.584 +void CT_MMFDevVideoRecordData::MdvroReturnPicture(TVideoPicture* aPicture)
   1.585 +	{
   1.586 +	TInt index = 0;
   1.587 +
   1.588 +	iReturnedPictures++;
   1.589 +	iBufferedPictures--;
   1.590 +
   1.591 +	for ( index = 0; index < KBufferInputPictures; index++)
   1.592 +		{
   1.593 +		if ( &(iPicture[index]) == aPicture )
   1.594 +			{//set it free
   1.595 +			iPicture[index].iOptions = 0;
   1.596 +			}
   1.597 +		}	
   1.598 +	HandleReturnedPicture();
   1.599 +	}
   1.600 +
   1.601 +/**
   1.602 + * Callback not used.
   1.603 + * 
   1.604 + * @return None
   1.605 + */
   1.606 +void CT_MMFDevVideoRecordData::MdvroSupplementalInfoSent()
   1.607 +	{
   1.608 +	}
   1.609 +
   1.610 +/**
   1.611 + * Observer callback in Custom interface Buffer management. 
   1.612 + * Client is notified a new buffer(s) is available 
   1.613 + * 
   1.614 + * @return None
   1.615 + */
   1.616 +void CT_MMFDevVideoRecordData::MdvroNewBuffers()
   1.617 +	{
   1.618 +	iCompressedBuffers ++;
   1.619 +	HandleNewBuffer();
   1.620 +	}
   1.621 +
   1.622 +/**
   1.623 + * Reports a fatal decoding or playback error to the client.
   1.624 + * 
   1.625 + * @param aError	The error code
   1.626 + * 
   1.627 + * @return None
   1.628 + */      
   1.629 +void CT_MMFDevVideoRecordData::MdvroFatalError(TInt aError)
   1.630 +	{
   1.631 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroFatalError"));
   1.632 +
   1.633 +	DecOutstanding();
   1.634 +
   1.635 +	ERR_PRINTF2(_L("A fatal error ocurred %i"), aError);
   1.636 +	SetAsyncError (iAsyncErrorIndex, aError);
   1.637 +	
   1.638 +	if(iDevvr != NULL)
   1.639 +		{
   1.640 +		delete iDevvr;
   1.641 +		iDevvr = NULL;
   1.642 +		}
   1.643 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroFatalError"));
   1.644 +	}
   1.645 +
   1.646 +/**
   1.647 + * Reports that DevVideoRecord initialization has completed. The interface can now be used for video recording. 
   1.648 + * 
   1.649 + * @param aError	Initialization error code, KErrNone if no error occurred
   1.650 + * 
   1.651 + * @return None
   1.652 + */
   1.653 +void CT_MMFDevVideoRecordData::MdvroInitializeComplete(TInt aError)
   1.654 +	{
   1.655 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroInitializeComplete"));
   1.656 +	DecOutstanding();
   1.657 +	if ( aError != KErrNone )
   1.658 +        {
   1.659 +        SetAsyncError (iAsyncErrorIndex, aError);
   1.660 +        ERR_PRINTF2(_L("Error at MdvroInitializeComplete %i"), aError);
   1.661 +        }
   1.662 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroInitializeComplete"));
   1.663 +	}
   1.664 +
   1.665 +/**
   1.666 + * Reports that the input video stream end has been reached and all pictures have been processed.
   1.667 + * This method is only called after the client has called InputEnd(). No more output pictures will be available.
   1.668 + * 
   1.669 + * @return None
   1.670 + */
   1.671 +void CT_MMFDevVideoRecordData::MdvroStreamEnd()
   1.672 +	{
   1.673 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroStreamEnd"));
   1.674 +	DecOutstanding();
   1.675 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroStreamEnd"));
   1.676 +	}
   1.677 +
   1.678 +/*
   1.679 + * HELPERS
   1.680 + */
   1.681 +
   1.682 +/**
   1.683 + * Sets the Picture Type for the test
   1.684 + * @param aSection			The section in the ini containing data for the command
   1.685 + */
   1.686 +void CT_MMFDevVideoRecordData::SetPictureTypeL(const TTEFSectionName& aSection)
   1.687 +	{
   1.688 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::SetPictureTypeL"));
   1.689 +	TInt rawPicLength=0;
   1.690 +	TInt picWidth=0;
   1.691 +	TInt picHeight=0;	
   1.692 +	
   1.693 +	if(!GetIntFromConfig(aSection, KFrameRate(), iFrameRate))
   1.694 +		{
   1.695 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrameRate());
   1.696 +		SetBlockResult(EFail);
   1.697 +		}
   1.698 +	
   1.699 +	if(!GetIntFromConfig(aSection, KRawPicLength(), rawPicLength))
   1.700 +		{
   1.701 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
   1.702 +		SetBlockResult(EFail);
   1.703 +		}
   1.704 +	
   1.705 +	if(!GetIntFromConfig(aSection, KPicWidth(), picWidth))
   1.706 +		{
   1.707 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
   1.708 +		SetBlockResult(EFail);
   1.709 +		}	
   1.710 +	
   1.711 +	if(!GetIntFromConfig(aSection, KPicHeight(), picHeight))
   1.712 +		{
   1.713 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
   1.714 +		SetBlockResult(EFail);
   1.715 +		}	
   1.716 +		
   1.717 +	iPictSize.SetSize(picHeight,picWidth);
   1.718 +	
   1.719 +	INFO_PRINTF1(_L("Creating Data buffers"));
   1.720 +	TUint8* pointer = NULL; 
   1.721 +	if (!iDatabuf)
   1.722 +        {
   1.723 +        //iDatabuf = new (ELeave) TUint8*[KBufferInputPictures];
   1.724 +        iDatabuf = new RPointerArray<TUint8>[KBufferInputPictures];
   1.725 +        
   1.726 +        for ( TInt i = 0; i < KBufferInputPictures; i ++ ) 
   1.727 +            {              
   1.728 +            pointer = new (ELeave) TUint8[rawPicLength];
   1.729 +            iDatabuf[i].Append(pointer);
   1.730 +            iPicture[i].iData.iRawData = new (ELeave) TPtr8(0, 0, 0);
   1.731 +            iPicture[i].iData.iRawData->Set(pointer, rawPicLength, rawPicLength );
   1.732 +            iPicture[i].iData.iDataSize.SetSize(iPictSize.iWidth, iPictSize.iHeight);
   1.733 +            }
   1.734 +        }
   1.735 +	INFO_PRINTF1(_L("Data buffers created"));
   1.736 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::SetPictureTypeL"));
   1.737 +	}
   1.738 +
   1.739 +/**
   1.740 + * create buffers to read data
   1.741 + */
   1.742 +void CT_MMFDevVideoRecordData::CreateBuffers()
   1.743 +	{
   1.744 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::CreateBuffers"));
   1.745 +	for (TInt i = 0; i < KBufferInputPictures; i ++)
   1.746 +		{
   1.747 +		INFO_PRINTF1(_L("creating buffers"));
   1.748 +		iPicture[i].iData.iRawData = NULL;
   1.749 +		INFO_PRINTF1(_L("buffers created"));
   1.750 +		}
   1.751 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::CreateBuffers"));
   1.752 +	}
   1.753 +	
   1.754 +
   1.755 +/**
   1.756 + *checks for input file and creates output files
   1.757 + * @param aSection			The section in the ini containing data for the command
   1.758 + */
   1.759 +int CT_MMFDevVideoRecordData::CreateFiles(const TTEFSectionName& aSection)
   1.760 +	{
   1.761 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::CreateFiles"));
   1.762 +	TInt err = KErrNone;
   1.763 +	TPtrC inputFile;
   1.764 +	TPtrC outputFile;
   1.765 +	TPtrC inputPath;
   1.766 +	TPtrC outputPath;
   1.767 +	if(!GetStringFromConfig(aSection, KInputFile(), inputFile))
   1.768 +		{
   1.769 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputFile());
   1.770 +		SetBlockResult(EFail);
   1.771 +		err = KErrNotFound;
   1.772 +		}
   1.773 +	if(!GetStringFromConfig(aSection, KOutputFile(), outputFile))
   1.774 +		{
   1.775 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputFile());
   1.776 +		SetBlockResult(EFail);
   1.777 +		err = KErrNotFound;
   1.778 +		}
   1.779 +	if(!GetStringFromConfig(aSection, KInputPath(), inputPath))
   1.780 +		{
   1.781 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputPath());
   1.782 +		SetBlockResult(EFail);
   1.783 +		err = KErrNotFound;
   1.784 +		}
   1.785 +	if(!GetStringFromConfig(aSection, KOutputPath(), outputPath))
   1.786 +		{
   1.787 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputFile());
   1.788 +		SetBlockResult(EFail);
   1.789 +		err = KErrNotFound;
   1.790 +		}	
   1.791 +	
   1.792 +    if(err == KErrNone)
   1.793 +    	{
   1.794 +		TFileName inFileName(inputPath);
   1.795 +	    inFileName.Append(inputFile);
   1.796 +	    TFileName outFileName(outputPath);
   1.797 +	    outFileName.Append(outputFile);
   1.798 +	    
   1.799 +	    err = OpenFile(outFileName, inFileName);
   1.800 +    	}
   1.801 +    INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::CreateFiles"));
   1.802 +    return err;
   1.803 +	}
   1.804 +
   1.805 +/**
   1.806 + * Opens input file.
   1.807 + * Creates output file.
   1.808 + * @param aOutFileName the output file
   1.809 + * @param aInFileName  the input file
   1.810 + */
   1.811 +int CT_MMFDevVideoRecordData::OpenFile(TFileName& aOutFileName, TFileName& aInFileName)
   1.812 +	{
   1.813 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::OpenFile"));
   1.814 +	TInt err = KErrNone;
   1.815 +	if ( (err=iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly)) != KErrNone)
   1.816 +		{  
   1.817 +		ERR_PRINTF2(_L("Couldn't open input file: %i"),err);
   1.818 +		}        
   1.819 +	else
   1.820 +		{
   1.821 +		if((err=iOutFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite))!= KErrNone)
   1.822 +			{
   1.823 +			ERR_PRINTF2(_L("Couldn't open output file: %i"),err);
   1.824 +			}
   1.825 +		}
   1.826 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::OpenFile"));
   1.827 +	return err;
   1.828 +	}
   1.829 +
   1.830 +/**
   1.831 + * gets new buffers from buffer array
   1.832 + */
   1.833 +void CT_MMFDevVideoRecordData::HandleNewBuffer()
   1.834 +	{
   1.835 +	TVideoOutputBuffer* tmp=NULL;
   1.836 +	TRAPD(error, tmp = iDevvr->NextBufferL());           
   1.837 +	if (error != KErrNone)
   1.838 +		{
   1.839 +		ERR_PRINTF2(_L("Error in getting NextBufferL, Error: %d"), error);
   1.840 +		SetBlockResult(EFail);
   1.841 +		}
   1.842 +	else
   1.843 +		{
   1.844 +		SaveAndReturnBuffer( tmp );
   1.845 +		}
   1.846 +	}
   1.847 +
   1.848 +/**
   1.849 + * handles the returned pictures 
   1.850 + */
   1.851 +void CT_MMFDevVideoRecordData::HandleReturnedPicture()
   1.852 +	{
   1.853 +	if ( iStopAfterAllFramesReturned )
   1.854 +		{
   1.855 +		}
   1.856 +	else
   1.857 +		{
   1.858 +		//iOutputRequests++;
   1.859 +		if ( FillAndSendBuffer() == 0 ) 
   1.860 +			{
   1.861 +			iStopAfterAllFramesReturned = ETrue;
   1.862 +			}
   1.863 +		}
   1.864 +	}
   1.865 +
   1.866 +/**
   1.867 + *handles out to file requests 
   1.868 + *@param aNumberOfPictures number of pictures to write
   1.869 + */
   1.870 +TInt CT_MMFDevVideoRecordData::HandleOutputRequest()
   1.871 +	{
   1.872 +	TInt request = 1;
   1.873 +	if ( FillAndSendBuffer() == 0 ) 
   1.874 +		{
   1.875 +		//all data read => stop
   1.876 +		iStopAfterAllFramesReturned = ETrue;
   1.877 +		request = 0;
   1.878 +		}
   1.879 +	return request;
   1.880 +	}
   1.881 +
   1.882 +/**
   1.883 + *writes buffer to file
   1.884 + *@param tmp current buffer
   1.885 + */
   1.886 +void CT_MMFDevVideoRecordData::SaveAndReturnBuffer(TVideoOutputBuffer* tmp)
   1.887 +    {
   1.888 +    iOutFile.Write( tmp->iData );
   1.889 +    iDevvr->ReturnBuffer( tmp );
   1.890 +    }
   1.891 +
   1.892 +/**
   1.893 + *fills buffer data buffer and process it
   1.894 + */
   1.895 +TInt CT_MMFDevVideoRecordData::FillAndSendBuffer()
   1.896 +	{
   1.897 +	TInt64 tsValue = 0;
   1.898 +	TInt index = 0;
   1.899 +	TInt status = KErrNone;
   1.900 +	TInt error = 1;
   1.901 +	if (iStopAfterAllFramesReturned)
   1.902 +		{
   1.903 +		error = 0;
   1.904 +		}
   1.905 +	else
   1.906 +		{
   1.907 +		for ( index = 0; index < KBufferInputPictures; index++ )
   1.908 +			{// find a free buffer
   1.909 +			if ( iPicture[index].iOptions == 0 )
   1.910 +				{            
   1.911 +				break;
   1.912 +				}
   1.913 +			} 
   1.914 +	
   1.915 +		if ( index == KBufferInputPictures )
   1.916 +			{// all buffers in use, hold on for now        
   1.917 +			error = -1;
   1.918 +			}
   1.919 +		else
   1.920 +			{
   1.921 +			// Reset buffer length
   1.922 +			iPicture[index].iData.iRawData->SetMax();
   1.923 +		
   1.924 +			status = iInFile.Read( *(iPicture[index].iData.iRawData));
   1.925 +			if ( status != KErrNone )
   1.926 +				{    
   1.927 +				iStopAfterAllFramesReturned = ETrue;
   1.928 +				iDevvr->InputEnd();
   1.929 +				error = 0;
   1.930 +				}
   1.931 +			else
   1.932 +				{
   1.933 +				// If the buffer is 0 or incomplete, stop test case
   1.934 +				if ( iPicture[index].iData.iRawData->Length() == 0 || iPicture[index].iData.iRawData->Length() < iPicture[index].iData.iRawData->MaxLength() )
   1.935 +					{        
   1.936 +					iStopAfterAllFramesReturned = ETrue;
   1.937 +					iDevvr->InputEnd();
   1.938 +					error = 0;
   1.939 +					}
   1.940 +				else
   1.941 +					{
   1.942 +					// write data
   1.943 +					tsValue = TReal(iTimeStamp) * TReal(1000000) / TReal(KVEDSPH263TimerResolution);
   1.944 +					iPicture[index].iTimestamp = tsValue;
   1.945 +					iPicture[index].iData.iDataFormat = EYuvRawData;
   1.946 +					iWrittenPictures++;  
   1.947 +					iBufferedPictures++;    
   1.948 +					iPicture[index].iOptions = 1;//mark to be used
   1.949 +					// send it as usually
   1.950 +					TRAPD(error, iDevvr->WritePictureL( &(iPicture[index]) ));
   1.951 +					if(error!=KErrNone)
   1.952 +						{
   1.953 +						ERR_PRINTF2(_L("Error int WritePictureL Error: %d"), error);
   1.954 +						SetError(error);
   1.955 +						}
   1.956 +					iTimeStamp ++;
   1.957 +					}
   1.958 +				}
   1.959 +			}
   1.960 +		}
   1.961 +	return error;
   1.962 +	}
   1.963 +
   1.964 +void CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL()
   1.965 +	{
   1.966 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL"));
   1.967 +	RArray<TUid> decoders;	
   1.968 +	RArray<TPictureRateAndSize> maxPictureRates;
   1.969 +	TBuf<255> mime;
   1.970 +	CleanupClosePushL (decoders);	
   1.971 +	iDevvr->GetEncoderListL(decoders);
   1.972 +	CVideoEncoderInfo* info = NULL;
   1.973 +	for (TInt i = 0; i < decoders.Count ();i++)
   1.974 +		{
   1.975 +		info =iDevvr->VideoEncoderInfoLC(decoders[i]);		
   1.976 +		TSize maxSize = info->MaxPictureSize();
   1.977 +		INFO_PRINTF6(_L("\n%S\nManufacturer%S\nUid: 0x%x\nAccelerated: %i\nSupports Direct Capture: %i"), 
   1.978 +				&info->Identifier(),
   1.979 +				&info->Manufacturer(),
   1.980 +				decoders[i].iUid,
   1.981 +				info->Accelerated(),
   1.982 +				info->SupportsDirectCapture());
   1.983 +		
   1.984 +		INFO_PRINTF3(_L("\nMax width %i, Max height %i"),maxSize.iWidth, maxSize.iHeight);
   1.985 +		
   1.986 +		maxPictureRates = info->MaxPictureRates(); 
   1.987 +
   1.988 +		INFO_PRINTF4(_L("\nData unit types supported:%d\nData unit encapsulations:%d\nMaximum number of bitrate layers supported:%d"),
   1.989 +				info->SupportedDataUnitTypes(),
   1.990 +				info->SupportedDataUnitEncapsulations(),
   1.991 +				info->MaxBitrateLayers()
   1.992 +				);
   1.993 +		
   1.994 +
   1.995 +		INFO_PRINTF4(_L("\nPicture options supported:%d\nSupportsPictureLoss:%i\nSupportsSliceLoss:%i"),
   1.996 +				info->SupportedPictureOptions(),
   1.997 +				info->SupportsPictureLoss(),
   1.998 +				info->SupportsSliceLoss()
   1.999 +				);
  1.1000 +		
  1.1001 +		INFO_PRINTF4(_L("\nSupplemental enhancement info:%i\nMaximum unequal error protection level:%d\nMaxBitrate:%d"),
  1.1002 +				info->SupportsSupplementalEnhancementInfo(),
  1.1003 +				info->MaxUnequalErrorProtectionLevels(),
  1.1004 +				info->MaxBitrate()
  1.1005 +				);
  1.1006 +		
  1.1007 +		INFO_PRINTF2(_L("Coding-standard specific information: %S"),&info->CodingStandardSpecificInfo());
  1.1008 +		TInt j = 0;
  1.1009 +		for (j = 0; j < maxPictureRates.Count(); j++)
  1.1010 +			{
  1.1011 +			TSize pictureSize=maxPictureRates[j].iPictureSize;			
  1.1012 +			INFO_PRINTF4(_L("max width: %i, max height %i, max rate %f"),
  1.1013 +					pictureSize.iWidth, pictureSize.iHeight, maxPictureRates[j].iPictureRate);
  1.1014 +			}
  1.1015 +		
  1.1016 +		const RPointerArray<CCompressedVideoFormat>& outputFormats =info->SupportedOutputFormats();
  1.1017 +		for (j = 0; j < outputFormats.Count(); j++)
  1.1018 +			{
  1.1019 +			mime.Copy(outputFormats[j]->MimeType());		
  1.1020 +			INFO_PRINTF3(_L("Supported type %d MIMETYPE: %S"),j,&mime);					
  1.1021 +			}
  1.1022 +		CleanupStack::Pop (info);
  1.1023 +		}
  1.1024 +	CleanupStack::PopAndDestroy(&decoders);
  1.1025 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL"));
  1.1026 +	}
  1.1027 +
  1.1028 +void CT_MMFDevVideoRecordData::DoCmdSetRateControlOptions(const TTEFSectionName& aSection)
  1.1029 +    {
  1.1030 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::SetRateControlOptions"));
  1.1031 +
  1.1032 +
  1.1033 +	TInt layer = 0;
  1.1034 +	TInt bitrateControlInt = 0;
  1.1035 +	TInt bitrate = 0;
  1.1036 +	TInt pictureQuality = 0;
  1.1037 +	TReal pictureRate;  
  1.1038 +	TReal qualityTemporalTradeoff;  
  1.1039 +	TReal latencyQualityTradeoff; 	
  1.1040 +	
  1.1041 +    if(!GetIntFromConfig(aSection, KLayer(), layer))
  1.1042 +        {
  1.1043 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLayer());
  1.1044 +        SetBlockResult(EFail);
  1.1045 +        }
  1.1046 +    if(!GetIntFromConfig(aSection, KBitrateControlType(), bitrateControlInt))
  1.1047 +        {
  1.1048 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBitrateControlType());
  1.1049 +        SetBlockResult(EFail);
  1.1050 +        }	
  1.1051 +    if(!GetIntFromConfig(aSection, KBitrate(), bitrate))
  1.1052 +        {
  1.1053 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLayer());
  1.1054 +        SetBlockResult(EFail);
  1.1055 +        }		
  1.1056 +    if(!GetIntFromConfig(aSection, KPictureQuality(), pictureQuality))
  1.1057 +        {
  1.1058 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPictureQuality());
  1.1059 +        SetBlockResult(EFail);
  1.1060 +        }	
  1.1061 +    if(!GetRealFromConfig(aSection, KPicRate(), pictureRate))
  1.1062 +        {
  1.1063 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPicRate());
  1.1064 +        SetBlockResult(EFail);
  1.1065 +        }	
  1.1066 +    if(!GetRealFromConfig(aSection, KQualityTempTradeOff(), qualityTemporalTradeoff))
  1.1067 +        {
  1.1068 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KQualityTempTradeOff());
  1.1069 +        SetBlockResult(EFail);
  1.1070 +        }	
  1.1071 +    if(!GetRealFromConfig(aSection, KLatencyQuality(), latencyQualityTradeoff))
  1.1072 +        {
  1.1073 +        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLatencyQuality());
  1.1074 +        SetBlockResult(EFail);
  1.1075 +        }	
  1.1076 +
  1.1077 +	TBitrateControlType bitrateControlType;
  1.1078 +	switch (bitrateControlInt) 
  1.1079 +		{
  1.1080 +		case 1: bitrateControlType = EBrControlNone;
  1.1081 +				break;
  1.1082 +		case 2: bitrateControlType = EBrControlStream;
  1.1083 +				break;		
  1.1084 +		case 3: bitrateControlType = EBrControlPicture;
  1.1085 +				break;		
  1.1086 +		default:bitrateControlType = EBrControlStream; 
  1.1087 +		}
  1.1088 +
  1.1089 +
  1.1090 +    TRateControlOptions rateControlOptions;
  1.1091 +	rateControlOptions.iControl = bitrateControlType;
  1.1092 +	rateControlOptions.iBitrate = bitrate;
  1.1093 +	rateControlOptions.iPictureQuality = pictureQuality;
  1.1094 +	rateControlOptions.iPictureRate = pictureRate;
  1.1095 +	rateControlOptions.iQualityTemporalTradeoff = qualityTemporalTradeoff;
  1.1096 +	rateControlOptions.iLatencyQualityTradeoff = latencyQualityTradeoff;
  1.1097 +
  1.1098 +	iDevvr->SetRateControlOptions(layer, rateControlOptions);  
  1.1099 +
  1.1100 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::SetRateControlOptions"));
  1.1101 +
  1.1102 +	}
  1.1103 +
  1.1104 +
  1.1105 +
  1.1106 +
  1.1107 +
  1.1108 +void CT_MMFDevVideoRecordData::DestroyData()
  1.1109 +	{
  1.1110 +	INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DestroyData"));
  1.1111 +	delete iDevvr;
  1.1112 +	iDevvr = NULL;
  1.1113 +	INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DestroyData"));
  1.1114 +	}