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 "devvideointernal.h" sl@0: #ifdef SYMBIAN_MULTIMEDIA_CODEC_API sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "videoplayhwdevice.h" sl@0: sl@0: void DevVideoUtilities::FindVideoDecoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray) sl@0: { sl@0: CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC(); sl@0: customMatchData->SetMatchType(EMatchInputDataFormat); sl@0: customMatchData->SetImplementationType(TUid::Uid(KUidVideoDecoder)); sl@0: // string value of the input source data sl@0: customMatchData->SetInputDataL(aMimeType); sl@0: sl@0: HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data" sl@0: MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation)); sl@0: CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData sl@0: } sl@0: sl@0: sl@0: void DevVideoUtilities::FindVideoEncoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray) sl@0: { sl@0: CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC(); sl@0: customMatchData->SetMatchType(EMatchOutputDataFormat); sl@0: customMatchData->SetImplementationType(TUid::Uid(KUidVideoEncoder)); sl@0: // string value of the input source data sl@0: customMatchData->SetOutputDataL(aMimeType); sl@0: sl@0: HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data" sl@0: MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation)); sl@0: CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData sl@0: } sl@0: sl@0: void DevVideoUtilities::CreatePuListL(RImplInfoPtrArray& aImplInfoArray) sl@0: { sl@0: // we can use REComSession::ListImplementationsL() straight, and skip the sort step of MmPluginUtils sl@0: // as this list is used purely to feedback into FindPu below, and see if the plugin is a PU and not a HwDevice sl@0: aImplInfoArray.Reset(); sl@0: REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray); sl@0: } sl@0: sl@0: sl@0: const CImplementationInformation* DevVideoUtilities::FindPu(const RImplInfoPtrArray& aImplInfoArray, TUid aPuUid) sl@0: { sl@0: CImplementationInformation* info = NULL; sl@0: for (TInt i=0;iImplementationUid() == aPuUid) sl@0: { sl@0: info = aImplInfoArray[i]; sl@0: } sl@0: } sl@0: return info; sl@0: } sl@0: sl@0: #endif // SYMBIAN_MULTIMEDIA_CODEC_API sl@0: sl@0: TInt DevVideoUtilities::ConvertTextToTUint32(const TDesC8& aData, TUint32& aNumber) sl@0: { sl@0: // Work out whether aData is in hex or not by looking for an 0x at the beginning sl@0: TInt error = KErrNone; sl@0: sl@0: _LIT8(K0x, "0x"); sl@0: if (aData.FindF(K0x) == 0) sl@0: { sl@0: // Data is in hex sl@0: // Discard the '0x' sl@0: TLex8 lex(aData.Right(aData.Length() - K0x().Length())); sl@0: error = lex.Val(aNumber, EHex); sl@0: } sl@0: else sl@0: { sl@0: // Assume aData is in decimal sl@0: TLex8 lex(aData); sl@0: error = lex.Val(aNumber, EDecimal); sl@0: } sl@0: sl@0: return error; sl@0: } sl@0: sl@0: void DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(const RImplInfoPtrArray& aPlugins, TUint32 aReqPrePostProcType, RArray& aMatchingPlugins) sl@0: { sl@0: aMatchingPlugins.Reset(); sl@0: sl@0: TInt count = aPlugins.Count(); sl@0: for (TInt i=0; iOpaqueData(), pluginPostProcType); sl@0: if (error == KErrNone) sl@0: { sl@0: // Check the plugin has at least the pre/post processing capabilities demanded by the client sl@0: if ((pluginPostProcType & aReqPrePostProcType) == aReqPrePostProcType) sl@0: { sl@0: User::LeaveIfError(aMatchingPlugins.Append(plugin->ImplementationUid())); sl@0: } sl@0: } sl@0: else if (error == KErrCorrupt) sl@0: { sl@0: // In debug mode leave, in release mode just swallow the error since we sl@0: // don't want to allow broken plugins to prevent other plugins being recognised. sl@0: #ifdef _DEBUG sl@0: User::Leave(error); sl@0: #endif //_DEBUG sl@0: } sl@0: else sl@0: { sl@0: User::Leave(error); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void DevVideoUtilities::SelectPluginBasedOnMatchType(const TDesC8& aMatchType, RImplInfoPtrArray& aImplInfoArray) sl@0: { sl@0: // In this function if allowing wildcards then TDesC8::Match is used which returns sl@0: // the position of the match or KErrNotFound sl@0: // If not allowing wildcards then TDesC8::Compare is used which returns a TInt which sl@0: // indicates if one descriptor is bigger than the other (0 if they are identical) sl@0: TBool matchResult = ETrue; sl@0: sl@0: if(aMatchType.Length() == 0) sl@0: { sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: TInt count = aImplInfoArray.Count(); sl@0: sl@0: _LIT8(KdataSeparator, "||"); sl@0: const TInt separatorLength = KdataSeparator().Length(); sl@0: sl@0: for (TInt index = 0; index < count;) sl@0: { sl@0: CImplementationInformation* plugin = aImplInfoArray[index]; sl@0: const TDesC8& mimeType = plugin->DataType(); sl@0: sl@0: // Look for the section separator marker '||' sl@0: TInt separatorPos = mimeType.Find(KdataSeparator); sl@0: sl@0: if(separatorPos == KErrNotFound) sl@0: { sl@0: matchResult = aMatchType.MatchF(mimeType) != KErrNotFound; sl@0: } sl@0: else sl@0: { sl@0: // Find the first section, up to the separator sl@0: TPtrC8 dataSection = mimeType.Left(separatorPos); sl@0: TPtrC8 remainingData = mimeType.Mid(separatorPos + separatorLength); sl@0: sl@0: // Match against each section in turn sl@0: while(separatorPos != KErrNotFound) sl@0: { sl@0: matchResult = aMatchType.MatchF(dataSection) != KErrNotFound; sl@0: sl@0: // If we found it then no need to continue, so return sl@0: if(matchResult) sl@0: break; sl@0: sl@0: // Move on to the next section sl@0: separatorPos = remainingData.Find(KdataSeparator); sl@0: if(separatorPos != KErrNotFound) sl@0: { sl@0: dataSection.Set(remainingData.Left(separatorPos)); sl@0: remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); sl@0: } sl@0: else sl@0: { sl@0: dataSection.Set(remainingData); sl@0: } sl@0: } // end of while sl@0: sl@0: // Check the final part sl@0: matchResult = aMatchType.MatchF(dataSection) != KErrNotFound; sl@0: sl@0: } //end of else sl@0: sl@0: // if a match was found increment the array, sl@0: // otherwise remove the element from the array sl@0: if (matchResult) sl@0: { sl@0: index++; sl@0: } sl@0: else sl@0: { sl@0: delete aImplInfoArray[index]; sl@0: aImplInfoArray.Remove(index); sl@0: count--; sl@0: } sl@0: sl@0: } //end of for sl@0: } sl@0: } sl@0: sl@0: