os/mm/mmhais/videohai/devvideo/src/DevVideo/devvideoplay.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <ecom/ecom.h>
sl@0
    17
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API	
sl@0
    18
#include <mdf/codecapiuids.hrh>
sl@0
    19
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    20
#include <mmf/devvideo/devvideohwdeviceadaptersetup.h>
sl@0
    21
#endif
sl@0
    22
#endif // SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
    23
sl@0
    24
#include "devvideoplay.h"
sl@0
    25
#include "videoplayhwdevice.h"
sl@0
    26
#include "devvideointernal.h"
sl@0
    27
sl@0
    28
#include <mm/mmpluginutils.h>
sl@0
    29
sl@0
    30
const THwDeviceId KHwDeviceIdVideoDecoder = 1;
sl@0
    31
const THwDeviceId KHwDeviceIdVideoPostProcessor = 2;
sl@0
    32
sl@0
    33
//
sl@0
    34
// CMMFVideoDecodeHwDevice
sl@0
    35
//
sl@0
    36
EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewL(TUid aUid, MMMFDevVideoPlayProxy& aProxy)
sl@0
    37
	{
sl@0
    38
	CMMFVideoDecodeHwDevice* s = reinterpret_cast<CMMFVideoDecodeHwDevice*> 
sl@0
    39
		(REComSession::CreateImplementationL(aUid, _FOFF(CMMFVideoDecodeHwDevice,iDtor_ID_Key)));
sl@0
    40
	s->SetProxy(aProxy);
sl@0
    41
	return s;
sl@0
    42
	}
sl@0
    43
sl@0
    44
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API	
sl@0
    45
const TInt KUidMDFVideoDecoderHwDeviceAdapter = 0x102737ED;
sl@0
    46
EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewPuAdapterL(const CImplementationInformation& aInfo, MMMFDevVideoPlayProxy& aProxy)
sl@0
    47
	{
sl@0
    48
	CMMFVideoDecodeHwDevice* hwdevice = NewL(TUid::Uid(KUidMDFVideoDecoderHwDeviceAdapter), aProxy);
sl@0
    49
	CleanupStack::PushL(hwdevice);
sl@0
    50
sl@0
    51
	MDevVideoHwDeviceAdapterSetup* setup = static_cast<MDevVideoHwDeviceAdapterSetup*>(
sl@0
    52
			hwdevice->CustomInterface(TUid::Uid(KUidDevVideoHwDeviceAdapterSetup)));
sl@0
    53
sl@0
    54
	if (setup!=NULL)
sl@0
    55
		{
sl@0
    56
		setup->LoadProcessingUnitL(aInfo);
sl@0
    57
		}
sl@0
    58
	CleanupStack::Pop(hwdevice);
sl@0
    59
	return hwdevice;
sl@0
    60
	}
sl@0
    61
#else
sl@0
    62
EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewPuAdapterL(const CImplementationInformation& /*aInfo*/, MMMFDevVideoPlayProxy& /*aProxy*/)
sl@0
    63
	{
sl@0
    64
	User::Leave(KErrNotSupported);
sl@0
    65
	return NULL;
sl@0
    66
	}
sl@0
    67
#endif // SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
    68
sl@0
    69
EXPORT_C CMMFVideoDecodeHwDevice::~CMMFVideoDecodeHwDevice()
sl@0
    70
	{
sl@0
    71
	REComSession::DestroyedImplementation(iDtor_ID_Key);
sl@0
    72
	}
sl@0
    73
sl@0
    74
EXPORT_C CMMFVideoDecodeHwDevice::CMMFVideoDecodeHwDevice()
sl@0
    75
	{
sl@0
    76
	}
sl@0
    77
sl@0
    78
sl@0
    79
//
sl@0
    80
// CMMFVideoPostProcHwDevice
sl@0
    81
//
sl@0
    82
EXPORT_C CMMFVideoPostProcHwDevice* CMMFVideoPostProcHwDevice::NewL(TUid aUid, MMMFDevVideoPlayProxy& aProxy)
sl@0
    83
	{
sl@0
    84
	CMMFVideoPostProcHwDevice* s = reinterpret_cast<CMMFVideoPostProcHwDevice*>
sl@0
    85
		(REComSession::CreateImplementationL(aUid, _FOFF(CMMFVideoPostProcHwDevice,iDtor_ID_Key)));
sl@0
    86
	s->SetProxy(aProxy);
sl@0
    87
	return s;
sl@0
    88
	}
sl@0
    89
sl@0
    90
EXPORT_C CMMFVideoPostProcHwDevice::~CMMFVideoPostProcHwDevice()
sl@0
    91
	{
sl@0
    92
	REComSession::DestroyedImplementation(iDtor_ID_Key);
sl@0
    93
	}
sl@0
    94
sl@0
    95
EXPORT_C CMMFVideoPostProcHwDevice::CMMFVideoPostProcHwDevice()
sl@0
    96
	{
sl@0
    97
	}
sl@0
    98
sl@0
    99
sl@0
   100
EXPORT_C TVideoInputBuffer::TVideoInputBuffer() :
sl@0
   101
	iData(0,0,0),
sl@0
   102
	iOptions(0),
sl@0
   103
	iDecodingTimestamp(0),
sl@0
   104
	iPresentationTimestamp(0),
sl@0
   105
	iPreRoll(EFalse),
sl@0
   106
	iSequenceNumber(0),
sl@0
   107
	iError(EFalse),
sl@0
   108
	iUser(NULL)
sl@0
   109
	{
sl@0
   110
	}
sl@0
   111
sl@0
   112
sl@0
   113
//
sl@0
   114
// CPostProcessorInfo
sl@0
   115
//
sl@0
   116
EXPORT_C CPostProcessorInfo* CPostProcessorInfo::NewL(TUid aUid,
sl@0
   117
													 const TDesC& aManufacturer,
sl@0
   118
													 const TDesC& aIdentifier,
sl@0
   119
													 TVersion aVersion,
sl@0
   120
													 const TArray<TUncompressedVideoFormat>& aSupportedFormats,
sl@0
   121
													 const TArray<TUint32>& aSupportedCombinations,
sl@0
   122
													 TBool aAccelerated,
sl@0
   123
													 TBool aSupportsDirectDisplay,
sl@0
   124
													 const TYuvToRgbCapabilities& aYuvToRgbCapabilities,
sl@0
   125
													 TUint32 aSupportedRotations,
sl@0
   126
													 TBool aSupportArbitraryScaling,
sl@0
   127
													 const TArray<TScaleFactor>& aSupportedScaleFactors,
sl@0
   128
													 TBool aAntiAliasedScaling,
sl@0
   129
													 const TDesC8& aImplementationSpecificInfo)
sl@0
   130
	{
sl@0
   131
	CPostProcessorInfo* s = new(ELeave) CPostProcessorInfo(aUid, 
sl@0
   132
														   aVersion, 
sl@0
   133
														   aAccelerated,
sl@0
   134
														   aSupportsDirectDisplay, 
sl@0
   135
														   aYuvToRgbCapabilities, 
sl@0
   136
														   aSupportedRotations, 
sl@0
   137
														   aSupportArbitraryScaling,
sl@0
   138
														   aAntiAliasedScaling);
sl@0
   139
sl@0
   140
	CleanupStack::PushL(s);
sl@0
   141
sl@0
   142
	s->ConstructL(aManufacturer,
sl@0
   143
				  aIdentifier,
sl@0
   144
				  aSupportedFormats,
sl@0
   145
				  aSupportedCombinations,
sl@0
   146
				  aSupportedScaleFactors,
sl@0
   147
				  aImplementationSpecificInfo);
sl@0
   148
	
sl@0
   149
	CleanupStack::Pop(s);
sl@0
   150
	return s;
sl@0
   151
	}
sl@0
   152
sl@0
   153
CPostProcessorInfo::CPostProcessorInfo(TUid aUid,
sl@0
   154
									   TVersion aVersion,
sl@0
   155
									   TBool aAccelerated,
sl@0
   156
									   TBool aSupportDirectDisplay,
sl@0
   157
									   const TYuvToRgbCapabilities& aYuvToRgbCapabilities,
sl@0
   158
									   TUint32 aSupportedRotations,
sl@0
   159
									   TBool aSupportArbitraryScaling,
sl@0
   160
									   TBool aAntiAliasedScaling) :
sl@0
   161
	iUid(aUid),
sl@0
   162
	iVersion(aVersion),
sl@0
   163
	iAccelerated(aAccelerated),
sl@0
   164
	iSupportDirectDisplay(aSupportDirectDisplay),
sl@0
   165
	iYuvToRgbCapabilities(aYuvToRgbCapabilities),
sl@0
   166
	iSupportedRotations(aSupportedRotations),
sl@0
   167
	iSupportArbitraryScaling(aSupportArbitraryScaling),
sl@0
   168
	iAntiAliasedScaling(aAntiAliasedScaling),
sl@0
   169
	iSupportsContentProtected(EFalse)
sl@0
   170
	{
sl@0
   171
	iSupportedScreens.Reset();
sl@0
   172
	}
sl@0
   173
sl@0
   174
void CPostProcessorInfo::ConstructL(const TDesC& aManufacturer,
sl@0
   175
									const TDesC& aIdentifier,
sl@0
   176
									const TArray<TUncompressedVideoFormat>& aSupportedFormats,
sl@0
   177
									const TArray<TUint32>& aSupportedCombinations,
sl@0
   178
									const TArray<TScaleFactor>& aSupportedScaleFactors,
sl@0
   179
									const TDesC8& aImplementationSpecificInfo)
sl@0
   180
	{
sl@0
   181
	iManufacturer = aManufacturer.AllocL();
sl@0
   182
	iIdentifier = aIdentifier.AllocL();
sl@0
   183
	iImplementationSpecificInfo = aImplementationSpecificInfo.AllocL();
sl@0
   184
sl@0
   185
	TInt i=0;
sl@0
   186
	TInt supportedFormatsCount = aSupportedFormats.Count();
sl@0
   187
	for (i=0; i<supportedFormatsCount; i++)
sl@0
   188
		{
sl@0
   189
		User::LeaveIfError(iSupportedFormats.Append(aSupportedFormats[i]));
sl@0
   190
		}
sl@0
   191
sl@0
   192
	TInt supportedCombinationsCount = aSupportedCombinations.Count();
sl@0
   193
	for (i=0; i<supportedCombinationsCount; i++)
sl@0
   194
		{
sl@0
   195
		User::LeaveIfError(iSupportedCombinations.Append(aSupportedCombinations[i]));
sl@0
   196
		}
sl@0
   197
sl@0
   198
	TInt supportedScaleFactors = aSupportedScaleFactors.Count();
sl@0
   199
	for (i=0; i<supportedScaleFactors; i++)
sl@0
   200
		{
sl@0
   201
		User::LeaveIfError(iSupportedScaleFactors.Append(aSupportedScaleFactors[i]));
sl@0
   202
		}
sl@0
   203
	}
sl@0
   204
				
sl@0
   205
EXPORT_C CPostProcessorInfo::~CPostProcessorInfo()
sl@0
   206
	{
sl@0
   207
	delete iManufacturer;
sl@0
   208
	delete iIdentifier;
sl@0
   209
	delete iImplementationSpecificInfo;
sl@0
   210
	iSupportedFormats.Reset();
sl@0
   211
	iSupportedCombinations.Reset();
sl@0
   212
	iSupportedScaleFactors.Reset();
sl@0
   213
	iSupportedScreens.Close();
sl@0
   214
	}
sl@0
   215
sl@0
   216
EXPORT_C TUid CPostProcessorInfo::Uid() const
sl@0
   217
	{
sl@0
   218
	return iUid;
sl@0
   219
	}
sl@0
   220
sl@0
   221
EXPORT_C const TDesC& CPostProcessorInfo::Manufacturer() const
sl@0
   222
	{
sl@0
   223
	return *iManufacturer;
sl@0
   224
	}
sl@0
   225
sl@0
   226
EXPORT_C const TDesC& CPostProcessorInfo::Identifier() const
sl@0
   227
	{
sl@0
   228
	return *iIdentifier;
sl@0
   229
	}
sl@0
   230
sl@0
   231
EXPORT_C TVersion CPostProcessorInfo::Version() const
sl@0
   232
	{
sl@0
   233
	return iVersion;
sl@0
   234
	}
sl@0
   235
sl@0
   236
EXPORT_C TBool CPostProcessorInfo::SupportsFormat(const TUncompressedVideoFormat& aFormat) const
sl@0
   237
	{
sl@0
   238
	TBool found = EFalse;
sl@0
   239
	TInt count = iSupportedFormats.Count();
sl@0
   240
	for (TInt i=0; i<count; i++)
sl@0
   241
		{
sl@0
   242
		if (iSupportedFormats[i] == aFormat)
sl@0
   243
			{
sl@0
   244
			found = ETrue;
sl@0
   245
			break;
sl@0
   246
			}
sl@0
   247
		}
sl@0
   248
	return found;
sl@0
   249
	}
sl@0
   250
sl@0
   251
EXPORT_C const RArray<TUncompressedVideoFormat>& CPostProcessorInfo::SupportedFormats() const
sl@0
   252
	{
sl@0
   253
	return iSupportedFormats;
sl@0
   254
	}
sl@0
   255
sl@0
   256
EXPORT_C TBool CPostProcessorInfo::SupportsCombination(TUint32 aCombination) const
sl@0
   257
	{
sl@0
   258
	TBool found = EFalse;
sl@0
   259
	TInt count = iSupportedCombinations.Count();
sl@0
   260
	for (TInt i=0; i<count; i++)
sl@0
   261
		{
sl@0
   262
		if (iSupportedCombinations[i] == aCombination)
sl@0
   263
			{
sl@0
   264
			found = ETrue;
sl@0
   265
			break;
sl@0
   266
			}
sl@0
   267
		}
sl@0
   268
	return found;
sl@0
   269
	}
sl@0
   270
sl@0
   271
EXPORT_C const RArray<TUint32>& CPostProcessorInfo::SupportedCombinations() const
sl@0
   272
	{
sl@0
   273
	return iSupportedCombinations;
sl@0
   274
	}
sl@0
   275
sl@0
   276
EXPORT_C TBool CPostProcessorInfo::Accelerated() const
sl@0
   277
	{
sl@0
   278
	return iAccelerated;
sl@0
   279
	}
sl@0
   280
sl@0
   281
EXPORT_C TBool CPostProcessorInfo::SupportsDirectDisplay() const
sl@0
   282
	{
sl@0
   283
	return iSupportDirectDisplay;
sl@0
   284
	}
sl@0
   285
sl@0
   286
EXPORT_C const TYuvToRgbCapabilities& CPostProcessorInfo::YuvToRgbCapabilities() const
sl@0
   287
	{
sl@0
   288
	return iYuvToRgbCapabilities;
sl@0
   289
	}
sl@0
   290
sl@0
   291
EXPORT_C TUint32 CPostProcessorInfo::SupportedRotations() const
sl@0
   292
	{
sl@0
   293
	return iSupportedRotations;
sl@0
   294
	}
sl@0
   295
sl@0
   296
EXPORT_C TBool CPostProcessorInfo::SupportsArbitraryScaling() const
sl@0
   297
	{
sl@0
   298
	return iSupportArbitraryScaling;
sl@0
   299
	}
sl@0
   300
sl@0
   301
EXPORT_C const RArray<TScaleFactor>& CPostProcessorInfo::SupportedScaleFactors() const
sl@0
   302
	{
sl@0
   303
	return iSupportedScaleFactors;
sl@0
   304
	}
sl@0
   305
sl@0
   306
EXPORT_C TBool CPostProcessorInfo::AntiAliasedScaling() const
sl@0
   307
	{
sl@0
   308
	return iAntiAliasedScaling;
sl@0
   309
	}
sl@0
   310
sl@0
   311
EXPORT_C const TDesC8& CPostProcessorInfo::ImplementationSpecificInfo() const
sl@0
   312
	{
sl@0
   313
	return *iImplementationSpecificInfo;
sl@0
   314
	}
sl@0
   315
sl@0
   316
EXPORT_C void CPostProcessorInfo::AddSupportedScreenL(TInt aScreenNo)
sl@0
   317
	{
sl@0
   318
#ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
sl@0
   319
	iSupportedScreens.AppendL(aScreenNo);
sl@0
   320
#else
sl@0
   321
	aScreenNo = aScreenNo; //Added to remove the warning
sl@0
   322
	User::Leave(KErrNotSupported);
sl@0
   323
#endif
sl@0
   324
	}
sl@0
   325
	
sl@0
   326
EXPORT_C void CPostProcessorInfo::GetSupportedScreensL(RArray<TInt>& aSupportedScreens) const
sl@0
   327
	{
sl@0
   328
#ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
sl@0
   329
	aSupportedScreens.Reset();
sl@0
   330
	TInt screensCount = iSupportedScreens.Count();
sl@0
   331
	for (TInt i = 0; i < screensCount;i++)
sl@0
   332
		{
sl@0
   333
		aSupportedScreens.AppendL(iSupportedScreens[i]);
sl@0
   334
		}
sl@0
   335
#else
sl@0
   336
	aSupportedScreens = aSupportedScreens;//Added to remove the warning
sl@0
   337
	User::Leave(KErrNotSupported);
sl@0
   338
#endif
sl@0
   339
	}
sl@0
   340
sl@0
   341
EXPORT_C void CPostProcessorInfo::SetSupportsContentProtected(const TBool aSetting)
sl@0
   342
	{
sl@0
   343
	iSupportsContentProtected = aSetting;
sl@0
   344
	}
sl@0
   345
sl@0
   346
EXPORT_C TBool CPostProcessorInfo::SupportsContentProtected() const
sl@0
   347
	{
sl@0
   348
	return iSupportsContentProtected;
sl@0
   349
	}
sl@0
   350
sl@0
   351
//
sl@0
   352
// CVideoDecoderInfo
sl@0
   353
//
sl@0
   354
EXPORT_C CVideoDecoderInfo* CVideoDecoderInfo::NewL(TUid aUid,
sl@0
   355
													const TDesC& aManufacturer,
sl@0
   356
													const TDesC& aIdentifier,
sl@0
   357
													TVersion aVersion,
sl@0
   358
													const TArray<CCompressedVideoFormat*>& aSupportedFormats,
sl@0
   359
													TBool aAccelerated,
sl@0
   360
													TBool aSupportsDirectDisplay,
sl@0
   361
													const TSize& aMaxPictureSize,
sl@0
   362
													TUint aMaxBitrate,
sl@0
   363
													const TArray<TPictureRateAndSize>& aMaxPictureRates,
sl@0
   364
													TBool aSupportsPictureLoss,
sl@0
   365
													TBool aSupportsSliceLoss,
sl@0
   366
													const TDesC8& aCodingStandardSpecificInfo,
sl@0
   367
													const TDesC8& aImplementationSpecificInfo)
sl@0
   368
	{
sl@0
   369
	CVideoDecoderInfo* s = new(ELeave) CVideoDecoderInfo(aUid,
sl@0
   370
														 aVersion,
sl@0
   371
														 aAccelerated,
sl@0
   372
														 aSupportsDirectDisplay,
sl@0
   373
														 aMaxPictureSize,
sl@0
   374
														 aMaxBitrate,
sl@0
   375
														 aSupportsPictureLoss,
sl@0
   376
														 aSupportsSliceLoss);
sl@0
   377
sl@0
   378
	CleanupStack::PushL(s);
sl@0
   379
	s->ConstructL(aManufacturer, aIdentifier, aSupportedFormats, aMaxPictureRates, aCodingStandardSpecificInfo, aImplementationSpecificInfo);
sl@0
   380
	CleanupStack::Pop(s);
sl@0
   381
	return s;
sl@0
   382
	}
sl@0
   383
sl@0
   384
CVideoDecoderInfo::CVideoDecoderInfo(TUid aUid,
sl@0
   385
									 TVersion aVersion,
sl@0
   386
									 TBool aAccelerated,
sl@0
   387
									 TBool aSupportsDirectDisplay,
sl@0
   388
									 const TSize& aMaxPictureSize,
sl@0
   389
								     TUint aMaxBitrate,
sl@0
   390
								     TBool aSupportsPictureLoss,
sl@0
   391
								     TBool aSupportsSliceLoss) :
sl@0
   392
	iUid(aUid),
sl@0
   393
	iVersion(aVersion),
sl@0
   394
	iAccelerated(aAccelerated),
sl@0
   395
	iSupportsDirectDisplay(aSupportsDirectDisplay),
sl@0
   396
	iMaxPictureSize(aMaxPictureSize),
sl@0
   397
	iMaxBitrate(aMaxBitrate),
sl@0
   398
	iSupportsPictureLoss(aSupportsPictureLoss),
sl@0
   399
	iSupportsSliceLoss(aSupportsSliceLoss),
sl@0
   400
	iSupportsContentProtected(EFalse)
sl@0
   401
	{
sl@0
   402
	iSupportedScreens.Reset();
sl@0
   403
	}
sl@0
   404
sl@0
   405
void CVideoDecoderInfo::ConstructL(const TDesC& aManufacturer,
sl@0
   406
								   const TDesC& aIdentifier,
sl@0
   407
								   const TArray<CCompressedVideoFormat*>& aSupportedFormats,
sl@0
   408
								   const TArray<TPictureRateAndSize>& aMaxPictureRates,
sl@0
   409
								   const TDesC8& aCodingStandardSpecificInfo,
sl@0
   410
								   const TDesC8& aImplementationSpecificInfo)
sl@0
   411
	{
sl@0
   412
	iManufacturer = aManufacturer.AllocL();
sl@0
   413
	iIdentifier = aIdentifier.AllocL();
sl@0
   414
	iCodingStandardSpecificInfo = aCodingStandardSpecificInfo.AllocL();
sl@0
   415
	iImplementationSpecificInfo = aImplementationSpecificInfo.AllocL();
sl@0
   416
sl@0
   417
	TInt i=0;
sl@0
   418
	TInt count = aSupportedFormats.Count();
sl@0
   419
	for (i=0; i<count; i++)
sl@0
   420
		{
sl@0
   421
		CCompressedVideoFormat* f = CCompressedVideoFormat::NewL(*(aSupportedFormats[i]));
sl@0
   422
		CleanupStack::PushL(f);
sl@0
   423
		User::LeaveIfError(iSupportedFormats.Append(f));
sl@0
   424
		CleanupStack::Pop(f);
sl@0
   425
		}
sl@0
   426
sl@0
   427
	count = aMaxPictureRates.Count();
sl@0
   428
	for (i=0; i<count; i++)
sl@0
   429
		{
sl@0
   430
		User::LeaveIfError(iMaxPictureRates.Append(aMaxPictureRates[i]));
sl@0
   431
		}
sl@0
   432
	}
sl@0
   433
sl@0
   434
EXPORT_C CVideoDecoderInfo::~CVideoDecoderInfo()
sl@0
   435
	{
sl@0
   436
	delete iManufacturer;
sl@0
   437
	delete iIdentifier;
sl@0
   438
	delete iCodingStandardSpecificInfo;
sl@0
   439
	delete iImplementationSpecificInfo;
sl@0
   440
	iSupportedFormats.ResetAndDestroy();
sl@0
   441
	iSupportedFormats.Close();
sl@0
   442
	iMaxPictureRates.Reset();
sl@0
   443
	iMaxPictureRates.Close();
sl@0
   444
	iSupportedScreens.Close();
sl@0
   445
	}
sl@0
   446
sl@0
   447
EXPORT_C TBool CVideoDecoderInfo::SupportsFormat(const CCompressedVideoFormat& aFormat) const
sl@0
   448
	{
sl@0
   449
	TBool result = EFalse;
sl@0
   450
	TInt count = iSupportedFormats.Count();
sl@0
   451
	for (TInt i=0; i<count; i++)
sl@0
   452
		{
sl@0
   453
		if (*(iSupportedFormats[i]) == aFormat)
sl@0
   454
			{
sl@0
   455
			result = ETrue;
sl@0
   456
			break;
sl@0
   457
			}
sl@0
   458
		}
sl@0
   459
	return result;
sl@0
   460
	}
sl@0
   461
sl@0
   462
EXPORT_C const RPointerArray<CCompressedVideoFormat>& CVideoDecoderInfo::SupportedFormats() const
sl@0
   463
	{
sl@0
   464
	return iSupportedFormats;
sl@0
   465
	}
sl@0
   466
sl@0
   467
EXPORT_C const TDesC& CVideoDecoderInfo::Manufacturer() const
sl@0
   468
	{
sl@0
   469
	return *iManufacturer;
sl@0
   470
	}
sl@0
   471
sl@0
   472
EXPORT_C const TDesC& CVideoDecoderInfo::Identifier() const
sl@0
   473
	{
sl@0
   474
	return *iIdentifier;
sl@0
   475
	}
sl@0
   476
sl@0
   477
EXPORT_C TVersion CVideoDecoderInfo::Version() const
sl@0
   478
	{
sl@0
   479
	return iVersion;
sl@0
   480
	}
sl@0
   481
sl@0
   482
EXPORT_C TUid CVideoDecoderInfo::Uid() const
sl@0
   483
	{
sl@0
   484
	return iUid;
sl@0
   485
	}
sl@0
   486
sl@0
   487
EXPORT_C TBool CVideoDecoderInfo::Accelerated() const
sl@0
   488
	{
sl@0
   489
	return iAccelerated;
sl@0
   490
	}
sl@0
   491
sl@0
   492
EXPORT_C TBool CVideoDecoderInfo::SupportsDirectDisplay() const
sl@0
   493
	{
sl@0
   494
	return iSupportsDirectDisplay;
sl@0
   495
	}
sl@0
   496
sl@0
   497
EXPORT_C const TSize& CVideoDecoderInfo::MaxPictureSize() const
sl@0
   498
	{
sl@0
   499
	return iMaxPictureSize;
sl@0
   500
	}
sl@0
   501
sl@0
   502
EXPORT_C TUint CVideoDecoderInfo::MaxBitrate() const
sl@0
   503
	{
sl@0
   504
	return iMaxBitrate;
sl@0
   505
	}
sl@0
   506
sl@0
   507
EXPORT_C const RArray<TPictureRateAndSize>& CVideoDecoderInfo::MaxPictureRates() const
sl@0
   508
	{
sl@0
   509
	return iMaxPictureRates;
sl@0
   510
	}
sl@0
   511
sl@0
   512
EXPORT_C TBool CVideoDecoderInfo::SupportsPictureLoss() const
sl@0
   513
	{
sl@0
   514
	return iSupportsPictureLoss;
sl@0
   515
	}
sl@0
   516
sl@0
   517
EXPORT_C TBool CVideoDecoderInfo::SupportsSliceLoss() const
sl@0
   518
	{
sl@0
   519
	return iSupportsSliceLoss;
sl@0
   520
	}
sl@0
   521
sl@0
   522
EXPORT_C const TDesC8& CVideoDecoderInfo::CodingStandardSpecificInfo() const
sl@0
   523
	{
sl@0
   524
	return *iCodingStandardSpecificInfo;
sl@0
   525
	}
sl@0
   526
sl@0
   527
EXPORT_C const TDesC8& CVideoDecoderInfo::ImplementationSpecificInfo() const
sl@0
   528
	{
sl@0
   529
	return *iImplementationSpecificInfo;
sl@0
   530
	}
sl@0
   531
sl@0
   532
EXPORT_C void CVideoDecoderInfo::AddSupportedScreenL(TInt aScreenNo)
sl@0
   533
	{
sl@0
   534
#ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
sl@0
   535
	iSupportedScreens.AppendL(aScreenNo);
sl@0
   536
#else
sl@0
   537
	aScreenNo = aScreenNo; //Added to remove the warning.
sl@0
   538
	User::Leave(KErrNotSupported);
sl@0
   539
#endif
sl@0
   540
	}
sl@0
   541
	
sl@0
   542
EXPORT_C void CVideoDecoderInfo::GetSupportedScreensL(RArray<TInt>& aSupportedScreens) const
sl@0
   543
	{
sl@0
   544
#ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
sl@0
   545
	aSupportedScreens.Reset();
sl@0
   546
	TInt screensCount = iSupportedScreens.Count();
sl@0
   547
	for (TInt i = 0; i < screensCount;i++)
sl@0
   548
		{
sl@0
   549
		aSupportedScreens.AppendL(iSupportedScreens[i]);
sl@0
   550
		}
sl@0
   551
#else
sl@0
   552
	aSupportedScreens = aSupportedScreens;//Added to remove the warning
sl@0
   553
	User::Leave(KErrNotSupported);
sl@0
   554
#endif
sl@0
   555
	}
sl@0
   556
sl@0
   557
EXPORT_C void CVideoDecoderInfo::SetSupportsContentProtected(const TBool aSetting)
sl@0
   558
	{
sl@0
   559
	iSupportsContentProtected = aSetting;
sl@0
   560
	}
sl@0
   561
sl@0
   562
EXPORT_C TBool CVideoDecoderInfo::SupportsContentProtected() const
sl@0
   563
	{
sl@0
   564
	return iSupportsContentProtected;
sl@0
   565
	}
sl@0
   566
sl@0
   567
//
sl@0
   568
// CMMFDevVideoPlay
sl@0
   569
//
sl@0
   570
EXPORT_C CMMFDevVideoPlay* CMMFDevVideoPlay::NewL(MMMFDevVideoPlayObserver& aObserver)
sl@0
   571
	{
sl@0
   572
	return new(ELeave) CMMFDevVideoPlay(aObserver);
sl@0
   573
	}
sl@0
   574
sl@0
   575
CMMFDevVideoPlay::CMMFDevVideoPlay(MMMFDevVideoPlayObserver& aObserver) :
sl@0
   576
	iObserver(aObserver),
sl@0
   577
	iInitializationState(ENotInitialized),
sl@0
   578
	iVideoPictureQue(_FOFF(TVideoPicture,iLink)),
sl@0
   579
	iVideoPictureQueIter(iVideoPictureQue)
sl@0
   580
	{
sl@0
   581
	}
sl@0
   582
sl@0
   583
EXPORT_C CMMFDevVideoPlay::~CMMFDevVideoPlay()
sl@0
   584
	{
sl@0
   585
	delete iVideoDecodeHwDevice;
sl@0
   586
	delete iVideoPostProcHwDevice;
sl@0
   587
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
   588
	iPuImplementations.ResetAndDestroy();
sl@0
   589
#endif
sl@0
   590
	}
sl@0
   591
sl@0
   592
EXPORT_C TBool CMMFDevVideoPlay::FindCommonFormat(const TArray<TUncompressedVideoFormat>& aFormats1, const TArray<TUncompressedVideoFormat>& aFormats2, TUncompressedVideoFormat& aCommonFormat)
sl@0
   593
	{
sl@0
   594
	// Find the least expensive format common to both arrays.
sl@0
   595
	// Expense is proportional to array position, so do search twice, using each array as a base
sl@0
   596
sl@0
   597
	TInt formats1Position;
sl@0
   598
	TInt formats2Position;
sl@0
   599
sl@0
   600
	const TUncompressedVideoFormat* firstTry = NULL;
sl@0
   601
	TInt firstTryCumulativePosition = -1;
sl@0
   602
	const TUncompressedVideoFormat* secondTry = NULL;
sl@0
   603
	TInt secondTryCumulativePosition = -1;
sl@0
   604
sl@0
   605
	TInt formats1Count = aFormats1.Count();
sl@0
   606
	TInt formats2Count = aFormats2.Count();
sl@0
   607
sl@0
   608
	for (formats1Position=0; formats1Position < formats1Count; formats1Position++)
sl@0
   609
		{
sl@0
   610
		const TUncompressedVideoFormat& format1 = aFormats1[formats1Position];
sl@0
   611
sl@0
   612
		for (formats2Position=0; formats2Position < formats2Count; formats2Position++)
sl@0
   613
			{
sl@0
   614
			const TUncompressedVideoFormat& format2 = aFormats2[formats2Position];
sl@0
   615
			if (format1 == format2)
sl@0
   616
				{
sl@0
   617
				firstTry = &format1;
sl@0
   618
				firstTryCumulativePosition = formats1Position+formats2Position;
sl@0
   619
				break;
sl@0
   620
				}
sl@0
   621
			}
sl@0
   622
sl@0
   623
		if (firstTry != NULL)
sl@0
   624
			break;
sl@0
   625
		}
sl@0
   626
sl@0
   627
	for (formats2Position=0; formats2Position < formats2Count; formats2Position++)
sl@0
   628
		{
sl@0
   629
		const TUncompressedVideoFormat& format2 = aFormats2[formats2Position];
sl@0
   630
sl@0
   631
		for (formats1Position=0; formats1Position < formats1Count; formats1Position++)
sl@0
   632
			{
sl@0
   633
			const TUncompressedVideoFormat& format1 = aFormats1[formats1Position];
sl@0
   634
			if (format1 == format2)
sl@0
   635
				{
sl@0
   636
				secondTry = &format1;
sl@0
   637
				secondTryCumulativePosition = formats1Position+formats2Position;
sl@0
   638
				break;
sl@0
   639
				}
sl@0
   640
			}
sl@0
   641
sl@0
   642
		if (secondTry != NULL)
sl@0
   643
			break;
sl@0
   644
		}
sl@0
   645
sl@0
   646
	TBool found = EFalse;
sl@0
   647
sl@0
   648
	if (firstTry!=NULL)
sl@0
   649
		{
sl@0
   650
		ASSERT(secondTry!=NULL);
sl@0
   651
		found = ETrue;
sl@0
   652
		// Work out which is cheaper
sl@0
   653
		if (firstTryCumulativePosition <= secondTryCumulativePosition)
sl@0
   654
			{
sl@0
   655
			aCommonFormat = *firstTry;
sl@0
   656
			}
sl@0
   657
		else
sl@0
   658
			{
sl@0
   659
			aCommonFormat = *secondTry;
sl@0
   660
			}
sl@0
   661
		}
sl@0
   662
sl@0
   663
	return found;
sl@0
   664
	}
sl@0
   665
sl@0
   666
EXPORT_C void CMMFDevVideoPlay::FindDecodersL(const TDesC8& aMimeType, TUint32 aPostProcType, RArray<TUid>& aDecoders, TBool aExactMatch)
sl@0
   667
	{
sl@0
   668
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
   669
	// find PU based plugins
sl@0
   670
	RImplInfoPtrArray codecPlugins;
sl@0
   671
	CleanupResetAndDestroyPushL(codecPlugins);
sl@0
   672
	DevVideoUtilities::FindVideoDecoderPluginsL(aMimeType, codecPlugins);	
sl@0
   673
sl@0
   674
	aDecoders.Reset();
sl@0
   675
	for (TInt i = 0; i < codecPlugins.Count();i++)
sl@0
   676
		{
sl@0
   677
		aDecoders.AppendL(codecPlugins[i]->ImplementationUid());
sl@0
   678
		}
sl@0
   679
		
sl@0
   680
	CleanupStack::PopAndDestroy(&codecPlugins);
sl@0
   681
#endif // SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
   682
	RImplInfoPtrArray plugins;
sl@0
   683
	CleanupResetAndDestroyPushL(plugins);
sl@0
   684
sl@0
   685
	MmPluginUtils::FindImplementationsL(KUidDevVideoDecoderHwDevice, plugins);
sl@0
   686
sl@0
   687
	DevVideoUtilities::SelectPluginBasedOnMatchType(aMimeType, plugins);
sl@0
   688
		
sl@0
   689
	DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(plugins, aPostProcType, aDecoders);
sl@0
   690
sl@0
   691
	// Perform the extra processing required if an exact match was requested
sl@0
   692
	if (aExactMatch)
sl@0
   693
		{
sl@0
   694
		// We now need to go through each of the plugins returned (which may have been matched using
sl@0
   695
		// a wildcard), instantiate each one, and perform an exact mime-type match.
sl@0
   696
		// Any plugins that don't support the desired mime type exactly will be removed from aDecoders.
sl@0
   697
		CCompressedVideoFormat* format = CCompressedVideoFormat::NewL(aMimeType);
sl@0
   698
		CleanupStack::PushL(format);
sl@0
   699
sl@0
   700
		for (TInt i=aDecoders.Count()-1; i>=0; i--)
sl@0
   701
			{
sl@0
   702
			TUid pluginUid = aDecoders[i];
sl@0
   703
			CVideoDecoderInfo* info = NULL;
sl@0
   704
			TRAPD(err, info = VideoDecoderInfoLC(pluginUid); CleanupStack::Pop(info););
sl@0
   705
			if (err == KErrNone)
sl@0
   706
				{
sl@0
   707
				if (!info->SupportsFormat(*format))
sl@0
   708
					{
sl@0
   709
					// The decoder doesn't support the format, so remove it from the list
sl@0
   710
					aDecoders.Remove(i);
sl@0
   711
					}
sl@0
   712
				delete info;
sl@0
   713
				}
sl@0
   714
			else if (err==KErrNotFound)
sl@0
   715
				{
sl@0
   716
				// we have a bogus UID so remove it from the list
sl@0
   717
				aDecoders.Remove(i);
sl@0
   718
				}
sl@0
   719
			else
sl@0
   720
				{
sl@0
   721
				User::Leave(err);
sl@0
   722
				}
sl@0
   723
			}
sl@0
   724
sl@0
   725
		CleanupStack::PopAndDestroy(format);
sl@0
   726
		}
sl@0
   727
sl@0
   728
	// Leave if we didn't find anything.
sl@0
   729
	if (aDecoders.Count() == 0)
sl@0
   730
		{
sl@0
   731
		User::Leave(KErrNotFound);
sl@0
   732
		}
sl@0
   733
sl@0
   734
	CleanupStack::PopAndDestroy(&plugins);
sl@0
   735
	}
sl@0
   736
sl@0
   737
EXPORT_C void CMMFDevVideoPlay::FindPostProcessorsL(TUint32 aPostProcType, RArray<TUid>& aPostProcessors)
sl@0
   738
	{
sl@0
   739
	RImplInfoPtrArray plugins;
sl@0
   740
	CleanupResetAndDestroyPushL(plugins);
sl@0
   741
sl@0
   742
	MmPluginUtils::FindImplementationsL(KUidDevVideoPostProcessorHwDevice, plugins);
sl@0
   743
sl@0
   744
	DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(plugins, aPostProcType, aPostProcessors);
sl@0
   745
sl@0
   746
	// Leave if we didn't find anything.
sl@0
   747
	if (aPostProcessors.Count() == 0)
sl@0
   748
		{
sl@0
   749
		User::Leave(KErrNotFound);
sl@0
   750
		}
sl@0
   751
sl@0
   752
	CleanupStack::PopAndDestroy(&plugins);
sl@0
   753
	}
sl@0
   754
sl@0
   755
EXPORT_C void CMMFDevVideoPlay::GetDecoderListL(RArray<TUid>& aDecoders)
sl@0
   756
	{
sl@0
   757
	RImplInfoPtrArray plugins;
sl@0
   758
	CleanupResetAndDestroyPushL(plugins);
sl@0
   759
sl@0
   760
	MmPluginUtils::FindImplementationsL(KUidDevVideoDecoderHwDevice, plugins);
sl@0
   761
sl@0
   762
	aDecoders.Reset();
sl@0
   763
sl@0
   764
	TInt count = plugins.Count();
sl@0
   765
	for (TInt i=0; i<count; i++)
sl@0
   766
		{
sl@0
   767
		User::LeaveIfError(aDecoders.Append(plugins[i]->ImplementationUid()));
sl@0
   768
		}
sl@0
   769
sl@0
   770
	CleanupStack::PopAndDestroy(&plugins);
sl@0
   771
	}
sl@0
   772
sl@0
   773
EXPORT_C void CMMFDevVideoPlay::GetPostProcessorListL(RArray<TUid>& aPostProcessors)
sl@0
   774
	{
sl@0
   775
	RImplInfoPtrArray plugins;
sl@0
   776
	CleanupResetAndDestroyPushL(plugins);
sl@0
   777
sl@0
   778
	MmPluginUtils::FindImplementationsL(KUidDevVideoPostProcessorHwDevice, plugins);
sl@0
   779
sl@0
   780
	aPostProcessors.Reset();
sl@0
   781
sl@0
   782
	TInt count = plugins.Count();
sl@0
   783
	for (TInt i=0; i<count; i++)
sl@0
   784
		{
sl@0
   785
		User::LeaveIfError(aPostProcessors.Append(plugins[i]->ImplementationUid()));
sl@0
   786
		}
sl@0
   787
sl@0
   788
	CleanupStack::PopAndDestroy(&plugins);
sl@0
   789
	}
sl@0
   790
sl@0
   791
EXPORT_C CVideoDecoderInfo* CMMFDevVideoPlay::VideoDecoderInfoLC(TUid aVideoDecoder)
sl@0
   792
	{
sl@0
   793
	CMMFVideoDecodeHwDevice* dev = CreateDecoderL(aVideoDecoder);
sl@0
   794
	CleanupStack::PushL(dev);
sl@0
   795
	CVideoDecoderInfo* info = dev->VideoDecoderInfoLC();
sl@0
   796
	CleanupStack::Pop(info);
sl@0
   797
	CleanupStack::PopAndDestroy(dev);
sl@0
   798
	CleanupStack::PushL(info);
sl@0
   799
	return info;
sl@0
   800
	}
sl@0
   801
sl@0
   802
EXPORT_C CPostProcessorInfo* CMMFDevVideoPlay::PostProcessorInfoLC(TUid aPostProcessor)
sl@0
   803
	{
sl@0
   804
	CMMFVideoPlayHwDevice* device = NULL;
sl@0
   805
sl@0
   806
	// Determine whether the aPostProcessor uid is for a decoder or a postprocessor hw device
sl@0
   807
	RArray<TUid> array;
sl@0
   808
	CleanupClosePushL(array);
sl@0
   809
	
sl@0
   810
	GetDecoderListL(array);
sl@0
   811
	TInt position = array.Find(aPostProcessor);
sl@0
   812
	if (position == KErrNotFound)
sl@0
   813
		{
sl@0
   814
		array.Reset();
sl@0
   815
		GetPostProcessorListL(array);
sl@0
   816
		position = array.Find(aPostProcessor);
sl@0
   817
		if (position != KErrNotFound)
sl@0
   818
			{
sl@0
   819
			// uid is a post processor
sl@0
   820
			device = static_cast<CMMFVideoPlayHwDevice*>(CMMFVideoPostProcHwDevice::NewL(aPostProcessor, *this));
sl@0
   821
			}
sl@0
   822
		}
sl@0
   823
	else
sl@0
   824
		{
sl@0
   825
		// uid is a decoder
sl@0
   826
		device = static_cast<CMMFVideoPlayHwDevice*>(CMMFVideoDecodeHwDevice::NewL(aPostProcessor, *this));
sl@0
   827
		}
sl@0
   828
	CleanupStack::PopAndDestroy(&array);
sl@0
   829
sl@0
   830
	CPostProcessorInfo* info = NULL;
sl@0
   831
	if (device)
sl@0
   832
		{
sl@0
   833
		CleanupStack::PushL(device);
sl@0
   834
		info = device->PostProcessorInfoLC();		
sl@0
   835
		CleanupStack::Pop(info);
sl@0
   836
		CleanupStack::PopAndDestroy(device);
sl@0
   837
		CleanupStack::PushL(info);
sl@0
   838
		}
sl@0
   839
	return info;
sl@0
   840
	}
sl@0
   841
sl@0
   842
EXPORT_C THwDeviceId CMMFDevVideoPlay::SelectDecoderL(TUid aDecoder)
sl@0
   843
	{
sl@0
   844
	// This method can only be called before InitializeL() has been called.
sl@0
   845
	CheckInitializationState(ENotInitialized);
sl@0
   846
sl@0
   847
	delete iVideoDecodeHwDevice;
sl@0
   848
	iVideoDecodeHwDevice = NULL;
sl@0
   849
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
   850
	iVideoDecodeHwDevice = CreateDecoderL(aDecoder);
sl@0
   851
#else
sl@0
   852
	iVideoDecodeHwDevice = CMMFVideoDecodeHwDevice::NewL(aDecoder, *this);
sl@0
   853
#endif // SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
   854
	return KHwDeviceIdVideoDecoder;
sl@0
   855
	}
sl@0
   856
sl@0
   857
EXPORT_C THwDeviceId CMMFDevVideoPlay::SelectPostProcessorL(TUid aPostProcessor)
sl@0
   858
	{
sl@0
   859
	// This method can only be called before InitializeL() has been called.
sl@0
   860
	CheckInitializationState(ENotInitialized);
sl@0
   861
sl@0
   862
	delete iVideoPostProcHwDevice;
sl@0
   863
	iVideoPostProcHwDevice = NULL;
sl@0
   864
	iVideoPostProcHwDevice = CMMFVideoPostProcHwDevice::NewL(aPostProcessor, *this);
sl@0
   865
sl@0
   866
	return KHwDeviceIdVideoPostProcessor;
sl@0
   867
	}
sl@0
   868
sl@0
   869
EXPORT_C TVideoPictureHeader* CMMFDevVideoPlay::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation, TVideoInputBuffer* aDataUnit)
sl@0
   870
	{
sl@0
   871
	return VideoDecodeHwDevice().GetHeaderInformationL(aDataUnitType, aDataUnitEncapsulation, aDataUnit);
sl@0
   872
	}
sl@0
   873
sl@0
   874
/**
sl@0
   875
Configures the Decoder using header information known by the client.
sl@0
   876
@param	"aVideoPictureHeader"	"Header information to configure the decoder with"
sl@0
   877
@leave	"The method will leave if an error occurs. Running out of data is not considered an error, 
sl@0
   878
		as described above.
sl@0
   879
@pre	"This method can only be called before the API has been initialized with Initialize()."
sl@0
   880
*/
sl@0
   881
EXPORT_C void CMMFDevVideoPlay::ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader)
sl@0
   882
	{
sl@0
   883
	CheckInitializationState(ENotInitialized);
sl@0
   884
sl@0
   885
	VideoDecodeHwDevice().ConfigureDecoderL(aVideoPictureHeader);
sl@0
   886
	}
sl@0
   887
sl@0
   888
sl@0
   889
sl@0
   890
EXPORT_C void CMMFDevVideoPlay::ReturnHeader(TVideoPictureHeader* aHeader)
sl@0
   891
	{
sl@0
   892
	// This method can only be called before InitializeL()
sl@0
   893
	CheckInitializationState(ENotInitialized);
sl@0
   894
sl@0
   895
	VideoDecodeHwDevice().ReturnHeader(aHeader);
sl@0
   896
	}
sl@0
   897
sl@0
   898
EXPORT_C void CMMFDevVideoPlay::SetInputFormatL(THwDeviceId aHwDevice, const TUncompressedVideoFormat& aFormat)
sl@0
   899
	{
sl@0
   900
	CheckInitializationState(ENotInitialized);
sl@0
   901
sl@0
   902
	VideoPostProcHwDevice(aHwDevice).SetInputFormatL(aFormat);
sl@0
   903
	}
sl@0
   904
sl@0
   905
EXPORT_C void CMMFDevVideoPlay::SetInputFormatL(THwDeviceId aHwDevice, const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder)
sl@0
   906
	{
sl@0
   907
	CheckInitializationState(ENotInitialized);
sl@0
   908
sl@0
   909
	VideoDecodeHwDevice(aHwDevice).SetInputFormatL(aFormat, aDataUnitType, aEncapsulation, aDataInOrder);
sl@0
   910
	}
sl@0
   911
sl@0
   912
EXPORT_C void CMMFDevVideoPlay::GetOutputFormatListL(THwDeviceId aHwDevice, RArray<TUncompressedVideoFormat>& aFormats)
sl@0
   913
	{
sl@0
   914
	CheckInitializationState(ENotInitialized);
sl@0
   915
sl@0
   916
	VideoPlayHwDevice(aHwDevice).GetOutputFormatListL(aFormats);
sl@0
   917
	}
sl@0
   918
sl@0
   919
EXPORT_C void CMMFDevVideoPlay::SetOutputFormatL(THwDeviceId aHwDevice, const TUncompressedVideoFormat &aFormat)
sl@0
   920
	{
sl@0
   921
	CheckInitializationState(ENotInitialized);
sl@0
   922
sl@0
   923
	VideoPlayHwDevice(aHwDevice).SetOutputFormatL(aFormat);
sl@0
   924
	}
sl@0
   925
sl@0
   926
EXPORT_C void CMMFDevVideoPlay::SetClockSource(MMMFClockSource* aClock)
sl@0
   927
	{
sl@0
   928
	CheckInitializationState(ENotInitialized);
sl@0
   929
sl@0
   930
	ASSERT(aClock);
sl@0
   931
sl@0
   932
	// Make sure we have at least one of the hwdevices set up
sl@0
   933
	__ASSERT_ALWAYS((iVideoDecodeHwDevice||iVideoPostProcHwDevice), DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
   934
sl@0
   935
	// Set the clock source on both hw devices.
sl@0
   936
	if (iVideoDecodeHwDevice)
sl@0
   937
		iVideoDecodeHwDevice->SetClockSource(aClock);
sl@0
   938
	if (iVideoPostProcHwDevice)
sl@0
   939
		iVideoPostProcHwDevice->SetClockSource(aClock);
sl@0
   940
	}
sl@0
   941
sl@0
   942
EXPORT_C void CMMFDevVideoPlay::SetVideoDestScreenL(TBool aScreen)
sl@0
   943
	{
sl@0
   944
	CheckInitializationState(ENotInitialized);
sl@0
   945
sl@0
   946
	// Pass on to the rendering hw device
sl@0
   947
	RenderingHwDevice().SetVideoDestScreenL(aScreen);
sl@0
   948
	}
sl@0
   949
sl@0
   950
EXPORT_C void CMMFDevVideoPlay::SynchronizeDecoding(TBool aSynchronize)
sl@0
   951
	{
sl@0
   952
	CheckInitializationState(ENotInitialized);
sl@0
   953
sl@0
   954
	VideoDecodeHwDevice().SynchronizeDecoding(aSynchronize);
sl@0
   955
	}
sl@0
   956
sl@0
   957
EXPORT_C void CMMFDevVideoPlay::SetBufferOptionsL(const TBufferOptions& aOptions)
sl@0
   958
	{
sl@0
   959
	CheckInitializationState(ENotInitialized);
sl@0
   960
sl@0
   961
	VideoDecodeHwDevice().SetBufferOptionsL(aOptions);
sl@0
   962
	}
sl@0
   963
sl@0
   964
EXPORT_C void CMMFDevVideoPlay::GetBufferOptions(TBufferOptions& aOptions)
sl@0
   965
	{
sl@0
   966
	CheckInitializationState(ENotInitialized);
sl@0
   967
sl@0
   968
	VideoDecodeHwDevice().GetBufferOptions(aOptions);
sl@0
   969
	}
sl@0
   970
sl@0
   971
EXPORT_C void CMMFDevVideoPlay::SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams)
sl@0
   972
	{
sl@0
   973
	CheckInitializationState(ENotInitialized);
sl@0
   974
sl@0
   975
	VideoDecodeHwDevice().SetHrdVbvSpec(aHrdVbvSpec, aHrdVbvParams);
sl@0
   976
	}
sl@0
   977
sl@0
   978
EXPORT_C void CMMFDevVideoPlay::SetPostProcessTypesL(THwDeviceId aHwDevice, TUint32 aPostProcCombination)
sl@0
   979
	{
sl@0
   980
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
   981
	
sl@0
   982
	VideoPlayHwDevice(aHwDevice).SetPostProcessTypesL(aPostProcCombination);
sl@0
   983
	}
sl@0
   984
sl@0
   985
EXPORT_C void CMMFDevVideoPlay::SetInputCropOptionsL(THwDeviceId aHwDevice, const TRect& aRect)
sl@0
   986
	{
sl@0
   987
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
   988
sl@0
   989
	VideoPlayHwDevice(aHwDevice).SetInputCropOptionsL(aRect);	
sl@0
   990
	}
sl@0
   991
sl@0
   992
EXPORT_C void CMMFDevVideoPlay::SetYuvToRgbOptionsL(THwDeviceId aHwDevice, const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
sl@0
   993
	{
sl@0
   994
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
   995
sl@0
   996
	VideoPlayHwDevice(aHwDevice).SetYuvToRgbOptionsL(aOptions, aYuvFormat, aRgbFormat);
sl@0
   997
	}
sl@0
   998
sl@0
   999
EXPORT_C void CMMFDevVideoPlay::SetYuvToRgbOptionsL(THwDeviceId aHwDevice, const TYuvToRgbOptions& aOptions)
sl@0
  1000
	{
sl@0
  1001
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
  1002
sl@0
  1003
	VideoPlayHwDevice(aHwDevice).SetYuvToRgbOptionsL(aOptions);
sl@0
  1004
	}
sl@0
  1005
sl@0
  1006
EXPORT_C void CMMFDevVideoPlay::SetRotateOptionsL(THwDeviceId aHwDevice, TRotationType aRotationType)
sl@0
  1007
	{
sl@0
  1008
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
  1009
sl@0
  1010
	VideoPlayHwDevice(aHwDevice).SetRotateOptionsL(aRotationType);
sl@0
  1011
	}
sl@0
  1012
sl@0
  1013
EXPORT_C void CMMFDevVideoPlay::SetScaleOptionsL(THwDeviceId aHwDevice, const TSize& aTargetSize, TBool aAntiAliasFiltering)
sl@0
  1014
	{
sl@0
  1015
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
  1016
sl@0
  1017
	VideoPlayHwDevice(aHwDevice).SetScaleOptionsL(aTargetSize, aAntiAliasFiltering);
sl@0
  1018
	}
sl@0
  1019
sl@0
  1020
EXPORT_C void CMMFDevVideoPlay::SetOutputCropOptionsL(THwDeviceId aHwDevice, const TRect& aRect)
sl@0
  1021
	{
sl@0
  1022
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
  1023
sl@0
  1024
	VideoPlayHwDevice(aHwDevice).SetOutputCropOptionsL(aRect);
sl@0
  1025
	}
sl@0
  1026
sl@0
  1027
EXPORT_C void CMMFDevVideoPlay::SetPostProcSpecificOptionsL(THwDeviceId aHwDevice, const TDesC8& aOptions)
sl@0
  1028
	{
sl@0
  1029
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
  1030
sl@0
  1031
	VideoPlayHwDevice(aHwDevice).SetPostProcSpecificOptionsL(aOptions);
sl@0
  1032
	}
sl@0
  1033
sl@0
  1034
EXPORT_C void CMMFDevVideoPlay::Initialize()
sl@0
  1035
	{
sl@0
  1036
	CheckInitializationState(ENotInitialized);
sl@0
  1037
sl@0
  1038
	// First introduce the two plugins to each other
sl@0
  1039
	ConnectPlugins();
sl@0
  1040
sl@0
  1041
	// Next initialize the first hwdevice in the chain
sl@0
  1042
	if (iVideoDecodeHwDevice)
sl@0
  1043
		{
sl@0
  1044
		iInitializationState = EInitializing;
sl@0
  1045
		iVideoDecodeHwDevice->Initialize();
sl@0
  1046
		}
sl@0
  1047
	else if (iVideoPostProcHwDevice)
sl@0
  1048
		{
sl@0
  1049
		iInitializationState = EInitializing;
sl@0
  1050
		iVideoPostProcHwDevice->Initialize();
sl@0
  1051
		}
sl@0
  1052
	else
sl@0
  1053
		{
sl@0
  1054
		// No hwdevice to initialize so panic
sl@0
  1055
		DevVideoPanic(EDevVideoPanicPreConditionViolation);
sl@0
  1056
		}
sl@0
  1057
	}
sl@0
  1058
sl@0
  1059
EXPORT_C void CMMFDevVideoPlay::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion)
sl@0
  1060
	{
sl@0
  1061
	CheckInitializationState(EInitialized);
sl@0
  1062
	RenderingHwDevice().StartDirectScreenAccessL(aVideoRect, aScreenDevice, aClipRegion);
sl@0
  1063
	}
sl@0
  1064
sl@0
  1065
EXPORT_C void CMMFDevVideoPlay::SetScreenClipRegion(const TRegion& aRegion)
sl@0
  1066
	{
sl@0
  1067
	CheckInitializationState(EInitialized);
sl@0
  1068
	RenderingHwDevice().SetScreenClipRegion(aRegion);
sl@0
  1069
	}
sl@0
  1070
sl@0
  1071
EXPORT_C void CMMFDevVideoPlay::SetPauseOnClipFail(TBool aPause)
sl@0
  1072
	{
sl@0
  1073
	CheckInitializationState(EInitialized);
sl@0
  1074
	RenderingHwDevice().SetPauseOnClipFail(aPause);
sl@0
  1075
	}
sl@0
  1076
sl@0
  1077
EXPORT_C void CMMFDevVideoPlay::AbortDirectScreenAccess()
sl@0
  1078
	{
sl@0
  1079
	CheckInitializationState(EInitialized);
sl@0
  1080
	RenderingHwDevice().AbortDirectScreenAccess();
sl@0
  1081
	}
sl@0
  1082
sl@0
  1083
EXPORT_C TBool CMMFDevVideoPlay::IsPlaying()
sl@0
  1084
	{
sl@0
  1085
	CheckInitializationState(EInitialized);
sl@0
  1086
	return RenderingHwDevice().IsPlaying();
sl@0
  1087
	}
sl@0
  1088
sl@0
  1089
EXPORT_C void CMMFDevVideoPlay::Redraw()
sl@0
  1090
	{
sl@0
  1091
	CheckInitializationState(EInitialized);
sl@0
  1092
	RenderingHwDevice().Redraw();
sl@0
  1093
	}
sl@0
  1094
sl@0
  1095
EXPORT_C void CMMFDevVideoPlay::Start()
sl@0
  1096
	{
sl@0
  1097
	CheckInitializationState(EInitialized);
sl@0
  1098
sl@0
  1099
	if (iVideoDecodeHwDevice)
sl@0
  1100
		iVideoDecodeHwDevice->Start();
sl@0
  1101
	if (iVideoPostProcHwDevice)
sl@0
  1102
		iVideoPostProcHwDevice->Start();
sl@0
  1103
	}
sl@0
  1104
sl@0
  1105
EXPORT_C void CMMFDevVideoPlay::Stop()
sl@0
  1106
	{
sl@0
  1107
	CheckInitializationState(EInitialized);
sl@0
  1108
sl@0
  1109
	if (iVideoDecodeHwDevice)
sl@0
  1110
		iVideoDecodeHwDevice->Stop();
sl@0
  1111
	if (iVideoPostProcHwDevice)
sl@0
  1112
		iVideoPostProcHwDevice->Stop();
sl@0
  1113
	}
sl@0
  1114
sl@0
  1115
EXPORT_C void CMMFDevVideoPlay::Pause()
sl@0
  1116
	{
sl@0
  1117
	CheckInitializationState(EInitialized);
sl@0
  1118
sl@0
  1119
	if (iVideoDecodeHwDevice)
sl@0
  1120
		iVideoDecodeHwDevice->Pause();
sl@0
  1121
	if (iVideoPostProcHwDevice)
sl@0
  1122
		iVideoPostProcHwDevice->Pause();
sl@0
  1123
	}
sl@0
  1124
sl@0
  1125
EXPORT_C void CMMFDevVideoPlay::Resume()
sl@0
  1126
	{
sl@0
  1127
	CheckInitializationState(EInitialized);
sl@0
  1128
sl@0
  1129
	if (iVideoDecodeHwDevice)
sl@0
  1130
		iVideoDecodeHwDevice->Resume();
sl@0
  1131
	if (iVideoPostProcHwDevice)
sl@0
  1132
		iVideoPostProcHwDevice->Resume();
sl@0
  1133
	}
sl@0
  1134
sl@0
  1135
EXPORT_C void CMMFDevVideoPlay::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
sl@0
  1136
	{
sl@0
  1137
	CheckInitializationState(EInitialized);
sl@0
  1138
sl@0
  1139
	if (iVideoDecodeHwDevice)
sl@0
  1140
		iVideoDecodeHwDevice->SetPosition(aPlaybackPosition);
sl@0
  1141
	if (iVideoPostProcHwDevice)
sl@0
  1142
		iVideoPostProcHwDevice->SetPosition(aPlaybackPosition);
sl@0
  1143
	}
sl@0
  1144
sl@0
  1145
EXPORT_C void CMMFDevVideoPlay::FreezePicture(const TTimeIntervalMicroSeconds& aPlaybackPosition)
sl@0
  1146
	{
sl@0
  1147
	CheckInitializationState(EInitialized);
sl@0
  1148
	RenderingHwDevice().FreezePicture(aPlaybackPosition);
sl@0
  1149
	}
sl@0
  1150
sl@0
  1151
EXPORT_C void CMMFDevVideoPlay::ReleaseFreeze(const TTimeIntervalMicroSeconds& aPlaybackPosition)
sl@0
  1152
	{
sl@0
  1153
	CheckInitializationState(EInitialized);
sl@0
  1154
	RenderingHwDevice().ReleaseFreeze(aPlaybackPosition);
sl@0
  1155
	}
sl@0
  1156
sl@0
  1157
EXPORT_C TTimeIntervalMicroSeconds CMMFDevVideoPlay::DecodingPosition()
sl@0
  1158
	{
sl@0
  1159
	CheckInitializationState(EInitialized);
sl@0
  1160
	return VideoDecodeHwDevice().DecodingPosition();
sl@0
  1161
	}
sl@0
  1162
sl@0
  1163
EXPORT_C TTimeIntervalMicroSeconds CMMFDevVideoPlay::PlaybackPosition()
sl@0
  1164
	{
sl@0
  1165
	CheckInitializationState(EInitialized);
sl@0
  1166
	return RenderingHwDevice().PlaybackPosition();
sl@0
  1167
	}
sl@0
  1168
sl@0
  1169
EXPORT_C TUint CMMFDevVideoPlay::PreDecoderBufferBytes()
sl@0
  1170
	{
sl@0
  1171
	CheckInitializationState(EInitialized);
sl@0
  1172
	return VideoDecodeHwDevice().PreDecoderBufferBytes();
sl@0
  1173
	}
sl@0
  1174
sl@0
  1175
EXPORT_C TUint CMMFDevVideoPlay::PictureBufferBytes()
sl@0
  1176
	{
sl@0
  1177
	CheckInitializationState(EInitialized);
sl@0
  1178
	return RenderingHwDevice().PictureBufferBytes();
sl@0
  1179
	}
sl@0
  1180
sl@0
  1181
EXPORT_C void CMMFDevVideoPlay::GetPictureCounters(TPictureCounters& aCounters)
sl@0
  1182
	{
sl@0
  1183
	CheckInitializationState(EInitialized);
sl@0
  1184
sl@0
  1185
	TPictureCounters decoderPictureCounters;
sl@0
  1186
	TPictureCounters postProcPictureCounters;
sl@0
  1187
sl@0
  1188
	if (iVideoDecodeHwDevice)
sl@0
  1189
		iVideoDecodeHwDevice->GetPictureCounters(decoderPictureCounters);
sl@0
  1190
sl@0
  1191
	if (iVideoPostProcHwDevice)
sl@0
  1192
		iVideoPostProcHwDevice->GetPictureCounters(postProcPictureCounters);
sl@0
  1193
sl@0
  1194
sl@0
  1195
	// Only the decoder (if any) knows the number of pictures decoded
sl@0
  1196
	aCounters.iPicturesDecoded = decoderPictureCounters.iPicturesDecoded;
sl@0
  1197
sl@0
  1198
	// Pictures skipped is sum of pictures skipped from decoder and postproc
sl@0
  1199
	aCounters.iPicturesSkipped = decoderPictureCounters.iPicturesSkipped
sl@0
  1200
									+ postProcPictureCounters.iPicturesSkipped;
sl@0
  1201
sl@0
  1202
	// Ask last plugin in chain for number of pictures displayed
sl@0
  1203
	if (iVideoPostProcHwDevice)
sl@0
  1204
		aCounters.iPicturesDisplayed = postProcPictureCounters.iPicturesDisplayed;
sl@0
  1205
	else
sl@0
  1206
		aCounters.iPicturesDisplayed = decoderPictureCounters.iPicturesDisplayed;
sl@0
  1207
sl@0
  1208
	// Ask first plugin in chain for number of input pictures
sl@0
  1209
	if (iVideoDecodeHwDevice)
sl@0
  1210
		aCounters.iTotalPictures = decoderPictureCounters.iTotalPictures;
sl@0
  1211
	else
sl@0
  1212
		aCounters.iTotalPictures = postProcPictureCounters.iTotalPictures;
sl@0
  1213
	}
sl@0
  1214
sl@0
  1215
EXPORT_C void CMMFDevVideoPlay::GetBitstreamCounters(TBitstreamCounters& aCounters)
sl@0
  1216
	{
sl@0
  1217
	CheckInitializationState(EInitialized);
sl@0
  1218
	VideoDecodeHwDevice().GetBitstreamCounters(aCounters);
sl@0
  1219
	}
sl@0
  1220
sl@0
  1221
EXPORT_C TUint CMMFDevVideoPlay::NumFreeBuffers()
sl@0
  1222
	{
sl@0
  1223
	CheckInitializationState(EInitialized);
sl@0
  1224
	return VideoDecodeHwDevice().NumFreeBuffers();
sl@0
  1225
	}
sl@0
  1226
sl@0
  1227
EXPORT_C void CMMFDevVideoPlay::SetComplexityLevel(THwDeviceId aHwDevice, TUint aLevel)
sl@0
  1228
	{
sl@0
  1229
	CheckInitializationState(EInitialized);
sl@0
  1230
	VideoPlayHwDevice(aHwDevice).SetComplexityLevel(aLevel);
sl@0
  1231
	}
sl@0
  1232
sl@0
  1233
EXPORT_C TUint CMMFDevVideoPlay::NumComplexityLevels(THwDeviceId aHwDevice)
sl@0
  1234
	{
sl@0
  1235
	CheckInitializationState(EInitialized);
sl@0
  1236
	return VideoPlayHwDevice(aHwDevice).NumComplexityLevels();
sl@0
  1237
	}
sl@0
  1238
sl@0
  1239
EXPORT_C void CMMFDevVideoPlay::GetComplexityLevelInfo(THwDeviceId aHwDevice, TUint aLevel, TComplexityLevelInfo& aInfo)
sl@0
  1240
	{
sl@0
  1241
	CheckInitializationState(EInitialized);
sl@0
  1242
	VideoPlayHwDevice(aHwDevice).GetComplexityLevelInfo(aLevel, aInfo);
sl@0
  1243
	}
sl@0
  1244
sl@0
  1245
EXPORT_C TVideoInputBuffer* CMMFDevVideoPlay::GetBufferL(TUint aBufferSize)
sl@0
  1246
	{
sl@0
  1247
	return VideoDecodeHwDevice().GetBufferL(aBufferSize);
sl@0
  1248
	}
sl@0
  1249
sl@0
  1250
EXPORT_C void CMMFDevVideoPlay::WriteCodedDataL(TVideoInputBuffer* aBuffer)
sl@0
  1251
	{
sl@0
  1252
	CheckInitializationState(EInitialized);
sl@0
  1253
	VideoDecodeHwDevice().WriteCodedDataL(aBuffer);
sl@0
  1254
	}
sl@0
  1255
sl@0
  1256
EXPORT_C void CMMFDevVideoPlay::WritePictureL(TVideoPicture* aPicture)
sl@0
  1257
	{
sl@0
  1258
	CheckInitializationState(EInitialized);
sl@0
  1259
	VideoPostProcHwDevice().WritePictureL(aPicture);
sl@0
  1260
	}
sl@0
  1261
sl@0
  1262
EXPORT_C void CMMFDevVideoPlay::InputEnd()
sl@0
  1263
	{
sl@0
  1264
	CheckInitializationState(EInitialized);
sl@0
  1265
	
sl@0
  1266
	//If decoder and post-processor exist,InputEnd() of decoder is issued
sl@0
  1267
	//and wait for reply from it before issuing PostProcessor InputEnd()
sl@0
  1268
	//iIsDecodeComplete is EFalse, until decoder responds
sl@0
  1269
	iIsDecodeComplete=EFalse;
sl@0
  1270
	
sl@0
  1271
	if (iVideoDecodeHwDevice)
sl@0
  1272
		{
sl@0
  1273
		iVideoDecodeHwDevice->InputEnd();
sl@0
  1274
		return;
sl@0
  1275
		}
sl@0
  1276
	if (iVideoPostProcHwDevice)
sl@0
  1277
		{
sl@0
  1278
		iVideoPostProcHwDevice->InputEnd();	
sl@0
  1279
		}
sl@0
  1280
	}
sl@0
  1281
sl@0
  1282
EXPORT_C void CMMFDevVideoPlay::GetNewPictureInfo(TUint& aNumPictures, TTimeIntervalMicroSeconds& aEarliestTimestamp, TTimeIntervalMicroSeconds& aLatestTimestamp)
sl@0
  1283
	{
sl@0
  1284
	CheckInitializationState(EInitialized);
sl@0
  1285
sl@0
  1286
	aNumPictures = iNumberOfVideoPictures;
sl@0
  1287
	if (iNumberOfVideoPictures > 0)
sl@0
  1288
		{
sl@0
  1289
		aEarliestTimestamp = iVideoPictureQue.First()->iTimestamp;
sl@0
  1290
		aLatestTimestamp = iVideoPictureQue.Last()->iTimestamp;
sl@0
  1291
		}
sl@0
  1292
	}
sl@0
  1293
sl@0
  1294
EXPORT_C TVideoPicture* CMMFDevVideoPlay::NextPictureL()
sl@0
  1295
	{
sl@0
  1296
sl@0
  1297
	CheckInitializationState(EInitialized);
sl@0
  1298
sl@0
  1299
	if (iNumberOfVideoPictures == 0)
sl@0
  1300
		return NULL;
sl@0
  1301
sl@0
  1302
	TVideoPicture* picture = iVideoPictureQue.First();
sl@0
  1303
sl@0
  1304
	// Remove the picture from the list
sl@0
  1305
	picture->iLink.Deque();
sl@0
  1306
	iNumberOfVideoPictures--;
sl@0
  1307
sl@0
  1308
	return picture;
sl@0
  1309
	}
sl@0
  1310
sl@0
  1311
EXPORT_C void CMMFDevVideoPlay::ReturnPicture(TVideoPicture* aPicture)
sl@0
  1312
	{
sl@0
  1313
	CheckInitializationState(EInitialized);
sl@0
  1314
sl@0
  1315
	// Return the picture to the hwdevice
sl@0
  1316
	RenderingHwDevice().ReturnPicture(aPicture);
sl@0
  1317
	}
sl@0
  1318
sl@0
  1319
EXPORT_C TBool CMMFDevVideoPlay::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat)
sl@0
  1320
	{
sl@0
  1321
	CheckInitializationState(EInitialized);
sl@0
  1322
	return RenderingHwDevice().GetSnapshotL(aPictureData, aFormat);
sl@0
  1323
	}
sl@0
  1324
sl@0
  1325
EXPORT_C void CMMFDevVideoPlay::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp)
sl@0
  1326
	{
sl@0
  1327
	CheckInitializationState(EInitialized);
sl@0
  1328
	RenderingHwDevice().GetTimedSnapshotL(aPictureData, aFormat, aPresentationTimestamp);
sl@0
  1329
	}
sl@0
  1330
sl@0
  1331
EXPORT_C void CMMFDevVideoPlay::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId)
sl@0
  1332
	{
sl@0
  1333
	CheckInitializationState(EInitialized);
sl@0
  1334
	RenderingHwDevice().GetTimedSnapshotL(aPictureData, aFormat, aPictureId);
sl@0
  1335
	}
sl@0
  1336
sl@0
  1337
EXPORT_C void CMMFDevVideoPlay::CancelTimedSnapshot()
sl@0
  1338
	{
sl@0
  1339
	CheckInitializationState(EInitialized);
sl@0
  1340
	RenderingHwDevice().CancelTimedSnapshot();
sl@0
  1341
	}
sl@0
  1342
sl@0
  1343
EXPORT_C void CMMFDevVideoPlay::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats)
sl@0
  1344
	{
sl@0
  1345
	CheckInitializationState(EInitialized);
sl@0
  1346
	RenderingHwDevice().GetSupportedSnapshotFormatsL(aFormats);
sl@0
  1347
	}
sl@0
  1348
sl@0
  1349
EXPORT_C void CMMFDevVideoPlay::CommitL()
sl@0
  1350
	{
sl@0
  1351
	CheckInitializationState(EInitialized);
sl@0
  1352
	if (iVideoDecodeHwDevice)
sl@0
  1353
		iVideoDecodeHwDevice->CommitL();
sl@0
  1354
	if (iVideoPostProcHwDevice)
sl@0
  1355
		iVideoPostProcHwDevice->CommitL();
sl@0
  1356
	}
sl@0
  1357
sl@0
  1358
EXPORT_C void CMMFDevVideoPlay::Revert()
sl@0
  1359
	{
sl@0
  1360
	CheckInitializationState(EInitialized);
sl@0
  1361
	if (iVideoDecodeHwDevice)
sl@0
  1362
		iVideoDecodeHwDevice->Revert();
sl@0
  1363
	if (iVideoPostProcHwDevice)
sl@0
  1364
		iVideoPostProcHwDevice->Revert();
sl@0
  1365
	}
sl@0
  1366
sl@0
  1367
EXPORT_C TAny* CMMFDevVideoPlay::CustomInterface(THwDeviceId aHwDevice, TUid aInterface)
sl@0
  1368
	{
sl@0
  1369
	CheckInitializationState(ENotInitialized|EInitialized);
sl@0
  1370
	return VideoHwDevice(aHwDevice).CustomInterface(aInterface);
sl@0
  1371
	}
sl@0
  1372
sl@0
  1373
void CMMFDevVideoPlay::MdvppNewPicture(TVideoPicture* aPicture)
sl@0
  1374
	{
sl@0
  1375
	iVideoPictureQue.AddLast(*aPicture);
sl@0
  1376
	iNumberOfVideoPictures++;
sl@0
  1377
sl@0
  1378
	iObserver.MdvpoNewPictures();
sl@0
  1379
	}
sl@0
  1380
sl@0
  1381
void CMMFDevVideoPlay::MdvppNewBuffers()
sl@0
  1382
	{
sl@0
  1383
	iObserver.MdvpoNewBuffers();
sl@0
  1384
	}
sl@0
  1385
sl@0
  1386
void CMMFDevVideoPlay::MdvppReturnPicture(TVideoPicture* aPicture)
sl@0
  1387
	{
sl@0
  1388
	iObserver.MdvpoReturnPicture(aPicture);
sl@0
  1389
	}
sl@0
  1390
sl@0
  1391
void CMMFDevVideoPlay::MdvppSupplementalInformation(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp, const TPictureId& aPictureId)
sl@0
  1392
	{
sl@0
  1393
	iObserver.MdvpoSupplementalInformation(aData, aTimestamp, aPictureId);
sl@0
  1394
	}
sl@0
  1395
sl@0
  1396
void CMMFDevVideoPlay::MdvppPictureLoss()
sl@0
  1397
	{
sl@0
  1398
	iObserver.MdvpoPictureLoss();
sl@0
  1399
	}
sl@0
  1400
sl@0
  1401
void CMMFDevVideoPlay::MdvppPictureLoss(const TArray<TPictureId>& aPictures)
sl@0
  1402
	{
sl@0
  1403
	iObserver.MdvpoPictureLoss(aPictures);
sl@0
  1404
	}
sl@0
  1405
sl@0
  1406
void CMMFDevVideoPlay::MdvppSliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture)
sl@0
  1407
	{
sl@0
  1408
	iObserver.MdvpoSliceLoss(aFirstMacroblock, aNumMacroblocks, aPicture);
sl@0
  1409
	}
sl@0
  1410
sl@0
  1411
void CMMFDevVideoPlay::MdvppReferencePictureSelection(const TDesC8& aSelectionData)
sl@0
  1412
	{
sl@0
  1413
	iObserver.MdvpoReferencePictureSelection(aSelectionData);
sl@0
  1414
	}
sl@0
  1415
sl@0
  1416
void CMMFDevVideoPlay::MdvppTimedSnapshotComplete(TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& aPresentationTimestamp, const TPictureId& aPictureId)
sl@0
  1417
	{
sl@0
  1418
	iObserver.MdvpoTimedSnapshotComplete(aError, aPictureData, aPresentationTimestamp, aPictureId);
sl@0
  1419
	}
sl@0
  1420
sl@0
  1421
void CMMFDevVideoPlay::MdvppFatalError(CMMFVideoHwDevice* aDevice, TInt aError)
sl@0
  1422
	{
sl@0
  1423
	// Make sure the other plugin gets stopped
sl@0
  1424
	__ASSERT_DEBUG((aDevice!=NULL) && ((aDevice==iVideoDecodeHwDevice) || (aDevice==iVideoPostProcHwDevice)), DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1425
	if ((aDevice == iVideoDecodeHwDevice) && (iVideoPostProcHwDevice))
sl@0
  1426
		iVideoPostProcHwDevice->Stop();
sl@0
  1427
	else if ((aDevice == iVideoPostProcHwDevice) && (iVideoDecodeHwDevice))
sl@0
  1428
		iVideoDecodeHwDevice->Stop();
sl@0
  1429
sl@0
  1430
	// Place the object in the "initialization failed" state to prevent any more method calls
sl@0
  1431
	// This state is purely internal so this is ok.
sl@0
  1432
	iInitializationState = EInitializationFailed;
sl@0
  1433
sl@0
  1434
	iObserver.MdvpoFatalError(aError);
sl@0
  1435
	}
sl@0
  1436
sl@0
  1437
void CMMFDevVideoPlay::MdvppInitializeComplete(CMMFVideoHwDevice* aDevice, TInt aError)
sl@0
  1438
	{
sl@0
  1439
	if (aDevice == iVideoDecodeHwDevice)
sl@0
  1440
		{
sl@0
  1441
		HandleDecodeInitializeComplete(aError);
sl@0
  1442
		}
sl@0
  1443
	else if (aDevice == iVideoPostProcHwDevice)
sl@0
  1444
		{
sl@0
  1445
		HandlePostProcInitializeComplete(aError);
sl@0
  1446
		}
sl@0
  1447
	else
sl@0
  1448
		{// We've been given a random pointer back!
sl@0
  1449
		DevVideoPanic(EDevVideoPanicPreConditionViolation);
sl@0
  1450
		}
sl@0
  1451
	}
sl@0
  1452
sl@0
  1453
sl@0
  1454
void CMMFDevVideoPlay::HandleDecodeInitializeComplete(TInt aError)
sl@0
  1455
	{
sl@0
  1456
	// Make sure we are in the correct state
sl@0
  1457
	__ASSERT_ALWAYS(iInitializationState==EInitializing, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1458
sl@0
  1459
	if (aError == KErrNone)
sl@0
  1460
		{
sl@0
  1461
		// If we have a post processor, initialize that.  Otherwise, we're initialized.
sl@0
  1462
		if (iVideoPostProcHwDevice)
sl@0
  1463
			{
sl@0
  1464
			iVideoPostProcHwDevice->Initialize();
sl@0
  1465
			// Now wait for the next callback
sl@0
  1466
			}
sl@0
  1467
		else
sl@0
  1468
			{
sl@0
  1469
			iInitializationState = EInitialized;
sl@0
  1470
			iObserver.MdvpoInitComplete(KErrNone);
sl@0
  1471
			}
sl@0
  1472
		}
sl@0
  1473
	else
sl@0
  1474
		{//aError
sl@0
  1475
		iInitializationState = EInitializationFailed;
sl@0
  1476
		iObserver.MdvpoInitComplete(aError);
sl@0
  1477
		}
sl@0
  1478
	}
sl@0
  1479
sl@0
  1480
void CMMFDevVideoPlay::HandlePostProcInitializeComplete(TInt aError)
sl@0
  1481
	{
sl@0
  1482
	// Make sure we are in the correct state
sl@0
  1483
	__ASSERT_ALWAYS(iInitializationState==EInitializing, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1484
sl@0
  1485
	if (aError == KErrNone)
sl@0
  1486
		{
sl@0
  1487
		// We're now fully initialized
sl@0
  1488
		iInitializationState = EInitialized;
sl@0
  1489
		iObserver.MdvpoInitComplete(KErrNone);
sl@0
  1490
		}
sl@0
  1491
	else
sl@0
  1492
		{//aError
sl@0
  1493
		iInitializationState = EInitializationFailed;
sl@0
  1494
		iObserver.MdvpoInitComplete(aError);
sl@0
  1495
		}
sl@0
  1496
	}
sl@0
  1497
sl@0
  1498
sl@0
  1499
void CMMFDevVideoPlay::MdvppStreamEnd()
sl@0
  1500
	{
sl@0
  1501
	// This method must be called the same number of times as the number of plugins we have
sl@0
  1502
	// before we call iObserver.MdvpoStreamEnd().
sl@0
  1503
	iNumberOfMdvppStreamEndCallbacks++;
sl@0
  1504
	
sl@0
  1505
	TUint numberOfPlugins = 0;
sl@0
  1506
	if (iVideoDecodeHwDevice && !iIsDecodeComplete)
sl@0
  1507
		{
sl@0
  1508
		iIsDecodeComplete = ETrue;
sl@0
  1509
		if(iVideoPostProcHwDevice)
sl@0
  1510
			{
sl@0
  1511
			iVideoPostProcHwDevice->InputEnd();
sl@0
  1512
			return;
sl@0
  1513
			}
sl@0
  1514
		}
sl@0
  1515
		
sl@0
  1516
	ASSERT(!iVideoDecodeHwDevice||iIsDecodeComplete);
sl@0
  1517
	if(iVideoDecodeHwDevice)
sl@0
  1518
		{
sl@0
  1519
		numberOfPlugins++;
sl@0
  1520
		}
sl@0
  1521
	
sl@0
  1522
	if (iVideoPostProcHwDevice)
sl@0
  1523
		{
sl@0
  1524
		numberOfPlugins++;
sl@0
  1525
		}
sl@0
  1526
sl@0
  1527
	if (iNumberOfMdvppStreamEndCallbacks == numberOfPlugins)
sl@0
  1528
		{
sl@0
  1529
		// We've received the correct number of callbacks so signal the client
sl@0
  1530
		iNumberOfMdvppStreamEndCallbacks = 0;
sl@0
  1531
		iObserver.MdvpoStreamEnd();
sl@0
  1532
		}
sl@0
  1533
	// else wait for the next plugin to call back
sl@0
  1534
	}
sl@0
  1535
sl@0
  1536
CMMFVideoPlayHwDevice& CMMFDevVideoPlay::VideoPlayHwDevice(THwDeviceId aHwDevice) const
sl@0
  1537
	{
sl@0
  1538
	if (aHwDevice == KHwDeviceIdVideoDecoder)
sl@0
  1539
		{
sl@0
  1540
		__ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1541
		return *iVideoDecodeHwDevice;
sl@0
  1542
		}
sl@0
  1543
	else if (aHwDevice == KHwDeviceIdVideoPostProcessor)
sl@0
  1544
		{
sl@0
  1545
		__ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1546
		return *iVideoPostProcHwDevice;
sl@0
  1547
		}
sl@0
  1548
	else
sl@0
  1549
		{
sl@0
  1550
		DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
sl@0
  1551
		// The following is unreachable
sl@0
  1552
		CMMFVideoPlayHwDevice* ret = NULL;
sl@0
  1553
		return *ret;
sl@0
  1554
		}
sl@0
  1555
	}
sl@0
  1556
sl@0
  1557
CMMFVideoPlayHwDevice& CMMFDevVideoPlay::RenderingHwDevice() const
sl@0
  1558
	{
sl@0
  1559
	// Return the last plugin in the chain
sl@0
  1560
	//  - the postprocessor if available, otherwise the videodecoder
sl@0
  1561
	if (iVideoPostProcHwDevice)
sl@0
  1562
		return *iVideoPostProcHwDevice;
sl@0
  1563
	else if (iVideoDecodeHwDevice)
sl@0
  1564
		return *iVideoDecodeHwDevice;
sl@0
  1565
	else
sl@0
  1566
		{
sl@0
  1567
		DevVideoPanic(EDevVideoPanicPreConditionViolation);
sl@0
  1568
		// The following is unreachable
sl@0
  1569
		CMMFVideoPlayHwDevice* ret = NULL;
sl@0
  1570
		return *ret;
sl@0
  1571
		}
sl@0
  1572
	}
sl@0
  1573
sl@0
  1574
sl@0
  1575
CMMFVideoDecodeHwDevice& CMMFDevVideoPlay::VideoDecodeHwDevice(THwDeviceId aHwDevice) const
sl@0
  1576
	{
sl@0
  1577
	if (aHwDevice == KHwDeviceIdVideoDecoder)
sl@0
  1578
		{
sl@0
  1579
		__ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1580
		return *iVideoDecodeHwDevice;
sl@0
  1581
		}
sl@0
  1582
	else
sl@0
  1583
		{
sl@0
  1584
		DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
sl@0
  1585
		// The following is unreachable
sl@0
  1586
		CMMFVideoDecodeHwDevice* ret = NULL;
sl@0
  1587
		return *ret;
sl@0
  1588
		}
sl@0
  1589
	}
sl@0
  1590
sl@0
  1591
CMMFVideoPostProcHwDevice& CMMFDevVideoPlay::VideoPostProcHwDevice(THwDeviceId aHwDevice) const
sl@0
  1592
	{
sl@0
  1593
	if (aHwDevice == KHwDeviceIdVideoPostProcessor)
sl@0
  1594
		{
sl@0
  1595
		__ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1596
		return *iVideoPostProcHwDevice;
sl@0
  1597
		}
sl@0
  1598
	else
sl@0
  1599
		{
sl@0
  1600
		DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
sl@0
  1601
		// The following is unreachable
sl@0
  1602
		CMMFVideoPostProcHwDevice* ret = NULL;
sl@0
  1603
		return *ret;
sl@0
  1604
		}
sl@0
  1605
	}
sl@0
  1606
sl@0
  1607
CMMFVideoDecodeHwDevice& CMMFDevVideoPlay::VideoDecodeHwDevice() const
sl@0
  1608
	{
sl@0
  1609
	return VideoDecodeHwDevice(KHwDeviceIdVideoDecoder);
sl@0
  1610
	}
sl@0
  1611
sl@0
  1612
CMMFVideoPostProcHwDevice& CMMFDevVideoPlay::VideoPostProcHwDevice() const
sl@0
  1613
	{
sl@0
  1614
	return VideoPostProcHwDevice(KHwDeviceIdVideoPostProcessor);
sl@0
  1615
	}
sl@0
  1616
sl@0
  1617
CMMFVideoHwDevice& CMMFDevVideoPlay::VideoHwDevice(THwDeviceId aHwDevice) const
sl@0
  1618
	{
sl@0
  1619
	if (aHwDevice == KHwDeviceIdVideoPostProcessor)
sl@0
  1620
		{
sl@0
  1621
		__ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1622
		return *iVideoPostProcHwDevice;
sl@0
  1623
		}
sl@0
  1624
	else if (aHwDevice == KHwDeviceIdVideoDecoder)
sl@0
  1625
		{
sl@0
  1626
		__ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1627
		return *iVideoDecodeHwDevice;
sl@0
  1628
		}
sl@0
  1629
	else
sl@0
  1630
		{
sl@0
  1631
		DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
sl@0
  1632
		// The following is unreachable
sl@0
  1633
		CMMFVideoHwDevice* ret = NULL;
sl@0
  1634
		return *ret;
sl@0
  1635
		}
sl@0
  1636
	}
sl@0
  1637
sl@0
  1638
void CMMFDevVideoPlay::CheckInitializationState(TUint aExpected)
sl@0
  1639
	{
sl@0
  1640
	__ASSERT_ALWAYS(iInitializationState&aExpected, DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1641
	}
sl@0
  1642
sl@0
  1643
void CMMFDevVideoPlay::ConnectPlugins()
sl@0
  1644
	{
sl@0
  1645
	__ASSERT_ALWAYS((iVideoDecodeHwDevice||iVideoPostProcHwDevice), DevVideoPanic(EDevVideoPanicPreConditionViolation));
sl@0
  1646
	if (iVideoDecodeHwDevice && iVideoPostProcHwDevice)
sl@0
  1647
		{
sl@0
  1648
		iVideoDecodeHwDevice->SetOutputDevice(iVideoPostProcHwDevice);
sl@0
  1649
		iVideoPostProcHwDevice->SetInputDevice(iVideoDecodeHwDevice);
sl@0
  1650
		}
sl@0
  1651
	}
sl@0
  1652
	
sl@0
  1653
CMMFVideoDecodeHwDevice* CMMFDevVideoPlay::CreateDecoderL(TUid aDecoder)
sl@0
  1654
	{
sl@0
  1655
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API	
sl@0
  1656
	// need to check whether we've  been given a PU
sl@0
  1657
	if (!iPuListCreated)
sl@0
  1658
		{
sl@0
  1659
		DevVideoUtilities::CreatePuListL(iPuImplementations);
sl@0
  1660
		iPuListCreated = ETrue;
sl@0
  1661
		}
sl@0
  1662
	const CImplementationInformation* info = DevVideoUtilities::FindPu(iPuImplementations, aDecoder);
sl@0
  1663
		
sl@0
  1664
	if (!info)
sl@0
  1665
		{
sl@0
  1666
		return CMMFVideoDecodeHwDevice::NewL(aDecoder, *this);
sl@0
  1667
		}
sl@0
  1668
	else
sl@0
  1669
		{
sl@0
  1670
		return CMMFVideoDecodeHwDevice::NewPuAdapterL(*info, *this);
sl@0
  1671
		}
sl@0
  1672
#else
sl@0
  1673
	return CMMFVideoDecodeHwDevice::NewL(aDecoder, *this);
sl@0
  1674
#endif // SYMBIAN_MULTIMEDIA_CODEC_API
sl@0
  1675
	}