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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
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>
22 #endif // SYMBIAN_MULTIMEDIA_CODEC_API
24 #include "devvideoplay.h"
25 #include "videoplayhwdevice.h"
26 #include "devvideointernal.h"
28 #include <mm/mmpluginutils.h>
30 const THwDeviceId KHwDeviceIdVideoDecoder = 1;
31 const THwDeviceId KHwDeviceIdVideoPostProcessor = 2;
34 // CMMFVideoDecodeHwDevice
36 EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewL(TUid aUid, MMMFDevVideoPlayProxy& aProxy)
38 CMMFVideoDecodeHwDevice* s = reinterpret_cast<CMMFVideoDecodeHwDevice*>
39 (REComSession::CreateImplementationL(aUid, _FOFF(CMMFVideoDecodeHwDevice,iDtor_ID_Key)));
44 #ifdef SYMBIAN_MULTIMEDIA_CODEC_API
45 const TInt KUidMDFVideoDecoderHwDeviceAdapter = 0x102737ED;
46 EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewPuAdapterL(const CImplementationInformation& aInfo, MMMFDevVideoPlayProxy& aProxy)
48 CMMFVideoDecodeHwDevice* hwdevice = NewL(TUid::Uid(KUidMDFVideoDecoderHwDeviceAdapter), aProxy);
49 CleanupStack::PushL(hwdevice);
51 MDevVideoHwDeviceAdapterSetup* setup = static_cast<MDevVideoHwDeviceAdapterSetup*>(
52 hwdevice->CustomInterface(TUid::Uid(KUidDevVideoHwDeviceAdapterSetup)));
56 setup->LoadProcessingUnitL(aInfo);
58 CleanupStack::Pop(hwdevice);
62 EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewPuAdapterL(const CImplementationInformation& /*aInfo*/, MMMFDevVideoPlayProxy& /*aProxy*/)
64 User::Leave(KErrNotSupported);
67 #endif // SYMBIAN_MULTIMEDIA_CODEC_API
69 EXPORT_C CMMFVideoDecodeHwDevice::~CMMFVideoDecodeHwDevice()
71 REComSession::DestroyedImplementation(iDtor_ID_Key);
74 EXPORT_C CMMFVideoDecodeHwDevice::CMMFVideoDecodeHwDevice()
80 // CMMFVideoPostProcHwDevice
82 EXPORT_C CMMFVideoPostProcHwDevice* CMMFVideoPostProcHwDevice::NewL(TUid aUid, MMMFDevVideoPlayProxy& aProxy)
84 CMMFVideoPostProcHwDevice* s = reinterpret_cast<CMMFVideoPostProcHwDevice*>
85 (REComSession::CreateImplementationL(aUid, _FOFF(CMMFVideoPostProcHwDevice,iDtor_ID_Key)));
90 EXPORT_C CMMFVideoPostProcHwDevice::~CMMFVideoPostProcHwDevice()
92 REComSession::DestroyedImplementation(iDtor_ID_Key);
95 EXPORT_C CMMFVideoPostProcHwDevice::CMMFVideoPostProcHwDevice()
100 EXPORT_C TVideoInputBuffer::TVideoInputBuffer() :
103 iDecodingTimestamp(0),
104 iPresentationTimestamp(0),
114 // CPostProcessorInfo
116 EXPORT_C CPostProcessorInfo* CPostProcessorInfo::NewL(TUid aUid,
117 const TDesC& aManufacturer,
118 const TDesC& aIdentifier,
120 const TArray<TUncompressedVideoFormat>& aSupportedFormats,
121 const TArray<TUint32>& aSupportedCombinations,
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)
131 CPostProcessorInfo* s = new(ELeave) CPostProcessorInfo(aUid,
134 aSupportsDirectDisplay,
135 aYuvToRgbCapabilities,
137 aSupportArbitraryScaling,
138 aAntiAliasedScaling);
140 CleanupStack::PushL(s);
142 s->ConstructL(aManufacturer,
145 aSupportedCombinations,
146 aSupportedScaleFactors,
147 aImplementationSpecificInfo);
149 CleanupStack::Pop(s);
153 CPostProcessorInfo::CPostProcessorInfo(TUid aUid,
156 TBool aSupportDirectDisplay,
157 const TYuvToRgbCapabilities& aYuvToRgbCapabilities,
158 TUint32 aSupportedRotations,
159 TBool aSupportArbitraryScaling,
160 TBool aAntiAliasedScaling) :
163 iAccelerated(aAccelerated),
164 iSupportDirectDisplay(aSupportDirectDisplay),
165 iYuvToRgbCapabilities(aYuvToRgbCapabilities),
166 iSupportedRotations(aSupportedRotations),
167 iSupportArbitraryScaling(aSupportArbitraryScaling),
168 iAntiAliasedScaling(aAntiAliasedScaling),
169 iSupportsContentProtected(EFalse)
171 iSupportedScreens.Reset();
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)
181 iManufacturer = aManufacturer.AllocL();
182 iIdentifier = aIdentifier.AllocL();
183 iImplementationSpecificInfo = aImplementationSpecificInfo.AllocL();
186 TInt supportedFormatsCount = aSupportedFormats.Count();
187 for (i=0; i<supportedFormatsCount; i++)
189 User::LeaveIfError(iSupportedFormats.Append(aSupportedFormats[i]));
192 TInt supportedCombinationsCount = aSupportedCombinations.Count();
193 for (i=0; i<supportedCombinationsCount; i++)
195 User::LeaveIfError(iSupportedCombinations.Append(aSupportedCombinations[i]));
198 TInt supportedScaleFactors = aSupportedScaleFactors.Count();
199 for (i=0; i<supportedScaleFactors; i++)
201 User::LeaveIfError(iSupportedScaleFactors.Append(aSupportedScaleFactors[i]));
205 EXPORT_C CPostProcessorInfo::~CPostProcessorInfo()
207 delete iManufacturer;
209 delete iImplementationSpecificInfo;
210 iSupportedFormats.Reset();
211 iSupportedCombinations.Reset();
212 iSupportedScaleFactors.Reset();
213 iSupportedScreens.Close();
216 EXPORT_C TUid CPostProcessorInfo::Uid() const
221 EXPORT_C const TDesC& CPostProcessorInfo::Manufacturer() const
223 return *iManufacturer;
226 EXPORT_C const TDesC& CPostProcessorInfo::Identifier() const
231 EXPORT_C TVersion CPostProcessorInfo::Version() const
236 EXPORT_C TBool CPostProcessorInfo::SupportsFormat(const TUncompressedVideoFormat& aFormat) const
238 TBool found = EFalse;
239 TInt count = iSupportedFormats.Count();
240 for (TInt i=0; i<count; i++)
242 if (iSupportedFormats[i] == aFormat)
251 EXPORT_C const RArray<TUncompressedVideoFormat>& CPostProcessorInfo::SupportedFormats() const
253 return iSupportedFormats;
256 EXPORT_C TBool CPostProcessorInfo::SupportsCombination(TUint32 aCombination) const
258 TBool found = EFalse;
259 TInt count = iSupportedCombinations.Count();
260 for (TInt i=0; i<count; i++)
262 if (iSupportedCombinations[i] == aCombination)
271 EXPORT_C const RArray<TUint32>& CPostProcessorInfo::SupportedCombinations() const
273 return iSupportedCombinations;
276 EXPORT_C TBool CPostProcessorInfo::Accelerated() const
281 EXPORT_C TBool CPostProcessorInfo::SupportsDirectDisplay() const
283 return iSupportDirectDisplay;
286 EXPORT_C const TYuvToRgbCapabilities& CPostProcessorInfo::YuvToRgbCapabilities() const
288 return iYuvToRgbCapabilities;
291 EXPORT_C TUint32 CPostProcessorInfo::SupportedRotations() const
293 return iSupportedRotations;
296 EXPORT_C TBool CPostProcessorInfo::SupportsArbitraryScaling() const
298 return iSupportArbitraryScaling;
301 EXPORT_C const RArray<TScaleFactor>& CPostProcessorInfo::SupportedScaleFactors() const
303 return iSupportedScaleFactors;
306 EXPORT_C TBool CPostProcessorInfo::AntiAliasedScaling() const
308 return iAntiAliasedScaling;
311 EXPORT_C const TDesC8& CPostProcessorInfo::ImplementationSpecificInfo() const
313 return *iImplementationSpecificInfo;
316 EXPORT_C void CPostProcessorInfo::AddSupportedScreenL(TInt aScreenNo)
318 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
319 iSupportedScreens.AppendL(aScreenNo);
321 aScreenNo = aScreenNo; //Added to remove the warning
322 User::Leave(KErrNotSupported);
326 EXPORT_C void CPostProcessorInfo::GetSupportedScreensL(RArray<TInt>& aSupportedScreens) const
328 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
329 aSupportedScreens.Reset();
330 TInt screensCount = iSupportedScreens.Count();
331 for (TInt i = 0; i < screensCount;i++)
333 aSupportedScreens.AppendL(iSupportedScreens[i]);
336 aSupportedScreens = aSupportedScreens;//Added to remove the warning
337 User::Leave(KErrNotSupported);
341 EXPORT_C void CPostProcessorInfo::SetSupportsContentProtected(const TBool aSetting)
343 iSupportsContentProtected = aSetting;
346 EXPORT_C TBool CPostProcessorInfo::SupportsContentProtected() const
348 return iSupportsContentProtected;
354 EXPORT_C CVideoDecoderInfo* CVideoDecoderInfo::NewL(TUid aUid,
355 const TDesC& aManufacturer,
356 const TDesC& aIdentifier,
358 const TArray<CCompressedVideoFormat*>& aSupportedFormats,
360 TBool aSupportsDirectDisplay,
361 const TSize& aMaxPictureSize,
363 const TArray<TPictureRateAndSize>& aMaxPictureRates,
364 TBool aSupportsPictureLoss,
365 TBool aSupportsSliceLoss,
366 const TDesC8& aCodingStandardSpecificInfo,
367 const TDesC8& aImplementationSpecificInfo)
369 CVideoDecoderInfo* s = new(ELeave) CVideoDecoderInfo(aUid,
372 aSupportsDirectDisplay,
375 aSupportsPictureLoss,
378 CleanupStack::PushL(s);
379 s->ConstructL(aManufacturer, aIdentifier, aSupportedFormats, aMaxPictureRates, aCodingStandardSpecificInfo, aImplementationSpecificInfo);
380 CleanupStack::Pop(s);
384 CVideoDecoderInfo::CVideoDecoderInfo(TUid aUid,
387 TBool aSupportsDirectDisplay,
388 const TSize& aMaxPictureSize,
390 TBool aSupportsPictureLoss,
391 TBool aSupportsSliceLoss) :
394 iAccelerated(aAccelerated),
395 iSupportsDirectDisplay(aSupportsDirectDisplay),
396 iMaxPictureSize(aMaxPictureSize),
397 iMaxBitrate(aMaxBitrate),
398 iSupportsPictureLoss(aSupportsPictureLoss),
399 iSupportsSliceLoss(aSupportsSliceLoss),
400 iSupportsContentProtected(EFalse)
402 iSupportedScreens.Reset();
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)
412 iManufacturer = aManufacturer.AllocL();
413 iIdentifier = aIdentifier.AllocL();
414 iCodingStandardSpecificInfo = aCodingStandardSpecificInfo.AllocL();
415 iImplementationSpecificInfo = aImplementationSpecificInfo.AllocL();
418 TInt count = aSupportedFormats.Count();
419 for (i=0; i<count; i++)
421 CCompressedVideoFormat* f = CCompressedVideoFormat::NewL(*(aSupportedFormats[i]));
422 CleanupStack::PushL(f);
423 User::LeaveIfError(iSupportedFormats.Append(f));
424 CleanupStack::Pop(f);
427 count = aMaxPictureRates.Count();
428 for (i=0; i<count; i++)
430 User::LeaveIfError(iMaxPictureRates.Append(aMaxPictureRates[i]));
434 EXPORT_C CVideoDecoderInfo::~CVideoDecoderInfo()
436 delete iManufacturer;
438 delete iCodingStandardSpecificInfo;
439 delete iImplementationSpecificInfo;
440 iSupportedFormats.ResetAndDestroy();
441 iSupportedFormats.Close();
442 iMaxPictureRates.Reset();
443 iMaxPictureRates.Close();
444 iSupportedScreens.Close();
447 EXPORT_C TBool CVideoDecoderInfo::SupportsFormat(const CCompressedVideoFormat& aFormat) const
449 TBool result = EFalse;
450 TInt count = iSupportedFormats.Count();
451 for (TInt i=0; i<count; i++)
453 if (*(iSupportedFormats[i]) == aFormat)
462 EXPORT_C const RPointerArray<CCompressedVideoFormat>& CVideoDecoderInfo::SupportedFormats() const
464 return iSupportedFormats;
467 EXPORT_C const TDesC& CVideoDecoderInfo::Manufacturer() const
469 return *iManufacturer;
472 EXPORT_C const TDesC& CVideoDecoderInfo::Identifier() const
477 EXPORT_C TVersion CVideoDecoderInfo::Version() const
482 EXPORT_C TUid CVideoDecoderInfo::Uid() const
487 EXPORT_C TBool CVideoDecoderInfo::Accelerated() const
492 EXPORT_C TBool CVideoDecoderInfo::SupportsDirectDisplay() const
494 return iSupportsDirectDisplay;
497 EXPORT_C const TSize& CVideoDecoderInfo::MaxPictureSize() const
499 return iMaxPictureSize;
502 EXPORT_C TUint CVideoDecoderInfo::MaxBitrate() const
507 EXPORT_C const RArray<TPictureRateAndSize>& CVideoDecoderInfo::MaxPictureRates() const
509 return iMaxPictureRates;
512 EXPORT_C TBool CVideoDecoderInfo::SupportsPictureLoss() const
514 return iSupportsPictureLoss;
517 EXPORT_C TBool CVideoDecoderInfo::SupportsSliceLoss() const
519 return iSupportsSliceLoss;
522 EXPORT_C const TDesC8& CVideoDecoderInfo::CodingStandardSpecificInfo() const
524 return *iCodingStandardSpecificInfo;
527 EXPORT_C const TDesC8& CVideoDecoderInfo::ImplementationSpecificInfo() const
529 return *iImplementationSpecificInfo;
532 EXPORT_C void CVideoDecoderInfo::AddSupportedScreenL(TInt aScreenNo)
534 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
535 iSupportedScreens.AppendL(aScreenNo);
537 aScreenNo = aScreenNo; //Added to remove the warning.
538 User::Leave(KErrNotSupported);
542 EXPORT_C void CVideoDecoderInfo::GetSupportedScreensL(RArray<TInt>& aSupportedScreens) const
544 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
545 aSupportedScreens.Reset();
546 TInt screensCount = iSupportedScreens.Count();
547 for (TInt i = 0; i < screensCount;i++)
549 aSupportedScreens.AppendL(iSupportedScreens[i]);
552 aSupportedScreens = aSupportedScreens;//Added to remove the warning
553 User::Leave(KErrNotSupported);
557 EXPORT_C void CVideoDecoderInfo::SetSupportsContentProtected(const TBool aSetting)
559 iSupportsContentProtected = aSetting;
562 EXPORT_C TBool CVideoDecoderInfo::SupportsContentProtected() const
564 return iSupportsContentProtected;
570 EXPORT_C CMMFDevVideoPlay* CMMFDevVideoPlay::NewL(MMMFDevVideoPlayObserver& aObserver)
572 return new(ELeave) CMMFDevVideoPlay(aObserver);
575 CMMFDevVideoPlay::CMMFDevVideoPlay(MMMFDevVideoPlayObserver& aObserver) :
576 iObserver(aObserver),
577 iInitializationState(ENotInitialized),
578 iVideoPictureQue(_FOFF(TVideoPicture,iLink)),
579 iVideoPictureQueIter(iVideoPictureQue)
583 EXPORT_C CMMFDevVideoPlay::~CMMFDevVideoPlay()
585 delete iVideoDecodeHwDevice;
586 delete iVideoPostProcHwDevice;
587 #ifdef SYMBIAN_MULTIMEDIA_CODEC_API
588 iPuImplementations.ResetAndDestroy();
592 EXPORT_C TBool CMMFDevVideoPlay::FindCommonFormat(const TArray<TUncompressedVideoFormat>& aFormats1, const TArray<TUncompressedVideoFormat>& aFormats2, TUncompressedVideoFormat& aCommonFormat)
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
597 TInt formats1Position;
598 TInt formats2Position;
600 const TUncompressedVideoFormat* firstTry = NULL;
601 TInt firstTryCumulativePosition = -1;
602 const TUncompressedVideoFormat* secondTry = NULL;
603 TInt secondTryCumulativePosition = -1;
605 TInt formats1Count = aFormats1.Count();
606 TInt formats2Count = aFormats2.Count();
608 for (formats1Position=0; formats1Position < formats1Count; formats1Position++)
610 const TUncompressedVideoFormat& format1 = aFormats1[formats1Position];
612 for (formats2Position=0; formats2Position < formats2Count; formats2Position++)
614 const TUncompressedVideoFormat& format2 = aFormats2[formats2Position];
615 if (format1 == format2)
618 firstTryCumulativePosition = formats1Position+formats2Position;
623 if (firstTry != NULL)
627 for (formats2Position=0; formats2Position < formats2Count; formats2Position++)
629 const TUncompressedVideoFormat& format2 = aFormats2[formats2Position];
631 for (formats1Position=0; formats1Position < formats1Count; formats1Position++)
633 const TUncompressedVideoFormat& format1 = aFormats1[formats1Position];
634 if (format1 == format2)
636 secondTry = &format1;
637 secondTryCumulativePosition = formats1Position+formats2Position;
642 if (secondTry != NULL)
646 TBool found = EFalse;
650 ASSERT(secondTry!=NULL);
652 // Work out which is cheaper
653 if (firstTryCumulativePosition <= secondTryCumulativePosition)
655 aCommonFormat = *firstTry;
659 aCommonFormat = *secondTry;
666 EXPORT_C void CMMFDevVideoPlay::FindDecodersL(const TDesC8& aMimeType, TUint32 aPostProcType, RArray<TUid>& aDecoders, TBool aExactMatch)
668 #ifdef SYMBIAN_MULTIMEDIA_CODEC_API
669 // find PU based plugins
670 RImplInfoPtrArray codecPlugins;
671 CleanupResetAndDestroyPushL(codecPlugins);
672 DevVideoUtilities::FindVideoDecoderPluginsL(aMimeType, codecPlugins);
675 for (TInt i = 0; i < codecPlugins.Count();i++)
677 aDecoders.AppendL(codecPlugins[i]->ImplementationUid());
680 CleanupStack::PopAndDestroy(&codecPlugins);
681 #endif // SYMBIAN_MULTIMEDIA_CODEC_API
682 RImplInfoPtrArray plugins;
683 CleanupResetAndDestroyPushL(plugins);
685 MmPluginUtils::FindImplementationsL(KUidDevVideoDecoderHwDevice, plugins);
687 DevVideoUtilities::SelectPluginBasedOnMatchType(aMimeType, plugins);
689 DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(plugins, aPostProcType, aDecoders);
691 // Perform the extra processing required if an exact match was requested
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);
700 for (TInt i=aDecoders.Count()-1; i>=0; i--)
702 TUid pluginUid = aDecoders[i];
703 CVideoDecoderInfo* info = NULL;
704 TRAPD(err, info = VideoDecoderInfoLC(pluginUid); CleanupStack::Pop(info););
707 if (!info->SupportsFormat(*format))
709 // The decoder doesn't support the format, so remove it from the list
714 else if (err==KErrNotFound)
716 // we have a bogus UID so remove it from the list
725 CleanupStack::PopAndDestroy(format);
728 // Leave if we didn't find anything.
729 if (aDecoders.Count() == 0)
731 User::Leave(KErrNotFound);
734 CleanupStack::PopAndDestroy(&plugins);
737 EXPORT_C void CMMFDevVideoPlay::FindPostProcessorsL(TUint32 aPostProcType, RArray<TUid>& aPostProcessors)
739 RImplInfoPtrArray plugins;
740 CleanupResetAndDestroyPushL(plugins);
742 MmPluginUtils::FindImplementationsL(KUidDevVideoPostProcessorHwDevice, plugins);
744 DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(plugins, aPostProcType, aPostProcessors);
746 // Leave if we didn't find anything.
747 if (aPostProcessors.Count() == 0)
749 User::Leave(KErrNotFound);
752 CleanupStack::PopAndDestroy(&plugins);
755 EXPORT_C void CMMFDevVideoPlay::GetDecoderListL(RArray<TUid>& aDecoders)
757 RImplInfoPtrArray plugins;
758 CleanupResetAndDestroyPushL(plugins);
760 MmPluginUtils::FindImplementationsL(KUidDevVideoDecoderHwDevice, plugins);
764 TInt count = plugins.Count();
765 for (TInt i=0; i<count; i++)
767 User::LeaveIfError(aDecoders.Append(plugins[i]->ImplementationUid()));
770 CleanupStack::PopAndDestroy(&plugins);
773 EXPORT_C void CMMFDevVideoPlay::GetPostProcessorListL(RArray<TUid>& aPostProcessors)
775 RImplInfoPtrArray plugins;
776 CleanupResetAndDestroyPushL(plugins);
778 MmPluginUtils::FindImplementationsL(KUidDevVideoPostProcessorHwDevice, plugins);
780 aPostProcessors.Reset();
782 TInt count = plugins.Count();
783 for (TInt i=0; i<count; i++)
785 User::LeaveIfError(aPostProcessors.Append(plugins[i]->ImplementationUid()));
788 CleanupStack::PopAndDestroy(&plugins);
791 EXPORT_C CVideoDecoderInfo* CMMFDevVideoPlay::VideoDecoderInfoLC(TUid aVideoDecoder)
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);
802 EXPORT_C CPostProcessorInfo* CMMFDevVideoPlay::PostProcessorInfoLC(TUid aPostProcessor)
804 CMMFVideoPlayHwDevice* device = NULL;
806 // Determine whether the aPostProcessor uid is for a decoder or a postprocessor hw device
808 CleanupClosePushL(array);
810 GetDecoderListL(array);
811 TInt position = array.Find(aPostProcessor);
812 if (position == KErrNotFound)
815 GetPostProcessorListL(array);
816 position = array.Find(aPostProcessor);
817 if (position != KErrNotFound)
819 // uid is a post processor
820 device = static_cast<CMMFVideoPlayHwDevice*>(CMMFVideoPostProcHwDevice::NewL(aPostProcessor, *this));
826 device = static_cast<CMMFVideoPlayHwDevice*>(CMMFVideoDecodeHwDevice::NewL(aPostProcessor, *this));
828 CleanupStack::PopAndDestroy(&array);
830 CPostProcessorInfo* info = NULL;
833 CleanupStack::PushL(device);
834 info = device->PostProcessorInfoLC();
835 CleanupStack::Pop(info);
836 CleanupStack::PopAndDestroy(device);
837 CleanupStack::PushL(info);
842 EXPORT_C THwDeviceId CMMFDevVideoPlay::SelectDecoderL(TUid aDecoder)
844 // This method can only be called before InitializeL() has been called.
845 CheckInitializationState(ENotInitialized);
847 delete iVideoDecodeHwDevice;
848 iVideoDecodeHwDevice = NULL;
849 #ifdef SYMBIAN_MULTIMEDIA_CODEC_API
850 iVideoDecodeHwDevice = CreateDecoderL(aDecoder);
852 iVideoDecodeHwDevice = CMMFVideoDecodeHwDevice::NewL(aDecoder, *this);
853 #endif // SYMBIAN_MULTIMEDIA_CODEC_API
854 return KHwDeviceIdVideoDecoder;
857 EXPORT_C THwDeviceId CMMFDevVideoPlay::SelectPostProcessorL(TUid aPostProcessor)
859 // This method can only be called before InitializeL() has been called.
860 CheckInitializationState(ENotInitialized);
862 delete iVideoPostProcHwDevice;
863 iVideoPostProcHwDevice = NULL;
864 iVideoPostProcHwDevice = CMMFVideoPostProcHwDevice::NewL(aPostProcessor, *this);
866 return KHwDeviceIdVideoPostProcessor;
869 EXPORT_C TVideoPictureHeader* CMMFDevVideoPlay::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation, TVideoInputBuffer* aDataUnit)
871 return VideoDecodeHwDevice().GetHeaderInformationL(aDataUnitType, aDataUnitEncapsulation, aDataUnit);
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,
879 @pre "This method can only be called before the API has been initialized with Initialize()."
881 EXPORT_C void CMMFDevVideoPlay::ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader)
883 CheckInitializationState(ENotInitialized);
885 VideoDecodeHwDevice().ConfigureDecoderL(aVideoPictureHeader);
890 EXPORT_C void CMMFDevVideoPlay::ReturnHeader(TVideoPictureHeader* aHeader)
892 // This method can only be called before InitializeL()
893 CheckInitializationState(ENotInitialized);
895 VideoDecodeHwDevice().ReturnHeader(aHeader);
898 EXPORT_C void CMMFDevVideoPlay::SetInputFormatL(THwDeviceId aHwDevice, const TUncompressedVideoFormat& aFormat)
900 CheckInitializationState(ENotInitialized);
902 VideoPostProcHwDevice(aHwDevice).SetInputFormatL(aFormat);
905 EXPORT_C void CMMFDevVideoPlay::SetInputFormatL(THwDeviceId aHwDevice, const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder)
907 CheckInitializationState(ENotInitialized);
909 VideoDecodeHwDevice(aHwDevice).SetInputFormatL(aFormat, aDataUnitType, aEncapsulation, aDataInOrder);
912 EXPORT_C void CMMFDevVideoPlay::GetOutputFormatListL(THwDeviceId aHwDevice, RArray<TUncompressedVideoFormat>& aFormats)
914 CheckInitializationState(ENotInitialized);
916 VideoPlayHwDevice(aHwDevice).GetOutputFormatListL(aFormats);
919 EXPORT_C void CMMFDevVideoPlay::SetOutputFormatL(THwDeviceId aHwDevice, const TUncompressedVideoFormat &aFormat)
921 CheckInitializationState(ENotInitialized);
923 VideoPlayHwDevice(aHwDevice).SetOutputFormatL(aFormat);
926 EXPORT_C void CMMFDevVideoPlay::SetClockSource(MMMFClockSource* aClock)
928 CheckInitializationState(ENotInitialized);
932 // Make sure we have at least one of the hwdevices set up
933 __ASSERT_ALWAYS((iVideoDecodeHwDevice||iVideoPostProcHwDevice), DevVideoPanic(EDevVideoPanicPreConditionViolation));
935 // Set the clock source on both hw devices.
936 if (iVideoDecodeHwDevice)
937 iVideoDecodeHwDevice->SetClockSource(aClock);
938 if (iVideoPostProcHwDevice)
939 iVideoPostProcHwDevice->SetClockSource(aClock);
942 EXPORT_C void CMMFDevVideoPlay::SetVideoDestScreenL(TBool aScreen)
944 CheckInitializationState(ENotInitialized);
946 // Pass on to the rendering hw device
947 RenderingHwDevice().SetVideoDestScreenL(aScreen);
950 EXPORT_C void CMMFDevVideoPlay::SynchronizeDecoding(TBool aSynchronize)
952 CheckInitializationState(ENotInitialized);
954 VideoDecodeHwDevice().SynchronizeDecoding(aSynchronize);
957 EXPORT_C void CMMFDevVideoPlay::SetBufferOptionsL(const TBufferOptions& aOptions)
959 CheckInitializationState(ENotInitialized);
961 VideoDecodeHwDevice().SetBufferOptionsL(aOptions);
964 EXPORT_C void CMMFDevVideoPlay::GetBufferOptions(TBufferOptions& aOptions)
966 CheckInitializationState(ENotInitialized);
968 VideoDecodeHwDevice().GetBufferOptions(aOptions);
971 EXPORT_C void CMMFDevVideoPlay::SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams)
973 CheckInitializationState(ENotInitialized);
975 VideoDecodeHwDevice().SetHrdVbvSpec(aHrdVbvSpec, aHrdVbvParams);
978 EXPORT_C void CMMFDevVideoPlay::SetPostProcessTypesL(THwDeviceId aHwDevice, TUint32 aPostProcCombination)
980 CheckInitializationState(ENotInitialized|EInitialized);
982 VideoPlayHwDevice(aHwDevice).SetPostProcessTypesL(aPostProcCombination);
985 EXPORT_C void CMMFDevVideoPlay::SetInputCropOptionsL(THwDeviceId aHwDevice, const TRect& aRect)
987 CheckInitializationState(ENotInitialized|EInitialized);
989 VideoPlayHwDevice(aHwDevice).SetInputCropOptionsL(aRect);
992 EXPORT_C void CMMFDevVideoPlay::SetYuvToRgbOptionsL(THwDeviceId aHwDevice, const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
994 CheckInitializationState(ENotInitialized|EInitialized);
996 VideoPlayHwDevice(aHwDevice).SetYuvToRgbOptionsL(aOptions, aYuvFormat, aRgbFormat);
999 EXPORT_C void CMMFDevVideoPlay::SetYuvToRgbOptionsL(THwDeviceId aHwDevice, const TYuvToRgbOptions& aOptions)
1001 CheckInitializationState(ENotInitialized|EInitialized);
1003 VideoPlayHwDevice(aHwDevice).SetYuvToRgbOptionsL(aOptions);
1006 EXPORT_C void CMMFDevVideoPlay::SetRotateOptionsL(THwDeviceId aHwDevice, TRotationType aRotationType)
1008 CheckInitializationState(ENotInitialized|EInitialized);
1010 VideoPlayHwDevice(aHwDevice).SetRotateOptionsL(aRotationType);
1013 EXPORT_C void CMMFDevVideoPlay::SetScaleOptionsL(THwDeviceId aHwDevice, const TSize& aTargetSize, TBool aAntiAliasFiltering)
1015 CheckInitializationState(ENotInitialized|EInitialized);
1017 VideoPlayHwDevice(aHwDevice).SetScaleOptionsL(aTargetSize, aAntiAliasFiltering);
1020 EXPORT_C void CMMFDevVideoPlay::SetOutputCropOptionsL(THwDeviceId aHwDevice, const TRect& aRect)
1022 CheckInitializationState(ENotInitialized|EInitialized);
1024 VideoPlayHwDevice(aHwDevice).SetOutputCropOptionsL(aRect);
1027 EXPORT_C void CMMFDevVideoPlay::SetPostProcSpecificOptionsL(THwDeviceId aHwDevice, const TDesC8& aOptions)
1029 CheckInitializationState(ENotInitialized|EInitialized);
1031 VideoPlayHwDevice(aHwDevice).SetPostProcSpecificOptionsL(aOptions);
1034 EXPORT_C void CMMFDevVideoPlay::Initialize()
1036 CheckInitializationState(ENotInitialized);
1038 // First introduce the two plugins to each other
1041 // Next initialize the first hwdevice in the chain
1042 if (iVideoDecodeHwDevice)
1044 iInitializationState = EInitializing;
1045 iVideoDecodeHwDevice->Initialize();
1047 else if (iVideoPostProcHwDevice)
1049 iInitializationState = EInitializing;
1050 iVideoPostProcHwDevice->Initialize();
1054 // No hwdevice to initialize so panic
1055 DevVideoPanic(EDevVideoPanicPreConditionViolation);
1059 EXPORT_C void CMMFDevVideoPlay::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion)
1061 CheckInitializationState(EInitialized);
1062 RenderingHwDevice().StartDirectScreenAccessL(aVideoRect, aScreenDevice, aClipRegion);
1065 EXPORT_C void CMMFDevVideoPlay::SetScreenClipRegion(const TRegion& aRegion)
1067 CheckInitializationState(EInitialized);
1068 RenderingHwDevice().SetScreenClipRegion(aRegion);
1071 EXPORT_C void CMMFDevVideoPlay::SetPauseOnClipFail(TBool aPause)
1073 CheckInitializationState(EInitialized);
1074 RenderingHwDevice().SetPauseOnClipFail(aPause);
1077 EXPORT_C void CMMFDevVideoPlay::AbortDirectScreenAccess()
1079 CheckInitializationState(EInitialized);
1080 RenderingHwDevice().AbortDirectScreenAccess();
1083 EXPORT_C TBool CMMFDevVideoPlay::IsPlaying()
1085 CheckInitializationState(EInitialized);
1086 return RenderingHwDevice().IsPlaying();
1089 EXPORT_C void CMMFDevVideoPlay::Redraw()
1091 CheckInitializationState(EInitialized);
1092 RenderingHwDevice().Redraw();
1095 EXPORT_C void CMMFDevVideoPlay::Start()
1097 CheckInitializationState(EInitialized);
1099 if (iVideoDecodeHwDevice)
1100 iVideoDecodeHwDevice->Start();
1101 if (iVideoPostProcHwDevice)
1102 iVideoPostProcHwDevice->Start();
1105 EXPORT_C void CMMFDevVideoPlay::Stop()
1107 CheckInitializationState(EInitialized);
1109 if (iVideoDecodeHwDevice)
1110 iVideoDecodeHwDevice->Stop();
1111 if (iVideoPostProcHwDevice)
1112 iVideoPostProcHwDevice->Stop();
1115 EXPORT_C void CMMFDevVideoPlay::Pause()
1117 CheckInitializationState(EInitialized);
1119 if (iVideoDecodeHwDevice)
1120 iVideoDecodeHwDevice->Pause();
1121 if (iVideoPostProcHwDevice)
1122 iVideoPostProcHwDevice->Pause();
1125 EXPORT_C void CMMFDevVideoPlay::Resume()
1127 CheckInitializationState(EInitialized);
1129 if (iVideoDecodeHwDevice)
1130 iVideoDecodeHwDevice->Resume();
1131 if (iVideoPostProcHwDevice)
1132 iVideoPostProcHwDevice->Resume();
1135 EXPORT_C void CMMFDevVideoPlay::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
1137 CheckInitializationState(EInitialized);
1139 if (iVideoDecodeHwDevice)
1140 iVideoDecodeHwDevice->SetPosition(aPlaybackPosition);
1141 if (iVideoPostProcHwDevice)
1142 iVideoPostProcHwDevice->SetPosition(aPlaybackPosition);
1145 EXPORT_C void CMMFDevVideoPlay::FreezePicture(const TTimeIntervalMicroSeconds& aPlaybackPosition)
1147 CheckInitializationState(EInitialized);
1148 RenderingHwDevice().FreezePicture(aPlaybackPosition);
1151 EXPORT_C void CMMFDevVideoPlay::ReleaseFreeze(const TTimeIntervalMicroSeconds& aPlaybackPosition)
1153 CheckInitializationState(EInitialized);
1154 RenderingHwDevice().ReleaseFreeze(aPlaybackPosition);
1157 EXPORT_C TTimeIntervalMicroSeconds CMMFDevVideoPlay::DecodingPosition()
1159 CheckInitializationState(EInitialized);
1160 return VideoDecodeHwDevice().DecodingPosition();
1163 EXPORT_C TTimeIntervalMicroSeconds CMMFDevVideoPlay::PlaybackPosition()
1165 CheckInitializationState(EInitialized);
1166 return RenderingHwDevice().PlaybackPosition();
1169 EXPORT_C TUint CMMFDevVideoPlay::PreDecoderBufferBytes()
1171 CheckInitializationState(EInitialized);
1172 return VideoDecodeHwDevice().PreDecoderBufferBytes();
1175 EXPORT_C TUint CMMFDevVideoPlay::PictureBufferBytes()
1177 CheckInitializationState(EInitialized);
1178 return RenderingHwDevice().PictureBufferBytes();
1181 EXPORT_C void CMMFDevVideoPlay::GetPictureCounters(TPictureCounters& aCounters)
1183 CheckInitializationState(EInitialized);
1185 TPictureCounters decoderPictureCounters;
1186 TPictureCounters postProcPictureCounters;
1188 if (iVideoDecodeHwDevice)
1189 iVideoDecodeHwDevice->GetPictureCounters(decoderPictureCounters);
1191 if (iVideoPostProcHwDevice)
1192 iVideoPostProcHwDevice->GetPictureCounters(postProcPictureCounters);
1195 // Only the decoder (if any) knows the number of pictures decoded
1196 aCounters.iPicturesDecoded = decoderPictureCounters.iPicturesDecoded;
1198 // Pictures skipped is sum of pictures skipped from decoder and postproc
1199 aCounters.iPicturesSkipped = decoderPictureCounters.iPicturesSkipped
1200 + postProcPictureCounters.iPicturesSkipped;
1202 // Ask last plugin in chain for number of pictures displayed
1203 if (iVideoPostProcHwDevice)
1204 aCounters.iPicturesDisplayed = postProcPictureCounters.iPicturesDisplayed;
1206 aCounters.iPicturesDisplayed = decoderPictureCounters.iPicturesDisplayed;
1208 // Ask first plugin in chain for number of input pictures
1209 if (iVideoDecodeHwDevice)
1210 aCounters.iTotalPictures = decoderPictureCounters.iTotalPictures;
1212 aCounters.iTotalPictures = postProcPictureCounters.iTotalPictures;
1215 EXPORT_C void CMMFDevVideoPlay::GetBitstreamCounters(TBitstreamCounters& aCounters)
1217 CheckInitializationState(EInitialized);
1218 VideoDecodeHwDevice().GetBitstreamCounters(aCounters);
1221 EXPORT_C TUint CMMFDevVideoPlay::NumFreeBuffers()
1223 CheckInitializationState(EInitialized);
1224 return VideoDecodeHwDevice().NumFreeBuffers();
1227 EXPORT_C void CMMFDevVideoPlay::SetComplexityLevel(THwDeviceId aHwDevice, TUint aLevel)
1229 CheckInitializationState(EInitialized);
1230 VideoPlayHwDevice(aHwDevice).SetComplexityLevel(aLevel);
1233 EXPORT_C TUint CMMFDevVideoPlay::NumComplexityLevels(THwDeviceId aHwDevice)
1235 CheckInitializationState(EInitialized);
1236 return VideoPlayHwDevice(aHwDevice).NumComplexityLevels();
1239 EXPORT_C void CMMFDevVideoPlay::GetComplexityLevelInfo(THwDeviceId aHwDevice, TUint aLevel, TComplexityLevelInfo& aInfo)
1241 CheckInitializationState(EInitialized);
1242 VideoPlayHwDevice(aHwDevice).GetComplexityLevelInfo(aLevel, aInfo);
1245 EXPORT_C TVideoInputBuffer* CMMFDevVideoPlay::GetBufferL(TUint aBufferSize)
1247 return VideoDecodeHwDevice().GetBufferL(aBufferSize);
1250 EXPORT_C void CMMFDevVideoPlay::WriteCodedDataL(TVideoInputBuffer* aBuffer)
1252 CheckInitializationState(EInitialized);
1253 VideoDecodeHwDevice().WriteCodedDataL(aBuffer);
1256 EXPORT_C void CMMFDevVideoPlay::WritePictureL(TVideoPicture* aPicture)
1258 CheckInitializationState(EInitialized);
1259 VideoPostProcHwDevice().WritePictureL(aPicture);
1262 EXPORT_C void CMMFDevVideoPlay::InputEnd()
1264 CheckInitializationState(EInitialized);
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;
1271 if (iVideoDecodeHwDevice)
1273 iVideoDecodeHwDevice->InputEnd();
1276 if (iVideoPostProcHwDevice)
1278 iVideoPostProcHwDevice->InputEnd();
1282 EXPORT_C void CMMFDevVideoPlay::GetNewPictureInfo(TUint& aNumPictures, TTimeIntervalMicroSeconds& aEarliestTimestamp, TTimeIntervalMicroSeconds& aLatestTimestamp)
1284 CheckInitializationState(EInitialized);
1286 aNumPictures = iNumberOfVideoPictures;
1287 if (iNumberOfVideoPictures > 0)
1289 aEarliestTimestamp = iVideoPictureQue.First()->iTimestamp;
1290 aLatestTimestamp = iVideoPictureQue.Last()->iTimestamp;
1294 EXPORT_C TVideoPicture* CMMFDevVideoPlay::NextPictureL()
1297 CheckInitializationState(EInitialized);
1299 if (iNumberOfVideoPictures == 0)
1302 TVideoPicture* picture = iVideoPictureQue.First();
1304 // Remove the picture from the list
1305 picture->iLink.Deque();
1306 iNumberOfVideoPictures--;
1311 EXPORT_C void CMMFDevVideoPlay::ReturnPicture(TVideoPicture* aPicture)
1313 CheckInitializationState(EInitialized);
1315 // Return the picture to the hwdevice
1316 RenderingHwDevice().ReturnPicture(aPicture);
1319 EXPORT_C TBool CMMFDevVideoPlay::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat)
1321 CheckInitializationState(EInitialized);
1322 return RenderingHwDevice().GetSnapshotL(aPictureData, aFormat);
1325 EXPORT_C void CMMFDevVideoPlay::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp)
1327 CheckInitializationState(EInitialized);
1328 RenderingHwDevice().GetTimedSnapshotL(aPictureData, aFormat, aPresentationTimestamp);
1331 EXPORT_C void CMMFDevVideoPlay::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId)
1333 CheckInitializationState(EInitialized);
1334 RenderingHwDevice().GetTimedSnapshotL(aPictureData, aFormat, aPictureId);
1337 EXPORT_C void CMMFDevVideoPlay::CancelTimedSnapshot()
1339 CheckInitializationState(EInitialized);
1340 RenderingHwDevice().CancelTimedSnapshot();
1343 EXPORT_C void CMMFDevVideoPlay::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats)
1345 CheckInitializationState(EInitialized);
1346 RenderingHwDevice().GetSupportedSnapshotFormatsL(aFormats);
1349 EXPORT_C void CMMFDevVideoPlay::CommitL()
1351 CheckInitializationState(EInitialized);
1352 if (iVideoDecodeHwDevice)
1353 iVideoDecodeHwDevice->CommitL();
1354 if (iVideoPostProcHwDevice)
1355 iVideoPostProcHwDevice->CommitL();
1358 EXPORT_C void CMMFDevVideoPlay::Revert()
1360 CheckInitializationState(EInitialized);
1361 if (iVideoDecodeHwDevice)
1362 iVideoDecodeHwDevice->Revert();
1363 if (iVideoPostProcHwDevice)
1364 iVideoPostProcHwDevice->Revert();
1367 EXPORT_C TAny* CMMFDevVideoPlay::CustomInterface(THwDeviceId aHwDevice, TUid aInterface)
1369 CheckInitializationState(ENotInitialized|EInitialized);
1370 return VideoHwDevice(aHwDevice).CustomInterface(aInterface);
1373 void CMMFDevVideoPlay::MdvppNewPicture(TVideoPicture* aPicture)
1375 iVideoPictureQue.AddLast(*aPicture);
1376 iNumberOfVideoPictures++;
1378 iObserver.MdvpoNewPictures();
1381 void CMMFDevVideoPlay::MdvppNewBuffers()
1383 iObserver.MdvpoNewBuffers();
1386 void CMMFDevVideoPlay::MdvppReturnPicture(TVideoPicture* aPicture)
1388 iObserver.MdvpoReturnPicture(aPicture);
1391 void CMMFDevVideoPlay::MdvppSupplementalInformation(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp, const TPictureId& aPictureId)
1393 iObserver.MdvpoSupplementalInformation(aData, aTimestamp, aPictureId);
1396 void CMMFDevVideoPlay::MdvppPictureLoss()
1398 iObserver.MdvpoPictureLoss();
1401 void CMMFDevVideoPlay::MdvppPictureLoss(const TArray<TPictureId>& aPictures)
1403 iObserver.MdvpoPictureLoss(aPictures);
1406 void CMMFDevVideoPlay::MdvppSliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture)
1408 iObserver.MdvpoSliceLoss(aFirstMacroblock, aNumMacroblocks, aPicture);
1411 void CMMFDevVideoPlay::MdvppReferencePictureSelection(const TDesC8& aSelectionData)
1413 iObserver.MdvpoReferencePictureSelection(aSelectionData);
1416 void CMMFDevVideoPlay::MdvppTimedSnapshotComplete(TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& aPresentationTimestamp, const TPictureId& aPictureId)
1418 iObserver.MdvpoTimedSnapshotComplete(aError, aPictureData, aPresentationTimestamp, aPictureId);
1421 void CMMFDevVideoPlay::MdvppFatalError(CMMFVideoHwDevice* aDevice, TInt aError)
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();
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;
1434 iObserver.MdvpoFatalError(aError);
1437 void CMMFDevVideoPlay::MdvppInitializeComplete(CMMFVideoHwDevice* aDevice, TInt aError)
1439 if (aDevice == iVideoDecodeHwDevice)
1441 HandleDecodeInitializeComplete(aError);
1443 else if (aDevice == iVideoPostProcHwDevice)
1445 HandlePostProcInitializeComplete(aError);
1448 {// We've been given a random pointer back!
1449 DevVideoPanic(EDevVideoPanicPreConditionViolation);
1454 void CMMFDevVideoPlay::HandleDecodeInitializeComplete(TInt aError)
1456 // Make sure we are in the correct state
1457 __ASSERT_ALWAYS(iInitializationState==EInitializing, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1459 if (aError == KErrNone)
1461 // If we have a post processor, initialize that. Otherwise, we're initialized.
1462 if (iVideoPostProcHwDevice)
1464 iVideoPostProcHwDevice->Initialize();
1465 // Now wait for the next callback
1469 iInitializationState = EInitialized;
1470 iObserver.MdvpoInitComplete(KErrNone);
1475 iInitializationState = EInitializationFailed;
1476 iObserver.MdvpoInitComplete(aError);
1480 void CMMFDevVideoPlay::HandlePostProcInitializeComplete(TInt aError)
1482 // Make sure we are in the correct state
1483 __ASSERT_ALWAYS(iInitializationState==EInitializing, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1485 if (aError == KErrNone)
1487 // We're now fully initialized
1488 iInitializationState = EInitialized;
1489 iObserver.MdvpoInitComplete(KErrNone);
1493 iInitializationState = EInitializationFailed;
1494 iObserver.MdvpoInitComplete(aError);
1499 void CMMFDevVideoPlay::MdvppStreamEnd()
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++;
1505 TUint numberOfPlugins = 0;
1506 if (iVideoDecodeHwDevice && !iIsDecodeComplete)
1508 iIsDecodeComplete = ETrue;
1509 if(iVideoPostProcHwDevice)
1511 iVideoPostProcHwDevice->InputEnd();
1516 ASSERT(!iVideoDecodeHwDevice||iIsDecodeComplete);
1517 if(iVideoDecodeHwDevice)
1522 if (iVideoPostProcHwDevice)
1527 if (iNumberOfMdvppStreamEndCallbacks == numberOfPlugins)
1529 // We've received the correct number of callbacks so signal the client
1530 iNumberOfMdvppStreamEndCallbacks = 0;
1531 iObserver.MdvpoStreamEnd();
1533 // else wait for the next plugin to call back
1536 CMMFVideoPlayHwDevice& CMMFDevVideoPlay::VideoPlayHwDevice(THwDeviceId aHwDevice) const
1538 if (aHwDevice == KHwDeviceIdVideoDecoder)
1540 __ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1541 return *iVideoDecodeHwDevice;
1543 else if (aHwDevice == KHwDeviceIdVideoPostProcessor)
1545 __ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1546 return *iVideoPostProcHwDevice;
1550 DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
1551 // The following is unreachable
1552 CMMFVideoPlayHwDevice* ret = NULL;
1557 CMMFVideoPlayHwDevice& CMMFDevVideoPlay::RenderingHwDevice() const
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;
1567 DevVideoPanic(EDevVideoPanicPreConditionViolation);
1568 // The following is unreachable
1569 CMMFVideoPlayHwDevice* ret = NULL;
1575 CMMFVideoDecodeHwDevice& CMMFDevVideoPlay::VideoDecodeHwDevice(THwDeviceId aHwDevice) const
1577 if (aHwDevice == KHwDeviceIdVideoDecoder)
1579 __ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1580 return *iVideoDecodeHwDevice;
1584 DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
1585 // The following is unreachable
1586 CMMFVideoDecodeHwDevice* ret = NULL;
1591 CMMFVideoPostProcHwDevice& CMMFDevVideoPlay::VideoPostProcHwDevice(THwDeviceId aHwDevice) const
1593 if (aHwDevice == KHwDeviceIdVideoPostProcessor)
1595 __ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1596 return *iVideoPostProcHwDevice;
1600 DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
1601 // The following is unreachable
1602 CMMFVideoPostProcHwDevice* ret = NULL;
1607 CMMFVideoDecodeHwDevice& CMMFDevVideoPlay::VideoDecodeHwDevice() const
1609 return VideoDecodeHwDevice(KHwDeviceIdVideoDecoder);
1612 CMMFVideoPostProcHwDevice& CMMFDevVideoPlay::VideoPostProcHwDevice() const
1614 return VideoPostProcHwDevice(KHwDeviceIdVideoPostProcessor);
1617 CMMFVideoHwDevice& CMMFDevVideoPlay::VideoHwDevice(THwDeviceId aHwDevice) const
1619 if (aHwDevice == KHwDeviceIdVideoPostProcessor)
1621 __ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1622 return *iVideoPostProcHwDevice;
1624 else if (aHwDevice == KHwDeviceIdVideoDecoder)
1626 __ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1627 return *iVideoDecodeHwDevice;
1631 DevVideoPanic(EDevVideoPanicInvalidHwDeviceId);
1632 // The following is unreachable
1633 CMMFVideoHwDevice* ret = NULL;
1638 void CMMFDevVideoPlay::CheckInitializationState(TUint aExpected)
1640 __ASSERT_ALWAYS(iInitializationState&aExpected, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1643 void CMMFDevVideoPlay::ConnectPlugins()
1645 __ASSERT_ALWAYS((iVideoDecodeHwDevice||iVideoPostProcHwDevice), DevVideoPanic(EDevVideoPanicPreConditionViolation));
1646 if (iVideoDecodeHwDevice && iVideoPostProcHwDevice)
1648 iVideoDecodeHwDevice->SetOutputDevice(iVideoPostProcHwDevice);
1649 iVideoPostProcHwDevice->SetInputDevice(iVideoDecodeHwDevice);
1653 CMMFVideoDecodeHwDevice* CMMFDevVideoPlay::CreateDecoderL(TUid aDecoder)
1655 #ifdef SYMBIAN_MULTIMEDIA_CODEC_API
1656 // need to check whether we've been given a PU
1657 if (!iPuListCreated)
1659 DevVideoUtilities::CreatePuListL(iPuImplementations);
1660 iPuListCreated = ETrue;
1662 const CImplementationInformation* info = DevVideoUtilities::FindPu(iPuImplementations, aDecoder);
1666 return CMMFVideoDecodeHwDevice::NewL(aDecoder, *this);
1670 return CMMFVideoDecodeHwDevice::NewPuAdapterL(*info, *this);
1673 return CMMFVideoDecodeHwDevice::NewL(aDecoder, *this);
1674 #endif // SYMBIAN_MULTIMEDIA_CODEC_API