sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: #include sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: #endif // SYMBIAN_MULTIMEDIA_CODEC_API sl@0: sl@0: #include "devvideoplay.h" sl@0: #include "videoplayhwdevice.h" sl@0: #include "devvideointernal.h" sl@0: sl@0: #include sl@0: sl@0: const THwDeviceId KHwDeviceIdVideoDecoder = 1; sl@0: const THwDeviceId KHwDeviceIdVideoPostProcessor = 2; sl@0: sl@0: // sl@0: // CMMFVideoDecodeHwDevice sl@0: // sl@0: EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewL(TUid aUid, MMMFDevVideoPlayProxy& aProxy) sl@0: { sl@0: CMMFVideoDecodeHwDevice* s = reinterpret_cast sl@0: (REComSession::CreateImplementationL(aUid, _FOFF(CMMFVideoDecodeHwDevice,iDtor_ID_Key))); sl@0: s->SetProxy(aProxy); sl@0: return s; sl@0: } sl@0: sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: const TInt KUidMDFVideoDecoderHwDeviceAdapter = 0x102737ED; sl@0: EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewPuAdapterL(const CImplementationInformation& aInfo, MMMFDevVideoPlayProxy& aProxy) sl@0: { sl@0: CMMFVideoDecodeHwDevice* hwdevice = NewL(TUid::Uid(KUidMDFVideoDecoderHwDeviceAdapter), aProxy); sl@0: CleanupStack::PushL(hwdevice); sl@0: sl@0: MDevVideoHwDeviceAdapterSetup* setup = static_cast( sl@0: hwdevice->CustomInterface(TUid::Uid(KUidDevVideoHwDeviceAdapterSetup))); sl@0: sl@0: if (setup!=NULL) sl@0: { sl@0: setup->LoadProcessingUnitL(aInfo); sl@0: } sl@0: CleanupStack::Pop(hwdevice); sl@0: return hwdevice; sl@0: } sl@0: #else sl@0: EXPORT_C CMMFVideoDecodeHwDevice* CMMFVideoDecodeHwDevice::NewPuAdapterL(const CImplementationInformation& /*aInfo*/, MMMFDevVideoPlayProxy& /*aProxy*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: return NULL; sl@0: } sl@0: #endif // SYMBIAN_MULTIMEDIA_CODEC_API sl@0: sl@0: EXPORT_C CMMFVideoDecodeHwDevice::~CMMFVideoDecodeHwDevice() sl@0: { sl@0: REComSession::DestroyedImplementation(iDtor_ID_Key); sl@0: } sl@0: sl@0: EXPORT_C CMMFVideoDecodeHwDevice::CMMFVideoDecodeHwDevice() sl@0: { sl@0: } sl@0: sl@0: sl@0: // sl@0: // CMMFVideoPostProcHwDevice sl@0: // sl@0: EXPORT_C CMMFVideoPostProcHwDevice* CMMFVideoPostProcHwDevice::NewL(TUid aUid, MMMFDevVideoPlayProxy& aProxy) sl@0: { sl@0: CMMFVideoPostProcHwDevice* s = reinterpret_cast sl@0: (REComSession::CreateImplementationL(aUid, _FOFF(CMMFVideoPostProcHwDevice,iDtor_ID_Key))); sl@0: s->SetProxy(aProxy); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CMMFVideoPostProcHwDevice::~CMMFVideoPostProcHwDevice() sl@0: { sl@0: REComSession::DestroyedImplementation(iDtor_ID_Key); sl@0: } sl@0: sl@0: EXPORT_C CMMFVideoPostProcHwDevice::CMMFVideoPostProcHwDevice() sl@0: { sl@0: } sl@0: sl@0: sl@0: EXPORT_C TVideoInputBuffer::TVideoInputBuffer() : sl@0: iData(0,0,0), sl@0: iOptions(0), sl@0: iDecodingTimestamp(0), sl@0: iPresentationTimestamp(0), sl@0: iPreRoll(EFalse), sl@0: iSequenceNumber(0), sl@0: iError(EFalse), sl@0: iUser(NULL) sl@0: { sl@0: } sl@0: sl@0: sl@0: // sl@0: // CPostProcessorInfo sl@0: // sl@0: EXPORT_C CPostProcessorInfo* CPostProcessorInfo::NewL(TUid aUid, sl@0: const TDesC& aManufacturer, sl@0: const TDesC& aIdentifier, sl@0: TVersion aVersion, sl@0: const TArray& aSupportedFormats, sl@0: const TArray& aSupportedCombinations, sl@0: TBool aAccelerated, sl@0: TBool aSupportsDirectDisplay, sl@0: const TYuvToRgbCapabilities& aYuvToRgbCapabilities, sl@0: TUint32 aSupportedRotations, sl@0: TBool aSupportArbitraryScaling, sl@0: const TArray& aSupportedScaleFactors, sl@0: TBool aAntiAliasedScaling, sl@0: const TDesC8& aImplementationSpecificInfo) sl@0: { sl@0: CPostProcessorInfo* s = new(ELeave) CPostProcessorInfo(aUid, sl@0: aVersion, sl@0: aAccelerated, sl@0: aSupportsDirectDisplay, sl@0: aYuvToRgbCapabilities, sl@0: aSupportedRotations, sl@0: aSupportArbitraryScaling, sl@0: aAntiAliasedScaling); sl@0: sl@0: CleanupStack::PushL(s); sl@0: sl@0: s->ConstructL(aManufacturer, sl@0: aIdentifier, sl@0: aSupportedFormats, sl@0: aSupportedCombinations, sl@0: aSupportedScaleFactors, sl@0: aImplementationSpecificInfo); sl@0: sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CPostProcessorInfo::CPostProcessorInfo(TUid aUid, sl@0: TVersion aVersion, sl@0: TBool aAccelerated, sl@0: TBool aSupportDirectDisplay, sl@0: const TYuvToRgbCapabilities& aYuvToRgbCapabilities, sl@0: TUint32 aSupportedRotations, sl@0: TBool aSupportArbitraryScaling, sl@0: TBool aAntiAliasedScaling) : sl@0: iUid(aUid), sl@0: iVersion(aVersion), sl@0: iAccelerated(aAccelerated), sl@0: iSupportDirectDisplay(aSupportDirectDisplay), sl@0: iYuvToRgbCapabilities(aYuvToRgbCapabilities), sl@0: iSupportedRotations(aSupportedRotations), sl@0: iSupportArbitraryScaling(aSupportArbitraryScaling), sl@0: iAntiAliasedScaling(aAntiAliasedScaling), sl@0: iSupportsContentProtected(EFalse) sl@0: { sl@0: iSupportedScreens.Reset(); sl@0: } sl@0: sl@0: void CPostProcessorInfo::ConstructL(const TDesC& aManufacturer, sl@0: const TDesC& aIdentifier, sl@0: const TArray& aSupportedFormats, sl@0: const TArray& aSupportedCombinations, sl@0: const TArray& aSupportedScaleFactors, sl@0: const TDesC8& aImplementationSpecificInfo) sl@0: { sl@0: iManufacturer = aManufacturer.AllocL(); sl@0: iIdentifier = aIdentifier.AllocL(); sl@0: iImplementationSpecificInfo = aImplementationSpecificInfo.AllocL(); sl@0: sl@0: TInt i=0; sl@0: TInt supportedFormatsCount = aSupportedFormats.Count(); sl@0: for (i=0; i& CPostProcessorInfo::SupportedFormats() const sl@0: { sl@0: return iSupportedFormats; sl@0: } sl@0: sl@0: EXPORT_C TBool CPostProcessorInfo::SupportsCombination(TUint32 aCombination) const sl@0: { sl@0: TBool found = EFalse; sl@0: TInt count = iSupportedCombinations.Count(); sl@0: for (TInt i=0; i& CPostProcessorInfo::SupportedCombinations() const sl@0: { sl@0: return iSupportedCombinations; sl@0: } sl@0: sl@0: EXPORT_C TBool CPostProcessorInfo::Accelerated() const sl@0: { sl@0: return iAccelerated; sl@0: } sl@0: sl@0: EXPORT_C TBool CPostProcessorInfo::SupportsDirectDisplay() const sl@0: { sl@0: return iSupportDirectDisplay; sl@0: } sl@0: sl@0: EXPORT_C const TYuvToRgbCapabilities& CPostProcessorInfo::YuvToRgbCapabilities() const sl@0: { sl@0: return iYuvToRgbCapabilities; sl@0: } sl@0: sl@0: EXPORT_C TUint32 CPostProcessorInfo::SupportedRotations() const sl@0: { sl@0: return iSupportedRotations; sl@0: } sl@0: sl@0: EXPORT_C TBool CPostProcessorInfo::SupportsArbitraryScaling() const sl@0: { sl@0: return iSupportArbitraryScaling; sl@0: } sl@0: sl@0: EXPORT_C const RArray& CPostProcessorInfo::SupportedScaleFactors() const sl@0: { sl@0: return iSupportedScaleFactors; sl@0: } sl@0: sl@0: EXPORT_C TBool CPostProcessorInfo::AntiAliasedScaling() const sl@0: { sl@0: return iAntiAliasedScaling; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CPostProcessorInfo::ImplementationSpecificInfo() const sl@0: { sl@0: return *iImplementationSpecificInfo; sl@0: } sl@0: sl@0: EXPORT_C void CPostProcessorInfo::AddSupportedScreenL(TInt aScreenNo) sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT sl@0: iSupportedScreens.AppendL(aScreenNo); sl@0: #else sl@0: aScreenNo = aScreenNo; //Added to remove the warning sl@0: User::Leave(KErrNotSupported); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C void CPostProcessorInfo::GetSupportedScreensL(RArray& aSupportedScreens) const sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT sl@0: aSupportedScreens.Reset(); sl@0: TInt screensCount = iSupportedScreens.Count(); sl@0: for (TInt i = 0; i < screensCount;i++) sl@0: { sl@0: aSupportedScreens.AppendL(iSupportedScreens[i]); sl@0: } sl@0: #else sl@0: aSupportedScreens = aSupportedScreens;//Added to remove the warning sl@0: User::Leave(KErrNotSupported); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C void CPostProcessorInfo::SetSupportsContentProtected(const TBool aSetting) sl@0: { sl@0: iSupportsContentProtected = aSetting; sl@0: } sl@0: sl@0: EXPORT_C TBool CPostProcessorInfo::SupportsContentProtected() const sl@0: { sl@0: return iSupportsContentProtected; sl@0: } sl@0: sl@0: // sl@0: // CVideoDecoderInfo sl@0: // sl@0: EXPORT_C CVideoDecoderInfo* CVideoDecoderInfo::NewL(TUid aUid, sl@0: const TDesC& aManufacturer, sl@0: const TDesC& aIdentifier, sl@0: TVersion aVersion, sl@0: const TArray& aSupportedFormats, sl@0: TBool aAccelerated, sl@0: TBool aSupportsDirectDisplay, sl@0: const TSize& aMaxPictureSize, sl@0: TUint aMaxBitrate, sl@0: const TArray& aMaxPictureRates, sl@0: TBool aSupportsPictureLoss, sl@0: TBool aSupportsSliceLoss, sl@0: const TDesC8& aCodingStandardSpecificInfo, sl@0: const TDesC8& aImplementationSpecificInfo) sl@0: { sl@0: CVideoDecoderInfo* s = new(ELeave) CVideoDecoderInfo(aUid, sl@0: aVersion, sl@0: aAccelerated, sl@0: aSupportsDirectDisplay, sl@0: aMaxPictureSize, sl@0: aMaxBitrate, sl@0: aSupportsPictureLoss, sl@0: aSupportsSliceLoss); sl@0: sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(aManufacturer, aIdentifier, aSupportedFormats, aMaxPictureRates, aCodingStandardSpecificInfo, aImplementationSpecificInfo); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CVideoDecoderInfo::CVideoDecoderInfo(TUid aUid, sl@0: TVersion aVersion, sl@0: TBool aAccelerated, sl@0: TBool aSupportsDirectDisplay, sl@0: const TSize& aMaxPictureSize, sl@0: TUint aMaxBitrate, sl@0: TBool aSupportsPictureLoss, sl@0: TBool aSupportsSliceLoss) : sl@0: iUid(aUid), sl@0: iVersion(aVersion), sl@0: iAccelerated(aAccelerated), sl@0: iSupportsDirectDisplay(aSupportsDirectDisplay), sl@0: iMaxPictureSize(aMaxPictureSize), sl@0: iMaxBitrate(aMaxBitrate), sl@0: iSupportsPictureLoss(aSupportsPictureLoss), sl@0: iSupportsSliceLoss(aSupportsSliceLoss), sl@0: iSupportsContentProtected(EFalse) sl@0: { sl@0: iSupportedScreens.Reset(); sl@0: } sl@0: sl@0: void CVideoDecoderInfo::ConstructL(const TDesC& aManufacturer, sl@0: const TDesC& aIdentifier, sl@0: const TArray& aSupportedFormats, sl@0: const TArray& aMaxPictureRates, sl@0: const TDesC8& aCodingStandardSpecificInfo, sl@0: const TDesC8& aImplementationSpecificInfo) sl@0: { sl@0: iManufacturer = aManufacturer.AllocL(); sl@0: iIdentifier = aIdentifier.AllocL(); sl@0: iCodingStandardSpecificInfo = aCodingStandardSpecificInfo.AllocL(); sl@0: iImplementationSpecificInfo = aImplementationSpecificInfo.AllocL(); sl@0: sl@0: TInt i=0; sl@0: TInt count = aSupportedFormats.Count(); sl@0: for (i=0; i& CVideoDecoderInfo::SupportedFormats() const sl@0: { sl@0: return iSupportedFormats; sl@0: } sl@0: sl@0: EXPORT_C const TDesC& CVideoDecoderInfo::Manufacturer() const sl@0: { sl@0: return *iManufacturer; sl@0: } sl@0: sl@0: EXPORT_C const TDesC& CVideoDecoderInfo::Identifier() const sl@0: { sl@0: return *iIdentifier; sl@0: } sl@0: sl@0: EXPORT_C TVersion CVideoDecoderInfo::Version() const sl@0: { sl@0: return iVersion; sl@0: } sl@0: sl@0: EXPORT_C TUid CVideoDecoderInfo::Uid() const sl@0: { sl@0: return iUid; sl@0: } sl@0: sl@0: EXPORT_C TBool CVideoDecoderInfo::Accelerated() const sl@0: { sl@0: return iAccelerated; sl@0: } sl@0: sl@0: EXPORT_C TBool CVideoDecoderInfo::SupportsDirectDisplay() const sl@0: { sl@0: return iSupportsDirectDisplay; sl@0: } sl@0: sl@0: EXPORT_C const TSize& CVideoDecoderInfo::MaxPictureSize() const sl@0: { sl@0: return iMaxPictureSize; sl@0: } sl@0: sl@0: EXPORT_C TUint CVideoDecoderInfo::MaxBitrate() const sl@0: { sl@0: return iMaxBitrate; sl@0: } sl@0: sl@0: EXPORT_C const RArray& CVideoDecoderInfo::MaxPictureRates() const sl@0: { sl@0: return iMaxPictureRates; sl@0: } sl@0: sl@0: EXPORT_C TBool CVideoDecoderInfo::SupportsPictureLoss() const sl@0: { sl@0: return iSupportsPictureLoss; sl@0: } sl@0: sl@0: EXPORT_C TBool CVideoDecoderInfo::SupportsSliceLoss() const sl@0: { sl@0: return iSupportsSliceLoss; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CVideoDecoderInfo::CodingStandardSpecificInfo() const sl@0: { sl@0: return *iCodingStandardSpecificInfo; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CVideoDecoderInfo::ImplementationSpecificInfo() const sl@0: { sl@0: return *iImplementationSpecificInfo; sl@0: } sl@0: sl@0: EXPORT_C void CVideoDecoderInfo::AddSupportedScreenL(TInt aScreenNo) sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT sl@0: iSupportedScreens.AppendL(aScreenNo); sl@0: #else sl@0: aScreenNo = aScreenNo; //Added to remove the warning. sl@0: User::Leave(KErrNotSupported); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C void CVideoDecoderInfo::GetSupportedScreensL(RArray& aSupportedScreens) const sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT sl@0: aSupportedScreens.Reset(); sl@0: TInt screensCount = iSupportedScreens.Count(); sl@0: for (TInt i = 0; i < screensCount;i++) sl@0: { sl@0: aSupportedScreens.AppendL(iSupportedScreens[i]); sl@0: } sl@0: #else sl@0: aSupportedScreens = aSupportedScreens;//Added to remove the warning sl@0: User::Leave(KErrNotSupported); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C void CVideoDecoderInfo::SetSupportsContentProtected(const TBool aSetting) sl@0: { sl@0: iSupportsContentProtected = aSetting; sl@0: } sl@0: sl@0: EXPORT_C TBool CVideoDecoderInfo::SupportsContentProtected() const sl@0: { sl@0: return iSupportsContentProtected; sl@0: } sl@0: sl@0: // sl@0: // CMMFDevVideoPlay sl@0: // sl@0: EXPORT_C CMMFDevVideoPlay* CMMFDevVideoPlay::NewL(MMMFDevVideoPlayObserver& aObserver) sl@0: { sl@0: return new(ELeave) CMMFDevVideoPlay(aObserver); sl@0: } sl@0: sl@0: CMMFDevVideoPlay::CMMFDevVideoPlay(MMMFDevVideoPlayObserver& aObserver) : sl@0: iObserver(aObserver), sl@0: iInitializationState(ENotInitialized), sl@0: iVideoPictureQue(_FOFF(TVideoPicture,iLink)), sl@0: iVideoPictureQueIter(iVideoPictureQue) sl@0: { sl@0: } sl@0: sl@0: EXPORT_C CMMFDevVideoPlay::~CMMFDevVideoPlay() sl@0: { sl@0: delete iVideoDecodeHwDevice; sl@0: delete iVideoPostProcHwDevice; sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: iPuImplementations.ResetAndDestroy(); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFDevVideoPlay::FindCommonFormat(const TArray& aFormats1, const TArray& aFormats2, TUncompressedVideoFormat& aCommonFormat) sl@0: { sl@0: // Find the least expensive format common to both arrays. sl@0: // Expense is proportional to array position, so do search twice, using each array as a base sl@0: sl@0: TInt formats1Position; sl@0: TInt formats2Position; sl@0: sl@0: const TUncompressedVideoFormat* firstTry = NULL; sl@0: TInt firstTryCumulativePosition = -1; sl@0: const TUncompressedVideoFormat* secondTry = NULL; sl@0: TInt secondTryCumulativePosition = -1; sl@0: sl@0: TInt formats1Count = aFormats1.Count(); sl@0: TInt formats2Count = aFormats2.Count(); sl@0: sl@0: for (formats1Position=0; formats1Position < formats1Count; formats1Position++) sl@0: { sl@0: const TUncompressedVideoFormat& format1 = aFormats1[formats1Position]; sl@0: sl@0: for (formats2Position=0; formats2Position < formats2Count; formats2Position++) sl@0: { sl@0: const TUncompressedVideoFormat& format2 = aFormats2[formats2Position]; sl@0: if (format1 == format2) sl@0: { sl@0: firstTry = &format1; sl@0: firstTryCumulativePosition = formats1Position+formats2Position; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (firstTry != NULL) sl@0: break; sl@0: } sl@0: sl@0: for (formats2Position=0; formats2Position < formats2Count; formats2Position++) sl@0: { sl@0: const TUncompressedVideoFormat& format2 = aFormats2[formats2Position]; sl@0: sl@0: for (formats1Position=0; formats1Position < formats1Count; formats1Position++) sl@0: { sl@0: const TUncompressedVideoFormat& format1 = aFormats1[formats1Position]; sl@0: if (format1 == format2) sl@0: { sl@0: secondTry = &format1; sl@0: secondTryCumulativePosition = formats1Position+formats2Position; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (secondTry != NULL) sl@0: break; sl@0: } sl@0: sl@0: TBool found = EFalse; sl@0: sl@0: if (firstTry!=NULL) sl@0: { sl@0: ASSERT(secondTry!=NULL); sl@0: found = ETrue; sl@0: // Work out which is cheaper sl@0: if (firstTryCumulativePosition <= secondTryCumulativePosition) sl@0: { sl@0: aCommonFormat = *firstTry; sl@0: } sl@0: else sl@0: { sl@0: aCommonFormat = *secondTry; sl@0: } sl@0: } sl@0: sl@0: return found; sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::FindDecodersL(const TDesC8& aMimeType, TUint32 aPostProcType, RArray& aDecoders, TBool aExactMatch) sl@0: { sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: // find PU based plugins sl@0: RImplInfoPtrArray codecPlugins; sl@0: CleanupResetAndDestroyPushL(codecPlugins); sl@0: DevVideoUtilities::FindVideoDecoderPluginsL(aMimeType, codecPlugins); sl@0: sl@0: aDecoders.Reset(); sl@0: for (TInt i = 0; i < codecPlugins.Count();i++) sl@0: { sl@0: aDecoders.AppendL(codecPlugins[i]->ImplementationUid()); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&codecPlugins); sl@0: #endif // SYMBIAN_MULTIMEDIA_CODEC_API sl@0: RImplInfoPtrArray plugins; sl@0: CleanupResetAndDestroyPushL(plugins); sl@0: sl@0: MmPluginUtils::FindImplementationsL(KUidDevVideoDecoderHwDevice, plugins); sl@0: sl@0: DevVideoUtilities::SelectPluginBasedOnMatchType(aMimeType, plugins); sl@0: sl@0: DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(plugins, aPostProcType, aDecoders); sl@0: sl@0: // Perform the extra processing required if an exact match was requested sl@0: if (aExactMatch) sl@0: { sl@0: // We now need to go through each of the plugins returned (which may have been matched using sl@0: // a wildcard), instantiate each one, and perform an exact mime-type match. sl@0: // Any plugins that don't support the desired mime type exactly will be removed from aDecoders. sl@0: CCompressedVideoFormat* format = CCompressedVideoFormat::NewL(aMimeType); sl@0: CleanupStack::PushL(format); sl@0: sl@0: for (TInt i=aDecoders.Count()-1; i>=0; i--) sl@0: { sl@0: TUid pluginUid = aDecoders[i]; sl@0: CVideoDecoderInfo* info = NULL; sl@0: TRAPD(err, info = VideoDecoderInfoLC(pluginUid); CleanupStack::Pop(info);); sl@0: if (err == KErrNone) sl@0: { sl@0: if (!info->SupportsFormat(*format)) sl@0: { sl@0: // The decoder doesn't support the format, so remove it from the list sl@0: aDecoders.Remove(i); sl@0: } sl@0: delete info; sl@0: } sl@0: else if (err==KErrNotFound) sl@0: { sl@0: // we have a bogus UID so remove it from the list sl@0: aDecoders.Remove(i); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(format); sl@0: } sl@0: sl@0: // Leave if we didn't find anything. sl@0: if (aDecoders.Count() == 0) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&plugins); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::FindPostProcessorsL(TUint32 aPostProcType, RArray& aPostProcessors) sl@0: { sl@0: RImplInfoPtrArray plugins; sl@0: CleanupResetAndDestroyPushL(plugins); sl@0: sl@0: MmPluginUtils::FindImplementationsL(KUidDevVideoPostProcessorHwDevice, plugins); sl@0: sl@0: DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(plugins, aPostProcType, aPostProcessors); sl@0: sl@0: // Leave if we didn't find anything. sl@0: if (aPostProcessors.Count() == 0) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&plugins); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetDecoderListL(RArray& aDecoders) sl@0: { sl@0: RImplInfoPtrArray plugins; sl@0: CleanupResetAndDestroyPushL(plugins); sl@0: sl@0: MmPluginUtils::FindImplementationsL(KUidDevVideoDecoderHwDevice, plugins); sl@0: sl@0: aDecoders.Reset(); sl@0: sl@0: TInt count = plugins.Count(); sl@0: for (TInt i=0; iImplementationUid())); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&plugins); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetPostProcessorListL(RArray& aPostProcessors) sl@0: { sl@0: RImplInfoPtrArray plugins; sl@0: CleanupResetAndDestroyPushL(plugins); sl@0: sl@0: MmPluginUtils::FindImplementationsL(KUidDevVideoPostProcessorHwDevice, plugins); sl@0: sl@0: aPostProcessors.Reset(); sl@0: sl@0: TInt count = plugins.Count(); sl@0: for (TInt i=0; iImplementationUid())); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&plugins); sl@0: } sl@0: sl@0: EXPORT_C CVideoDecoderInfo* CMMFDevVideoPlay::VideoDecoderInfoLC(TUid aVideoDecoder) sl@0: { sl@0: CMMFVideoDecodeHwDevice* dev = CreateDecoderL(aVideoDecoder); sl@0: CleanupStack::PushL(dev); sl@0: CVideoDecoderInfo* info = dev->VideoDecoderInfoLC(); sl@0: CleanupStack::Pop(info); sl@0: CleanupStack::PopAndDestroy(dev); sl@0: CleanupStack::PushL(info); sl@0: return info; sl@0: } sl@0: sl@0: EXPORT_C CPostProcessorInfo* CMMFDevVideoPlay::PostProcessorInfoLC(TUid aPostProcessor) sl@0: { sl@0: CMMFVideoPlayHwDevice* device = NULL; sl@0: sl@0: // Determine whether the aPostProcessor uid is for a decoder or a postprocessor hw device sl@0: RArray array; sl@0: CleanupClosePushL(array); sl@0: sl@0: GetDecoderListL(array); sl@0: TInt position = array.Find(aPostProcessor); sl@0: if (position == KErrNotFound) sl@0: { sl@0: array.Reset(); sl@0: GetPostProcessorListL(array); sl@0: position = array.Find(aPostProcessor); sl@0: if (position != KErrNotFound) sl@0: { sl@0: // uid is a post processor sl@0: device = static_cast(CMMFVideoPostProcHwDevice::NewL(aPostProcessor, *this)); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // uid is a decoder sl@0: device = static_cast(CMMFVideoDecodeHwDevice::NewL(aPostProcessor, *this)); sl@0: } sl@0: CleanupStack::PopAndDestroy(&array); sl@0: sl@0: CPostProcessorInfo* info = NULL; sl@0: if (device) sl@0: { sl@0: CleanupStack::PushL(device); sl@0: info = device->PostProcessorInfoLC(); sl@0: CleanupStack::Pop(info); sl@0: CleanupStack::PopAndDestroy(device); sl@0: CleanupStack::PushL(info); sl@0: } sl@0: return info; sl@0: } sl@0: sl@0: EXPORT_C THwDeviceId CMMFDevVideoPlay::SelectDecoderL(TUid aDecoder) sl@0: { sl@0: // This method can only be called before InitializeL() has been called. sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: delete iVideoDecodeHwDevice; sl@0: iVideoDecodeHwDevice = NULL; sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: iVideoDecodeHwDevice = CreateDecoderL(aDecoder); sl@0: #else sl@0: iVideoDecodeHwDevice = CMMFVideoDecodeHwDevice::NewL(aDecoder, *this); sl@0: #endif // SYMBIAN_MULTIMEDIA_CODEC_API sl@0: return KHwDeviceIdVideoDecoder; sl@0: } sl@0: sl@0: EXPORT_C THwDeviceId CMMFDevVideoPlay::SelectPostProcessorL(TUid aPostProcessor) sl@0: { sl@0: // This method can only be called before InitializeL() has been called. sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: delete iVideoPostProcHwDevice; sl@0: iVideoPostProcHwDevice = NULL; sl@0: iVideoPostProcHwDevice = CMMFVideoPostProcHwDevice::NewL(aPostProcessor, *this); sl@0: sl@0: return KHwDeviceIdVideoPostProcessor; sl@0: } sl@0: sl@0: EXPORT_C TVideoPictureHeader* CMMFDevVideoPlay::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation, TVideoInputBuffer* aDataUnit) sl@0: { sl@0: return VideoDecodeHwDevice().GetHeaderInformationL(aDataUnitType, aDataUnitEncapsulation, aDataUnit); sl@0: } sl@0: sl@0: /** sl@0: Configures the Decoder using header information known by the client. sl@0: @param "aVideoPictureHeader" "Header information to configure the decoder with" sl@0: @leave "The method will leave if an error occurs. Running out of data is not considered an error, sl@0: as described above. sl@0: @pre "This method can only be called before the API has been initialized with Initialize()." sl@0: */ sl@0: EXPORT_C void CMMFDevVideoPlay::ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice().ConfigureDecoderL(aVideoPictureHeader); sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::ReturnHeader(TVideoPictureHeader* aHeader) sl@0: { sl@0: // This method can only be called before InitializeL() sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice().ReturnHeader(aHeader); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetInputFormatL(THwDeviceId aHwDevice, const TUncompressedVideoFormat& aFormat) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoPostProcHwDevice(aHwDevice).SetInputFormatL(aFormat); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetInputFormatL(THwDeviceId aHwDevice, const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice(aHwDevice).SetInputFormatL(aFormat, aDataUnitType, aEncapsulation, aDataInOrder); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetOutputFormatListL(THwDeviceId aHwDevice, RArray& aFormats) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).GetOutputFormatListL(aFormats); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetOutputFormatL(THwDeviceId aHwDevice, const TUncompressedVideoFormat &aFormat) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetOutputFormatL(aFormat); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetClockSource(MMMFClockSource* aClock) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: ASSERT(aClock); sl@0: sl@0: // Make sure we have at least one of the hwdevices set up sl@0: __ASSERT_ALWAYS((iVideoDecodeHwDevice||iVideoPostProcHwDevice), DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: sl@0: // Set the clock source on both hw devices. sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->SetClockSource(aClock); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->SetClockSource(aClock); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetVideoDestScreenL(TBool aScreen) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: // Pass on to the rendering hw device sl@0: RenderingHwDevice().SetVideoDestScreenL(aScreen); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SynchronizeDecoding(TBool aSynchronize) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice().SynchronizeDecoding(aSynchronize); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetBufferOptionsL(const TBufferOptions& aOptions) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice().SetBufferOptionsL(aOptions); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetBufferOptions(TBufferOptions& aOptions) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice().GetBufferOptions(aOptions); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams) sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: VideoDecodeHwDevice().SetHrdVbvSpec(aHrdVbvSpec, aHrdVbvParams); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetPostProcessTypesL(THwDeviceId aHwDevice, TUint32 aPostProcCombination) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetPostProcessTypesL(aPostProcCombination); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetInputCropOptionsL(THwDeviceId aHwDevice, const TRect& aRect) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetInputCropOptionsL(aRect); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetYuvToRgbOptionsL(THwDeviceId aHwDevice, const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetYuvToRgbOptionsL(aOptions, aYuvFormat, aRgbFormat); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetYuvToRgbOptionsL(THwDeviceId aHwDevice, const TYuvToRgbOptions& aOptions) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetYuvToRgbOptionsL(aOptions); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetRotateOptionsL(THwDeviceId aHwDevice, TRotationType aRotationType) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetRotateOptionsL(aRotationType); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetScaleOptionsL(THwDeviceId aHwDevice, const TSize& aTargetSize, TBool aAntiAliasFiltering) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetScaleOptionsL(aTargetSize, aAntiAliasFiltering); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetOutputCropOptionsL(THwDeviceId aHwDevice, const TRect& aRect) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetOutputCropOptionsL(aRect); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetPostProcSpecificOptionsL(THwDeviceId aHwDevice, const TDesC8& aOptions) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: sl@0: VideoPlayHwDevice(aHwDevice).SetPostProcSpecificOptionsL(aOptions); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Initialize() sl@0: { sl@0: CheckInitializationState(ENotInitialized); sl@0: sl@0: // First introduce the two plugins to each other sl@0: ConnectPlugins(); sl@0: sl@0: // Next initialize the first hwdevice in the chain sl@0: if (iVideoDecodeHwDevice) sl@0: { sl@0: iInitializationState = EInitializing; sl@0: iVideoDecodeHwDevice->Initialize(); sl@0: } sl@0: else if (iVideoPostProcHwDevice) sl@0: { sl@0: iInitializationState = EInitializing; sl@0: iVideoPostProcHwDevice->Initialize(); sl@0: } sl@0: else sl@0: { sl@0: // No hwdevice to initialize so panic sl@0: DevVideoPanic(EDevVideoPanicPreConditionViolation); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().StartDirectScreenAccessL(aVideoRect, aScreenDevice, aClipRegion); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetScreenClipRegion(const TRegion& aRegion) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().SetScreenClipRegion(aRegion); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetPauseOnClipFail(TBool aPause) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().SetPauseOnClipFail(aPause); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::AbortDirectScreenAccess() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().AbortDirectScreenAccess(); sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFDevVideoPlay::IsPlaying() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return RenderingHwDevice().IsPlaying(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Redraw() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().Redraw(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Start() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->Start(); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->Start(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Stop() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->Stop(); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->Stop(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Pause() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->Pause(); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->Pause(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Resume() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->Resume(); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->Resume(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->SetPosition(aPlaybackPosition); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->SetPosition(aPlaybackPosition); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::FreezePicture(const TTimeIntervalMicroSeconds& aPlaybackPosition) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().FreezePicture(aPlaybackPosition); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::ReleaseFreeze(const TTimeIntervalMicroSeconds& aPlaybackPosition) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().ReleaseFreeze(aPlaybackPosition); sl@0: } sl@0: sl@0: EXPORT_C TTimeIntervalMicroSeconds CMMFDevVideoPlay::DecodingPosition() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return VideoDecodeHwDevice().DecodingPosition(); sl@0: } sl@0: sl@0: EXPORT_C TTimeIntervalMicroSeconds CMMFDevVideoPlay::PlaybackPosition() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return RenderingHwDevice().PlaybackPosition(); sl@0: } sl@0: sl@0: EXPORT_C TUint CMMFDevVideoPlay::PreDecoderBufferBytes() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return VideoDecodeHwDevice().PreDecoderBufferBytes(); sl@0: } sl@0: sl@0: EXPORT_C TUint CMMFDevVideoPlay::PictureBufferBytes() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return RenderingHwDevice().PictureBufferBytes(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetPictureCounters(TPictureCounters& aCounters) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: TPictureCounters decoderPictureCounters; sl@0: TPictureCounters postProcPictureCounters; sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->GetPictureCounters(decoderPictureCounters); sl@0: sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->GetPictureCounters(postProcPictureCounters); sl@0: sl@0: sl@0: // Only the decoder (if any) knows the number of pictures decoded sl@0: aCounters.iPicturesDecoded = decoderPictureCounters.iPicturesDecoded; sl@0: sl@0: // Pictures skipped is sum of pictures skipped from decoder and postproc sl@0: aCounters.iPicturesSkipped = decoderPictureCounters.iPicturesSkipped sl@0: + postProcPictureCounters.iPicturesSkipped; sl@0: sl@0: // Ask last plugin in chain for number of pictures displayed sl@0: if (iVideoPostProcHwDevice) sl@0: aCounters.iPicturesDisplayed = postProcPictureCounters.iPicturesDisplayed; sl@0: else sl@0: aCounters.iPicturesDisplayed = decoderPictureCounters.iPicturesDisplayed; sl@0: sl@0: // Ask first plugin in chain for number of input pictures sl@0: if (iVideoDecodeHwDevice) sl@0: aCounters.iTotalPictures = decoderPictureCounters.iTotalPictures; sl@0: else sl@0: aCounters.iTotalPictures = postProcPictureCounters.iTotalPictures; sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetBitstreamCounters(TBitstreamCounters& aCounters) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: VideoDecodeHwDevice().GetBitstreamCounters(aCounters); sl@0: } sl@0: sl@0: EXPORT_C TUint CMMFDevVideoPlay::NumFreeBuffers() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return VideoDecodeHwDevice().NumFreeBuffers(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::SetComplexityLevel(THwDeviceId aHwDevice, TUint aLevel) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: VideoPlayHwDevice(aHwDevice).SetComplexityLevel(aLevel); sl@0: } sl@0: sl@0: EXPORT_C TUint CMMFDevVideoPlay::NumComplexityLevels(THwDeviceId aHwDevice) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return VideoPlayHwDevice(aHwDevice).NumComplexityLevels(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetComplexityLevelInfo(THwDeviceId aHwDevice, TUint aLevel, TComplexityLevelInfo& aInfo) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: VideoPlayHwDevice(aHwDevice).GetComplexityLevelInfo(aLevel, aInfo); sl@0: } sl@0: sl@0: EXPORT_C TVideoInputBuffer* CMMFDevVideoPlay::GetBufferL(TUint aBufferSize) sl@0: { sl@0: return VideoDecodeHwDevice().GetBufferL(aBufferSize); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::WriteCodedDataL(TVideoInputBuffer* aBuffer) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: VideoDecodeHwDevice().WriteCodedDataL(aBuffer); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::WritePictureL(TVideoPicture* aPicture) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: VideoPostProcHwDevice().WritePictureL(aPicture); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::InputEnd() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: //If decoder and post-processor exist,InputEnd() of decoder is issued sl@0: //and wait for reply from it before issuing PostProcessor InputEnd() sl@0: //iIsDecodeComplete is EFalse, until decoder responds sl@0: iIsDecodeComplete=EFalse; sl@0: sl@0: if (iVideoDecodeHwDevice) sl@0: { sl@0: iVideoDecodeHwDevice->InputEnd(); sl@0: return; sl@0: } sl@0: if (iVideoPostProcHwDevice) sl@0: { sl@0: iVideoPostProcHwDevice->InputEnd(); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetNewPictureInfo(TUint& aNumPictures, TTimeIntervalMicroSeconds& aEarliestTimestamp, TTimeIntervalMicroSeconds& aLatestTimestamp) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: aNumPictures = iNumberOfVideoPictures; sl@0: if (iNumberOfVideoPictures > 0) sl@0: { sl@0: aEarliestTimestamp = iVideoPictureQue.First()->iTimestamp; sl@0: aLatestTimestamp = iVideoPictureQue.Last()->iTimestamp; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TVideoPicture* CMMFDevVideoPlay::NextPictureL() sl@0: { sl@0: sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: if (iNumberOfVideoPictures == 0) sl@0: return NULL; sl@0: sl@0: TVideoPicture* picture = iVideoPictureQue.First(); sl@0: sl@0: // Remove the picture from the list sl@0: picture->iLink.Deque(); sl@0: iNumberOfVideoPictures--; sl@0: sl@0: return picture; sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::ReturnPicture(TVideoPicture* aPicture) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: sl@0: // Return the picture to the hwdevice sl@0: RenderingHwDevice().ReturnPicture(aPicture); sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFDevVideoPlay::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: return RenderingHwDevice().GetSnapshotL(aPictureData, aFormat); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().GetTimedSnapshotL(aPictureData, aFormat, aPresentationTimestamp); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().GetTimedSnapshotL(aPictureData, aFormat, aPictureId); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::CancelTimedSnapshot() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().CancelTimedSnapshot(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::GetSupportedSnapshotFormatsL(RArray& aFormats) sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: RenderingHwDevice().GetSupportedSnapshotFormatsL(aFormats); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::CommitL() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->CommitL(); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->CommitL(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFDevVideoPlay::Revert() sl@0: { sl@0: CheckInitializationState(EInitialized); sl@0: if (iVideoDecodeHwDevice) sl@0: iVideoDecodeHwDevice->Revert(); sl@0: if (iVideoPostProcHwDevice) sl@0: iVideoPostProcHwDevice->Revert(); sl@0: } sl@0: sl@0: EXPORT_C TAny* CMMFDevVideoPlay::CustomInterface(THwDeviceId aHwDevice, TUid aInterface) sl@0: { sl@0: CheckInitializationState(ENotInitialized|EInitialized); sl@0: return VideoHwDevice(aHwDevice).CustomInterface(aInterface); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppNewPicture(TVideoPicture* aPicture) sl@0: { sl@0: iVideoPictureQue.AddLast(*aPicture); sl@0: iNumberOfVideoPictures++; sl@0: sl@0: iObserver.MdvpoNewPictures(); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppNewBuffers() sl@0: { sl@0: iObserver.MdvpoNewBuffers(); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppReturnPicture(TVideoPicture* aPicture) sl@0: { sl@0: iObserver.MdvpoReturnPicture(aPicture); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppSupplementalInformation(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp, const TPictureId& aPictureId) sl@0: { sl@0: iObserver.MdvpoSupplementalInformation(aData, aTimestamp, aPictureId); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppPictureLoss() sl@0: { sl@0: iObserver.MdvpoPictureLoss(); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppPictureLoss(const TArray& aPictures) sl@0: { sl@0: iObserver.MdvpoPictureLoss(aPictures); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppSliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture) sl@0: { sl@0: iObserver.MdvpoSliceLoss(aFirstMacroblock, aNumMacroblocks, aPicture); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppReferencePictureSelection(const TDesC8& aSelectionData) sl@0: { sl@0: iObserver.MdvpoReferencePictureSelection(aSelectionData); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppTimedSnapshotComplete(TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& aPresentationTimestamp, const TPictureId& aPictureId) sl@0: { sl@0: iObserver.MdvpoTimedSnapshotComplete(aError, aPictureData, aPresentationTimestamp, aPictureId); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppFatalError(CMMFVideoHwDevice* aDevice, TInt aError) sl@0: { sl@0: // Make sure the other plugin gets stopped sl@0: __ASSERT_DEBUG((aDevice!=NULL) && ((aDevice==iVideoDecodeHwDevice) || (aDevice==iVideoPostProcHwDevice)), DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: if ((aDevice == iVideoDecodeHwDevice) && (iVideoPostProcHwDevice)) sl@0: iVideoPostProcHwDevice->Stop(); sl@0: else if ((aDevice == iVideoPostProcHwDevice) && (iVideoDecodeHwDevice)) sl@0: iVideoDecodeHwDevice->Stop(); sl@0: sl@0: // Place the object in the "initialization failed" state to prevent any more method calls sl@0: // This state is purely internal so this is ok. sl@0: iInitializationState = EInitializationFailed; sl@0: sl@0: iObserver.MdvpoFatalError(aError); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::MdvppInitializeComplete(CMMFVideoHwDevice* aDevice, TInt aError) sl@0: { sl@0: if (aDevice == iVideoDecodeHwDevice) sl@0: { sl@0: HandleDecodeInitializeComplete(aError); sl@0: } sl@0: else if (aDevice == iVideoPostProcHwDevice) sl@0: { sl@0: HandlePostProcInitializeComplete(aError); sl@0: } sl@0: else sl@0: {// We've been given a random pointer back! sl@0: DevVideoPanic(EDevVideoPanicPreConditionViolation); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CMMFDevVideoPlay::HandleDecodeInitializeComplete(TInt aError) sl@0: { sl@0: // Make sure we are in the correct state sl@0: __ASSERT_ALWAYS(iInitializationState==EInitializing, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: sl@0: if (aError == KErrNone) sl@0: { sl@0: // If we have a post processor, initialize that. Otherwise, we're initialized. sl@0: if (iVideoPostProcHwDevice) sl@0: { sl@0: iVideoPostProcHwDevice->Initialize(); sl@0: // Now wait for the next callback sl@0: } sl@0: else sl@0: { sl@0: iInitializationState = EInitialized; sl@0: iObserver.MdvpoInitComplete(KErrNone); sl@0: } sl@0: } sl@0: else sl@0: {//aError sl@0: iInitializationState = EInitializationFailed; sl@0: iObserver.MdvpoInitComplete(aError); sl@0: } sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::HandlePostProcInitializeComplete(TInt aError) sl@0: { sl@0: // Make sure we are in the correct state sl@0: __ASSERT_ALWAYS(iInitializationState==EInitializing, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: sl@0: if (aError == KErrNone) sl@0: { sl@0: // We're now fully initialized sl@0: iInitializationState = EInitialized; sl@0: iObserver.MdvpoInitComplete(KErrNone); sl@0: } sl@0: else sl@0: {//aError sl@0: iInitializationState = EInitializationFailed; sl@0: iObserver.MdvpoInitComplete(aError); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CMMFDevVideoPlay::MdvppStreamEnd() sl@0: { sl@0: // This method must be called the same number of times as the number of plugins we have sl@0: // before we call iObserver.MdvpoStreamEnd(). sl@0: iNumberOfMdvppStreamEndCallbacks++; sl@0: sl@0: TUint numberOfPlugins = 0; sl@0: if (iVideoDecodeHwDevice && !iIsDecodeComplete) sl@0: { sl@0: iIsDecodeComplete = ETrue; sl@0: if(iVideoPostProcHwDevice) sl@0: { sl@0: iVideoPostProcHwDevice->InputEnd(); sl@0: return; sl@0: } sl@0: } sl@0: sl@0: ASSERT(!iVideoDecodeHwDevice||iIsDecodeComplete); sl@0: if(iVideoDecodeHwDevice) sl@0: { sl@0: numberOfPlugins++; sl@0: } sl@0: sl@0: if (iVideoPostProcHwDevice) sl@0: { sl@0: numberOfPlugins++; sl@0: } sl@0: sl@0: if (iNumberOfMdvppStreamEndCallbacks == numberOfPlugins) sl@0: { sl@0: // We've received the correct number of callbacks so signal the client sl@0: iNumberOfMdvppStreamEndCallbacks = 0; sl@0: iObserver.MdvpoStreamEnd(); sl@0: } sl@0: // else wait for the next plugin to call back sl@0: } sl@0: sl@0: CMMFVideoPlayHwDevice& CMMFDevVideoPlay::VideoPlayHwDevice(THwDeviceId aHwDevice) const sl@0: { sl@0: if (aHwDevice == KHwDeviceIdVideoDecoder) sl@0: { sl@0: __ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: return *iVideoDecodeHwDevice; sl@0: } sl@0: else if (aHwDevice == KHwDeviceIdVideoPostProcessor) sl@0: { sl@0: __ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: return *iVideoPostProcHwDevice; sl@0: } sl@0: else sl@0: { sl@0: DevVideoPanic(EDevVideoPanicInvalidHwDeviceId); sl@0: // The following is unreachable sl@0: CMMFVideoPlayHwDevice* ret = NULL; sl@0: return *ret; sl@0: } sl@0: } sl@0: sl@0: CMMFVideoPlayHwDevice& CMMFDevVideoPlay::RenderingHwDevice() const sl@0: { sl@0: // Return the last plugin in the chain sl@0: // - the postprocessor if available, otherwise the videodecoder sl@0: if (iVideoPostProcHwDevice) sl@0: return *iVideoPostProcHwDevice; sl@0: else if (iVideoDecodeHwDevice) sl@0: return *iVideoDecodeHwDevice; sl@0: else sl@0: { sl@0: DevVideoPanic(EDevVideoPanicPreConditionViolation); sl@0: // The following is unreachable sl@0: CMMFVideoPlayHwDevice* ret = NULL; sl@0: return *ret; sl@0: } sl@0: } sl@0: sl@0: sl@0: CMMFVideoDecodeHwDevice& CMMFDevVideoPlay::VideoDecodeHwDevice(THwDeviceId aHwDevice) const sl@0: { sl@0: if (aHwDevice == KHwDeviceIdVideoDecoder) sl@0: { sl@0: __ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: return *iVideoDecodeHwDevice; sl@0: } sl@0: else sl@0: { sl@0: DevVideoPanic(EDevVideoPanicInvalidHwDeviceId); sl@0: // The following is unreachable sl@0: CMMFVideoDecodeHwDevice* ret = NULL; sl@0: return *ret; sl@0: } sl@0: } sl@0: sl@0: CMMFVideoPostProcHwDevice& CMMFDevVideoPlay::VideoPostProcHwDevice(THwDeviceId aHwDevice) const sl@0: { sl@0: if (aHwDevice == KHwDeviceIdVideoPostProcessor) sl@0: { sl@0: __ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: return *iVideoPostProcHwDevice; sl@0: } sl@0: else sl@0: { sl@0: DevVideoPanic(EDevVideoPanicInvalidHwDeviceId); sl@0: // The following is unreachable sl@0: CMMFVideoPostProcHwDevice* ret = NULL; sl@0: return *ret; sl@0: } sl@0: } sl@0: sl@0: CMMFVideoDecodeHwDevice& CMMFDevVideoPlay::VideoDecodeHwDevice() const sl@0: { sl@0: return VideoDecodeHwDevice(KHwDeviceIdVideoDecoder); sl@0: } sl@0: sl@0: CMMFVideoPostProcHwDevice& CMMFDevVideoPlay::VideoPostProcHwDevice() const sl@0: { sl@0: return VideoPostProcHwDevice(KHwDeviceIdVideoPostProcessor); sl@0: } sl@0: sl@0: CMMFVideoHwDevice& CMMFDevVideoPlay::VideoHwDevice(THwDeviceId aHwDevice) const sl@0: { sl@0: if (aHwDevice == KHwDeviceIdVideoPostProcessor) sl@0: { sl@0: __ASSERT_ALWAYS(iVideoPostProcHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: return *iVideoPostProcHwDevice; sl@0: } sl@0: else if (aHwDevice == KHwDeviceIdVideoDecoder) sl@0: { sl@0: __ASSERT_ALWAYS(iVideoDecodeHwDevice, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: return *iVideoDecodeHwDevice; sl@0: } sl@0: else sl@0: { sl@0: DevVideoPanic(EDevVideoPanicInvalidHwDeviceId); sl@0: // The following is unreachable sl@0: CMMFVideoHwDevice* ret = NULL; sl@0: return *ret; sl@0: } sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::CheckInitializationState(TUint aExpected) sl@0: { sl@0: __ASSERT_ALWAYS(iInitializationState&aExpected, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: } sl@0: sl@0: void CMMFDevVideoPlay::ConnectPlugins() sl@0: { sl@0: __ASSERT_ALWAYS((iVideoDecodeHwDevice||iVideoPostProcHwDevice), DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: if (iVideoDecodeHwDevice && iVideoPostProcHwDevice) sl@0: { sl@0: iVideoDecodeHwDevice->SetOutputDevice(iVideoPostProcHwDevice); sl@0: iVideoPostProcHwDevice->SetInputDevice(iVideoDecodeHwDevice); sl@0: } sl@0: } sl@0: sl@0: CMMFVideoDecodeHwDevice* CMMFDevVideoPlay::CreateDecoderL(TUid aDecoder) sl@0: { sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: // need to check whether we've been given a PU sl@0: if (!iPuListCreated) sl@0: { sl@0: DevVideoUtilities::CreatePuListL(iPuImplementations); sl@0: iPuListCreated = ETrue; sl@0: } sl@0: const CImplementationInformation* info = DevVideoUtilities::FindPu(iPuImplementations, aDecoder); sl@0: sl@0: if (!info) sl@0: { sl@0: return CMMFVideoDecodeHwDevice::NewL(aDecoder, *this); sl@0: } sl@0: else sl@0: { sl@0: return CMMFVideoDecodeHwDevice::NewPuAdapterL(*info, *this); sl@0: } sl@0: #else sl@0: return CMMFVideoDecodeHwDevice::NewL(aDecoder, *this); sl@0: #endif // SYMBIAN_MULTIMEDIA_CODEC_API sl@0: }