os/mm/mmapitest/devvideohaitest/src/T_CMMFDevVideoPlayData.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <datawrapper.h>
sl@0
    20
#include <devvideoplay.h>
sl@0
    21
#include <devvideobase.h> 
sl@0
    22
#include <hal.h>
sl@0
    23
#include <devvideoconstants.h>
sl@0
    24
#include "t_cmmfdevvideoplaydata.h"
sl@0
    25
#include "t_devvideoconstants.h"
sl@0
    26
sl@0
    27
/*@{*/
sl@0
    28
//LIT's to get params from ini files
sl@0
    29
_LIT(KPostPro,								"postprocessor");
sl@0
    30
_LIT(KCodec,								"codec");
sl@0
    31
_LIT(KCombination,							"combination");
sl@0
    32
_LIT(KScreenout,							"screen");
sl@0
    33
_LIT(KFramerate,							"framerate");
sl@0
    34
_LIT(KInputfile,							"inputfile");
sl@0
    35
_LIT(KOutputfile,							"outputfile");
sl@0
    36
_LIT(KSynch,								"synch");
sl@0
    37
_LIT(KDecoder, 								"dec");
sl@0
    38
_LIT(KRotation, 							"rotation");
sl@0
    39
_LIT(KWidth, 								"width");
sl@0
    40
_LIT(KHeight, 								"height");
sl@0
    41
_LIT(Kx, 									"x");
sl@0
    42
_LIT(Ky, 									"y");
sl@0
    43
_LIT(KPos, 									"pos");
sl@0
    44
_LIT(KAntiAliasFiltering,					"antiAliasFiltering");
sl@0
    45
_LIT(KMimeType,								"mimeType");
sl@0
    46
_LIT(KUseDecoder,							"useDecoder");
sl@0
    47
_LIT(KInputPath,							"inputPath");
sl@0
    48
_LIT(KOutputPath,							"outputPath");
sl@0
    49
_LIT(KDisplayMode,							"displayMode");
sl@0
    50
_LIT(KBuf,									"buffer");
sl@0
    51
_LIT(KDataInOrder, 							"dataInOrder");
sl@0
    52
_LIT(KTVideoDataUnitType, 					"TVideoDataUnitType");
sl@0
    53
_LIT(KTVideoDataUnitEncapsulation, 			"TVideoDataUnitEncapsulation");
sl@0
    54
//H264
sl@0
    55
_LIT(KUid,									"uidInt");
sl@0
    56
_LIT(KBuffMgmt,								"buffMgmt");
sl@0
    57
_LIT(KOutput,								"output");
sl@0
    58
_LIT(KHwdev,								"hwdev");
sl@0
    59
_LIT(KDataUnitTypeInt,						"dataUnitTypeInt");
sl@0
    60
_LIT(KEncapsulation,						"encapsulation");
sl@0
    61
_LIT(KFormat,								"format");
sl@0
    62
_LIT(KDataFormat,                           "dataFormat");
sl@0
    63
_LIT(KDataLayout,                           "dataLayout");
sl@0
    64
_LIT(KPattern,                              "pattern");
sl@0
    65
_LIT(KAspectRatioNum,                       "aspectRatioNum");
sl@0
    66
_LIT(KAspectRatioDenom,                     "aspectRatioDenom");
sl@0
    67
_LIT(KCoefficients,                         "coefficients");
sl@0
    68
_LIT(KPreDecodeBufferSize,                  "preDecodeBufferSize");
sl@0
    69
_LIT(KMaxPostDecodeBufferSize,              "maxPostDecodeBufferSize");
sl@0
    70
_LIT(KPreDecoderBufferPeriodInt,			"preDecoderBufferPeriodInt");
sl@0
    71
_LIT(KPostDecoderBufferPeriodInt,           "postDecoderBufferPeriodInt");
sl@0
    72
_LIT(KMaxInputBufferSize,                   "maxInputBufferSize");
sl@0
    73
_LIT(KMinNumInputBuffers,                   "minNumInputBuffers");
sl@0
    74
_LIT(KInputEnd,								"inputEnd");
sl@0
    75
_LIT(KDest,                                 "dest");
sl@0
    76
_LIT(KX,                                    "x");
sl@0
    77
_LIT(KY,                                    "y");
sl@0
    78
_LIT(KSync,                                 "sync");
sl@0
    79
/*@}*/
sl@0
    80
sl@0
    81
/*@{*/
sl@0
    82
//LIT's to identify commands
sl@0
    83
_LIT(KCmdNewL,								"NewL");
sl@0
    84
_LIT(KCmdDestructor,						"~");
sl@0
    85
_LIT(KCmdInitialize,						"Initialize");
sl@0
    86
_LIT(KCmdStart,								"Start");
sl@0
    87
_LIT(KCmdStop,								"Stop");
sl@0
    88
_LIT(KCmdPause,								"Pause");
sl@0
    89
_LIT(KCmdResume,							"Resume");
sl@0
    90
_LIT(KCmdSetRotateOptionsL,					"SetRotateOptionsL");
sl@0
    91
_LIT(KCmdSetScaleOptionsL,					"SetScaleOptionsL");
sl@0
    92
_LIT(KCmdSetPosition,						"SetPosition");
sl@0
    93
_LIT(KCmdSetClockSource,					"SetClockSource");
sl@0
    94
_LIT(KCmdSelectDecoderL,					"SelectDecoderL");
sl@0
    95
_LIT(KCmdSetInputFormat,					"SetInputFormat");
sl@0
    96
_LIT(KCmdSelectPostProcessorL,				"SelectPostProcessorL");
sl@0
    97
_LIT(KCmdPostProcessorInfoLC,				"PostProcessorInfoLC");
sl@0
    98
_LIT(KCmdFindCommonFormat,					"FindCommonFormat");
sl@0
    99
_LIT(KCmdSetOutputFormatL,					"SetOutputFormatL");
sl@0
   100
_LIT(KCmdGetHeaderInformationL,				"GetHeaderInformationL");
sl@0
   101
_LIT(KCmdReturnHeader,						"ReturnHeader");
sl@0
   102
_LIT(KCmdSetVideoDestScreenL,				"SetVideoDestScreenL");
sl@0
   103
_LIT(KCmdGetBufferOptions,					"GetBufferOptions");
sl@0
   104
_LIT(KCmdSetBufferOptionsL,					"SetBufferOptionsL");
sl@0
   105
_LIT(KCmdSetPostProcessTypesL,				"SetPostProcessTypesL");
sl@0
   106
_LIT(KCmdGetOutputFormatListL,				"GetOutputFormatListL");
sl@0
   107
_LIT(KCmdAbortDirectScreenAccess,			"AbortDirectScreenAccess");
sl@0
   108
_LIT(KCmdStartDirectScreenAccess,			"StartDirectScreenAccess");
sl@0
   109
_LIT(KCmdUtilityGetEnvironment,  			"UtilityGetEnvironment");
sl@0
   110
/*@}*/
sl@0
   111
_LIT(KCmdH264CreateDecTest,  				"H264CreateDecTest");
sl@0
   112
_LIT(KCmdH264SelectPostProcessor,           "H264SelectPostProcessor");
sl@0
   113
_LIT(KCmdH264SetPostProcessTypes,           "H264SetPostProcessTypes");
sl@0
   114
_LIT(KCmdH264SetInputFormatCompr,			"H264SetInputFormatCompr");	
sl@0
   115
_LIT(KCmdH264SetOutputFormat,				"H264SetOutputFormat");
sl@0
   116
_LIT(KCmdH264SetBufferOptions,				"H264SetBufferOptions");
sl@0
   117
_LIT(KCmdH264ListFrameSize,                 "H264ListFrameSize");
sl@0
   118
_LIT(KCmdH264SetVideoDestScreen,            "H264SetVideoDestScreen"); 
sl@0
   119
_LIT(KCmdH264SetWindowRect,                 "H264SetWindowRect");    
sl@0
   120
_LIT(KCmdH264Initialize,					"H264Initialize");
sl@0
   121
_LIT(KCmdH264Start,							"H264Start");
sl@0
   122
_LIT(KCmdH264Stop,							"H264Stop");
sl@0
   123
_LIT(KCmdH264Pause,                         "H264Pause");
sl@0
   124
_LIT(KCmdH264Resume,                        "H264Resume");
sl@0
   125
_LIT(KCmdH264IOFrameMatch,					"H264IOFrameMatch");
sl@0
   126
_LIT(KCmdH264FindCommonFormats,             "H264FindCommonFormats");    
sl@0
   127
_LIT(KCmdH264GetHeaderInformation,          "H264GetHeaderInformation");
sl@0
   128
_LIT(KCmdH264EnableSynchronization,         "H264EnableSynchronization");
sl@0
   129
_LIT(KCmdH264SetScaleOptions,               "H264SetScaleOptions");
sl@0
   130
_LIT(KCmdH264SetRotateOptions,              "H264SetRotateOptions");
sl@0
   131
_LIT(KCmdH264SynchronizeDecoding,           "H264SynchronizeDecoding");
sl@0
   132
_LIT(KCmdH264Delete,                        "H264Delete");
sl@0
   133
_LIT(KCmdH264SetPosition,                   "H264SetPosition");
sl@0
   134
_LIT(KCmdH264AbortDirectScreenAccess,       "H264AbortDirectScreenAccess");
sl@0
   135
sl@0
   136
/*@{*/
sl@0
   137
_LIT(KNoCodec,								"ENoCodec");
sl@0
   138
_LIT(KH263,									"EH263");
sl@0
   139
_LIT(KMPEG4,								"EMPEG4");
sl@0
   140
_LIT(KH264,									"EH264");
sl@0
   141
_LIT(KRV9,									"ERV9");
sl@0
   142
/*@}*/
sl@0
   143
sl@0
   144
const CDataWrapperBase::TEnumEntryTable	CT_CMMFDevVideoPlay::iCodecs[] =
sl@0
   145
	{
sl@0
   146
	KNoCodec,	ENoCodec,
sl@0
   147
	KH263,		EH263,
sl@0
   148
	KMPEG4,		EMPEG4,
sl@0
   149
	KH264,		EH264,
sl@0
   150
	KRV9,		ERV9
sl@0
   151
	};
sl@0
   152
sl@0
   153
/*@{*/
sl@0
   154
//LIT's for display mode
sl@0
   155
_LIT(KNone,									"ENone");
sl@0
   156
_LIT(KGray2,								"EGray2");
sl@0
   157
_LIT(KGray4,								"EGray4");
sl@0
   158
_LIT(KGray16,								"EGray16");
sl@0
   159
_LIT(KGray256,								"EGray256");
sl@0
   160
_LIT(KColor16,								"EColor16");
sl@0
   161
_LIT(KColor256,								"EColor256");
sl@0
   162
_LIT(KColor64K,								"EColor64K");
sl@0
   163
_LIT(KColor16M,								"EColor16M");
sl@0
   164
_LIT(KRgb,									"ERgb");
sl@0
   165
_LIT(KColor4K,								"EColor4K");
sl@0
   166
_LIT(KColor16MU,							"EColor16MU");
sl@0
   167
_LIT(KColor16MA,							"EColor16MA");
sl@0
   168
_LIT(KColorLast,							"EColorLast");
sl@0
   169
/*@}*/
sl@0
   170
sl@0
   171
const CDataWrapperBase::TEnumEntryTable	CT_CMMFDevVideoPlay::iDisplayModes[] =
sl@0
   172
	{
sl@0
   173
	KNone,		ENone,
sl@0
   174
	KGray2,		EGray2,
sl@0
   175
	KGray4,		EGray4,
sl@0
   176
	KGray16,	EGray16,
sl@0
   177
	KGray256,	EGray256,
sl@0
   178
	KColor16,	EColor16,
sl@0
   179
	KColor256,	EColor256,
sl@0
   180
	KColor64K,	EColor64K,
sl@0
   181
	KColor16M,	EColor16M,
sl@0
   182
	KRgb,		ERgb,
sl@0
   183
	KColor4K,	EColor4K,
sl@0
   184
	KColor16MU,	EColor16MU,
sl@0
   185
	KColor16MA,	EColor16MA,
sl@0
   186
	KColorLast,	EColorLast,
sl@0
   187
	KColor64K,	EColor64K,
sl@0
   188
	};
sl@0
   189
sl@0
   190
/*@{*/
sl@0
   191
//LIT's for rotation
sl@0
   192
_LIT(KRotateNone,							"ERotateNone");
sl@0
   193
_LIT(KRotate90Clockwise,					"ERotate90Clockwise");
sl@0
   194
_LIT(KRotate90Anticlockwise,				"ERotate90Anticlockwise");
sl@0
   195
_LIT(KRotate180,							"ERotate180");
sl@0
   196
/*@}*/
sl@0
   197
const CDataWrapperBase::TEnumEntryTable	CT_CMMFDevVideoPlay::iRotations[] =
sl@0
   198
	{
sl@0
   199
	KRotateNone,			ERotateNone,
sl@0
   200
	KRotate90Clockwise,		ERotate90Clockwise,
sl@0
   201
	KRotate90Anticlockwise,	ERotate90Anticlockwise,
sl@0
   202
	KRotate180,				ERotate180
sl@0
   203
	};
sl@0
   204
sl@0
   205
/*@{*/
sl@0
   206
//LIT's for Video Data Unit Type
sl@0
   207
_LIT(KEDuCodedPicture,						"EDuCodedPicture");
sl@0
   208
_LIT(KEDuVideoSegment,						"EDuVideoSegment");
sl@0
   209
_LIT(KEDuSeveralSegments,					"EDuSeveralSegments");
sl@0
   210
_LIT(KEDuArbitraryStreamSection,			"EDuArbitraryStreamSection");
sl@0
   211
/*@}*/
sl@0
   212
sl@0
   213
const CDataWrapperBase::TEnumEntryTable	CT_CMMFDevVideoPlay::iTVideoDataUnitType[] =
sl@0
   214
	{
sl@0
   215
	KEDuCodedPicture,				EDuCodedPicture,
sl@0
   216
	KEDuVideoSegment,				EDuVideoSegment,
sl@0
   217
	KEDuSeveralSegments,			EDuSeveralSegments,
sl@0
   218
	KEDuArbitraryStreamSection,		EDuArbitraryStreamSection 
sl@0
   219
	};
sl@0
   220
sl@0
   221
/*@{*/
sl@0
   222
//LIT's for video data unit encapsulation
sl@0
   223
_LIT(KEDuElementaryStream,					"EDuElementaryStream");
sl@0
   224
_LIT(KEDuGenericPayload,					"EDuGenericPayload");
sl@0
   225
_LIT(KEDuRtpPayload,						"EDuRtpPayload");
sl@0
   226
/*@}*/
sl@0
   227
const CDataWrapperBase::TEnumEntryTable	CT_CMMFDevVideoPlay::iTVideoDataUnitEncapsulation[] =
sl@0
   228
	{
sl@0
   229
	KEDuElementaryStream,	EDuElementaryStream,
sl@0
   230
	KEDuGenericPayload,		EDuGenericPayload,
sl@0
   231
	KEDuRtpPayload,			EDuRtpPayload
sl@0
   232
	};
sl@0
   233
sl@0
   234
//H264
sl@0
   235
// -----------------------------------------------------------------------------
sl@0
   236
// class CEngineObserver
sl@0
   237
// -----------------------------------------------------------------------------
sl@0
   238
//
sl@0
   239
CEngineObserver::CEngineObserver(CT_CMMFDevVideoPlay& aTestClass) :
sl@0
   240
  iTestClass(aTestClass)
sl@0
   241
    {
sl@0
   242
    
sl@0
   243
    }
sl@0
   244
void CEngineObserver::MvdeStreamEndReached()
sl@0
   245
    {
sl@0
   246
    iTestClass.DecOutstanding();
sl@0
   247
    }
sl@0
   248
void CEngineObserver::MvdeSetError(TInt aError)
sl@0
   249
    {
sl@0
   250
    iTestClass.SetError(aError);
sl@0
   251
    }
sl@0
   252
sl@0
   253
/**
sl@0
   254
 * Public destructor
sl@0
   255
 */
sl@0
   256
CT_CMMFDevVideoPlay::~CT_CMMFDevVideoPlay()
sl@0
   257
	{
sl@0
   258
	INFO_PRINTF1(_L("CT_CMMFDevVideoPlay Destructor In"));
sl@0
   259
	if(!iUse264)
sl@0
   260
	    {
sl@0
   261
	    if(iDsaStarted)
sl@0
   262
	        {
sl@0
   263
	        iDevvp->AbortDirectScreenAccess();      
sl@0
   264
	        iDsaStarted = EFalse;
sl@0
   265
	        }
sl@0
   266
	    DestroyData();
sl@0
   267
	    }
sl@0
   268
sl@0
   269
    iUse264 = EFalse;
sl@0
   270
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay Destructor Out"));
sl@0
   271
	}
sl@0
   272
sl@0
   273
/**
sl@0
   274
 * Return a pointer to the object that the data wraps
sl@0
   275
 * @return	pointer to the object that the data wraps
sl@0
   276
 */
sl@0
   277
TAny* CT_CMMFDevVideoPlay::GetObject()
sl@0
   278
	{
sl@0
   279
	return iDevvp;
sl@0
   280
	}
sl@0
   281
sl@0
   282
/**
sl@0
   283
 * Command that destroy the wrapped object and helper objects
sl@0
   284
 */ 
sl@0
   285
void CT_CMMFDevVideoPlay::DoCmdDestructor()
sl@0
   286
	{
sl@0
   287
	DestroyData();	
sl@0
   288
	if ( iFileOpen )
sl@0
   289
		{
sl@0
   290
		CloseFile();
sl@0
   291
		iFileOpen = EFalse;
sl@0
   292
		}
sl@0
   293
	if ( iDsaStarted )
sl@0
   294
		{
sl@0
   295
		iDevvp->AbortDirectScreenAccess();      
sl@0
   296
		iDsaStarted = EFalse;
sl@0
   297
		}      		
sl@0
   298
	//Postproc input buffer
sl@0
   299
	if ( !iCIBuffMgmtOn && iRawInBuffer)
sl@0
   300
		{ 
sl@0
   301
		delete (TUint8*)iRawInBuffer->iData.iRawData->Ptr();
sl@0
   302
		delete iRawInBuffer->iData.iRawData;
sl@0
   303
		delete iRawInBuffer;
sl@0
   304
		iRawInBuffer = NULL;
sl@0
   305
		}    	
sl@0
   306
	if(iScreenDevice)
sl@0
   307
		{
sl@0
   308
		delete iScreenDevice;
sl@0
   309
		iScreenDevice = NULL;
sl@0
   310
		RFbsSession::Disconnect();
sl@0
   311
		}		
sl@0
   312
	if(iClock)
sl@0
   313
		{
sl@0
   314
		delete iClock;
sl@0
   315
		iClock = NULL;
sl@0
   316
		}		
sl@0
   317
	iFrameSizeList.Close();
sl@0
   318
	iFs.Close();
sl@0
   319
	REComSession::FinalClose(); 	
sl@0
   320
	if(iInfo)
sl@0
   321
		{
sl@0
   322
		delete iInfo;
sl@0
   323
		iInfo=NULL;
sl@0
   324
		}	
sl@0
   325
	while(Outstanding())
sl@0
   326
		{
sl@0
   327
		INFO_PRINTF1(_L("DoCmdDestructor DecOutstanding()"));
sl@0
   328
		DecOutstanding();
sl@0
   329
		}
sl@0
   330
	}
sl@0
   331
sl@0
   332
/**
sl@0
   333
 * Helper method tha destroy the wrapped object
sl@0
   334
 */
sl@0
   335
void CT_CMMFDevVideoPlay::DestroyData()
sl@0
   336
{
sl@0
   337
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DestroyData")); 
sl@0
   338
	// Delete Devvideo play 
sl@0
   339
	delete iDevvp;
sl@0
   340
	iDevvp = NULL;
sl@0
   341
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DestroyData"));
sl@0
   342
}
sl@0
   343
sl@0
   344
/**
sl@0
   345
 * Two phase constructor
sl@0
   346
 *
sl@0
   347
 * @leave	system wide error
sl@0
   348
 */
sl@0
   349
CT_CMMFDevVideoPlay* CT_CMMFDevVideoPlay::NewL()
sl@0
   350
	{	
sl@0
   351
	CT_CMMFDevVideoPlay*	ret=new (ELeave) CT_CMMFDevVideoPlay();
sl@0
   352
	CleanupStack::PushL(ret);
sl@0
   353
	ret->ConstructL();
sl@0
   354
	CleanupStack::Pop(ret);
sl@0
   355
	return ret;		
sl@0
   356
	}
sl@0
   357
sl@0
   358
/**
sl@0
   359
 * Protected constructor. First phase construction
sl@0
   360
 */
sl@0
   361
CT_CMMFDevVideoPlay::CT_CMMFDevVideoPlay()
sl@0
   362
	:
sl@0
   363
	iDevvp(NULL),
sl@0
   364
	iDecHWDevId(0),
sl@0
   365
	iPostProcId(0),
sl@0
   366
	iInBuffSize(0),
sl@0
   367
	iInputEnd(EFalse),
sl@0
   368
	iDsaStarted(EFalse),
sl@0
   369
	iSynchronized(EFalse),
sl@0
   370
	iFrameListed(EFalse),
sl@0
   371
	iPictureSize(0,0),
sl@0
   372
	iAsyncErrorIndex(0),
sl@0
   373
	iFileOpen(EFalse),
sl@0
   374
	iCodedInBuffer(NULL),
sl@0
   375
	iOutBuffer(NULL),
sl@0
   376
	iRawInBuffer(NULL),
sl@0
   377
	iTimeStamp(0),
sl@0
   378
	iFrameTimeInterval(0),
sl@0
   379
	iSentBuffCount(0),
sl@0
   380
	iReturnedBuffCount(0),
sl@0
   381
	iPictureLoss(0),
sl@0
   382
	iStreamEnd(EFalse),
sl@0
   383
	iCodecType(EH263),
sl@0
   384
	iClock(NULL),
sl@0
   385
	iDirectScreenAccess(EFalse),
sl@0
   386
	iCIBuffMgmtOn(EFalse),
sl@0
   387
	iFrameMeasurement(EFalse),
sl@0
   388
	iCommonFormatFound(EFalse),
sl@0
   389
	iErrorInputBuffer(EFalse),
sl@0
   390
	iEngine(NULL),
sl@0
   391
	iObserver(NULL),
sl@0
   392
	iUse264(EFalse),
sl@0
   393
	iFrameRate(15)
sl@0
   394
	{
sl@0
   395
	}
sl@0
   396
sl@0
   397
/**
sl@0
   398
 * Second phase construction
sl@0
   399
 * @internalComponent
sl@0
   400
 * @return	N/A
sl@0
   401
 * @pre		None
sl@0
   402
 * @post	None * @leave	system wide error
sl@0
   403
 */
sl@0
   404
void CT_CMMFDevVideoPlay::ConstructL()
sl@0
   405
	{		
sl@0
   406
    iClock = CSystemClockSource::NewL();
sl@0
   407
	}
sl@0
   408
sl@0
   409
/**
sl@0
   410
 * Process a command read from the ini file
sl@0
   411
 * @param aCommand			The command to process
sl@0
   412
 * @param aSection			The section in the ini containing data for the command
sl@0
   413
 * @param aAsyncErrorIndex	Command index for async calls to return errors to 
sl@0
   414
 * @return					ETrue if the command is processed *
sl@0
   415
 * @leave					System wide error
sl@0
   416
 */
sl@0
   417
TBool CT_CMMFDevVideoPlay::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection,
sl@0
   418
											 const TInt aAsyncErrorIndex)
sl@0
   419
	{	
sl@0
   420
	TBool	ret=ETrue;
sl@0
   421
sl@0
   422
	if ( aCommand==KCmdDestructor )
sl@0
   423
		{
sl@0
   424
		DoCmdDestructor();
sl@0
   425
		}
sl@0
   426
	else if ( aCommand==KCmdNewL )
sl@0
   427
		{
sl@0
   428
		DoCmdNewL(aSection);
sl@0
   429
		}
sl@0
   430
	else if ( aCommand==KCmdInitialize )
sl@0
   431
		{
sl@0
   432
		DoCmdInitialize(aAsyncErrorIndex);
sl@0
   433
		}
sl@0
   434
	else if ( aCommand==KCmdStart )
sl@0
   435
		{
sl@0
   436
		DoCmdStart(aAsyncErrorIndex);
sl@0
   437
		}
sl@0
   438
	else if ( aCommand==KCmdStop )
sl@0
   439
		{
sl@0
   440
		DoCmdStop();
sl@0
   441
		}
sl@0
   442
	else if ( aCommand==KCmdSetPosition )
sl@0
   443
		{
sl@0
   444
		DoCmdSetPosition(aSection);
sl@0
   445
		}
sl@0
   446
	else if ( aCommand==KCmdPause )
sl@0
   447
		{
sl@0
   448
		DoCmdPause();
sl@0
   449
		}
sl@0
   450
	else if ( aCommand==KCmdResume )
sl@0
   451
		{
sl@0
   452
		DoCmdResume();
sl@0
   453
		}
sl@0
   454
	else if ( aCommand==KCmdSetRotateOptionsL )
sl@0
   455
		{
sl@0
   456
		DoCmdSetRotateOptionsL(aSection);
sl@0
   457
		}
sl@0
   458
	else if ( aCommand==KCmdSetScaleOptionsL )
sl@0
   459
		{
sl@0
   460
		DoCmdSetScaleOptionsL(aSection);
sl@0
   461
		}
sl@0
   462
	else if ( aCommand==KCmdSetClockSource )
sl@0
   463
		{
sl@0
   464
		DoCmdSetClockSource(aSection);
sl@0
   465
		}
sl@0
   466
	else if ( aCommand==KCmdSelectDecoderL )
sl@0
   467
		{
sl@0
   468
		DoCmdSelectDecoderL(aSection);
sl@0
   469
		}
sl@0
   470
	else if ( aCommand==KCmdSelectPostProcessorL )
sl@0
   471
		{
sl@0
   472
		DoCmdSelectPostProcessorL(aSection);
sl@0
   473
		}
sl@0
   474
	else if ( aCommand==KCmdPostProcessorInfoLC )
sl@0
   475
		{
sl@0
   476
		DoCmdPostProcessorInfoLC();
sl@0
   477
		}
sl@0
   478
	else if ( aCommand==KCmdGetOutputFormatListL )
sl@0
   479
		{
sl@0
   480
		DoCmdGetOutputFormatListL(aSection);
sl@0
   481
		}	
sl@0
   482
	else if ( aCommand==KCmdFindCommonFormat )
sl@0
   483
		{
sl@0
   484
		DoCmdFindCommonFormat();
sl@0
   485
		}
sl@0
   486
	else if ( aCommand==KCmdSetOutputFormatL )
sl@0
   487
		{
sl@0
   488
		DoCmdSetOutputFormatL(aSection);
sl@0
   489
		}
sl@0
   490
	else if ( aCommand==KCmdGetHeaderInformationL )
sl@0
   491
		{
sl@0
   492
		DoCmdGetHeaderInformationL(aSection);
sl@0
   493
		}	
sl@0
   494
	else if ( aCommand==KCmdReturnHeader )
sl@0
   495
		{
sl@0
   496
		DoCmdReturnHeader();
sl@0
   497
		}	
sl@0
   498
	else if ( aCommand==KCmdSetVideoDestScreenL )
sl@0
   499
		{
sl@0
   500
		DoCmdSetVideoDestScreenL();
sl@0
   501
		}
sl@0
   502
	else if ( aCommand==KCmdGetBufferOptions )
sl@0
   503
		{
sl@0
   504
		DoCmdGetBufferOptions();
sl@0
   505
		}
sl@0
   506
	else if ( aCommand==KCmdSetBufferOptionsL )
sl@0
   507
		{
sl@0
   508
		DoCmdSetBufferOptionsL();
sl@0
   509
		}	
sl@0
   510
	else if ( aCommand==KCmdSetPostProcessTypesL )
sl@0
   511
		{
sl@0
   512
		DoCmdSetPostProcessTypesL(aSection);
sl@0
   513
		}
sl@0
   514
	else if ( aCommand==KCmdSetInputFormat )
sl@0
   515
		{
sl@0
   516
		DoCmdSetInputFormatL(aSection);
sl@0
   517
		}
sl@0
   518
	else if ( aCommand==KCmdStartDirectScreenAccess )
sl@0
   519
		{
sl@0
   520
		DoCmdStartDirectScreenAccessL(aSection);
sl@0
   521
		}
sl@0
   522
	else if ( aCommand==KCmdAbortDirectScreenAccess )
sl@0
   523
		{
sl@0
   524
		DoCmdAbortDirectScreenAccess();
sl@0
   525
		}
sl@0
   526
	else if ( aCommand==KCmdUtilityGetEnvironment )
sl@0
   527
		{
sl@0
   528
		DoCmdUtilityGetEnvironmentL();
sl@0
   529
		}
sl@0
   530
	else if ( aCommand==KCmdH264CreateDecTest)
sl@0
   531
		{
sl@0
   532
		DoCmdH264CreateDecTest(aSection);
sl@0
   533
		}
sl@0
   534
	else if (aCommand==KCmdH264SelectPostProcessor)
sl@0
   535
	    {
sl@0
   536
	    DoCmdH264SelectPostProcessor(aSection);
sl@0
   537
	    }
sl@0
   538
	else if (aCommand==KCmdH264SetPostProcessTypes)
sl@0
   539
	    {
sl@0
   540
	    DoCmdH264SetPostProcessTypes(aSection);
sl@0
   541
	    }
sl@0
   542
	else if (aCommand==KCmdH264SetInputFormatCompr)
sl@0
   543
		{
sl@0
   544
		DoCmdH264SetInputFormatCompr(aSection);
sl@0
   545
		}
sl@0
   546
	else if (aCommand==KCmdH264SetOutputFormat)
sl@0
   547
		{
sl@0
   548
		DoCmdH264SetOutputFormat(aSection);
sl@0
   549
		}
sl@0
   550
	else if (aCommand==KCmdH264SetBufferOptions)
sl@0
   551
		{
sl@0
   552
		DoCmdH264SetBufferOptions(aSection);
sl@0
   553
		}
sl@0
   554
	else if (aCommand==KCmdH264ListFrameSize)
sl@0
   555
	    {
sl@0
   556
	    DoCmdH264ListFrameSize();
sl@0
   557
	    }
sl@0
   558
	else if (aCommand==KCmdH264SetVideoDestScreen)
sl@0
   559
	    {
sl@0
   560
	    DoCmdH264SetVideoDestScreen(aSection);
sl@0
   561
	    }
sl@0
   562
	else if (aCommand==KCmdH264SetWindowRect)
sl@0
   563
	    {
sl@0
   564
	    DoCmdH264SetWindowRect(aSection);
sl@0
   565
	    }
sl@0
   566
	else if (aCommand==KCmdH264Initialize)
sl@0
   567
		{
sl@0
   568
		DoCmdH264Initialize();
sl@0
   569
		}
sl@0
   570
	else if (aCommand==KCmdH264Start)
sl@0
   571
		{
sl@0
   572
		DoCmdH264Start(aSection);
sl@0
   573
		}
sl@0
   574
	else if (aCommand==KCmdH264IOFrameMatch)
sl@0
   575
		{
sl@0
   576
		DoCmdH264IOFrameNumMatch();
sl@0
   577
		}
sl@0
   578
	else if (aCommand==KCmdH264Stop)
sl@0
   579
		{
sl@0
   580
		DoCmdH264Stop();
sl@0
   581
		}
sl@0
   582
	else if (aCommand==KCmdH264GetHeaderInformation)
sl@0
   583
	    {
sl@0
   584
	    DoCmdH264GetHeaderInformation(aSection);
sl@0
   585
	    }
sl@0
   586
	else if (aCommand==KCmdH264FindCommonFormats)
sl@0
   587
	    {
sl@0
   588
	    DoCmdH264FindCommonFormats();
sl@0
   589
	    }
sl@0
   590
	else if (aCommand==KCmdH264EnableSynchronization)
sl@0
   591
	    {
sl@0
   592
	    DoCmdH264EnableSynchronization(aSection);
sl@0
   593
	    }
sl@0
   594
	else if (aCommand==KCmdH264SetScaleOptions)
sl@0
   595
	    {
sl@0
   596
	    DoCmdH264SetScaleOptions(aSection);
sl@0
   597
	    }
sl@0
   598
	else if (aCommand==KCmdH264SetRotateOptions)
sl@0
   599
	    {
sl@0
   600
	    DoCmdH264SetRotateOptions(aSection);
sl@0
   601
	    }
sl@0
   602
	else if (aCommand==KCmdH264SynchronizeDecoding)
sl@0
   603
	    {
sl@0
   604
	    DoCmdH264SynchronizeDecoding(aSection);
sl@0
   605
	    }
sl@0
   606
	else if (aCommand==KCmdH264Delete)
sl@0
   607
	    {
sl@0
   608
	    DoCmdH264Delete();
sl@0
   609
	    }
sl@0
   610
    else if (aCommand==KCmdH264Pause)
sl@0
   611
        {
sl@0
   612
        DoCmdH264Pause();
sl@0
   613
        }
sl@0
   614
    else if (aCommand==KCmdH264Resume)
sl@0
   615
        {
sl@0
   616
        DoCmdH264Resume();
sl@0
   617
        }
sl@0
   618
    else if (aCommand==KCmdH264SetPosition)
sl@0
   619
        {
sl@0
   620
        DoCmdH264SetPosition(aSection);
sl@0
   621
        }
sl@0
   622
	else if (aCommand==KCmdH264AbortDirectScreenAccess)
sl@0
   623
		{
sl@0
   624
		DoCmdH264AbortDirectScreenAccess();
sl@0
   625
		}
sl@0
   626
	else
sl@0
   627
		{
sl@0
   628
		ERR_PRINTF1(_L("Unknown command"));
sl@0
   629
		ret = EFalse;
sl@0
   630
		}
sl@0
   631
	return ret;
sl@0
   632
	}
sl@0
   633
sl@0
   634
/**
sl@0
   635
 * Constructs CMMFDevVideoPlay instance and initialize params.
sl@0
   636
 * @param	aSection	- The section to read from the ini file
sl@0
   637
 * @return	none
sl@0
   638
 */
sl@0
   639
void CT_CMMFDevVideoPlay::DoCmdNewL(const TTEFSectionName& aSection)
sl@0
   640
	{
sl@0
   641
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdNewL"));
sl@0
   642
	TBool dataOk = ETrue;
sl@0
   643
	DestroyData();	
sl@0
   644
	TRAPD(err, iDevvp = CMMFDevVideoPlay::NewL(*this));
sl@0
   645
	if ( err!=KErrNone)
sl@0
   646
		{
sl@0
   647
		ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdNewL failed with error %d"), err);
sl@0
   648
		SetError (err);
sl@0
   649
		dataOk = EFalse;
sl@0
   650
		}	
sl@0
   651
	if(dataOk)
sl@0
   652
		{
sl@0
   653
		TRAP(err, InitializeParamsL(aSection));	
sl@0
   654
		if (err != KErrNone)
sl@0
   655
			{
sl@0
   656
			ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdNewL failed in InitializeParamsL. Error: %d"), err);
sl@0
   657
			SetError (err);
sl@0
   658
			}
sl@0
   659
		CreateFiles(aSection);	
sl@0
   660
		}	
sl@0
   661
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdNewL"));
sl@0
   662
	}  
sl@0
   663
sl@0
   664
/**
sl@0
   665
 * Open File session
sl@0
   666
 */ 
sl@0
   667
void CT_CMMFDevVideoPlay::CreateFiles(const TTEFSectionName& aSection)
sl@0
   668
	{     
sl@0
   669
	TPtrC inputPath;
sl@0
   670
	TPtrC outputPath;
sl@0
   671
	TPtrC inputfile;
sl@0
   672
	TPtrC outputfile;
sl@0
   673
	TBool screenout = EFalse;
sl@0
   674
	TInt error = KErrNone;
sl@0
   675
	TBool dataOk = ETrue;
sl@0
   676
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::CreateFiles"));
sl@0
   677
	
sl@0
   678
	if ( !(GetBoolFromConfig(aSection, KScreenout(), screenout)))
sl@0
   679
		{
sl@0
   680
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KScreenout());
sl@0
   681
		SetBlockResult(EFail);
sl@0
   682
		dataOk = EFalse;
sl@0
   683
		}
sl@0
   684
	if ( !(GetStringFromConfig(aSection, KInputfile(),inputfile)))
sl@0
   685
		{
sl@0
   686
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputfile());
sl@0
   687
		SetBlockResult(EFail);
sl@0
   688
		dataOk = EFalse;
sl@0
   689
		}
sl@0
   690
	if ( !screenout)
sl@0
   691
		{
sl@0
   692
		if ( !(GetStringFromConfig(aSection, KOutputfile(),outputfile)))
sl@0
   693
			{
sl@0
   694
			ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputfile());
sl@0
   695
			SetBlockResult(EFail);
sl@0
   696
			dataOk = EFalse;
sl@0
   697
			}
sl@0
   698
		} 
sl@0
   699
	if ( !(GetStringFromConfig(aSection, KInputPath(),inputPath)))
sl@0
   700
		{
sl@0
   701
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputPath());
sl@0
   702
		SetBlockResult(EFail);
sl@0
   703
		dataOk = EFalse;
sl@0
   704
		}			
sl@0
   705
	if(dataOk)
sl@0
   706
		{		
sl@0
   707
		error = iFs.Connect ();
sl@0
   708
		if ( error!=KErrNone)
sl@0
   709
			{
sl@0
   710
			ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdNewL failed with error %d"), error);
sl@0
   711
			SetError (error);
sl@0
   712
			}
sl@0
   713
		else
sl@0
   714
			{
sl@0
   715
			TFileName inFileName(inputPath);
sl@0
   716
			inFileName.Append (inputfile);
sl@0
   717
			//Open File
sl@0
   718
			if ( screenout)
sl@0
   719
				{
sl@0
   720
				TRAPD(err, OpenFileL(inFileName));
sl@0
   721
				if ( err != KErrNone)
sl@0
   722
					{
sl@0
   723
					ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdNewL failed with error %d"), err);
sl@0
   724
					SetError (err);
sl@0
   725
					}
sl@0
   726
				iFileOpen = ETrue;
sl@0
   727
				INFO_PRINTF1(_L("File Opened!"));
sl@0
   728
				}
sl@0
   729
			else
sl@0
   730
				{
sl@0
   731
				if ( ! (GetStringFromConfig(aSection, KOutputPath(),outputPath)))
sl@0
   732
					{
sl@0
   733
					ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputPath());
sl@0
   734
					SetBlockResult(EFail);
sl@0
   735
					}
sl@0
   736
				TFileName outFileName(outputPath);
sl@0
   737
				outFileName.Append (outputfile);
sl@0
   738
				TRAPD(err, OpenFileL(outFileName, inFileName));
sl@0
   739
				if ( err != KErrNone)
sl@0
   740
					{
sl@0
   741
					ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::OpenFileL failed with error %d"), err);
sl@0
   742
					SetError (err);
sl@0
   743
					}
sl@0
   744
				iFileOpen = ETrue;
sl@0
   745
				}
sl@0
   746
			}												
sl@0
   747
		}	
sl@0
   748
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::CreateFiles"));
sl@0
   749
	}
sl@0
   750
sl@0
   751
/**
sl@0
   752
 * Initilize Engine parameters 
sl@0
   753
 * @param	aSection	-	The section to read from the ini file
sl@0
   754
 * @return	none
sl@0
   755
 */
sl@0
   756
void CT_CMMFDevVideoPlay::InitializeParamsL(const TTEFSectionName& aSection)
sl@0
   757
	{
sl@0
   758
	TInt codec = 0;
sl@0
   759
	TBool dataOk = ETrue;
sl@0
   760
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::InitializeParamsL"));
sl@0
   761
	if ( !(GetEnumFromConfig(aSection, KCodec(), iCodecs, codec)))
sl@0
   762
		{
sl@0
   763
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCodec());
sl@0
   764
		SetBlockResult(EFail);
sl@0
   765
		dataOk = EFalse;
sl@0
   766
		}	
sl@0
   767
	if ( !(GetBoolFromConfig(aSection, KScreenout(), iDirectScreenAccess)))
sl@0
   768
		{
sl@0
   769
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KScreenout());
sl@0
   770
		SetBlockResult(EFail);
sl@0
   771
		dataOk = EFalse;
sl@0
   772
		}
sl@0
   773
	
sl@0
   774
	if(dataOk)
sl@0
   775
		{
sl@0
   776
		iCodecType=(TVideoCodec)codec;
sl@0
   777
		if (iDirectScreenAccess)
sl@0
   778
			{
sl@0
   779
			User::LeaveIfError(FbsStartup());
sl@0
   780
			}
sl@0
   781
		}	
sl@0
   782
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::InitializeParamsL"));
sl@0
   783
	}
sl@0
   784
sl@0
   785
/**
sl@0
   786
 * Sets the clock source in case the sync parameter is true
sl@0
   787
 * @param	aSection	- The section to read from the ini file
sl@0
   788
 * @return	none
sl@0
   789
 */
sl@0
   790
void CT_CMMFDevVideoPlay::DoCmdSetClockSource(const TTEFSectionName& aSection)
sl@0
   791
	{
sl@0
   792
	TInt framerate = 0;
sl@0
   793
	TInt synch = 0;
sl@0
   794
	TBool dataOk = ETrue;
sl@0
   795
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetClockSource"));	
sl@0
   796
	if ( !( GetIntFromConfig(aSection, KFramerate(), framerate)) )
sl@0
   797
        {
sl@0
   798
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFramerate());
sl@0
   799
        SetBlockResult(EFail);
sl@0
   800
        dataOk = EFalse;
sl@0
   801
        }
sl@0
   802
	if ( !( GetIntFromConfig(aSection,KSynch(), synch)) )
sl@0
   803
        {
sl@0
   804
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSynch());
sl@0
   805
        SetBlockResult(EFail);
sl@0
   806
        dataOk = EFalse;
sl@0
   807
        }
sl@0
   808
	if(dataOk)
sl@0
   809
		{
sl@0
   810
		if (synch) //Set Clock and frame rate for syncronization    
sl@0
   811
	       	{    
sl@0
   812
	       	TRAPD(err, ListFrameSizeL(iCodecType));
sl@0
   813
	    	if ( err != KErrNone)
sl@0
   814
	    		{
sl@0
   815
	    		ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::ListFrameSizeL failed with error %d"), err);
sl@0
   816
	    		SetError (err);
sl@0
   817
	    		}
sl@0
   818
	    	else
sl@0
   819
	    		{
sl@0
   820
	    		INFO_PRINTF1(_L("List Frame done!"));    	
sl@0
   821
		       	iDevvp->SetClockSource(iClock);  
sl@0
   822
		        iSynchronized = ETrue;
sl@0
   823
		        iFrameTimeInterval = (TInt64)(1000000/framerate);
sl@0
   824
		        iFramerate = framerate;
sl@0
   825
	    		}	    	
sl@0
   826
	       	}
sl@0
   827
		}		
sl@0
   828
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetClockSource"));
sl@0
   829
	}
sl@0
   830
sl@0
   831
/**
sl@0
   832
 * Gets the decoders list and Select a Decoder
sl@0
   833
 * @param	aSection	-	Section to read from the ini file
sl@0
   834
 * @return none
sl@0
   835
 */
sl@0
   836
void CT_CMMFDevVideoPlay::DoCmdSelectDecoderL(const TTEFSectionName& aSection)
sl@0
   837
	{
sl@0
   838
	TInt decoder;
sl@0
   839
	TBool dataOk = ETrue;
sl@0
   840
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSelectDecoder"));
sl@0
   841
	if ( !(GetHexFromConfig(aSection, KDecoder(), decoder)))
sl@0
   842
		{
sl@0
   843
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDecoder());
sl@0
   844
		SetBlockResult(EFail);
sl@0
   845
		dataOk = EFalse;
sl@0
   846
		}
sl@0
   847
	if(dataOk)
sl@0
   848
		{
sl@0
   849
		iSelectDecoder=TUid::Uid(decoder);
sl@0
   850
		TRAPD(err, iDecHWDevId = iDevvp->SelectDecoderL(iSelectDecoder));
sl@0
   851
		if (err != KErrNone)
sl@0
   852
			{
sl@0
   853
			ERR_PRINTF2(_L("SelectDecoderL left with error: %d"), err);
sl@0
   854
			SetError(err);
sl@0
   855
			}
sl@0
   856
		}	
sl@0
   857
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSelectDecoder"));
sl@0
   858
	}
sl@0
   859
sl@0
   860
/**
sl@0
   861
 * Gets the postprocessores list and Select a PostProcessor
sl@0
   862
 * @param	aSection	-	Section to read from the ini file
sl@0
   863
 * @return	none
sl@0
   864
 */
sl@0
   865
void CT_CMMFDevVideoPlay::DoCmdSelectPostProcessorL(const TTEFSectionName& aSection)
sl@0
   866
	{
sl@0
   867
	TInt postPro;
sl@0
   868
	TBool dataOk = ETrue;
sl@0
   869
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSelectPostProcessor"));
sl@0
   870
	if ( !(GetHexFromConfig(aSection, KPostPro(), postPro)))
sl@0
   871
		{
sl@0
   872
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDecoder());
sl@0
   873
		SetBlockResult(EFail);
sl@0
   874
		dataOk = EFalse;
sl@0
   875
		}
sl@0
   876
	if(dataOk)
sl@0
   877
		{
sl@0
   878
		iSelectPostProcessor=TUid::Uid(postPro);
sl@0
   879
		TRAPD(err, iPostProcId = iDevvp->SelectPostProcessorL(iSelectPostProcessor));
sl@0
   880
		if (err != KErrNone)
sl@0
   881
			{
sl@0
   882
			ERR_PRINTF2(_L("SelectPostProcessorL left with error %d"), err);
sl@0
   883
	        SetError(err);
sl@0
   884
			}
sl@0
   885
		}	
sl@0
   886
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSelectPostProcessor"));
sl@0
   887
	}
sl@0
   888
sl@0
   889
/**
sl@0
   890
 * Sets the input format for the decoder and the postprocessor
sl@0
   891
 * @param	aSection	-	Section to read from the ini file
sl@0
   892
 * @return	none
sl@0
   893
 */
sl@0
   894
void CT_CMMFDevVideoPlay::DoCmdSetInputFormatL(const TTEFSectionName& aSection)
sl@0
   895
	{
sl@0
   896
	TBuf8<50> mimetype;
sl@0
   897
	TBool useDecoder = ETrue;
sl@0
   898
	TInt tVideoDataUnitType = EDuCodedPicture;
sl@0
   899
	TInt tVideoDataUnitEncapsulation = EDuElementaryStream;
sl@0
   900
	TBool dataInOrder=ETrue;	
sl@0
   901
	TPtrC mimeType;
sl@0
   902
	TBool dataOk = ETrue;
sl@0
   903
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetInputFormat"));
sl@0
   904
	if(!GetStringFromConfig(aSection, KMimeType(), mimeType))
sl@0
   905
		{
sl@0
   906
		ERR_PRINTF1(_L("Mime type not retrieved, command will not be executed"));
sl@0
   907
		SetBlockResult(EFail);
sl@0
   908
		dataOk = EFalse;
sl@0
   909
		}
sl@0
   910
	if ( !(GetBoolFromConfig(aSection, KUseDecoder(), useDecoder)))
sl@0
   911
		{
sl@0
   912
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUseDecoder());
sl@0
   913
		SetBlockResult(EFail);
sl@0
   914
		dataOk = EFalse;
sl@0
   915
		}
sl@0
   916
		
sl@0
   917
	if( !(GetBoolFromConfig(aSection, KDataInOrder(), dataInOrder)))
sl@0
   918
		{
sl@0
   919
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file, using default value"),&KDataInOrder());
sl@0
   920
		}			
sl@0
   921
	if(! (GetEnumFromConfig(aSection, KTVideoDataUnitType(), iTVideoDataUnitType,tVideoDataUnitType)))
sl@0
   922
		{
sl@0
   923
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file, using default value"),&KTVideoDataUnitType());
sl@0
   924
		}
sl@0
   925
	if( !(GetEnumFromConfig(aSection, KTVideoDataUnitEncapsulation(), iTVideoDataUnitEncapsulation,tVideoDataUnitEncapsulation)))
sl@0
   926
		{
sl@0
   927
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file, using default value"),&KTVideoDataUnitEncapsulation());
sl@0
   928
		}	
sl@0
   929
	if(dataOk)
sl@0
   930
		{
sl@0
   931
		mimetype.Append(mimeType);
sl@0
   932
		if ( useDecoder) //Decoder
sl@0
   933
			{
sl@0
   934
			CCompressedVideoFormat* compressedFormat=NULL;
sl@0
   935
			TRAPD(error, compressedFormat = CCompressedVideoFormat::NewL (mimetype));
sl@0
   936
			if (error != KErrNone)
sl@0
   937
				{
sl@0
   938
				ERR_PRINTF2(_L("Error in CCompressedVideoFormat::NewL: %d"), error);
sl@0
   939
				SetError (error);
sl@0
   940
				}
sl@0
   941
			else
sl@0
   942
				{
sl@0
   943
				CleanupStack::PushL (compressedFormat);
sl@0
   944
				TRAP(error,
sl@0
   945
						iDevvp->SetInputFormatL(iDecHWDevId, *compressedFormat, 
sl@0
   946
									(TVideoDataUnitType)tVideoDataUnitType, 
sl@0
   947
									(TVideoDataUnitEncapsulation)tVideoDataUnitEncapsulation,
sl@0
   948
									dataInOrder));
sl@0
   949
				CleanupStack::PopAndDestroy (compressedFormat);
sl@0
   950
				if ( error != KErrNone)
sl@0
   951
					{
sl@0
   952
					ERR_PRINTF2(_L("Error in SetInputFormatL for decoder: %d"), error);
sl@0
   953
					SetError (error);
sl@0
   954
					}
sl@0
   955
				else
sl@0
   956
					{
sl@0
   957
					INFO_PRINTF1(_L("SetInputFormatL done!"));			
sl@0
   958
					}
sl@0
   959
				}
sl@0
   960
			
sl@0
   961
			}
sl@0
   962
		else // PostProcessor
sl@0
   963
			{
sl@0
   964
			TRAPD(err, iDevvp->SetInputFormatL(iPostProcId, iCommonFormat));
sl@0
   965
			if ( err != KErrNone)
sl@0
   966
				{
sl@0
   967
				ERR_PRINTF2(_L("Error in SetInputFormatL for PostProcessor: %d"), err);
sl@0
   968
				SetError (err);
sl@0
   969
				}
sl@0
   970
			}
sl@0
   971
		}	
sl@0
   972
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetInputFormat"));
sl@0
   973
	}
sl@0
   974
sl@0
   975
/**
sl@0
   976
 * Gets the output format list from the decoder and the postprocessor
sl@0
   977
 * @param	aSection	-	The section to read from the ini file
sl@0
   978
 * @return	none
sl@0
   979
 */
sl@0
   980
void CT_CMMFDevVideoPlay::DoCmdGetOutputFormatListL(const TTEFSectionName& aSection)
sl@0
   981
	{
sl@0
   982
	TBool useDecoder = ETrue; //ETrue - Decoder , EFalse - PostProcessor
sl@0
   983
	TBool dataOk = ETrue;
sl@0
   984
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdGetOutputFormatListL"));
sl@0
   985
	if ( !(GetBoolFromConfig(aSection, KUseDecoder(), useDecoder)))
sl@0
   986
		{
sl@0
   987
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUseDecoder());
sl@0
   988
		SetBlockResult(EFail);
sl@0
   989
		dataOk = EFalse;
sl@0
   990
		}
sl@0
   991
	if(dataOk)
sl@0
   992
		{
sl@0
   993
		if ( useDecoder) //Decoder
sl@0
   994
			{
sl@0
   995
			TRAPD(err, iDevvp->GetOutputFormatListL(iDecHWDevId, iDecFormats));
sl@0
   996
			if ( err != KErrNone)
sl@0
   997
				{
sl@0
   998
				ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdGetOutputFormatListL failed with error %d"), err);
sl@0
   999
				SetError (err);
sl@0
  1000
				}
sl@0
  1001
			}
sl@0
  1002
		else //PostProcessor
sl@0
  1003
			{
sl@0
  1004
			TRAPD(err1, iDevvp->GetOutputFormatListL(iPostProcId, iPPFormats));
sl@0
  1005
			if ( err1 != KErrNone)
sl@0
  1006
				{
sl@0
  1007
				ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdGetOutputFormatListL left with error %d"), err1);
sl@0
  1008
				SetError (err1);
sl@0
  1009
				}
sl@0
  1010
			}
sl@0
  1011
		}	
sl@0
  1012
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdGetOutputFormatListL"));
sl@0
  1013
	}
sl@0
  1014
sl@0
  1015
/**
sl@0
  1016
 * Gets the postprocessor info.
sl@0
  1017
 */
sl@0
  1018
void CT_CMMFDevVideoPlay::DoCmdPostProcessorInfoLC()
sl@0
  1019
	{
sl@0
  1020
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdPostProcessorInfo"));
sl@0
  1021
	delete iInfo;
sl@0
  1022
	iInfo=NULL;
sl@0
  1023
	TRAPD(err, {iInfo = iDevvp->PostProcessorInfoLC(iSelectPostProcessor); CleanupStack::Pop(iInfo);} );
sl@0
  1024
	if ( err!=KErrNone )
sl@0
  1025
		{
sl@0
  1026
		ERR_PRINTF2(_L("PostProcessorInfoLC failed with error %i"),err);
sl@0
  1027
		}
sl@0
  1028
	else
sl@0
  1029
		{
sl@0
  1030
		iPPFormats = iInfo->SupportedFormats();
sl@0
  1031
		}
sl@0
  1032
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdPostProcessorInfo"));
sl@0
  1033
	}
sl@0
  1034
sl@0
  1035
/**
sl@0
  1036
 * Find common format for dec output and postproc input. 
sl@0
  1037
 * Precondition: The command GetOutputList has to be called before, for the Decoder and the postprocessor,
sl@0
  1038
 * because in this method we use both list to find the common format.
sl@0
  1039
 */
sl@0
  1040
void CT_CMMFDevVideoPlay::DoCmdFindCommonFormat()
sl@0
  1041
	{
sl@0
  1042
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdFindCommonFormat"));
sl@0
  1043
	if ( iDevvp->FindCommonFormat (iDecFormats.Array (), iPPFormats.Array (), iCommonFormat) )
sl@0
  1044
		{
sl@0
  1045
		INFO_PRINTF1(_L("DoCmdFindCommonFormat found common Format!"));
sl@0
  1046
		}
sl@0
  1047
	else
sl@0
  1048
		{
sl@0
  1049
		iCommonFormat = iDecFormats[0];
sl@0
  1050
		ERR_PRINTF1(_L("Error in CT_CMMFDevVideoPlay::DoCmdFindCommonFormat: Common Format not found."));
sl@0
  1051
		SetBlockResult(EFail);
sl@0
  1052
		}
sl@0
  1053
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdFindCommonFormat"));
sl@0
  1054
	}
sl@0
  1055
sl@0
  1056
/**
sl@0
  1057
 * Sets the output format for both the decoder and the postprocessor.
sl@0
  1058
 * @param	aSection	-	The section to read from the ini file
sl@0
  1059
 * @return	none
sl@0
  1060
 */
sl@0
  1061
void CT_CMMFDevVideoPlay::DoCmdSetOutputFormatL(const TTEFSectionName& aSection)
sl@0
  1062
	{
sl@0
  1063
	TBool useDecoder = ETrue;
sl@0
  1064
	TBool dataOk = ETrue;
sl@0
  1065
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetOutputFormat"));
sl@0
  1066
	if ( !(GetBoolFromConfig(aSection, KUseDecoder(), useDecoder)))
sl@0
  1067
		{
sl@0
  1068
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUseDecoder());
sl@0
  1069
		SetBlockResult(EFail);
sl@0
  1070
		dataOk = EFalse;
sl@0
  1071
		}
sl@0
  1072
	if(dataOk)
sl@0
  1073
		{
sl@0
  1074
		if ( useDecoder)
sl@0
  1075
			{ //Decoder			
sl@0
  1076
			TRAPD(error, iDevvp->SetOutputFormatL (iDecHWDevId, iCommonFormat));
sl@0
  1077
			if(error != KErrNone)
sl@0
  1078
				{
sl@0
  1079
				ERR_PRINTF2(_L("SetOutputFormatL left with error %d"), error);
sl@0
  1080
				SetError(error);
sl@0
  1081
				}
sl@0
  1082
			}
sl@0
  1083
		else
sl@0
  1084
			{ //PostProcessor
sl@0
  1085
			if ( iDirectScreenAccess)
sl@0
  1086
				{
sl@0
  1087
				//Set Output Fomat
sl@0
  1088
				TUncompressedVideoFormat outFormat;
sl@0
  1089
				outFormat.iDataFormat = ERgbRawData;
sl@0
  1090
				outFormat.iRgbFormat = ERgb32bit888; //RGB format for display         
sl@0
  1091
				TRAPD(error, iDevvp->SetOutputFormatL (iPostProcId, outFormat));
sl@0
  1092
				if(error != KErrNone)
sl@0
  1093
					{
sl@0
  1094
					ERR_PRINTF2(_L("SetOutputFormatL left with error %d"), error);
sl@0
  1095
					SetError(error);
sl@0
  1096
					}
sl@0
  1097
sl@0
  1098
				}
sl@0
  1099
			else // Memory buffer output
sl@0
  1100
				{
sl@0
  1101
				TRAPD(error, iDevvp->SetOutputFormatL (iPostProcId, iCommonFormat));
sl@0
  1102
				if(error != KErrNone)
sl@0
  1103
					{
sl@0
  1104
					ERR_PRINTF2(_L("SetOutputFormatL left with error %d"), error);
sl@0
  1105
					SetError(error);
sl@0
  1106
					}
sl@0
  1107
				}
sl@0
  1108
			}
sl@0
  1109
		}	
sl@0
  1110
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetOutputFormat"));
sl@0
  1111
	}
sl@0
  1112
sl@0
  1113
sl@0
  1114
/**
sl@0
  1115
 * Gets the header information.
sl@0
  1116
 * @param	aSection	-	The section to read from the ini file
sl@0
  1117
 * @return	none
sl@0
  1118
 */
sl@0
  1119
void CT_CMMFDevVideoPlay::DoCmdGetHeaderInformationL(const TTEFSectionName& aSection)
sl@0
  1120
	{
sl@0
  1121
	TInt bufSize = 0;
sl@0
  1122
	TBool dataOk = ETrue;
sl@0
  1123
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdGetHeaderInformationL"));
sl@0
  1124
	if ( !(GetIntFromConfig(aSection, KBuf(), bufSize)))
sl@0
  1125
		{
sl@0
  1126
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBuf());
sl@0
  1127
		SetBlockResult(EFail);
sl@0
  1128
		dataOk = EFalse;
sl@0
  1129
		}		
sl@0
  1130
	if(dataOk)
sl@0
  1131
		{
sl@0
  1132
		INFO_PRINTF1(_L("GetHeaderInformationL init..!"));
sl@0
  1133
		TInt err = KErrNone;
sl@0
  1134
		iHeaderInfo = NULL;
sl@0
  1135
		HBufC8* tempBuff=  NULL;
sl@0
  1136
		//Read Picture header : Size is not known
sl@0
  1137
		TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
sl@0
  1138
		CleanupStack::PushL ( codedBuffer);
sl@0
  1139
		if ( iFrameListed) //frame size known 
sl@0
  1140
			{
sl@0
  1141
			tempBuff = HBufC8::NewLC(iInBuffSize);
sl@0
  1142
			codedBuffer->iData.Set (tempBuff->Des ());
sl@0
  1143
			if(iFrameSizeList.Count() > 0)
sl@0
  1144
				{
sl@0
  1145
				err = ReadOneCodedPicture (codedBuffer, iFrameSizeList[0]);
sl@0
  1146
				}
sl@0
  1147
			else
sl@0
  1148
				{
sl@0
  1149
				err = KErrGeneral;
sl@0
  1150
				}
sl@0
  1151
			
sl@0
  1152
			TInt pos =0;
sl@0
  1153
			if ( iInFile.Seek (ESeekStart, pos))
sl@0
  1154
				{
sl@0
  1155
				err = KErrGeneral;
sl@0
  1156
				}
sl@0
  1157
			if ( err < 0)
sl@0
  1158
				{
sl@0
  1159
				CleanupStack::PopAndDestroy (tempBuff);
sl@0
  1160
				}
sl@0
  1161
			}
sl@0
  1162
		else //frame size not known 
sl@0
  1163
			{
sl@0
  1164
			iInBuffSize = KH263MaxCodedSizeQCIF;
sl@0
  1165
			err = KErrOverflow;
sl@0
  1166
			while ( (err == KErrOverflow) && (iInBuffSize <= KMP4MaxCodedSizeVGA))
sl@0
  1167
				{
sl@0
  1168
				tempBuff = HBufC8::NewLC(iInBuffSize);
sl@0
  1169
				codedBuffer->iData.Set (tempBuff->Des ());
sl@0
  1170
				err = ReadOneCodedPicture (codedBuffer);
sl@0
  1171
				TInt pos =0;
sl@0
  1172
				if ( iInFile.Seek (ESeekStart, pos))
sl@0
  1173
					{
sl@0
  1174
					err = KErrGeneral;
sl@0
  1175
					}
sl@0
  1176
				if ( iInputEnd)
sl@0
  1177
					{
sl@0
  1178
					err = KErrNotFound;
sl@0
  1179
					}
sl@0
  1180
				if ( err < 0)
sl@0
  1181
					{
sl@0
  1182
					CleanupStack::PopAndDestroy (tempBuff);
sl@0
  1183
					iInBuffSize = 4*iInBuffSize;
sl@0
  1184
					}
sl@0
  1185
				}
sl@0
  1186
			}
sl@0
  1187
		// Reitrieve header information from bitstream 
sl@0
  1188
		if ( err < 0)
sl@0
  1189
			{
sl@0
  1190
			CleanupStack::PopAndDestroy (codedBuffer);
sl@0
  1191
			}
sl@0
  1192
		else
sl@0
  1193
			{
sl@0
  1194
			TRAPD(error, iHeaderInfo = iDevvp->GetHeaderInformationL(EDuCodedPicture, EDuElementaryStream,codedBuffer));
sl@0
  1195
			CleanupStack::PopAndDestroy (tempBuff);
sl@0
  1196
			CleanupStack::PopAndDestroy (codedBuffer);		
sl@0
  1197
			if ( error != KErrNone)
sl@0
  1198
				{
sl@0
  1199
				ERR_PRINTF2(_L("Error in DoCmdGetHeaderInformationL: %d"), error);
sl@0
  1200
				SetError(error);				
sl@0
  1201
				}
sl@0
  1202
			else
sl@0
  1203
				{
sl@0
  1204
				//Check Header info 
sl@0
  1205
				if ( iHeaderInfo)
sl@0
  1206
					{
sl@0
  1207
					//Size in Memory
sl@0
  1208
					iPictureSize = iHeaderInfo->iDisplayedRect.Size ();
sl@0
  1209
					// Display rect  
sl@0
  1210
					TSize dispsize = iHeaderInfo->iDisplayedRect.Size ();
sl@0
  1211
					iDispRect.SetSize (dispsize);
sl@0
  1212
					INFO_PRINTF3(_L("Size from Header, Height: %d Width: %d"),dispsize.iHeight,
sl@0
  1213
							dispsize.iWidth);
sl@0
  1214
					INFO_PRINTF3(_L("Size from iPictureSize, Height: %d Width: %d"),iPictureSize.iHeight,
sl@0
  1215
							iPictureSize.iWidth);
sl@0
  1216
					}
sl@0
  1217
				// Set size of decoder input buffer
sl@0
  1218
				if ( !iFrameListed)
sl@0
  1219
					{
sl@0
  1220
					iInBuffSize = bufSize;
sl@0
  1221
					}
sl@0
  1222
				}				
sl@0
  1223
			}
sl@0
  1224
		}
sl@0
  1225
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdGetHeaderInformationL"));
sl@0
  1226
	}
sl@0
  1227
sl@0
  1228
/**
sl@0
  1229
 * Returns  the HeaderInformation of the video
sl@0
  1230
 */
sl@0
  1231
void CT_CMMFDevVideoPlay::DoCmdReturnHeader()
sl@0
  1232
	{
sl@0
  1233
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdReturnHeader"));
sl@0
  1234
	if (iHeaderInfo)
sl@0
  1235
		{
sl@0
  1236
		iDevvp->ReturnHeader(iHeaderInfo);
sl@0
  1237
		}
sl@0
  1238
	else
sl@0
  1239
		{
sl@0
  1240
		ERR_PRINTF1(_L("Error in DoCmdReturnHeader!"));
sl@0
  1241
  		SetBlockResult(EFail);
sl@0
  1242
		}
sl@0
  1243
		INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdReturnHeader"));
sl@0
  1244
	}
sl@0
  1245
sl@0
  1246
/**
sl@0
  1247
 * Sets output on screen or memory buffer
sl@0
  1248
 */
sl@0
  1249
void CT_CMMFDevVideoPlay::DoCmdSetVideoDestScreenL()
sl@0
  1250
	{
sl@0
  1251
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetVideoDestScreenL"));
sl@0
  1252
	TRAPD(err, iDevvp->SetVideoDestScreenL(iDirectScreenAccess));
sl@0
  1253
	if (err != KErrNone)
sl@0
  1254
  		{
sl@0
  1255
  		ERR_PRINTF2(_L("Error in DoCmdSetVideoDestScreenL: %d"), err);
sl@0
  1256
  		SetError(err);
sl@0
  1257
  		}	
sl@0
  1258
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetVideoDestScreenL"));
sl@0
  1259
	}
sl@0
  1260
    
sl@0
  1261
/**
sl@0
  1262
 * Gets the buffer options.
sl@0
  1263
 */
sl@0
  1264
void CT_CMMFDevVideoPlay::DoCmdGetBufferOptions()
sl@0
  1265
	{
sl@0
  1266
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdGetBufferOptions"));
sl@0
  1267
	iDevvp->GetBufferOptions(iBufferOptions);	
sl@0
  1268
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdGetBufferOptions"));
sl@0
  1269
	}
sl@0
  1270
sl@0
  1271
/**
sl@0
  1272
 * Sets the buffer options for the DevVideoPlay
sl@0
  1273
 */
sl@0
  1274
void CT_CMMFDevVideoPlay::DoCmdSetBufferOptionsL()
sl@0
  1275
	{
sl@0
  1276
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetBufferOptionsL"));
sl@0
  1277
	iBufferOptions.iMaxInputBufferSize = iInBuffSize;
sl@0
  1278
	//iBufferOptions.iMaxPostDecodeBufferSize = 0;	
sl@0
  1279
	iBufferOptions.iPreDecodeBufferSize = 0;
sl@0
  1280
	iBufferOptions.iMinNumInputBuffers = KNumOfInputBuffers;
sl@0
  1281
	TRAPD(err, iDevvp->SetBufferOptionsL(iBufferOptions));
sl@0
  1282
	if ( err != KErrNone)
sl@0
  1283
		{
sl@0
  1284
		ERR_PRINTF2(_L("Error in DoCmdSetBufferOptionsL: %d"), err);
sl@0
  1285
		SetError (err);
sl@0
  1286
		}
sl@0
  1287
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetBufferOptionsL"));
sl@0
  1288
	}
sl@0
  1289
sl@0
  1290
/**
sl@0
  1291
 * Sets the options for the postprocessor
sl@0
  1292
 */
sl@0
  1293
void CT_CMMFDevVideoPlay::DoCmdSetPostProcessTypesL(const TTEFSectionName& aSection)
sl@0
  1294
	{
sl@0
  1295
	TInt combination = 0;
sl@0
  1296
	TBool dataOk = ETrue;
sl@0
  1297
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetPostProcessTypesL"));
sl@0
  1298
	if ( ! (GetHexFromConfig(aSection, KCombination(), combination)) )
sl@0
  1299
        {
sl@0
  1300
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCombination());
sl@0
  1301
        SetBlockResult(EFail);
sl@0
  1302
        dataOk = EFalse;
sl@0
  1303
        }
sl@0
  1304
	if(dataOk)
sl@0
  1305
		{
sl@0
  1306
		TRAPD(err,iDevvp->SetPostProcessTypesL(iPostProcId, combination));
sl@0
  1307
		if( err!=KErrNone )
sl@0
  1308
			{
sl@0
  1309
			ERR_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdSetPostProcessTypesL left with error %d"), err);
sl@0
  1310
			SetError(err);		
sl@0
  1311
			} 
sl@0
  1312
		}	
sl@0
  1313
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetPostProcessTypesL"));
sl@0
  1314
	}
sl@0
  1315
sl@0
  1316
/**
sl@0
  1317
 * Initialize the decoder with the specified parameters.
sl@0
  1318
 * @return - KErrNone if no error
sl@0
  1319
 */ 
sl@0
  1320
void CT_CMMFDevVideoPlay::DoCmdInitialize(const TInt aAsyncErrorIndex)
sl@0
  1321
    {  
sl@0
  1322
    INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdInitialize"));
sl@0
  1323
    iAsyncErrorIndex = aAsyncErrorIndex;    
sl@0
  1324
    iDevvp->Initialize();
sl@0
  1325
    IncOutstanding();	
sl@0
  1326
    INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdInitialize"));
sl@0
  1327
    }
sl@0
  1328
sl@0
  1329
/**
sl@0
  1330
 * Starts video decoding directly to the display frame buffer using Direct Screen Access. Playback to the display can start immediately.
sl@0
  1331
 * 
sl@0
  1332
 * @return None
sl@0
  1333
 */
sl@0
  1334
void CT_CMMFDevVideoPlay::DoCmdStart(const TInt aAsyncErrorIndex)
sl@0
  1335
    {
sl@0
  1336
    INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdStart"));
sl@0
  1337
    iAsyncErrorIndex = aAsyncErrorIndex;
sl@0
  1338
    // Start DevVideoPlay
sl@0
  1339
    INFO_PRINTF1(_L("Start Decoding Engine.."));
sl@0
  1340
   	iDevvp->Start();    	
sl@0
  1341
   	//Reset Clock at Stream Start
sl@0
  1342
   	if ( iSynchronized ) 
sl@0
  1343
   	    { 	
sl@0
  1344
   	    TTimeIntervalMicroSeconds offset(KStartOffset);
sl@0
  1345
   	    iClock->Reset(offset);  
sl@0
  1346
   	    }
sl@0
  1347
   	INFO_PRINTF1(_L("Start Data transfer."));
sl@0
  1348
   	TRAPD(err, HandleNewBufferL()); 
sl@0
  1349
   	if (err != KErrNone)
sl@0
  1350
   	    {
sl@0
  1351
   	    ERR_PRINTF2(_L("HandleNewBufferL()left with error %d"),err);
sl@0
  1352
   	    SetError(err);
sl@0
  1353
   	    }
sl@0
  1354
   	else
sl@0
  1355
   	   {
sl@0
  1356
   	    if(!iErrorInputBuffer)
sl@0
  1357
   	    	{
sl@0
  1358
   	    	IncOutstanding();
sl@0
  1359
   		    INFO_PRINTF1(_L("Start..done!"));     
sl@0
  1360
   		    INFO_PRINTF2(_L("iFrameSizeList.Count %d"),iFrameSizeList.Count());  
sl@0
  1361
   	    	} 	       
sl@0
  1362
   	   }         	   
sl@0
  1363
    INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdStart"));
sl@0
  1364
    }
sl@0
  1365
sl@0
  1366
/**
sl@0
  1367
 * Stops the playback
sl@0
  1368
 * @param	aSection	-	The section to read from the ini file
sl@0
  1369
 * @return	none
sl@0
  1370
 */
sl@0
  1371
void CT_CMMFDevVideoPlay::DoCmdStartDirectScreenAccessL(const TTEFSectionName& aSection)
sl@0
  1372
	{
sl@0
  1373
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdStartDirectScreenAccessL"));	
sl@0
  1374
	if ( !iScreenDevice)
sl@0
  1375
		{
sl@0
  1376
		delete iScreenDevice;
sl@0
  1377
		iScreenDevice = NULL;
sl@0
  1378
		RFbsSession::Disconnect();
sl@0
  1379
		TDisplayMode displayMode; //0 - Decoder , 1 - PostProcessor
sl@0
  1380
		TInt value = 0;
sl@0
  1381
		if ( !(GetEnumFromConfig(aSection, KDisplayMode(), iDisplayModes, value)))
sl@0
  1382
			{
sl@0
  1383
			ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDisplayMode());
sl@0
  1384
			SetBlockResult(EFail);
sl@0
  1385
			}
sl@0
  1386
		displayMode = (TDisplayMode)value;
sl@0
  1387
		User::LeaveIfError (RFbsSession::Connect());
sl@0
  1388
		
sl@0
  1389
		TRAPD(error, iScreenDevice = CFbsScreenDevice::NewL (KScreenNumber, displayMode));
sl@0
  1390
		if(error != KErrNone)
sl@0
  1391
			{
sl@0
  1392
			ERR_PRINTF2(_L("Error creating screen device"),error);
sl@0
  1393
			SetError(error);
sl@0
  1394
			}
sl@0
  1395
		}
sl@0
  1396
	
sl@0
  1397
	if ( iDispRect.iBr.iY > KQVGAHeight)
sl@0
  1398
		{
sl@0
  1399
		iDispRect.iTl.iY = 0;
sl@0
  1400
		iDispRect.SetHeight (KQVGAHeight);
sl@0
  1401
		}
sl@0
  1402
	if ( iDispRect.iBr.iX > KQVGAWidth)
sl@0
  1403
		{
sl@0
  1404
		iDispRect.iTl.iX = 0;
sl@0
  1405
		iDispRect.SetWidth (KQVGAWidth);
sl@0
  1406
		}
sl@0
  1407
	
sl@0
  1408
	TRegionFix<1> region(iDispRect);
sl@0
  1409
	//Start DSA
sl@0
  1410
sl@0
  1411
	INFO_PRINTF2(_L("Size window Y: %d"),iDispRect.Height());
sl@0
  1412
	INFO_PRINTF2(_L("Size window X: %d"),iDispRect.Width());
sl@0
  1413
sl@0
  1414
	TRAPD(error,iDevvp->StartDirectScreenAccessL(iDispRect, *iScreenDevice, region));
sl@0
  1415
	if ( error != KErrNone)
sl@0
  1416
		{
sl@0
  1417
		ERR_PRINTF2(_L("StartDirectScreenAccessL error: %d"),error);
sl@0
  1418
		SetError(error);
sl@0
  1419
		}
sl@0
  1420
	else
sl@0
  1421
		{
sl@0
  1422
		iDsaStarted = ETrue;
sl@0
  1423
		}
sl@0
  1424
	
sl@0
  1425
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdStartDirectScreenAccessL"));
sl@0
  1426
	}
sl@0
  1427
sl@0
  1428
/** 
sl@0
  1429
 * Stop Devvideoplay 
sl@0
  1430
 */
sl@0
  1431
void CT_CMMFDevVideoPlay::DoCmdStop()
sl@0
  1432
	{
sl@0
  1433
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdStop"));
sl@0
  1434
	iDevvp->Stop ();
sl@0
  1435
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdStop"));
sl@0
  1436
	}
sl@0
  1437
sl@0
  1438
/**
sl@0
  1439
 * Aborts Direct Screen Access completely
sl@0
  1440
 * @return None
sl@0
  1441
 */
sl@0
  1442
void CT_CMMFDevVideoPlay::DoCmdAbortDirectScreenAccess()
sl@0
  1443
	{
sl@0
  1444
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdAbortDirectScreenAccess"));
sl@0
  1445
	if ( iDirectScreenAccess && iDsaStarted)
sl@0
  1446
		{
sl@0
  1447
		iDevvp->AbortDirectScreenAccess ();
sl@0
  1448
		INFO_PRINTF1(_L("Abort Direct Screen Access Done"));
sl@0
  1449
		iDsaStarted = EFalse;
sl@0
  1450
		}
sl@0
  1451
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdAbortDirectScreenAccess"));
sl@0
  1452
	}
sl@0
  1453
sl@0
  1454
/**
sl@0
  1455
 * Pause the decoding process
sl@0
  1456
 */
sl@0
  1457
void CT_CMMFDevVideoPlay::DoCmdPause()
sl@0
  1458
	{
sl@0
  1459
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdPause"));
sl@0
  1460
	if ( iSynchronized)
sl@0
  1461
		{
sl@0
  1462
		iClock->Suspend (); //Stop Clock source
sl@0
  1463
		}
sl@0
  1464
	iDevvp->Pause();
sl@0
  1465
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdPause"));
sl@0
  1466
	}
sl@0
  1467
sl@0
  1468
/**
sl@0
  1469
 * Resume the decodind process
sl@0
  1470
 */
sl@0
  1471
void CT_CMMFDevVideoPlay::DoCmdResume()
sl@0
  1472
	{
sl@0
  1473
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdResume"));
sl@0
  1474
	if ( iSynchronized)
sl@0
  1475
		{
sl@0
  1476
		iClock->Resume (); //Restart Clock source
sl@0
  1477
		}
sl@0
  1478
	iDevvp->Resume ();	
sl@0
  1479
	if ( iDecHWDevId)
sl@0
  1480
		{		
sl@0
  1481
		if ( iDevvp->NumFreeBuffers () > 0 )
sl@0
  1482
			{
sl@0
  1483
			INFO_PRINTF1(_L("Restart data transfer."));
sl@0
  1484
	    	TRAPD(err1, HandleNewBufferL()); 
sl@0
  1485
	        if (err1 != KErrNone)
sl@0
  1486
	        	{
sl@0
  1487
	        	ERR_PRINTF2(_L("HandleNewBufferL()left with error %d"),err1);
sl@0
  1488
	        	SetError(err1);
sl@0
  1489
	        	return;
sl@0
  1490
	        	}
sl@0
  1491
			}
sl@0
  1492
		}
sl@0
  1493
sl@0
  1494
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdResume"));
sl@0
  1495
	}
sl@0
  1496
sl@0
  1497
/**
sl@0
  1498
 * Rotating the display
sl@0
  1499
 * @param	aSection	-	The section to read from the ini file
sl@0
  1500
 * @return	none
sl@0
  1501
 */
sl@0
  1502
void CT_CMMFDevVideoPlay::DoCmdSetRotateOptionsL(const TTEFSectionName& aSection)
sl@0
  1503
	{
sl@0
  1504
	TRotationType rotation;
sl@0
  1505
	TInt rotItem;
sl@0
  1506
	TBool dataOk = ETrue;
sl@0
  1507
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetRotateOptionsL"));
sl@0
  1508
	if ( !( GetEnumFromConfig(aSection, KRotation(), iRotations, rotItem)))
sl@0
  1509
		{
sl@0
  1510
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRotation());
sl@0
  1511
        SetBlockResult(EFail);
sl@0
  1512
        dataOk = EFalse;
sl@0
  1513
		}
sl@0
  1514
	if(dataOk)
sl@0
  1515
		{
sl@0
  1516
		rotation = (TRotationType)rotItem;		
sl@0
  1517
		TRAPD(error,iDevvp->SetRotateOptionsL(iPostProcId, rotation));
sl@0
  1518
		if ( error != KErrNone)
sl@0
  1519
			{
sl@0
  1520
			ERR_PRINTF2(_L("DoCmdSetRotateOptionsL! Error = %d"),error);
sl@0
  1521
			SetError (error);
sl@0
  1522
			}
sl@0
  1523
		}	
sl@0
  1524
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetRotateOptionsL"));
sl@0
  1525
	}
sl@0
  1526
sl@0
  1527
/**
sl@0
  1528
 * Setting the screen options
sl@0
  1529
 * @param	aSection	-	The section to read from the ini file
sl@0
  1530
 * @return	none
sl@0
  1531
 */
sl@0
  1532
void CT_CMMFDevVideoPlay::DoCmdSetScaleOptionsL(const TTEFSectionName& aSection)
sl@0
  1533
    {
sl@0
  1534
	TInt width;
sl@0
  1535
	TInt height;
sl@0
  1536
  	TInt x,y;
sl@0
  1537
  	TBool antiAliasFiltering = ETrue;
sl@0
  1538
  	TBool dataOk = ETrue;
sl@0
  1539
  	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetScaleOptionsL"));
sl@0
  1540
	if ( !(GetIntFromConfig(aSection, Kx(), x)) )
sl@0
  1541
        {
sl@0
  1542
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &Kx());
sl@0
  1543
        SetBlockResult(EFail);
sl@0
  1544
        dataOk = EFalse;
sl@0
  1545
        }
sl@0
  1546
	if ( !(GetIntFromConfig(aSection, Ky(), y)) )
sl@0
  1547
        {
sl@0
  1548
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &Ky());
sl@0
  1549
        SetBlockResult(EFail);
sl@0
  1550
        dataOk = EFalse;
sl@0
  1551
        } 
sl@0
  1552
	if ( !(GetIntFromConfig(aSection, KWidth(), width)) )
sl@0
  1553
        {
sl@0
  1554
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KWidth());
sl@0
  1555
        SetBlockResult(EFail);
sl@0
  1556
        dataOk = EFalse;
sl@0
  1557
        }
sl@0
  1558
	if ( !(GetIntFromConfig(aSection, KHeight(), height)) )
sl@0
  1559
        {
sl@0
  1560
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHeight());
sl@0
  1561
        SetBlockResult(EFail);
sl@0
  1562
        dataOk = EFalse;
sl@0
  1563
        }	
sl@0
  1564
	GetBoolFromConfig(aSection, KAntiAliasFiltering(),antiAliasFiltering);
sl@0
  1565
 	if(dataOk)
sl@0
  1566
 		{
sl@0
  1567
 		TSize size(width, height);	  
sl@0
  1568
 		TRAPD(error, SetWindowRect(x, y,size));
sl@0
  1569
 		if ( error != KErrNone)
sl@0
  1570
 			{
sl@0
  1571
 			ERR_PRINTF2(_L("SetWindowRect! left with Error = %d"),error);
sl@0
  1572
 			SetBlockResult (EFail);
sl@0
  1573
 			}
sl@0
  1574
sl@0
  1575
 		TRAP(error, iDevvp->SetScaleOptionsL(iPostProcId, size, antiAliasFiltering));
sl@0
  1576
 		if ( error != KErrNone)
sl@0
  1577
 			{
sl@0
  1578
 			ERR_PRINTF2(_L("SetScaleOptionsL! left with Error = %d"),error);
sl@0
  1579
 			SetError (error);
sl@0
  1580
 			}
sl@0
  1581
 		}	
sl@0
  1582
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetScaleOptionsL"));
sl@0
  1583
    }
sl@0
  1584
sl@0
  1585
/**
sl@0
  1586
 * Sets the new position for playback and decoding. It is use for forward and backward
sl@0
  1587
 */
sl@0
  1588
void CT_CMMFDevVideoPlay::DoCmdSetPosition(const TTEFSectionName& aSection)
sl@0
  1589
	{
sl@0
  1590
	TInt pos;
sl@0
  1591
	Int64 time = 0;
sl@0
  1592
	TBool dataOk = ETrue;
sl@0
  1593
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdSetPosition"));
sl@0
  1594
	if ( !(GetIntFromConfig(aSection, KPos(), pos)) ) //This parameter indicates seconds to move forward/backward from the current position
sl@0
  1595
		{
sl@0
  1596
	    ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPos());
sl@0
  1597
	    SetBlockResult(EFail);
sl@0
  1598
	    dataOk = EFalse;
sl@0
  1599
		}
sl@0
  1600
	if(dataOk)
sl@0
  1601
		{
sl@0
  1602
		pos = pos*iFramerate;	
sl@0
  1603
		INFO_PRINTF2(_L("pos %i"),pos);
sl@0
  1604
		if((pos > iFrameSizeList.Count()) || ((pos+iSentBuffCount) < 0))
sl@0
  1605
			{
sl@0
  1606
			ERR_PRINTF2(_L("Invalid value, check %S from INI file"), &KPos());
sl@0
  1607
			//SetBlockResult(EFail);
sl@0
  1608
			}
sl@0
  1609
		else
sl@0
  1610
			{
sl@0
  1611
			iSentBuffCount +=pos;
sl@0
  1612
			TTimeIntervalMicroSeconds timeStamp;	
sl@0
  1613
			if ( iSynchronized )
sl@0
  1614
				{
sl@0
  1615
				timeStamp = (TTimeIntervalMicroSeconds)(iSentBuffCount*iFrameTimeInterval);
sl@0
  1616
				time = timeStamp.Int64();
sl@0
  1617
				iClock->Reset(timeStamp);  
sl@0
  1618
				iTimeStamp = time; 		 
sl@0
  1619
				}
sl@0
  1620
			else
sl@0
  1621
				{
sl@0
  1622
				timeStamp = (TTimeIntervalMicroSeconds)(iSentBuffCount);    
sl@0
  1623
				}
sl@0
  1624
			 
sl@0
  1625
			iDevvp->SetPosition(timeStamp);
sl@0
  1626
			 
sl@0
  1627
			TInt temp=0;
sl@0
  1628
			for(TInt i=0; i < iSentBuffCount; i++)
sl@0
  1629
				{
sl@0
  1630
				temp += iFrameSizeList[i];
sl@0
  1631
				}			 
sl@0
  1632
			TInt error = KErrNone;
sl@0
  1633
			error = iInFile.Seek(ESeekStart,temp);
sl@0
  1634
			if (error != KErrNone)
sl@0
  1635
				{
sl@0
  1636
				ERR_PRINTF2(_L("Error Seeking in file, check ini for parameter POS: %d"),error);
sl@0
  1637
				SetBlockResult(EFail);
sl@0
  1638
				}
sl@0
  1639
			}		
sl@0
  1640
		}	
sl@0
  1641
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdSetPosition"));
sl@0
  1642
	}
sl@0
  1643
sl@0
  1644
/**
sl@0
  1645
 * Utility command to get the initial parameters
sl@0
  1646
 */
sl@0
  1647
void CT_CMMFDevVideoPlay::DoCmdUtilityGetEnvironmentL()
sl@0
  1648
	{	
sl@0
  1649
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::DoCmdUtilityGetEnvironmentL"));
sl@0
  1650
			
sl@0
  1651
	CPostProcessorInfo *infoPost = NULL;
sl@0
  1652
	RArray< TUid > postProcessors;
sl@0
  1653
	iDevvp->GetPostProcessorListL(postProcessors);
sl@0
  1654
	for(TInt i = 0; i< postProcessors.Count(); i++)
sl@0
  1655
		{
sl@0
  1656
		INFO_PRINTF3(_L("PostProcessors %d = 0x%x"),i,postProcessors[i]);
sl@0
  1657
		TRAPD(err,infoPost = iDevvp->PostProcessorInfoLC(postProcessors[i]);CleanupStack::Pop(infoPost));
sl@0
  1658
		if(err != KErrNone)
sl@0
  1659
			{
sl@0
  1660
			ERR_PRINTF1(_L("Error in getting Devvp->PostProcessorInfoLC(postProcessors[i])"));
sl@0
  1661
			}
sl@0
  1662
		else
sl@0
  1663
			{
sl@0
  1664
			TBool supported = infoPost->SupportsDirectDisplay();
sl@0
  1665
			if (supported)
sl@0
  1666
				{
sl@0
  1667
				INFO_PRINTF1(_L("Direct Display Supported"));
sl@0
  1668
				}
sl@0
  1669
			else
sl@0
  1670
				{
sl@0
  1671
				INFO_PRINTF1(_L("Direct Display Not Supported"));
sl@0
  1672
				}	
sl@0
  1673
			const RArray<TUint32> combinations = infoPost->SupportedCombinations();	  
sl@0
  1674
			for (i = 0; i < combinations.Count(); i++)
sl@0
  1675
				{
sl@0
  1676
				INFO_PRINTF2(_L("Supported Combination : %d"),combinations[i]);
sl@0
  1677
				}
sl@0
  1678
			TUint32 test = 0x3040;	
sl@0
  1679
			if (infoPost->SupportsCombination(test))
sl@0
  1680
				{
sl@0
  1681
				INFO_PRINTF2(_L("Combination %x is Supported"),test);
sl@0
  1682
				}
sl@0
  1683
			else
sl@0
  1684
				{
sl@0
  1685
				INFO_PRINTF2(_L("Combination %x is NOT Supported"),test);
sl@0
  1686
				}
sl@0
  1687
			test = 0x40;//play	
sl@0
  1688
			if (infoPost->SupportsCombination(test))
sl@0
  1689
				{
sl@0
  1690
				INFO_PRINTF2(_L("Combination %x is Supported"),test);
sl@0
  1691
				}
sl@0
  1692
			else
sl@0
  1693
				{
sl@0
  1694
				INFO_PRINTF2(_L("Combination %x is NOT Supported"),test);
sl@0
  1695
				}
sl@0
  1696
			test = 0x44;//rotation
sl@0
  1697
			if (infoPost->SupportsCombination(test))
sl@0
  1698
				{
sl@0
  1699
				INFO_PRINTF2(_L("Combination %x is Supported"),test);
sl@0
  1700
				}
sl@0
  1701
			else
sl@0
  1702
				{
sl@0
  1703
				INFO_PRINTF2(_L("Combination %x is NOT Supported"),test);
sl@0
  1704
				}
sl@0
  1705
			test = 0x48;//scale
sl@0
  1706
			if (infoPost->SupportsCombination(test))
sl@0
  1707
				{
sl@0
  1708
				INFO_PRINTF2(_L("Combination %x is Supported"),test);
sl@0
  1709
				}
sl@0
  1710
			else
sl@0
  1711
				{
sl@0
  1712
				INFO_PRINTF2(_L("Combination %x is NOT Supported"),test);
sl@0
  1713
				}
sl@0
  1714
			TUint32 rotations = infoPost->SupportedRotations();
sl@0
  1715
			if (rotations == 0)
sl@0
  1716
				{
sl@0
  1717
				INFO_PRINTF1(_L("Rotation is Not Supported"));
sl@0
  1718
				}
sl@0
  1719
			else
sl@0
  1720
				{
sl@0
  1721
				INFO_PRINTF2(_L("Supported rotation : %d"),rotations);
sl@0
  1722
				}
sl@0
  1723
			supported = infoPost->SupportsArbitraryScaling();
sl@0
  1724
			if (supported)
sl@0
  1725
				{
sl@0
  1726
				INFO_PRINTF1(_L("Arbitrary Scaling is Supported"));
sl@0
  1727
				}
sl@0
  1728
			else
sl@0
  1729
				{
sl@0
  1730
				RArray<TScaleFactor> scaleFactors = infoPost->SupportedScaleFactors();
sl@0
  1731
				TScaleFactor factor;
sl@0
  1732
				for (i = 0; i < scaleFactors.Count(); i++)
sl@0
  1733
					{
sl@0
  1734
					factor = scaleFactors[i];
sl@0
  1735
					INFO_PRINTF3(_L("Scale factor: scale num - %d scale denom - %d"),factor.iScaleNum,factor.iScaleDenom);
sl@0
  1736
					}		
sl@0
  1737
				}
sl@0
  1738
			}
sl@0
  1739
		
sl@0
  1740
		}
sl@0
  1741
	
sl@0
  1742
  			
sl@0
  1743
	RArray<TUid> decoders;
sl@0
  1744
	iDevvp->GetDecoderListL(decoders);
sl@0
  1745
	CVideoDecoderInfo *infDec =NULL;
sl@0
  1746
	INFO_PRINTF1(_L("INFORMATION ABOUT DECODERS:"));
sl@0
  1747
	for(TInt i = 0; i< decoders.Count(); i++)
sl@0
  1748
		{		
sl@0
  1749
		TRAPD(err, infDec = iDevvp->VideoDecoderInfoLC(decoders[i]);CleanupStack::Pop(infDec));		
sl@0
  1750
		if(err != KErrNone )
sl@0
  1751
			{
sl@0
  1752
			 ERR_PRINTF1(_L("Error in iDevvp->VideoDecoderInfoLC(decoders[i])"));
sl@0
  1753
			}
sl@0
  1754
		else
sl@0
  1755
			{
sl@0
  1756
			INFO_PRINTF6(_L("\nDecoder =0x%x\n Identifier = %S\n Accelerated = %i\n Supports Direct Display: %i\n Manufacturer%S"), 
sl@0
  1757
					decoders[i].iUid,
sl@0
  1758
					&infDec->Identifier(),
sl@0
  1759
					infDec->Accelerated(),
sl@0
  1760
					infDec->SupportsDirectDisplay(),
sl@0
  1761
					&infDec->Manufacturer());				
sl@0
  1762
			INFO_PRINTF1(_L("SUPPORTED FORMATS:"));
sl@0
  1763
			TBuf<255> mime;
sl@0
  1764
			const RPointerArray<CCompressedVideoFormat>& outputFormats =infDec->SupportedFormats();
sl@0
  1765
			for (TInt j = 0; j < outputFormats.Count(); j++)
sl@0
  1766
				{
sl@0
  1767
				mime.Copy(outputFormats[j]->MimeType());		
sl@0
  1768
				INFO_PRINTF3(_L("Supported type %d MIMETYPE: %S"),j,&mime);					
sl@0
  1769
				}	
sl@0
  1770
			INFO_PRINTF1(_L("\n\n"));	
sl@0
  1771
			}						
sl@0
  1772
		}
sl@0
  1773
		    
sl@0
  1774
	TInt colors = 0;
sl@0
  1775
	HAL::Get(HALData::EDisplayColors, colors);
sl@0
  1776
	INFO_PRINTF2(_L("Display colors : %d"),colors);
sl@0
  1777
	INFO_PRINTF1(_L("Display mode!"));
sl@0
  1778
	switch(colors)
sl@0
  1779
		{
sl@0
  1780
		case 0:
sl@0
  1781
	 		INFO_PRINTF1(_L("None"));
sl@0
  1782
	 	break;		
sl@0
  1783
		case 16777216:
sl@0
  1784
			INFO_PRINTF1(_L("EColor16MU"));
sl@0
  1785
		break;
sl@0
  1786
		case 65536:
sl@0
  1787
			INFO_PRINTF1(_L("EColor64K"));
sl@0
  1788
		break;
sl@0
  1789
		case 4096:
sl@0
  1790
			INFO_PRINTF1(_L("EColor4K"));
sl@0
  1791
		break;
sl@0
  1792
		default:
sl@0
  1793
			INFO_PRINTF1(_L("Default mode EColor4K"));
sl@0
  1794
		}
sl@0
  1795
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::DoCmdUtilityGetEnvironmentL"));
sl@0
  1796
	}
sl@0
  1797
sl@0
  1798
/**
sl@0
  1799
 * Sets the original window for display
sl@0
  1800
 */
sl@0
  1801
void CT_CMMFDevVideoPlay::SetWindowRect(TInt aX, TInt aY, TSize aSize)
sl@0
  1802
    {
sl@0
  1803
    INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::SetWindowRect"));
sl@0
  1804
    iDispRect.SetRect(TPoint(aX,aY),aSize);
sl@0
  1805
    INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::SetWindowRect"));
sl@0
  1806
    }
sl@0
  1807
sl@0
  1808
/**
sl@0
  1809
 * Read one coded picture into decoder input buffer
sl@0
  1810
 * 
sl@0
  1811
 * @param aCodedInBuffer
sl@0
  1812
 * 
sl@0
  1813
 * @return err
sl@0
  1814
 */
sl@0
  1815
TInt CT_CMMFDevVideoPlay::ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer)
sl@0
  1816
	{
sl@0
  1817
	TInt buffLength = iInBuffSize;
sl@0
  1818
	TBool found = EFalse;
sl@0
  1819
	TInt pos =0;
sl@0
  1820
	TUint8* testData= NULL;
sl@0
  1821
	TInt err = KErrNone;	
sl@0
  1822
	if ( aCodedInBuffer->iData.MaxLength ()< buffLength)
sl@0
  1823
		{
sl@0
  1824
		err = KErrOverflow;
sl@0
  1825
		return err;
sl@0
  1826
		}
sl@0
  1827
	aCodedInBuffer->iData.SetLength (0);
sl@0
  1828
	//Read data from Input File  
sl@0
  1829
	err = iInFile.Read (aCodedInBuffer->iData, buffLength);
sl@0
  1830
	if ( err != KErrNone)
sl@0
  1831
		{
sl@0
  1832
		return err;
sl@0
  1833
		}
sl@0
  1834
	//Buffer is not full,  reset size of buffer   
sl@0
  1835
	if ( aCodedInBuffer->iData.Length ()< buffLength)
sl@0
  1836
		{
sl@0
  1837
		buffLength = aCodedInBuffer->iData.Length ();
sl@0
  1838
		}
sl@0
  1839
	testData = const_cast<TUint8*>(aCodedInBuffer->iData.Ptr());
sl@0
  1840
	//Check the length of one coded picture
sl@0
  1841
	if ( (iCodecType == EH263) || ((testData[0] == 0x00) && (testData[1] == 0x00) & ((testData[2] & 0xFC) == 0x80)))
sl@0
  1842
		{
sl@0
  1843
		if ( (aCodedInBuffer->iData.Length() > 0))
sl@0
  1844
			{
sl@0
  1845
			pos = KScLength; //skip first 3 byte (PSC)   
sl@0
  1846
			// Find next PSC
sl@0
  1847
			while ( pos < (buffLength - KScLength) && !found)
sl@0
  1848
				{
sl@0
  1849
				if ( (testData[pos+1] == 0x00) && (testData[pos+2] == 0x00) & ((testData[pos+3] & 0xFC) == 0x80))
sl@0
  1850
					{
sl@0
  1851
					found = ETrue;
sl@0
  1852
					}
sl@0
  1853
				pos++;
sl@0
  1854
				}
sl@0
  1855
			}
sl@0
  1856
		else
sl@0
  1857
			{
sl@0
  1858
			iInputEnd = ETrue;
sl@0
  1859
			return err;
sl@0
  1860
			}
sl@0
  1861
		}
sl@0
  1862
	else
sl@0
  1863
		if ( iCodecType == EMPEG4)
sl@0
  1864
			{
sl@0
  1865
			if ( (aCodedInBuffer->iData.Length() > 0))
sl@0
  1866
				{
sl@0
  1867
				// Check if start code of Visual Object Sequence              
sl@0
  1868
				pos = 0;
sl@0
  1869
				while ( pos < (buffLength - KScLength) && !found)
sl@0
  1870
					{ // Find 1st VOP start code in the buffer              
sl@0
  1871
					if ( (testData[pos] == 0x00) && (testData[pos+1] == 0x00)&& (testData[pos+2] == 0x01) && (testData[pos+3] == 0xB6))
sl@0
  1872
						{
sl@0
  1873
						while (pos < (buffLength - KScLength-1) && !found)
sl@0
  1874
							{
sl@0
  1875
							pos++;
sl@0
  1876
							// Find 2nd start code in the buffer >> End of a Picture
sl@0
  1877
							if ( (testData[pos+1] == 0x00) && (testData[pos+2] == 0x00)&& (testData[pos+3] == 0x01) && (testData[pos+4] != 0xB1))
sl@0
  1878
								{
sl@0
  1879
								found = ETrue;
sl@0
  1880
								}
sl@0
  1881
							}
sl@0
  1882
						}
sl@0
  1883
					pos++;
sl@0
  1884
					}
sl@0
  1885
				}
sl@0
  1886
			else
sl@0
  1887
				{
sl@0
  1888
				iInputEnd = ETrue;
sl@0
  1889
				return err;
sl@0
  1890
				}
sl@0
  1891
			}
sl@0
  1892
		else
sl@0
  1893
			{
sl@0
  1894
			err = KErrNotSupported;
sl@0
  1895
			}
sl@0
  1896
	// Start and End of a picure are found 
sl@0
  1897
	if ( found)
sl@0
  1898
		{
sl@0
  1899
		//Set Size to length of the header + one picure, and reset position to be read next time
sl@0
  1900
		aCodedInBuffer->iData.SetLength (pos);
sl@0
  1901
		TInt tempLength = pos - buffLength;
sl@0
  1902
		err = iInFile.Seek (ESeekCurrent, tempLength);
sl@0
  1903
		}
sl@0
  1904
	// All data in Buffer are checked and end of data not found 
sl@0
  1905
	else
sl@0
  1906
		{
sl@0
  1907
		if ( pos >= (iInBuffSize-3))
sl@0
  1908
			{
sl@0
  1909
			err = KErrOverflow;
sl@0
  1910
			}
sl@0
  1911
		}
sl@0
  1912
	if ( err == KErrNone)
sl@0
  1913
		{
sl@0
  1914
		err = pos;
sl@0
  1915
		}	
sl@0
  1916
	return err;	
sl@0
  1917
	}          
sl@0
  1918
    
sl@0
  1919
/**
sl@0
  1920
 * Read one coded picture into decoder input buffer, frame size is known 
sl@0
  1921
 * 
sl@0
  1922
 * @param aCodedInBuffer
sl@0
  1923
 * @param aSize				- frame size
sl@0
  1924
 * @return err				- The error
sl@0
  1925
 */
sl@0
  1926
TInt CT_CMMFDevVideoPlay::ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer, TInt aSize)
sl@0
  1927
    {
sl@0
  1928
    TInt err = KErrNone;        
sl@0
  1929
    if(aCodedInBuffer !=NULL)
sl@0
  1930
    	{
sl@0
  1931
    	err = iInFile.Read(aCodedInBuffer->iData, aSize);                
sl@0
  1932
    	}
sl@0
  1933
    else
sl@0
  1934
    	{
sl@0
  1935
    	INFO_PRINTF1(_L("aCodedInBuffer is NULL"));
sl@0
  1936
    	err = KErrNotFound;
sl@0
  1937
    	}
sl@0
  1938
    if (aSize == 0)
sl@0
  1939
    	{
sl@0
  1940
    	iInputEnd = ETrue;
sl@0
  1941
    	}
sl@0
  1942
    return err;
sl@0
  1943
    }
sl@0
  1944
sl@0
  1945
sl@0
  1946
/**
sl@0
  1947
 * Notifies the client that one or more new empty input buffers are available
sl@0
  1948
 * @return None
sl@0
  1949
 */
sl@0
  1950
void CT_CMMFDevVideoPlay::MdvpoNewBuffers()
sl@0
  1951
    {
sl@0
  1952
	TRAPD(err, HandleNewBufferL()); 
sl@0
  1953
	if (err != KErrNone)
sl@0
  1954
		{
sl@0
  1955
		ERR_PRINTF2(_L("HandleNewBufferL()left with error %d"),err);
sl@0
  1956
		SetBlockResult(EFail);    	
sl@0
  1957
		}
sl@0
  1958
    }
sl@0
  1959
sl@0
  1960
/**
sl@0
  1961
 * Returns a used input video picture back to the caller. The picture memory can be re-used or freed. 
sl@0
  1962
 * 
sl@0
  1963
 * @param aPicture	the picture to return
sl@0
  1964
 */
sl@0
  1965
void CT_CMMFDevVideoPlay::MdvpoReturnPicture(TVideoPicture* aPicture)
sl@0
  1966
    {   
sl@0
  1967
    if ( iRawInBuffer == aPicture )
sl@0
  1968
        {        
sl@0
  1969
    	TRAPD(err1, HandleNewBufferL()); 
sl@0
  1970
        if (err1 != KErrNone)
sl@0
  1971
        	{
sl@0
  1972
        	ERR_PRINTF2(_L("HandleNewBufferL()left with error %d"),err1);
sl@0
  1973
        	SetBlockResult(EFail);
sl@0
  1974
        	}
sl@0
  1975
        }    
sl@0
  1976
    }
sl@0
  1977
sl@0
  1978
/**
sl@0
  1979
 * Delivers supplemental information from a coded data unit.
sl@0
  1980
 * 
sl@0
  1981
 * @param aData			The supplemental data. The reference is only valid until the method returns, and thus the data must be processed or copied immediately
sl@0
  1982
 * @param aTimestamp	The presentation timestamp for the picture that the supplemental data is part of
sl@0
  1983
 * @param aPictureId	Picture identifier for the picture. If a picture ID is not available, aPictureId.iIdType is set to ENone
sl@0
  1984
 * 
sl@0
  1985
 * @return None
sl@0
  1986
 */
sl@0
  1987
void CT_CMMFDevVideoPlay::MdvpoSupplementalInformation(const TDesC8& /*aData*/, const TTimeIntervalMicroSeconds& /*aTimestamp*/, const TPictureId& /*aPictureId*/)
sl@0
  1988
    {	  
sl@0
  1989
    }
sl@0
  1990
sl@0
  1991
/**
sl@0
  1992
 * Back channel information from the decoder, indicating a picture loss without specifying the lost picture.
sl@0
  1993
 * 
sl@0
  1994
 * @return None
sl@0
  1995
 */
sl@0
  1996
void CT_CMMFDevVideoPlay::MdvpoPictureLoss()
sl@0
  1997
    {
sl@0
  1998
    iPictureLoss++;      
sl@0
  1999
    }
sl@0
  2000
sl@0
  2001
/**
sl@0
  2002
 * Back channel information from the decoder, indicating a picture loss without specifying the lost picture.
sl@0
  2003
 * 
sl@0
  2004
 * @param aPictures	Picture identifiers for the lost pictures.
sl@0
  2005
 * 
sl@0
  2006
 * @return None
sl@0
  2007
 */
sl@0
  2008
void CT_CMMFDevVideoPlay::MdvpoPictureLoss(const TArray<TPictureId>& aPictures)
sl@0
  2009
    {         
sl@0
  2010
    iPictureLoss += aPictures.Count();     
sl@0
  2011
    }
sl@0
  2012
sl@0
  2013
/**
sl@0
  2014
 * Back channel information from the decoder, indicating the loss of consecutive macroblocks in raster scan order.
sl@0
  2015
 * 
sl@0
  2016
 * @param aFirstMacroblock	The first lost macroblock
sl@0
  2017
 * @param aNumMacroblocks	The number of lost macroblocks that are consecutive in raster-scan order
sl@0
  2018
 * @param aPicture			The picture identifier for the picture where the macroblocks were lost
sl@0
  2019
 * 
sl@0
  2020
 * @return None
sl@0
  2021
 */
sl@0
  2022
void CT_CMMFDevVideoPlay::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
sl@0
  2023
    {  
sl@0
  2024
    }
sl@0
  2025
sl@0
  2026
/**
sl@0
  2027
 * Back channel information from the decoder, indicating a reference picture selection request. 
sl@0
  2028
 * 
sl@0
  2029
 * @param aSelectionData	The	reference picture selection request message. 
sl@0
  2030
 * 
sl@0
  2031
 * @return None
sl@0
  2032
 */
sl@0
  2033
void CT_CMMFDevVideoPlay::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/)
sl@0
  2034
    {
sl@0
  2035
    }
sl@0
  2036
sl@0
  2037
/**
sl@0
  2038
 * Called when a timed snapshot request has been completed. When this method is called, the snapshot has been taken, and the memory reserved for the picture can be re-used or freed. 
sl@0
  2039
 * 
sl@0
  2040
 * @param aError					An error code, KErrNone if no errors occurred.
sl@0
  2041
 * @param aPictureData				The snapshot picture data
sl@0
  2042
 * @param aPresentationTimestamp	The presentation timestamp for the snapshot picture
sl@0
  2043
 * @param aPictureId				Picture identifier for the picture. If a picture ID is not available, aPictureId.iIdType is set to ENone
sl@0
  2044
 * 
sl@0
  2045
 * @return None
sl@0
  2046
 */
sl@0
  2047
void CT_CMMFDevVideoPlay::MdvpoTimedSnapshotComplete(TInt aError, TPictureData* /*aPictureData*/, 
sl@0
  2048
														const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/,
sl@0
  2049
														const TPictureId& /*aPictureId*/)
sl@0
  2050
    {
sl@0
  2051
    if(aError!= KErrNone)
sl@0
  2052
    	{
sl@0
  2053
    	INFO_PRINTF2(_L("An error has ocurred: %i in CT_CMMFDevVideoPlay::MdvpoTimedSnapshotComplete"),aError);
sl@0
  2054
    	}    
sl@0
  2055
    }    
sl@0
  2056
sl@0
  2057
/**
sl@0
  2058
 * Notifies the client that one or more new output pictures are available. 
sl@0
  2059
 * 
sl@0
  2060
 * @return None
sl@0
  2061
 */    
sl@0
  2062
void CT_CMMFDevVideoPlay::MdvpoNewPictures()
sl@0
  2063
    {    
sl@0
  2064
    GetReturnedPicture();
sl@0
  2065
    }
sl@0
  2066
sl@0
  2067
/**
sl@0
  2068
 * Reports a fatal decoding or playback error to the client.
sl@0
  2069
 * 
sl@0
  2070
 * @param aError	The error code
sl@0
  2071
 * 
sl@0
  2072
 * @return None
sl@0
  2073
 */       
sl@0
  2074
void CT_CMMFDevVideoPlay::MdvpoFatalError(TInt aError)
sl@0
  2075
    {
sl@0
  2076
    INFO_PRINTF1(_L("MdvpoFatalError DecOutstanding"));
sl@0
  2077
    DecOutstanding();
sl@0
  2078
    ERR_PRINTF2(_L("A Fatal error has ocurred: %i"),aError);
sl@0
  2079
    HandleRuntimeError(aError);  
sl@0
  2080
    }
sl@0
  2081
sl@0
  2082
/**
sl@0
  2083
 * Reports that DevVideoPlay initialization has completed. The interface can now be used for video playback. 
sl@0
  2084
 * 
sl@0
  2085
 * @param aError	Initialization error code, KErrNone if no error occurred
sl@0
  2086
 * 
sl@0
  2087
 * @return None
sl@0
  2088
 */
sl@0
  2089
void CT_CMMFDevVideoPlay::MdvpoInitComplete(TInt aError)
sl@0
  2090
	{
sl@0
  2091
sl@0
  2092
	if ( aError == KErrNone)
sl@0
  2093
		{
sl@0
  2094
		INFO_PRINTF1(_L("MdvpoInitComplete OK"));
sl@0
  2095
		//Initilize parameters for Decoding/Playback
sl@0
  2096
		iCodedInBuffer = NULL;
sl@0
  2097
		iOutBuffer =NULL;
sl@0
  2098
		iSentBuffCount = 0;
sl@0
  2099
		iReturnedBuffCount = 0;
sl@0
  2100
		iPictureLoss =0;
sl@0
  2101
		iInputEnd = EFalse;
sl@0
  2102
		iStreamEnd = EFalse;
sl@0
  2103
		iTimeStamp = 0;
sl@0
  2104
		}
sl@0
  2105
	else
sl@0
  2106
		{		
sl@0
  2107
		ERR_PRINTF2(_L("MdvpoInitComplete Error %d"), aError);
sl@0
  2108
		SetAsyncError (iAsyncErrorIndex, aError);
sl@0
  2109
		}
sl@0
  2110
	INFO_PRINTF1(_L("MdvpoInitComplete DecOutstanding"));	
sl@0
  2111
	DecOutstanding ();
sl@0
  2112
	}
sl@0
  2113
sl@0
  2114
/**
sl@0
  2115
 * Reports that the input video stream end has been reached and all pictures have been processed.
sl@0
  2116
 * This method is only called after the client has called InputEnd(). No more output pictures will be available.
sl@0
  2117
 * 
sl@0
  2118
 * @return None
sl@0
  2119
 */
sl@0
  2120
void CT_CMMFDevVideoPlay::MdvpoStreamEnd()
sl@0
  2121
    {
sl@0
  2122
	iStreamEnd = ETrue;     
sl@0
  2123
    INFO_PRINTF1(_L("Stream End!"));
sl@0
  2124
    INFO_PRINTF2(_L("iSentBuffCount: %d"),iSentBuffCount);
sl@0
  2125
    INFO_PRINTF2(_L("iReturnedBuffCount: %d"),iReturnedBuffCount);
sl@0
  2126
    INFO_PRINTF2(_L("iPictureLoss: %d"),iPictureLoss);
sl@0
  2127
    INFO_PRINTF1(_L("MdvpoStreamEnd DecOutStanding"));
sl@0
  2128
   	DecOutstanding();
sl@0
  2129
    }
sl@0
  2130
sl@0
  2131
sl@0
  2132
/**
sl@0
  2133
 * Get Next input data 
sl@0
  2134
 * 
sl@0
  2135
 * @return None
sl@0
  2136
 */
sl@0
  2137
void CT_CMMFDevVideoPlay::HandleNewBufferL()
sl@0
  2138
    {
sl@0
  2139
	if ( !iInputEnd )
sl@0
  2140
		{
sl@0
  2141
		if ( iDecHWDevId || iCIBuffMgmtOn ) //Retrieve buffer from Hwdevice
sl@0
  2142
			{
sl@0
  2143
			GetInputBuffer();     
sl@0
  2144
			}
sl@0
  2145
		else
sl@0
  2146
			{
sl@0
  2147
			FillAndSendBufferL();   // Postproc input
sl@0
  2148
			}
sl@0
  2149
		}	
sl@0
  2150
    }
sl@0
  2151
sl@0
  2152
/**
sl@0
  2153
 * Retrieve decoder input buffer
sl@0
  2154
 * 
sl@0
  2155
 * @return None
sl@0
  2156
 */
sl@0
  2157
void CT_CMMFDevVideoPlay::GetInputBuffer()
sl@0
  2158
    {
sl@0
  2159
    //TBool buffer = EFalse; 	 	 
sl@0
  2160
    if ( iDecHWDevId )
sl@0
  2161
    	{	
sl@0
  2162
    	TRAPD(error, iCodedInBuffer = iDevvp->GetBufferL(iInBuffSize));
sl@0
  2163
    	if (error != KErrNone)
sl@0
  2164
    		{	
sl@0
  2165
    		ERR_PRINTF2(_L("Error GetInputBufferL!. Error %d"),error);
sl@0
  2166
    		iErrorInputBuffer = ETrue;
sl@0
  2167
    		SetError(error);    		
sl@0
  2168
    		}
sl@0
  2169
    	else
sl@0
  2170
    		{
sl@0
  2171
    		if ( iCodedInBuffer )
sl@0
  2172
    	    	{    	    	    	       	    	
sl@0
  2173
    	        TRAPD(error, FillAndSendBufferL());
sl@0
  2174
    	        if (error != KErrNone)
sl@0
  2175
    	     	   {
sl@0
  2176
    	     	   ERR_PRINTF2(_L("Error GetInputBufferL->FillAndSendBufferL!. Error %d"),error);
sl@0
  2177
    	     	   SetBlockResult(EFail);        	   
sl@0
  2178
    	     	   }
sl@0
  2179
    	    	}
sl@0
  2180
    		}    
sl@0
  2181
    	} 
sl@0
  2182
    }
sl@0
  2183
    
sl@0
  2184
    
sl@0
  2185
    
sl@0
  2186
/**
sl@0
  2187
 * Fill data into input buffer and send to devvideoplay 
sl@0
  2188
 * 
sl@0
  2189
 * @return None
sl@0
  2190
 */
sl@0
  2191
void CT_CMMFDevVideoPlay::FillAndSendBufferL()
sl@0
  2192
	{
sl@0
  2193
	TInt err = KErrNone;	
sl@0
  2194
	if ( iDecHWDevId)
sl@0
  2195
		{
sl@0
  2196
		if ( iSynchronized)
sl@0
  2197
			{
sl@0
  2198
			TInt size = 0;
sl@0
  2199
			if((iSentBuffCount>=0) && (iSentBuffCount < iFrameSizeList.Count()))
sl@0
  2200
				{
sl@0
  2201
				size = iFrameSizeList[iSentBuffCount];
sl@0
  2202
				}
sl@0
  2203
			else
sl@0
  2204
				{
sl@0
  2205
				ERR_PRINTF2(_L("error %i"),iSentBuffCount);
sl@0
  2206
				}
sl@0
  2207
			
sl@0
  2208
			err = ReadOneCodedPicture (iCodedInBuffer, size); // Read compressed data of one picture from file 
sl@0
  2209
			}
sl@0
  2210
		else
sl@0
  2211
			{
sl@0
  2212
			err = ReadOneCodedPicture (iCodedInBuffer); // Read compressed data of one picture from file 
sl@0
  2213
			}
sl@0
  2214
		}
sl@0
  2215
	else // Postproc input case
sl@0
  2216
		{
sl@0
  2217
		err = ReadRawPicture (); // Read raw data for one picture      
sl@0
  2218
		}
sl@0
  2219
	if ( iInputEnd)
sl@0
  2220
		{
sl@0
  2221
		iDevvp->InputEnd (); // All input Data sent        
sl@0
  2222
		return;
sl@0
  2223
		}
sl@0
  2224
	if ( err >= 0)
sl@0
  2225
		{
sl@0
  2226
		if ( iDecHWDevId)
sl@0
  2227
			{
sl@0
  2228
			iCodedInBuffer->iOptions = TVideoInputBuffer::EDecodingTimestamp;
sl@0
  2229
			if ( iPostProcId)
sl@0
  2230
				{
sl@0
  2231
				iCodedInBuffer->iOptions |= TVideoInputBuffer::EPresentationTimestamp;
sl@0
  2232
				}
sl@0
  2233
			if ( iSynchronized)
sl@0
  2234
				{
sl@0
  2235
				iCodedInBuffer->iDecodingTimestamp = iTimeStamp;
sl@0
  2236
				if ( iPostProcId)
sl@0
  2237
					{
sl@0
  2238
					iCodedInBuffer->iPresentationTimestamp = iTimeStamp;
sl@0
  2239
					}
sl@0
  2240
				iTimeStamp += iFrameTimeInterval;
sl@0
  2241
				}
sl@0
  2242
			else // Clock source is not set
sl@0
  2243
				{
sl@0
  2244
				iCodedInBuffer->iDecodingTimestamp = iSentBuffCount;
sl@0
  2245
				if ( iPostProcId)
sl@0
  2246
					{
sl@0
  2247
					iCodedInBuffer->iPresentationTimestamp = iSentBuffCount;
sl@0
  2248
					}
sl@0
  2249
				}
sl@0
  2250
			if ( iFrameMeasurement)
sl@0
  2251
				{
sl@0
  2252
				iClock->Reset (); // Reset Timer 
sl@0
  2253
				}
sl@0
  2254
			TRAPD(error,iDevvp->WriteCodedDataL(iCodedInBuffer)); // Input Data Sent to Decoder 
sl@0
  2255
			if ( error != KErrNone)
sl@0
  2256
				{
sl@0
  2257
				ERR_PRINTF2(_L("Error Writing data!. Error %d"),error);
sl@0
  2258
				SetError(error);
sl@0
  2259
				return;
sl@0
  2260
				}
sl@0
  2261
			}
sl@0
  2262
		else
sl@0
  2263
			{
sl@0
  2264
			iRawInBuffer->iData.iDataSize.SetSize (iPictureSize.iWidth,
sl@0
  2265
					iPictureSize.iHeight);
sl@0
  2266
			iRawInBuffer->iOptions |= (TVideoPicture::ETimestamp);
sl@0
  2267
			if ( iSynchronized)
sl@0
  2268
				{
sl@0
  2269
				iRawInBuffer->iTimestamp = iTimeStamp;
sl@0
  2270
				iTimeStamp += iFrameTimeInterval;
sl@0
  2271
				}
sl@0
  2272
			else
sl@0
  2273
				{
sl@0
  2274
				iRawInBuffer->iTimestamp = iSentBuffCount;
sl@0
  2275
				}
sl@0
  2276
			TRAPD(error, iDevvp->WritePictureL (iRawInBuffer)); // Input Data Sent to PostProcessor 
sl@0
  2277
			if (error != KErrNone)
sl@0
  2278
				{
sl@0
  2279
				ERR_PRINTF2(_L("Error Writing Picture!. Error %d"),error);
sl@0
  2280
				SetError(error);
sl@0
  2281
				return;
sl@0
  2282
				}
sl@0
  2283
			}
sl@0
  2284
		iSentBuffCount++;
sl@0
  2285
		}
sl@0
  2286
	else
sl@0
  2287
		{
sl@0
  2288
		iInputEnd = ETrue;
sl@0
  2289
		iDevvp->InputEnd ();
sl@0
  2290
		return;
sl@0
  2291
		}	
sl@0
  2292
	} 
sl@0
  2293
   
sl@0
  2294
sl@0
  2295
/**
sl@0
  2296
 * Retrieve output picture
sl@0
  2297
 * 
sl@0
  2298
 * @return None
sl@0
  2299
 */
sl@0
  2300
void CT_CMMFDevVideoPlay::GetReturnedPicture()
sl@0
  2301
	{
sl@0
  2302
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::GetReturnedPicture"));
sl@0
  2303
	TRAPD(err, iOutBuffer = iDevvp->NextPictureL());
sl@0
  2304
	if ( err != KErrNone)
sl@0
  2305
		{
sl@0
  2306
        HandleRuntimeError(err);
sl@0
  2307
        ERR_PRINTF1(_L("Error en GetReturnedPicture!!"));
sl@0
  2308
        }        
sl@0
  2309
    if ( iOutBuffer )
sl@0
  2310
        {       
sl@0
  2311
        iReturnedBuffCount++;
sl@0
  2312
        SaveAndReturnPicture();
sl@0
  2313
        }
sl@0
  2314
    INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::GetReturnedPicture"));
sl@0
  2315
    }
sl@0
  2316
sl@0
  2317
/**
sl@0
  2318
 * This function finishes the async call depending on the error occured while handling the picture
sl@0
  2319
 * 
sl@0
  2320
 * @param aError Error Value passed
sl@0
  2321
 * @return none
sl@0
  2322
 */
sl@0
  2323
void CT_CMMFDevVideoPlay::HandleRuntimeError(TInt aError)
sl@0
  2324
	{
sl@0
  2325
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::HandleRuntimeError"));
sl@0
  2326
	ERR_PRINTF2(_L("HandleRuntimeError! Error = %d"),aError);
sl@0
  2327
	SetError (aError);
sl@0
  2328
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::HandleRuntimeError"));
sl@0
  2329
	}    
sl@0
  2330
sl@0
  2331
/**
sl@0
  2332
 * Store output data into a file
sl@0
  2333
 * 
sl@0
  2334
 * @return None
sl@0
  2335
 */
sl@0
  2336
void CT_CMMFDevVideoPlay::SaveAndReturnPicture()
sl@0
  2337
	{
sl@0
  2338
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::SaveAndReturnPicture"));
sl@0
  2339
	TInt err = iOutFile.Write (*(iOutBuffer->iData.iRawData), iOutBuffer->iData.iRawData->Size ());
sl@0
  2340
	iDevvp->ReturnPicture (iOutBuffer);
sl@0
  2341
	iOutBuffer = NULL;
sl@0
  2342
	if ( err != KErrNone)
sl@0
  2343
		{
sl@0
  2344
		HandleRuntimeError (err);
sl@0
  2345
		}
sl@0
  2346
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::SaveAndReturnPicture"));
sl@0
  2347
	}
sl@0
  2348
sl@0
  2349
/**
sl@0
  2350
 * List size of each frame of coded bitstream 
sl@0
  2351
 * 
sl@0
  2352
 * @param  aCodec picture 
sl@0
  2353
 * @return none
sl@0
  2354
 */
sl@0
  2355
void CT_CMMFDevVideoPlay::ListFrameSizeL(TVideoCodec aCodec)
sl@0
  2356
	{
sl@0
  2357
	TInt framesize = 0;
sl@0
  2358
	TInt readpos = 0;
sl@0
  2359
	TInt buffsize = KH263MaxCodedSizeQCIF; //buffer size for listing frame size
sl@0
  2360
	iCodecType = aCodec; // this is for ReadOneCodedPicture
sl@0
  2361
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::ListFrameSizeL"));
sl@0
  2362
	//Initial buffer size
sl@0
  2363
	// Allocate buffer 
sl@0
  2364
	TVideoInputBuffer* videoBuffer = new(ELeave) TVideoInputBuffer;
sl@0
  2365
	CleanupStack::PushL (videoBuffer);
sl@0
  2366
	HBufC8* tempBuff = HBufC8::NewLC( buffsize);
sl@0
  2367
	videoBuffer->iData.Set (tempBuff->Des ());
sl@0
  2368
	while (!iInputEnd)
sl@0
  2369
		{
sl@0
  2370
		iInBuffSize = buffsize;
sl@0
  2371
		videoBuffer->iData.SetLength (0);
sl@0
  2372
		framesize = ReadOneCodedPicture (videoBuffer);//        
sl@0
  2373
		if ( framesize >= 0) // Frame size is added to list
sl@0
  2374
			{
sl@0
  2375
			iFrameSizeList.AppendL (framesize);
sl@0
  2376
			readpos += framesize;
sl@0
  2377
			}
sl@0
  2378
		else // resize buffer to bigger one
sl@0
  2379
			{
sl@0
  2380
			if ( buffsize < KMP4MaxCodedSizeVGA)
sl@0
  2381
				{
sl@0
  2382
				CleanupStack::PopAndDestroy(tempBuff);
sl@0
  2383
				buffsize = buffsize + KH263MaxCodedSizeQCIF;
sl@0
  2384
				tempBuff = HBufC8::NewLC( buffsize);
sl@0
  2385
				videoBuffer->iData.Set (tempBuff->Des ());
sl@0
  2386
				iInFile.Seek (ESeekStart, readpos);
sl@0
  2387
				}
sl@0
  2388
			else
sl@0
  2389
				{
sl@0
  2390
				framesize = KErrNotFound;
sl@0
  2391
				break;
sl@0
  2392
				}
sl@0
  2393
			}
sl@0
  2394
		}
sl@0
  2395
	//Reset file postion to start
sl@0
  2396
	TInt pos =0;
sl@0
  2397
	iInFile.Seek (ESeekStart, pos);
sl@0
  2398
	iInputEnd = EFalse;
sl@0
  2399
	// cleanup    
sl@0
  2400
	CleanupStack::PopAndDestroy(2, videoBuffer);
sl@0
  2401
	//Error case
sl@0
  2402
	if ( framesize < 0)
sl@0
  2403
		{
sl@0
  2404
		User::Leave (framesize);
sl@0
  2405
		}
sl@0
  2406
	//Set frame size listed   
sl@0
  2407
	iFrameListed = ETrue;
sl@0
  2408
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::ListFrameSizeL"));
sl@0
  2409
	}
sl@0
  2410
sl@0
  2411
/**
sl@0
  2412
 * Closes the opened files
sl@0
  2413
 */
sl@0
  2414
void CT_CMMFDevVideoPlay::CloseFile()
sl@0
  2415
	{	
sl@0
  2416
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::CloseFile"));
sl@0
  2417
	iInFile.Close ();
sl@0
  2418
	if ( !iDirectScreenAccess)
sl@0
  2419
		{
sl@0
  2420
		iOutFile.Close ();
sl@0
  2421
		}
sl@0
  2422
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::CloseFile"));
sl@0
  2423
	}
sl@0
  2424
sl@0
  2425
/**
sl@0
  2426
 * Opens the input and output file
sl@0
  2427
 * @param	aInFileName		-	The name of input file
sl@0
  2428
 * @param	aOutFileName	-	The name of output file
sl@0
  2429
 * @return	none
sl@0
  2430
 */
sl@0
  2431
void CT_CMMFDevVideoPlay::OpenFileL(TFileName& aOutFileName, TFileName& aInFileName)
sl@0
  2432
	{
sl@0
  2433
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::OpenFileL"));
sl@0
  2434
	TInt err = iInFile.Open (iFs, aInFileName, EFileRead | EFileShareReadersOnly);
sl@0
  2435
	User::LeaveIfError (err);
sl@0
  2436
	err = iOutFile.Replace (iFs, aOutFileName,
sl@0
  2437
			EFileShareExclusive|EFileWrite);
sl@0
  2438
	if ( err!= KErrNone)
sl@0
  2439
		{
sl@0
  2440
		iInFile.Close ();
sl@0
  2441
		User::Leave(err);
sl@0
  2442
		}
sl@0
  2443
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::OpenFileL"));
sl@0
  2444
	}
sl@0
  2445
sl@0
  2446
/**
sl@0
  2447
 * Opens the input File
sl@0
  2448
 * @param	aInFileName	-The name of input file
sl@0
  2449
 * @return	none 
sl@0
  2450
 */
sl@0
  2451
void CT_CMMFDevVideoPlay::OpenFileL(TFileName& aInFileName)
sl@0
  2452
	{
sl@0
  2453
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::OpenFileL"));
sl@0
  2454
	User::LeaveIfError(iInFile.Open (iFs, aInFileName, EFileRead | EFileShareReadersOnly));
sl@0
  2455
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::OpenFileL"));
sl@0
  2456
	}
sl@0
  2457
sl@0
  2458
/**
sl@0
  2459
 * Read one raw picture into postprocessor input buffer
sl@0
  2460
 */
sl@0
  2461
TInt CT_CMMFDevVideoPlay::ReadRawPicture()
sl@0
  2462
	{
sl@0
  2463
	INFO_PRINTF1(_L("*START*CT_CMMFDevVideoPlay::ReadRawPicture"));
sl@0
  2464
	iRawInBuffer->iData.iRawData->Set ((TUint8*)iRawInBuffer->iData.iRawData->Ptr(), 0, iInBuffSize);
sl@0
  2465
	TInt err = iInFile.Read (*(iRawInBuffer->iData.iRawData), iInBuffSize);
sl@0
  2466
	if ( !err)
sl@0
  2467
		{
sl@0
  2468
		if ( (iRawInBuffer->iData.iRawData->Length()) == 0)
sl@0
  2469
			{
sl@0
  2470
			iInputEnd = ETrue;
sl@0
  2471
			}
sl@0
  2472
		}
sl@0
  2473
	INFO_PRINTF1(_L("*END*CT_CMMFDevVideoPlay::ReadRawPicture"));
sl@0
  2474
	return err;
sl@0
  2475
	}
sl@0
  2476
sl@0
  2477
void CT_CMMFDevVideoPlay::DoCmdH264CreateDecTest(const TTEFSectionName& aSection)
sl@0
  2478
    {
sl@0
  2479
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::CreateDecTest, In"));
sl@0
  2480
    iUse264 = ETrue;
sl@0
  2481
    TInt uidInt = 0;
sl@0
  2482
    TInt output = 0;
sl@0
  2483
    TInt width = 0;
sl@0
  2484
    TInt height = 0;
sl@0
  2485
    TInt buffMgmt = 0;
sl@0
  2486
    TInt codec = 0;
sl@0
  2487
    TPtrC inputfile;
sl@0
  2488
    TPtrC inputDirectory;
sl@0
  2489
    
sl@0
  2490
    iObserver = new (ELeave) CEngineObserver(*this);
sl@0
  2491
    //Create Decoder test engine     
sl@0
  2492
    iEngine = CVDecTestEngine::NewL(*iObserver);    
sl@0
  2493
sl@0
  2494
    //Read from test case file 
sl@0
  2495
	if(!GetHexFromConfig(aSection, KUid(), uidInt))
sl@0
  2496
		{
sl@0
  2497
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUid());
sl@0
  2498
		SetBlockResult(EFail);
sl@0
  2499
		}
sl@0
  2500
	if(!GetIntFromConfig(aSection, KBuffMgmt(), buffMgmt))
sl@0
  2501
		{
sl@0
  2502
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBuffMgmt());
sl@0
  2503
		SetBlockResult(EFail);
sl@0
  2504
		}
sl@0
  2505
	if(!GetIntFromConfig(aSection, KOutput(), output))
sl@0
  2506
		{
sl@0
  2507
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutput());
sl@0
  2508
		SetBlockResult(EFail);
sl@0
  2509
		}
sl@0
  2510
	if(!GetIntFromConfig(aSection, KWidth(), width))
sl@0
  2511
		{
sl@0
  2512
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KWidth());
sl@0
  2513
		SetBlockResult(EFail);
sl@0
  2514
		}
sl@0
  2515
	if(!GetIntFromConfig(aSection, KHeight(), height))
sl@0
  2516
		{
sl@0
  2517
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHeight());
sl@0
  2518
		SetBlockResult(EFail);
sl@0
  2519
		}
sl@0
  2520
	if(!GetIntFromConfig(aSection, KCodec(), codec))
sl@0
  2521
		{
sl@0
  2522
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCodec());
sl@0
  2523
		SetBlockResult(EFail);
sl@0
  2524
		}
sl@0
  2525
	if(!GetStringFromConfig(aSection, KInputPath(), inputDirectory))
sl@0
  2526
		{
sl@0
  2527
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputPath());
sl@0
  2528
		SetBlockResult(EFail);
sl@0
  2529
		}
sl@0
  2530
	if(!GetStringFromConfig(aSection, KInputfile(), inputfile))
sl@0
  2531
		{
sl@0
  2532
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputfile());
sl@0
  2533
		SetBlockResult(EFail);
sl@0
  2534
		}
sl@0
  2535
  
sl@0
  2536
	//Open File
sl@0
  2537
    TFileName inFileName(inputDirectory);
sl@0
  2538
    inFileName.Append(inputfile);
sl@0
  2539
sl@0
  2540
	TUid decoderUid;
sl@0
  2541
    decoderUid.iUid = uidInt;
sl@0
  2542
    INFO_PRINTF2(_L("Decoder uid is [%x]"), decoderUid.iUid);
sl@0
  2543
sl@0
  2544
	TSize size;
sl@0
  2545
	size.SetSize(width, height);
sl@0
  2546
        
sl@0
  2547
    if (output == EDecodedFile) 
sl@0
  2548
    	{
sl@0
  2549
    	TPtrC outputfile;
sl@0
  2550
    	TPtrC outputDirectory;
sl@0
  2551
		if ( ! (GetStringFromConfig(aSection, KOutputPath(),outputDirectory)))
sl@0
  2552
			{
sl@0
  2553
			ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputPath());
sl@0
  2554
			SetBlockResult(EFail);
sl@0
  2555
			}
sl@0
  2556
		if ( !(GetStringFromConfig(aSection, KOutputfile(),outputfile)))
sl@0
  2557
			{
sl@0
  2558
			ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputfile());
sl@0
  2559
			SetBlockResult(EFail);
sl@0
  2560
			}
sl@0
  2561
    		
sl@0
  2562
    	//Start sequence    
sl@0
  2563
    	iEngine->SetUpL(size, EFalse, buffMgmt);
sl@0
  2564
    	TFileName outFileName(outputDirectory);
sl@0
  2565
    	outFileName.Append(outputfile);   
sl@0
  2566
    	iEngine->OpenFileL(outFileName, inFileName);
sl@0
  2567
    	}
sl@0
  2568
    else if (output == EScreenOutput) 
sl@0
  2569
    	{
sl@0
  2570
   		iEngine->SetUpL(size, ETrue, buffMgmt);    	   
sl@0
  2571
    	iEngine->OpenFileL(inFileName);    	
sl@0
  2572
    	}               
sl@0
  2573
    
sl@0
  2574
    TRAPD(result, iEngine->SelectDecoderL(decoderUid));
sl@0
  2575
    if(result != KErrNone)
sl@0
  2576
        {
sl@0
  2577
        ERR_PRINTF2(_L("SelectDecoderL left with error %d"), result);
sl@0
  2578
        SetError(result);
sl@0
  2579
        }
sl@0
  2580
    
sl@0
  2581
    TVideoCodec videoCodec;
sl@0
  2582
    if (codec == 1) 
sl@0
  2583
    	{
sl@0
  2584
    	videoCodec = EH263;	
sl@0
  2585
    	}
sl@0
  2586
    else if (codec == 2) 
sl@0
  2587
    	{
sl@0
  2588
    	videoCodec = EMPEG4;	
sl@0
  2589
    	}
sl@0
  2590
    else if (codec == 3) 
sl@0
  2591
    	{
sl@0
  2592
    	videoCodec = EAVC;	
sl@0
  2593
    	}
sl@0
  2594
    else if (codec == 4) 
sl@0
  2595
    	{
sl@0
  2596
    	videoCodec = EVC1;	
sl@0
  2597
    	}	
sl@0
  2598
    else if (codec == 5) 
sl@0
  2599
    	{
sl@0
  2600
    	videoCodec = EFLV;	
sl@0
  2601
    	}	
sl@0
  2602
		else if (codec == 6) 
sl@0
  2603
    	{
sl@0
  2604
    	videoCodec = EVP6;	
sl@0
  2605
    	}
sl@0
  2606
    else 
sl@0
  2607
    	{
sl@0
  2608
    	videoCodec = EMPEG4;	
sl@0
  2609
    	}
sl@0
  2610
    iEngine->SetCodecType(videoCodec);
sl@0
  2611
    
sl@0
  2612
    iFileOpen = ETrue;
sl@0
  2613
   
sl@0
  2614
	INFO_PRINTF1(_L("CT_MMFDevVideoPlayData::CreateDecTest, Out"));
sl@0
  2615
    }
sl@0
  2616
sl@0
  2617
void CT_CMMFDevVideoPlay::DoCmdH264SetInputFormatCompr(const TTEFSectionName& aSection)
sl@0
  2618
    {
sl@0
  2619
    INFO_PRINTF1(_L("CT_MMFDevVideoPlayData::SetInputFormatCompr, In"));
sl@0
  2620
  
sl@0
  2621
    TInt hwdev = 0;
sl@0
  2622
    TInt dataUnitTypeInt = 0;
sl@0
  2623
    TInt encapsulation = 0;
sl@0
  2624
    TInt dataInOrder = 0;
sl@0
  2625
    TPtrC format;
sl@0
  2626
	if(!GetIntFromConfig(aSection, KHwdev(), hwdev))
sl@0
  2627
		{
sl@0
  2628
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHwdev());
sl@0
  2629
		SetBlockResult(EFail);
sl@0
  2630
		}
sl@0
  2631
	if(!GetIntFromConfig(aSection, KDataUnitTypeInt(), dataUnitTypeInt))
sl@0
  2632
		{
sl@0
  2633
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDataUnitTypeInt());
sl@0
  2634
		SetBlockResult(EFail);
sl@0
  2635
		}
sl@0
  2636
	if(!GetIntFromConfig(aSection, KEncapsulation(), encapsulation))
sl@0
  2637
		{
sl@0
  2638
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KEncapsulation());
sl@0
  2639
		SetBlockResult(EFail);
sl@0
  2640
		}
sl@0
  2641
	if(!GetBoolFromConfig(aSection, KDataInOrder(), dataInOrder))
sl@0
  2642
		{
sl@0
  2643
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDataInOrder());
sl@0
  2644
		SetBlockResult(EFail);
sl@0
  2645
		}
sl@0
  2646
	if(!GetStringFromConfig(aSection, KFormat(), format))
sl@0
  2647
		{
sl@0
  2648
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFormat());
sl@0
  2649
		SetBlockResult(EFail);
sl@0
  2650
		}
sl@0
  2651
	
sl@0
  2652
	TVideoDataUnitType dataUnitType;
sl@0
  2653
	switch (dataUnitTypeInt)
sl@0
  2654
		{
sl@0
  2655
		case 1: dataUnitType = EDuCodedPicture;
sl@0
  2656
				break;
sl@0
  2657
		case 2: dataUnitType = EDuVideoSegment;
sl@0
  2658
				break;
sl@0
  2659
		case 3: dataUnitType = EDuSeveralSegments;
sl@0
  2660
				break;			
sl@0
  2661
		case 4: dataUnitType = EDuArbitraryStreamSection;
sl@0
  2662
				break;				
sl@0
  2663
		default:dataUnitType = EDuCodedPicture;			
sl@0
  2664
		}
sl@0
  2665
			
sl@0
  2666
	TVideoDataUnitEncapsulation dataEncapsulation;
sl@0
  2667
	
sl@0
  2668
	switch (encapsulation) 
sl@0
  2669
		{
sl@0
  2670
		case 1: dataEncapsulation = EDuElementaryStream;
sl@0
  2671
				break;
sl@0
  2672
		case 2: dataEncapsulation = EDuGenericPayload;
sl@0
  2673
				break;
sl@0
  2674
		case 3: dataEncapsulation = EDuRtpPayload;
sl@0
  2675
				break;
sl@0
  2676
		default:dataEncapsulation = EDuElementaryStream;				
sl@0
  2677
		}
sl@0
  2678
	
sl@0
  2679
	TBuf8<128> buf;
sl@0
  2680
	buf.Copy(format);
sl@0
  2681
	CCompressedVideoFormat* compressedFormat = CCompressedVideoFormat::NewL(buf);    
sl@0
  2682
			     	
sl@0
  2683
	TRAPD(result, iEngine->SetInputFormatL(hwdev,*compressedFormat, dataUnitType, dataEncapsulation, dataInOrder));
sl@0
  2684
    if(result != KErrNone)
sl@0
  2685
        {
sl@0
  2686
        ERR_PRINTF2(_L("SetInputFormatL left with error %d"), result);
sl@0
  2687
        SetError(result);
sl@0
  2688
        }    
sl@0
  2689
    delete compressedFormat;
sl@0
  2690
    
sl@0
  2691
    INFO_PRINTF1(_L("CT_MMFDevVideoPlayData::SetInputFormatCompr, Out"));
sl@0
  2692
    }
sl@0
  2693
sl@0
  2694
void CT_CMMFDevVideoPlay::DoCmdH264SetOutputFormat(const TTEFSectionName& aSection)
sl@0
  2695
	{
sl@0
  2696
	TInt hwdev = 0;
sl@0
  2697
	TInt dataFormat = 0;
sl@0
  2698
    TInt dataLayout = 0;
sl@0
  2699
    TInt pattern = 0;
sl@0
  2700
    TInt aspectRatioNum = 1;
sl@0
  2701
    TInt aspectRatioDenom = 1;
sl@0
  2702
    TInt coefficients = 0;
sl@0
  2703
        
sl@0
  2704
    //Read from test case file 
sl@0
  2705
    if ( !(GetIntFromConfig(aSection, KHwdev(), hwdev)))
sl@0
  2706
        {
sl@0
  2707
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHwdev());
sl@0
  2708
        SetBlockResult(EFail);
sl@0
  2709
        }
sl@0
  2710
    if ( !(GetIntFromConfig(aSection, KDataFormat(), dataFormat)))
sl@0
  2711
        {
sl@0
  2712
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDataFormat());
sl@0
  2713
        SetBlockResult(EFail);
sl@0
  2714
        }
sl@0
  2715
    
sl@0
  2716
    if ( !(GetIntFromConfig(aSection, KDataLayout(), dataLayout)))
sl@0
  2717
        {
sl@0
  2718
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDataLayout());
sl@0
  2719
        SetBlockResult(EFail);
sl@0
  2720
        }   
sl@0
  2721
    
sl@0
  2722
    TUncompressedVideoFormat unCompressedFormat;
sl@0
  2723
    
sl@0
  2724
    switch (dataFormat)
sl@0
  2725
    	{
sl@0
  2726
    	case 1: 
sl@0
  2727
    	    unCompressedFormat.iDataFormat = ERgbRawData;    				
sl@0
  2728
    		unCompressedFormat.iRgbFormat = ERgb32bit888;
sl@0
  2729
    		break;    				
sl@0
  2730
    	case 2: unCompressedFormat.iDataFormat = ERgbFbsBitmap;
sl@0
  2731
    			switch (dataLayout) 
sl@0
  2732
    				{
sl@0
  2733
    				case 1: unCompressedFormat.iRgbFormat = ERgb16bit444;
sl@0
  2734
    						break;
sl@0
  2735
    				case 2: unCompressedFormat.iRgbFormat = ERgb16bit565;
sl@0
  2736
    						break;
sl@0
  2737
					case 3: unCompressedFormat.iRgbFormat = ERgb32bit888;
sl@0
  2738
    						break;
sl@0
  2739
    				case 4: unCompressedFormat.iRgbFormat = EFbsBitmapColor4K;
sl@0
  2740
    						break;
sl@0
  2741
    				case 5: unCompressedFormat.iRgbFormat = EFbsBitmapColor16M;
sl@0
  2742
    						break;				    							
sl@0
  2743
    				case 6: unCompressedFormat.iRgbFormat = EFbsBitmapColor16MU;
sl@0
  2744
    						break;		
sl@0
  2745
    				default: unCompressedFormat.iRgbFormat = ERgb16bit444;
sl@0
  2746
    				}
sl@0
  2747
    			break;
sl@0
  2748
    	case 3: unCompressedFormat.iDataFormat = EYuvRawData;
sl@0
  2749
                if ( !(GetIntFromConfig(aSection, KPattern(), pattern)))
sl@0
  2750
                    {
sl@0
  2751
                    ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPattern());
sl@0
  2752
                    SetBlockResult(EFail);
sl@0
  2753
                    }
sl@0
  2754
                if ( !(GetIntFromConfig(aSection, KAspectRatioNum(), aspectRatioNum)))
sl@0
  2755
                    {
sl@0
  2756
                    ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KAspectRatioNum());
sl@0
  2757
                    SetBlockResult(EFail);
sl@0
  2758
                    }
sl@0
  2759
                if ( !(GetIntFromConfig(aSection, KAspectRatioDenom(), aspectRatioDenom)))
sl@0
  2760
                    {
sl@0
  2761
                    ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KAspectRatioDenom());
sl@0
  2762
                    SetBlockResult(EFail);
sl@0
  2763
                    }
sl@0
  2764
                if(!GetHexFromConfig(aSection, KCoefficients(), coefficients))
sl@0
  2765
                    {
sl@0
  2766
                    ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCoefficients());
sl@0
  2767
                    SetBlockResult(EFail);
sl@0
  2768
                    }
sl@0
  2769
    			switch (dataLayout) 
sl@0
  2770
    				{
sl@0
  2771
    				case 1: unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
sl@0
  2772
    						break;
sl@0
  2773
    				case 2: unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
sl@0
  2774
    						break;
sl@0
  2775
					case 3: unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
sl@0
  2776
    						break;
sl@0
  2777
    				case 4: unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataSemiPlanar;
sl@0
  2778
    						break;
sl@0
  2779
    				default:unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;    							    					 
sl@0
  2780
    				}
sl@0
  2781
    			switch (pattern) 
sl@0
  2782
    				{
sl@0
  2783
    				case 1: unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma1;
sl@0
  2784
    						break;
sl@0
  2785
    				case 2: unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma2;
sl@0
  2786
    						break;
sl@0
  2787
					case 3: unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma3;
sl@0
  2788
    						break;
sl@0
  2789
    				case 4: unCompressedFormat.iYuvFormat.iPattern = EYuv422Chroma1;
sl@0
  2790
    						break;
sl@0
  2791
    				case 5: unCompressedFormat.iYuvFormat.iPattern = EYuv422Chroma2;
sl@0
  2792
    						break;    							
sl@0
  2793
    				default:unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma2; 
sl@0
  2794
    				}
sl@0
  2795
    			switch (coefficients) 
sl@0
  2796
    				{
sl@0
  2797
    				case 1: unCompressedFormat.iYuvFormat.iCoefficients = EYuvRange0;
sl@0
  2798
    						break;
sl@0
  2799
    				case 2: unCompressedFormat.iYuvFormat.iCoefficients = EYuvRange1;
sl@0
  2800
    						break;
sl@0
  2801
					case 3: unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt709;
sl@0
  2802
    						break;
sl@0
  2803
    				case 4: unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
sl@0
  2804
    						break;
sl@0
  2805
    				case 5: unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
sl@0
  2806
    						break;    							
sl@0
  2807
    				case 6: unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601;
sl@0
  2808
    						break;    							
sl@0
  2809
    				case 7: unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
sl@0
  2810
    						break;    							
sl@0
  2811
    				case 8: unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
sl@0
  2812
    						break;    									
sl@0
  2813
    				case 9: unCompressedFormat.iYuvFormat.iCoefficients = ECustomYuvMatrix;
sl@0
  2814
    						break;    							
sl@0
  2815
    				default:unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt709Range0; 
sl@0
  2816
    				}	
sl@0
  2817
    			unCompressedFormat.iYuvFormat.iAspectRatioNum = aspectRatioNum;
sl@0
  2818
    			unCompressedFormat.iYuvFormat.iAspectRatioDenom = aspectRatioDenom;
sl@0
  2819
    			// We don't use conversion
sl@0
  2820
				unCompressedFormat.iYuvFormat.iYuv2RgbMatrix = NULL;
sl@0
  2821
				unCompressedFormat.iYuvFormat.iRgb2YuvMatrix = NULL;
sl@0
  2822
sl@0
  2823
    			break;
sl@0
  2824
    		default:	    unCompressedFormat.iDataFormat = EYuvRawData;
sl@0
  2825
						    unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataPlanar; 
sl@0
  2826
						    unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma1;
sl@0
  2827
						    unCompressedFormat.iYuvFormat.iAspectRatioNum = 1;
sl@0
  2828
						    unCompressedFormat.iYuvFormat.iAspectRatioDenom = 1;
sl@0
  2829
						    unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
sl@0
  2830
						    
sl@0
  2831
						    // We don't use conversion
sl@0
  2832
						    unCompressedFormat.iYuvFormat.iYuv2RgbMatrix = NULL;
sl@0
  2833
						    unCompressedFormat.iYuvFormat.iRgb2YuvMatrix = NULL;
sl@0
  2834
    	}            
sl@0
  2835
    
sl@0
  2836
    TRAPD(result, iEngine->SetOutputFormatL(hwdev, unCompressedFormat));
sl@0
  2837
    if(result != KErrNone)
sl@0
  2838
        {
sl@0
  2839
        ERR_PRINTF2(_L("SetOutputFormatL left with error %d"), result);
sl@0
  2840
        SetError(result);
sl@0
  2841
        }
sl@0
  2842
	}
sl@0
  2843
sl@0
  2844
void CT_CMMFDevVideoPlay::DoCmdH264SetBufferOptions(const TTEFSectionName& aSection)
sl@0
  2845
	{
sl@0
  2846
    TInt preDecodeBufferSize = 0;
sl@0
  2847
	TInt maxPostDecodeBufferSize = 0;
sl@0
  2848
	TInt preDecoderBufferPeriodInt = 0;
sl@0
  2849
	TInt postDecoderBufferPeriodInt = 0;
sl@0
  2850
	TInt maxInputBufferSize = 0;
sl@0
  2851
	TInt minNumInputBuffers = 0;
sl@0
  2852
sl@0
  2853
    if ( !(GetIntFromConfig(aSection, KPreDecodeBufferSize(), preDecodeBufferSize)))
sl@0
  2854
        {
sl@0
  2855
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPreDecodeBufferSize());
sl@0
  2856
        SetBlockResult(EFail);
sl@0
  2857
        }
sl@0
  2858
    if ( !(GetIntFromConfig(aSection, KMaxPostDecodeBufferSize(), maxPostDecodeBufferSize)))
sl@0
  2859
        {
sl@0
  2860
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMaxPostDecodeBufferSize());
sl@0
  2861
        SetBlockResult(EFail);
sl@0
  2862
        }
sl@0
  2863
    if ( !(GetIntFromConfig(aSection, KPreDecoderBufferPeriodInt(), preDecoderBufferPeriodInt)))
sl@0
  2864
        {
sl@0
  2865
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPreDecoderBufferPeriodInt());
sl@0
  2866
        SetBlockResult(EFail);
sl@0
  2867
        }
sl@0
  2868
    if ( !(GetIntFromConfig(aSection, KPostDecoderBufferPeriodInt(), postDecoderBufferPeriodInt)))
sl@0
  2869
        {
sl@0
  2870
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPostDecoderBufferPeriodInt());
sl@0
  2871
        SetBlockResult(EFail);
sl@0
  2872
        }
sl@0
  2873
    if ( !(GetIntFromConfig(aSection, KMaxInputBufferSize(), maxInputBufferSize)))
sl@0
  2874
        {
sl@0
  2875
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMaxInputBufferSize());
sl@0
  2876
        SetBlockResult(EFail);
sl@0
  2877
        }
sl@0
  2878
    if ( !(GetIntFromConfig(aSection, KMinNumInputBuffers(), minNumInputBuffers)))
sl@0
  2879
        {
sl@0
  2880
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMinNumInputBuffers());
sl@0
  2881
        SetBlockResult(EFail);
sl@0
  2882
        }    
sl@0
  2883
sl@0
  2884
    CMMFDevVideoPlay::TBufferOptions bufferOptions;
sl@0
  2885
	bufferOptions.iPreDecodeBufferSize = preDecodeBufferSize;
sl@0
  2886
	bufferOptions.iMaxPostDecodeBufferSize = maxPostDecodeBufferSize;
sl@0
  2887
	bufferOptions.iPreDecoderBufferPeriod = preDecoderBufferPeriodInt;
sl@0
  2888
	bufferOptions.iPostDecoderBufferPeriod = postDecoderBufferPeriodInt;
sl@0
  2889
	bufferOptions.iMaxInputBufferSize = maxInputBufferSize;
sl@0
  2890
	bufferOptions.iMinNumInputBuffers = minNumInputBuffers;
sl@0
  2891
sl@0
  2892
	TRAPD(result, iEngine->SetBufferOptionsL(bufferOptions));
sl@0
  2893
    if(result != KErrNone)
sl@0
  2894
        {
sl@0
  2895
        ERR_PRINTF2(_L("SetBufferOptionsL left with error %d"), result);
sl@0
  2896
        SetError(result);
sl@0
  2897
        }
sl@0
  2898
	}
sl@0
  2899
sl@0
  2900
void CT_CMMFDevVideoPlay::DoCmdH264Initialize()
sl@0
  2901
	{
sl@0
  2902
	INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Initialize, In"));
sl@0
  2903
	iEngine->Initialize();
sl@0
  2904
	IncOutstanding();
sl@0
  2905
	INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Initialize, Out"));
sl@0
  2906
	}
sl@0
  2907
sl@0
  2908
void  CT_CMMFDevVideoPlay::DoCmdH264Start(const TTEFSectionName& aSection)
sl@0
  2909
	{
sl@0
  2910
	INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Start, In"));
sl@0
  2911
    TInt inputEnd = 0;
sl@0
  2912
    if ( !(GetIntFromConfig(aSection, KInputEnd(), inputEnd)))
sl@0
  2913
        {
sl@0
  2914
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputEnd());
sl@0
  2915
        SetBlockResult(EFail);
sl@0
  2916
        }
sl@0
  2917
    if (inputEnd != 0)  
sl@0
  2918
    	{
sl@0
  2919
    	iEngine->Start(ETrue);
sl@0
  2920
    	}
sl@0
  2921
    else 
sl@0
  2922
    	{
sl@0
  2923
    	iEngine->Start(EFalse);
sl@0
  2924
    	}
sl@0
  2925
    IncOutstanding();
sl@0
  2926
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Start, Out"));
sl@0
  2927
	}
sl@0
  2928
sl@0
  2929
void CT_CMMFDevVideoPlay::DoCmdH264Stop()
sl@0
  2930
    {
sl@0
  2931
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Stop, In"));
sl@0
  2932
    TRAPD(result, iEngine->Stop());
sl@0
  2933
    if(result != KErrNone)
sl@0
  2934
        {
sl@0
  2935
        ERR_PRINTF2(_L("Stop left with error %d"), result);
sl@0
  2936
        SetError(result);
sl@0
  2937
        }
sl@0
  2938
    INFO_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdH264Stop, Out result=%d"),result);
sl@0
  2939
    }
sl@0
  2940
sl@0
  2941
void CT_CMMFDevVideoPlay::DoCmdH264Pause()
sl@0
  2942
    {
sl@0
  2943
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Pause, In"));
sl@0
  2944
    TInt result = KErrNone;
sl@0
  2945
    result = iEngine->Pause();
sl@0
  2946
    INFO_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdH264Pause, Out result=%d"),result);    
sl@0
  2947
    }
sl@0
  2948
sl@0
  2949
void CT_CMMFDevVideoPlay::DoCmdH264Resume()
sl@0
  2950
    {
sl@0
  2951
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Resume, In"));
sl@0
  2952
    TInt result = KErrNone;
sl@0
  2953
    result = iEngine->Resume();
sl@0
  2954
    INFO_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdH264Resume, Out result=%d"),result);    
sl@0
  2955
    }
sl@0
  2956
sl@0
  2957
void CT_CMMFDevVideoPlay::DoCmdH264IOFrameNumMatch()
sl@0
  2958
	{
sl@0
  2959
    iEngine->SetFrameMatch( ETrue );
sl@0
  2960
	}
sl@0
  2961
sl@0
  2962
void CT_CMMFDevVideoPlay::DoCmdH264ListFrameSize()
sl@0
  2963
    {
sl@0
  2964
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264ListFrameSize, In"));
sl@0
  2965
    RArray<TInt> framesizes;
sl@0
  2966
    TRAPD(result, iEngine->ListFrameSizeL(framesizes));
sl@0
  2967
    if(result != KErrNone)
sl@0
  2968
        {
sl@0
  2969
        ERR_PRINTF2(_L("ListFrameSizeL left with error %d"), result);
sl@0
  2970
        SetError(result);
sl@0
  2971
        }
sl@0
  2972
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264ListFrameSize, Out"));
sl@0
  2973
    }
sl@0
  2974
sl@0
  2975
void CT_CMMFDevVideoPlay::DoCmdH264SetVideoDestScreen(const TTEFSectionName& aSection)
sl@0
  2976
    {
sl@0
  2977
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::SetVideoDestScreen, In"));
sl@0
  2978
   
sl@0
  2979
    TBool dest = 0;
sl@0
  2980
    if(!GetBoolFromConfig(aSection, KDest(), dest))
sl@0
  2981
        {
sl@0
  2982
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDest());
sl@0
  2983
        SetBlockResult(EFail);
sl@0
  2984
        }
sl@0
  2985
sl@0
  2986
    TRAPD(result, iEngine->SetVideoDestScreenL(dest));
sl@0
  2987
    if(result != KErrNone)
sl@0
  2988
        {
sl@0
  2989
        ERR_PRINTF2(_L("SetVideoDestScreenL left with error %d"), result);
sl@0
  2990
        SetError(result);
sl@0
  2991
        }    
sl@0
  2992
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetVideoDestScreen, Out"));
sl@0
  2993
    } 
sl@0
  2994
sl@0
  2995
void CT_CMMFDevVideoPlay::DoCmdH264SetWindowRect(const TTEFSectionName& aSection)
sl@0
  2996
    {
sl@0
  2997
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetWindowRect, In"));
sl@0
  2998
    
sl@0
  2999
    TInt x;
sl@0
  3000
    TInt y;
sl@0
  3001
    TInt width;
sl@0
  3002
    TInt height;
sl@0
  3003
sl@0
  3004
    if ( !(GetIntFromConfig(aSection, KX(), x)))
sl@0
  3005
        {
sl@0
  3006
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KX());
sl@0
  3007
        SetBlockResult(EFail);
sl@0
  3008
        }
sl@0
  3009
    if ( !(GetIntFromConfig(aSection, KY(), y)))
sl@0
  3010
        {
sl@0
  3011
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KY());
sl@0
  3012
        SetBlockResult(EFail);
sl@0
  3013
        }
sl@0
  3014
    if ( !(GetIntFromConfig(aSection, KWidth(), width)))
sl@0
  3015
        {
sl@0
  3016
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KWidth());
sl@0
  3017
        SetBlockResult(EFail);
sl@0
  3018
        }
sl@0
  3019
    if ( !(GetIntFromConfig(aSection, KHeight(), height)))
sl@0
  3020
        {
sl@0
  3021
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHeight());
sl@0
  3022
        SetBlockResult(EFail);
sl@0
  3023
        }
sl@0
  3024
sl@0
  3025
    TSize size(width, height);
sl@0
  3026
    
sl@0
  3027
    iEngine->SetWindowRect(x, y, size);
sl@0
  3028
    
sl@0
  3029
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetWindowRect, Out"));  
sl@0
  3030
    }
sl@0
  3031
sl@0
  3032
void CT_CMMFDevVideoPlay::DoCmdH264SelectPostProcessor(const TTEFSectionName& aSection)
sl@0
  3033
    {
sl@0
  3034
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SelectPostProcessor, In"));
sl@0
  3035
    
sl@0
  3036
    TInt uidInt = 0;
sl@0
  3037
    if(!GetHexFromConfig(aSection, KUid(), uidInt))
sl@0
  3038
        {
sl@0
  3039
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUid());
sl@0
  3040
        SetBlockResult(EFail);
sl@0
  3041
        }
sl@0
  3042
    
sl@0
  3043
    TUid postproUid;
sl@0
  3044
    postproUid.iUid = uidInt;
sl@0
  3045
    INFO_PRINTF2(_L("PostProcessor uid is [%x]"), postproUid.iUid);
sl@0
  3046
                
sl@0
  3047
    TRAPD(result, iEngine->SelectPostProcessorL(postproUid));
sl@0
  3048
    if(result != KErrNone)
sl@0
  3049
        {
sl@0
  3050
        ERR_PRINTF2(_L("SelectPostProcessorL left with error %d"), result);
sl@0
  3051
        SetError(result);
sl@0
  3052
        }     
sl@0
  3053
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SelectPostProcessor, Out"));
sl@0
  3054
    }
sl@0
  3055
sl@0
  3056
void CT_CMMFDevVideoPlay::DoCmdH264SetPostProcessTypes(const TTEFSectionName& aSection)
sl@0
  3057
    {
sl@0
  3058
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetPostProcessTypes, In"));
sl@0
  3059
    
sl@0
  3060
    TInt combination = 0;
sl@0
  3061
    TInt hwdev = 0;
sl@0
  3062
sl@0
  3063
    if(!GetIntFromConfig(aSection, KHwdev(), hwdev))
sl@0
  3064
        {
sl@0
  3065
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHwdev());
sl@0
  3066
        SetBlockResult(EFail);
sl@0
  3067
        }
sl@0
  3068
    if(!GetHexFromConfig(aSection, KCombination(), combination))
sl@0
  3069
        {
sl@0
  3070
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCombination());
sl@0
  3071
        SetBlockResult(EFail);
sl@0
  3072
        }
sl@0
  3073
    
sl@0
  3074
    TRAPD(result, iEngine->SetPostProcessTypesL(hwdev, combination));
sl@0
  3075
    if(result != KErrNone)
sl@0
  3076
        {
sl@0
  3077
        ERR_PRINTF2(_L("SetPostProcessTypesL left with error %d"), result);
sl@0
  3078
        SetError(result);
sl@0
  3079
        }    
sl@0
  3080
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetPostProcessTypes, In"));
sl@0
  3081
    }
sl@0
  3082
sl@0
  3083
void CT_CMMFDevVideoPlay::DoCmdH264FindCommonFormats()
sl@0
  3084
    {
sl@0
  3085
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264FindCommonFormats, In") );
sl@0
  3086
      
sl@0
  3087
    TRAPD(result, iEngine->FindCommonFormatsL());
sl@0
  3088
    if(result != KErrNone)
sl@0
  3089
        {
sl@0
  3090
        ERR_PRINTF2(_L("FindCommonFormatsL left with error %d"), result);
sl@0
  3091
        SetError(result);
sl@0
  3092
        }     
sl@0
  3093
    INFO_PRINTF2(_L("CT_CMMFDevVideoPlay::DoCmdH264FindCommonFormats, Out [%d]"), result);
sl@0
  3094
    }
sl@0
  3095
sl@0
  3096
sl@0
  3097
void CT_CMMFDevVideoPlay::DoCmdH264GetHeaderInformation(const TTEFSectionName& aSection)
sl@0
  3098
    {
sl@0
  3099
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::GetHeaderInformation, In") );
sl@0
  3100
    TInt result = KErrNone; 
sl@0
  3101
    TInt dataUnitTypeInt = 0;
sl@0
  3102
    TBool getDataUnitTypeInt = ETrue;
sl@0
  3103
    if(!GetIntFromConfig(aSection, KDataUnitTypeInt(), dataUnitTypeInt))
sl@0
  3104
        {
sl@0
  3105
        getDataUnitTypeInt = EFalse;
sl@0
  3106
        }
sl@0
  3107
    TInt encapsulation = 0;
sl@0
  3108
    TBool getEncapsulation = ETrue;
sl@0
  3109
    if(!GetIntFromConfig(aSection, KEncapsulation(), encapsulation))
sl@0
  3110
        {
sl@0
  3111
        getEncapsulation = EFalse;
sl@0
  3112
        }
sl@0
  3113
    if(getDataUnitTypeInt && getEncapsulation)
sl@0
  3114
        {
sl@0
  3115
        TVideoDataUnitType dataUnitType;
sl@0
  3116
        switch (dataUnitTypeInt)
sl@0
  3117
            {
sl@0
  3118
            case 1: dataUnitType = EDuCodedPicture;
sl@0
  3119
                    break;
sl@0
  3120
            case 2: dataUnitType = EDuVideoSegment;
sl@0
  3121
                    break;
sl@0
  3122
            case 3: dataUnitType = EDuSeveralSegments;
sl@0
  3123
                    break;          
sl@0
  3124
            case 4: dataUnitType = EDuArbitraryStreamSection;
sl@0
  3125
                    break;              
sl@0
  3126
            default:dataUnitType = EDuCodedPicture;         
sl@0
  3127
            }
sl@0
  3128
                
sl@0
  3129
        TVideoDataUnitEncapsulation dataEncapsulation;      
sl@0
  3130
        switch (encapsulation) 
sl@0
  3131
            {
sl@0
  3132
            case 1: dataEncapsulation = EDuElementaryStream;
sl@0
  3133
                    break;
sl@0
  3134
            case 2: dataEncapsulation = EDuGenericPayload;
sl@0
  3135
                    break;
sl@0
  3136
            case 3: dataEncapsulation = EDuRtpPayload;
sl@0
  3137
                    break;
sl@0
  3138
            default:dataEncapsulation = EDuElementaryStream;                
sl@0
  3139
            }
sl@0
  3140
        
sl@0
  3141
        TRAP(result, iEngine->GetHeaderInformationL(dataUnitType, dataEncapsulation));
sl@0
  3142
        }
sl@0
  3143
    else 
sl@0
  3144
        {
sl@0
  3145
        TRAP(result, iEngine->GetHeaderInformationL());
sl@0
  3146
        }           
sl@0
  3147
    if(result != KErrNone)
sl@0
  3148
        {
sl@0
  3149
        ERR_PRINTF2(_L("GetHeaderInformationL left with error %d"), result);
sl@0
  3150
        SetError(result);
sl@0
  3151
        }     
sl@0
  3152
    INFO_PRINTF2(_L("CT_CMMFDevVideoPlay::GetHeaderInformation, Out [%d]"), result);
sl@0
  3153
    }
sl@0
  3154
sl@0
  3155
void CT_CMMFDevVideoPlay::DoCmdH264EnableSynchronization(const TTEFSectionName& aSection)
sl@0
  3156
    {
sl@0
  3157
    if(!GetIntFromConfig(aSection, KFramerate(), iFrameRate))
sl@0
  3158
        {
sl@0
  3159
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFramerate());
sl@0
  3160
        SetBlockResult(EFail);
sl@0
  3161
        }
sl@0
  3162
    
sl@0
  3163
    iEngine->EnableSynchronization(iFrameRate);
sl@0
  3164
    }
sl@0
  3165
sl@0
  3166
void CT_CMMFDevVideoPlay::DoCmdH264SetScaleOptions(const TTEFSectionName& aSection)
sl@0
  3167
    {
sl@0
  3168
    TInt width = 0;
sl@0
  3169
    TInt height = 0;
sl@0
  3170
    TInt antiAliasing = 0;
sl@0
  3171
    TInt hwdev = 0;
sl@0
  3172
sl@0
  3173
    if ( !(GetIntFromConfig(aSection, KHwdev(), hwdev)))
sl@0
  3174
        {
sl@0
  3175
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHwdev());
sl@0
  3176
        SetBlockResult(EFail);
sl@0
  3177
        }   
sl@0
  3178
    if ( !(GetIntFromConfig(aSection, KWidth(), width)))
sl@0
  3179
        {
sl@0
  3180
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KWidth());
sl@0
  3181
        SetBlockResult(EFail);
sl@0
  3182
        }
sl@0
  3183
    if ( !(GetIntFromConfig(aSection, KHeight(), height)))
sl@0
  3184
        {
sl@0
  3185
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHeight());
sl@0
  3186
        SetBlockResult(EFail);
sl@0
  3187
        }
sl@0
  3188
    if ( !(GetIntFromConfig(aSection, KY(), antiAliasing)))
sl@0
  3189
        {
sl@0
  3190
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KY());
sl@0
  3191
        SetBlockResult(EFail);
sl@0
  3192
        }
sl@0
  3193
 
sl@0
  3194
    TSize size(width, height);
sl@0
  3195
      
sl@0
  3196
    TRAPD(result, iEngine->SetScaleOptionsL(hwdev, size, antiAliasing));
sl@0
  3197
    if(result != KErrNone)
sl@0
  3198
        {
sl@0
  3199
        ERR_PRINTF2(_L("FindCommonFormatsL left with error %d"), result);
sl@0
  3200
        SetError(result);
sl@0
  3201
        } 
sl@0
  3202
    }
sl@0
  3203
sl@0
  3204
void CT_CMMFDevVideoPlay::DoCmdH264SetRotateOptions(const TTEFSectionName& aSection)
sl@0
  3205
{
sl@0
  3206
    TInt rotItem = 0;       
sl@0
  3207
    TInt hwdev = 0;
sl@0
  3208
    if ( !(GetIntFromConfig(aSection, KHwdev(), hwdev)))
sl@0
  3209
        {
sl@0
  3210
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHwdev());
sl@0
  3211
        SetBlockResult(EFail);
sl@0
  3212
        }   
sl@0
  3213
    if ( !(GetIntFromConfig(aSection, KRotation(), rotItem)))
sl@0
  3214
        {
sl@0
  3215
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRotation());
sl@0
  3216
        SetBlockResult(EFail);
sl@0
  3217
        }
sl@0
  3218
    TRotationType rotation;   
sl@0
  3219
    switch(rotItem)
sl@0
  3220
    {
sl@0
  3221
        case 0:
sl@0
  3222
            rotation = ERotateNone;
sl@0
  3223
            break;
sl@0
  3224
        case 90:
sl@0
  3225
            rotation = ERotate90Clockwise;
sl@0
  3226
            break;              
sl@0
  3227
        case 180:        
sl@0
  3228
            rotation = ERotate180;
sl@0
  3229
            break;        
sl@0
  3230
        case 270:
sl@0
  3231
            rotation = ERotate90Anticlockwise;
sl@0
  3232
            break;              
sl@0
  3233
        default:               
sl@0
  3234
            rotation = ERotateNone;                             
sl@0
  3235
    }
sl@0
  3236
    TRAPD(result, iEngine->SetRotateOptionsL(hwdev, rotation));
sl@0
  3237
    if(result != KErrNone)
sl@0
  3238
        {
sl@0
  3239
        ERR_PRINTF2(_L("SetRotateOptionsL left with error %d"), result);
sl@0
  3240
        SetError(result);
sl@0
  3241
        } 
sl@0
  3242
}
sl@0
  3243
sl@0
  3244
void CT_CMMFDevVideoPlay::DoCmdH264SynchronizeDecoding(const TTEFSectionName& aSection)
sl@0
  3245
    {
sl@0
  3246
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SynchronizeDecoding, In"));
sl@0
  3247
    TBool sync = 0;
sl@0
  3248
    if(!GetBoolFromConfig(aSection, KSync(), sync))
sl@0
  3249
        {
sl@0
  3250
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSync());
sl@0
  3251
        SetBlockResult(EFail);
sl@0
  3252
        }
sl@0
  3253
    iEngine->SynchronizeDecoding(sync);
sl@0
  3254
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SynchronizeDecoding, Out"));
sl@0
  3255
    }
sl@0
  3256
sl@0
  3257
void CT_CMMFDevVideoPlay::DoCmdH264Delete()
sl@0
  3258
    {
sl@0
  3259
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Delete, In"));
sl@0
  3260
    if (iFileOpen && iUse264)
sl@0
  3261
        {
sl@0
  3262
        iEngine->CloseFile();
sl@0
  3263
        }
sl@0
  3264
    iEngine->TearDown();
sl@0
  3265
    if(iEngine)
sl@0
  3266
        {
sl@0
  3267
        delete iEngine;
sl@0
  3268
        iEngine = NULL;
sl@0
  3269
        }
sl@0
  3270
    if(iObserver)
sl@0
  3271
        {
sl@0
  3272
        delete iObserver;
sl@0
  3273
        iObserver = NULL;
sl@0
  3274
        }
sl@0
  3275
    if(iClock)
sl@0
  3276
        {
sl@0
  3277
        delete iClock;
sl@0
  3278
        iClock = NULL;
sl@0
  3279
        }
sl@0
  3280
    while(Outstanding())
sl@0
  3281
        {
sl@0
  3282
        INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Delete DecOutstanding()"));
sl@0
  3283
        DecOutstanding();
sl@0
  3284
        }
sl@0
  3285
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264Delete, Out"));
sl@0
  3286
    }
sl@0
  3287
sl@0
  3288
void CT_CMMFDevVideoPlay::DoCmdH264SetPosition(const TTEFSectionName& aSection)
sl@0
  3289
    {
sl@0
  3290
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetPosition, In"));
sl@0
  3291
    TInt pos;
sl@0
  3292
    TBool dataOk = ETrue;
sl@0
  3293
    if ( !(GetIntFromConfig(aSection, KPos(), pos)) ) //This parameter indicates seconds to move forward/backward from the current position
sl@0
  3294
        {
sl@0
  3295
        ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPos());
sl@0
  3296
        SetBlockResult(EFail);
sl@0
  3297
        dataOk = EFalse;
sl@0
  3298
        }
sl@0
  3299
    if(dataOk)
sl@0
  3300
        {
sl@0
  3301
        TInt frameTimeInterval = (TInt64)(1000000/iFrameRate);
sl@0
  3302
        TInt newPosition = (iEngine->PlaybackPosition()).Int64()/frameTimeInterval + pos;
sl@0
  3303
        INFO_PRINTF2(_L("set to position %d"),newPosition);
sl@0
  3304
        TInt maxPosition = iEngine->GetFrameSizeCount();
sl@0
  3305
        INFO_PRINTF2(_L("total framesize count %d"),maxPosition);
sl@0
  3306
        if(newPosition >= maxPosition)
sl@0
  3307
            {
sl@0
  3308
            INFO_PRINTF3(_L("Invalid forward position %d, auto set to maximum framesize count %d"),newPosition,maxPosition-1);
sl@0
  3309
            newPosition = maxPosition - 1;
sl@0
  3310
            }
sl@0
  3311
        if(newPosition <= 0)
sl@0
  3312
            {
sl@0
  3313
            INFO_PRINTF2(_L("Invalid backward position %d, auto set to starting position."),newPosition);
sl@0
  3314
            newPosition = 1;
sl@0
  3315
            }
sl@0
  3316
        TTimeIntervalMicroSeconds timestamp = newPosition*frameTimeInterval;  
sl@0
  3317
        iEngine->SetPosition(timestamp);
sl@0
  3318
        }
sl@0
  3319
    INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264SetPosition, Out"));
sl@0
  3320
    }
sl@0
  3321
sl@0
  3322
void CT_CMMFDevVideoPlay::DoCmdH264AbortDirectScreenAccess()
sl@0
  3323
	{
sl@0
  3324
	INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264AbortDirectScreenAccess In"));
sl@0
  3325
	iEngine->AbortDirectScreenAccess();
sl@0
  3326
	INFO_PRINTF1(_L("CT_CMMFDevVideoPlay::DoCmdH264AbortDirectScreenAccess, Out"));
sl@0
  3327
	}