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 "devvideointernal.h"
17 #ifdef SYMBIAN_MULTIMEDIA_CODEC_API
18 #include <mdf/codecapiresolverdata.h>
19 #include <mdf/codecapiuids.hrh>
20 #include <mdf/codecapiresolver.hrh>
21 #include <mm/mmpluginutils.h>
23 #include "videoplayhwdevice.h"
25 void DevVideoUtilities::FindVideoDecoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray)
27 CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC();
28 customMatchData->SetMatchType(EMatchInputDataFormat);
29 customMatchData->SetImplementationType(TUid::Uid(KUidVideoDecoder));
30 // string value of the input source data
31 customMatchData->SetInputDataL(aMimeType);
33 HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data"
34 MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation));
35 CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData
39 void DevVideoUtilities::FindVideoEncoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray)
41 CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC();
42 customMatchData->SetMatchType(EMatchOutputDataFormat);
43 customMatchData->SetImplementationType(TUid::Uid(KUidVideoEncoder));
44 // string value of the input source data
45 customMatchData->SetOutputDataL(aMimeType);
47 HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data"
48 MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation));
49 CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData
52 void DevVideoUtilities::CreatePuListL(RImplInfoPtrArray& aImplInfoArray)
54 // we can use REComSession::ListImplementationsL() straight, and skip the sort step of MmPluginUtils
55 // as this list is used purely to feedback into FindPu below, and see if the plugin is a PU and not a HwDevice
56 aImplInfoArray.Reset();
57 REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray);
61 const CImplementationInformation* DevVideoUtilities::FindPu(const RImplInfoPtrArray& aImplInfoArray, TUid aPuUid)
63 CImplementationInformation* info = NULL;
64 for (TInt i=0;i<aImplInfoArray.Count() && info == NULL;i++)
66 if (aImplInfoArray[i]->ImplementationUid() == aPuUid)
68 info = aImplInfoArray[i];
74 #endif // SYMBIAN_MULTIMEDIA_CODEC_API
76 TInt DevVideoUtilities::ConvertTextToTUint32(const TDesC8& aData, TUint32& aNumber)
78 // Work out whether aData is in hex or not by looking for an 0x at the beginning
79 TInt error = KErrNone;
82 if (aData.FindF(K0x) == 0)
86 TLex8 lex(aData.Right(aData.Length() - K0x().Length()));
87 error = lex.Val(aNumber, EHex);
91 // Assume aData is in decimal
93 error = lex.Val(aNumber, EDecimal);
99 void DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(const RImplInfoPtrArray& aPlugins, TUint32 aReqPrePostProcType, RArray<TUid>& aMatchingPlugins)
101 aMatchingPlugins.Reset();
103 TInt count = aPlugins.Count();
104 for (TInt i=0; i<count; i++)
106 const CImplementationInformation* plugin = aPlugins[i];
107 TUint32 pluginPostProcType = 0;
108 TInt error = ConvertTextToTUint32(plugin->OpaqueData(), pluginPostProcType);
109 if (error == KErrNone)
111 // Check the plugin has at least the pre/post processing capabilities demanded by the client
112 if ((pluginPostProcType & aReqPrePostProcType) == aReqPrePostProcType)
114 User::LeaveIfError(aMatchingPlugins.Append(plugin->ImplementationUid()));
117 else if (error == KErrCorrupt)
119 // In debug mode leave, in release mode just swallow the error since we
120 // don't want to allow broken plugins to prevent other plugins being recognised.
132 void DevVideoUtilities::SelectPluginBasedOnMatchType(const TDesC8& aMatchType, RImplInfoPtrArray& aImplInfoArray)
134 // In this function if allowing wildcards then TDesC8::Match is used which returns
135 // the position of the match or KErrNotFound
136 // If not allowing wildcards then TDesC8::Compare is used which returns a TInt which
137 // indicates if one descriptor is bigger than the other (0 if they are identical)
138 TBool matchResult = ETrue;
140 if(aMatchType.Length() == 0)
146 TInt count = aImplInfoArray.Count();
148 _LIT8(KdataSeparator, "||");
149 const TInt separatorLength = KdataSeparator().Length();
151 for (TInt index = 0; index < count;)
153 CImplementationInformation* plugin = aImplInfoArray[index];
154 const TDesC8& mimeType = plugin->DataType();
156 // Look for the section separator marker '||'
157 TInt separatorPos = mimeType.Find(KdataSeparator);
159 if(separatorPos == KErrNotFound)
161 matchResult = aMatchType.MatchF(mimeType) != KErrNotFound;
165 // Find the first section, up to the separator
166 TPtrC8 dataSection = mimeType.Left(separatorPos);
167 TPtrC8 remainingData = mimeType.Mid(separatorPos + separatorLength);
169 // Match against each section in turn
170 while(separatorPos != KErrNotFound)
172 matchResult = aMatchType.MatchF(dataSection) != KErrNotFound;
174 // If we found it then no need to continue, so return
178 // Move on to the next section
179 separatorPos = remainingData.Find(KdataSeparator);
180 if(separatorPos != KErrNotFound)
182 dataSection.Set(remainingData.Left(separatorPos));
183 remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
187 dataSection.Set(remainingData);
191 // Check the final part
192 matchResult = aMatchType.MatchF(dataSection) != KErrNotFound;
196 // if a match was found increment the array,
197 // otherwise remove the element from the array
204 delete aImplInfoArray[index];
205 aImplInfoArray.Remove(index);