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