Update contrib.
1 // Copyright (c) 2005-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 #include <ecom/ecomerrorcodes.h>
18 #include <ecom/ecomresolverparams.h>
19 #include <ecom/implementationinformation.h>
20 #include <ecom/publicregistry.h>
21 #include <mdf/codecapiresolverdata.h>
22 #include <mdf/codecapiresolverutils.h>
23 #include <mdf/codecapivideoresolverutils.h>
24 #include <mdf/codecapiuids.hrh>
25 #include "codecapiresolver.h"
28 Constructs a CCodecApiResolver object.
30 A reference to the instantiated registry information
31 @return An instance of the class or NULL.
33 CCodecApiResolver* CCodecApiResolver::NewL (MPublicRegistry& aRegistry)
35 return new(ELeave) CCodecApiResolver (aRegistry);
42 CCodecApiResolver::~CCodecApiResolver()
49 CCodecApiResolver::CCodecApiResolver (MPublicRegistry& aRegistry) :
55 Requests the resolver to identify the most appropriate interface implementation.
57 The interface for which an implementation is requested.
58 @param aAdditionalParameters
59 The parameters which must match for an implementation to be suitable.
60 @return The unique id of the implementation which satisfies the specified parameters.
61 KNullUid if not implementation is found.
63 TUid CCodecApiResolver::IdentifyImplementationL(TUid /*aInterfaceUid*/,
64 const TEComResolverParams& /*aAdditionalParameters*/) const
71 Lists all the implementations which satisfy the specified interface definition and the
72 resolve parameters supplied.
74 The interface for which an implementation is requested.
75 @param aAdditionalParameters
76 The parameters which must match for an implementation to be suitable.
77 @return Pointer to an array of suitable implementations. Ownership of this array is passed
78 to the calling function.
80 RImplInfoArray* CCodecApiResolver::ListAllL(TUid aInterfaceUid,
81 const TEComResolverParams& aAdditionalParameters) const
83 RImplInfoArray* retList = new (ELeave) RImplInfoArray;
84 // coverity[double_push]
85 CleanupStack::PushL(retList);
86 CleanupClosePushL(*retList);
88 CCodecApiResolverData* customMatch = CCodecApiResolverData::NewLC(aAdditionalParameters.DataType());
90 TCodecApiResolverMatchType matchType = customMatch->MatchType();
91 TUid implementationTypeUid = customMatch->ImplementationType();
93 // create a list with all
94 RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
95 const TInt count = fullList.Count();
97 for(TInt index = 0; index < count; index++)
99 TBool matchFound = EFalse;
100 const CImplementationInformation& impData = *(fullList[index]);
101 CCodecApiOpaqueData* parse = NULL;
102 const TDesC8* opaqueData = &impData.OpaqueData();
103 // if opaque data is empty, move to the next element in the list
104 if (opaqueData->Length() == 0)
108 // create an instance of the class which holds the opaque data
109 TInt error = KErrNotFound;
111 if (implementationTypeUid == TUid::Uid(KUidAudioCodec))
113 TRAP(error, parse = CCodecApiOpaqueData::NewL(impData.OpaqueData()));
117 if ((implementationTypeUid == TUid::Uid(KUidVideoEncoder))
118 || implementationTypeUid == TUid::Uid(KUidVideoDecoder))
120 TRAP(error, parse = CCodecApiVideoOpaqueData::NewL(impData.OpaqueData()));
124 error = KErrNotSupported;
128 CleanupStack::PushL(parse);
132 if ((error == KErrNotSupported) || (error == KErrCorrupt))
134 // means that the resource entry was not valid
135 // we ignore this plugin and try the next one
136 CleanupStack::PopAndDestroy(parse);
143 } //end of if (error!=KErrNone)
145 // check if the uids are different. If they are, move to the next element
147 if (implementationTypeUid != parse->TypeUid())
149 CleanupStack::PopAndDestroy(parse);
154 // check that the input data type is what we are looking for
155 case EMatchInputDataFormat:
156 if (parse->CompareInputDataType(customMatch->InputDataFormat()))
161 // check that the output data type is what we are looking for
162 case EMatchOutputDataFormat:
163 if (parse->CompareOutputDataType(customMatch->OutputDataFormat()))
168 // check that the input and output data type is what we are looking for
169 case EMatchInputAndOutputDataFormat:
170 if (parse->CompareInputDataType(customMatch->InputDataFormat())
171 && parse->CompareOutputDataType(customMatch->OutputDataFormat()))
178 //matchFound was initialised to EFalse, so fall through
181 // if a match was found, it will be appended to the list returned by this method
184 User::LeaveIfError(retList->Append(fullList[index]));
186 CleanupStack::PopAndDestroy(parse);
189 CleanupStack::PopAndDestroy(customMatch);
190 CleanupStack::Pop(2, retList);