sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <ecom/ecom.h>
|
sl@0
|
17 |
#include <ecom/ecomerrorcodes.h>
|
sl@0
|
18 |
#include <ecom/ecomresolverparams.h>
|
sl@0
|
19 |
#include <ecom/implementationinformation.h>
|
sl@0
|
20 |
#include <ecom/publicregistry.h>
|
sl@0
|
21 |
#include <mdf/codecapiresolverdata.h>
|
sl@0
|
22 |
#include <mdf/codecapiresolverutils.h>
|
sl@0
|
23 |
#include <mdf/codecapivideoresolverutils.h>
|
sl@0
|
24 |
#include <mdf/codecapiuids.hrh>
|
sl@0
|
25 |
#include "codecapiresolver.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
Constructs a CCodecApiResolver object.
|
sl@0
|
29 |
@param aRegistry
|
sl@0
|
30 |
A reference to the instantiated registry information
|
sl@0
|
31 |
@return An instance of the class or NULL.
|
sl@0
|
32 |
*/
|
sl@0
|
33 |
CCodecApiResolver* CCodecApiResolver::NewL (MPublicRegistry& aRegistry)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
return new(ELeave) CCodecApiResolver (aRegistry);
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
Class destructor.
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
CCodecApiResolver::~CCodecApiResolver()
|
sl@0
|
43 |
{
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
Class constructor.
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
CCodecApiResolver::CCodecApiResolver (MPublicRegistry& aRegistry) :
|
sl@0
|
50 |
CResolver (aRegistry)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
/**
|
sl@0
|
55 |
Requests the resolver to identify the most appropriate interface implementation.
|
sl@0
|
56 |
@param aInterfaceUid
|
sl@0
|
57 |
The interface for which an implementation is requested.
|
sl@0
|
58 |
@param aAdditionalParameters
|
sl@0
|
59 |
The parameters which must match for an implementation to be suitable.
|
sl@0
|
60 |
@return The unique id of the implementation which satisfies the specified parameters.
|
sl@0
|
61 |
KNullUid if not implementation is found.
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
TUid CCodecApiResolver::IdentifyImplementationL(TUid /*aInterfaceUid*/,
|
sl@0
|
64 |
const TEComResolverParams& /*aAdditionalParameters*/) const
|
sl@0
|
65 |
{
|
sl@0
|
66 |
return KNullUid;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Lists all the implementations which satisfy the specified interface definition and the
|
sl@0
|
72 |
resolve parameters supplied.
|
sl@0
|
73 |
@param aInterfaceUid
|
sl@0
|
74 |
The interface for which an implementation is requested.
|
sl@0
|
75 |
@param aAdditionalParameters
|
sl@0
|
76 |
The parameters which must match for an implementation to be suitable.
|
sl@0
|
77 |
@return Pointer to an array of suitable implementations. Ownership of this array is passed
|
sl@0
|
78 |
to the calling function.
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
RImplInfoArray* CCodecApiResolver::ListAllL(TUid aInterfaceUid,
|
sl@0
|
81 |
const TEComResolverParams& aAdditionalParameters) const
|
sl@0
|
82 |
{
|
sl@0
|
83 |
RImplInfoArray* retList = new (ELeave) RImplInfoArray;
|
sl@0
|
84 |
// coverity[double_push]
|
sl@0
|
85 |
CleanupStack::PushL(retList);
|
sl@0
|
86 |
CleanupClosePushL(*retList);
|
sl@0
|
87 |
|
sl@0
|
88 |
CCodecApiResolverData* customMatch = CCodecApiResolverData::NewLC(aAdditionalParameters.DataType());
|
sl@0
|
89 |
|
sl@0
|
90 |
TCodecApiResolverMatchType matchType = customMatch->MatchType();
|
sl@0
|
91 |
TUid implementationTypeUid = customMatch->ImplementationType();
|
sl@0
|
92 |
|
sl@0
|
93 |
// create a list with all
|
sl@0
|
94 |
RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
|
sl@0
|
95 |
const TInt count = fullList.Count();
|
sl@0
|
96 |
|
sl@0
|
97 |
for(TInt index = 0; index < count; index++)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
TBool matchFound = EFalse;
|
sl@0
|
100 |
const CImplementationInformation& impData = *(fullList[index]);
|
sl@0
|
101 |
CCodecApiOpaqueData* parse = NULL;
|
sl@0
|
102 |
const TDesC8* opaqueData = &impData.OpaqueData();
|
sl@0
|
103 |
// if opaque data is empty, move to the next element in the list
|
sl@0
|
104 |
if (opaqueData->Length() == 0)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
continue;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
// create an instance of the class which holds the opaque data
|
sl@0
|
109 |
TInt error = KErrNotFound;
|
sl@0
|
110 |
|
sl@0
|
111 |
if (implementationTypeUid == TUid::Uid(KUidAudioCodec))
|
sl@0
|
112 |
{
|
sl@0
|
113 |
TRAP(error, parse = CCodecApiOpaqueData::NewL(impData.OpaqueData()));
|
sl@0
|
114 |
}
|
sl@0
|
115 |
else
|
sl@0
|
116 |
{
|
sl@0
|
117 |
if ((implementationTypeUid == TUid::Uid(KUidVideoEncoder))
|
sl@0
|
118 |
|| implementationTypeUid == TUid::Uid(KUidVideoDecoder))
|
sl@0
|
119 |
{
|
sl@0
|
120 |
TRAP(error, parse = CCodecApiVideoOpaqueData::NewL(impData.OpaqueData()));
|
sl@0
|
121 |
}
|
sl@0
|
122 |
else
|
sl@0
|
123 |
{
|
sl@0
|
124 |
error = KErrNotSupported;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
CleanupStack::PushL(parse);
|
sl@0
|
129 |
|
sl@0
|
130 |
if (error)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
if ((error == KErrNotSupported) || (error == KErrCorrupt))
|
sl@0
|
133 |
{
|
sl@0
|
134 |
// means that the resource entry was not valid
|
sl@0
|
135 |
// we ignore this plugin and try the next one
|
sl@0
|
136 |
CleanupStack::PopAndDestroy(parse);
|
sl@0
|
137 |
continue;
|
sl@0
|
138 |
}
|
sl@0
|
139 |
else
|
sl@0
|
140 |
{
|
sl@0
|
141 |
User::Leave(error);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
} //end of if (error!=KErrNone)
|
sl@0
|
144 |
|
sl@0
|
145 |
// check if the uids are different. If they are, move to the next element
|
sl@0
|
146 |
// in the list
|
sl@0
|
147 |
if (implementationTypeUid != parse->TypeUid())
|
sl@0
|
148 |
{
|
sl@0
|
149 |
CleanupStack::PopAndDestroy(parse);
|
sl@0
|
150 |
continue;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
switch(matchType)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
// check that the input data type is what we are looking for
|
sl@0
|
155 |
case EMatchInputDataFormat:
|
sl@0
|
156 |
if (parse->CompareInputDataType(customMatch->InputDataFormat()))
|
sl@0
|
157 |
{
|
sl@0
|
158 |
matchFound = ETrue;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
break;
|
sl@0
|
161 |
// check that the output data type is what we are looking for
|
sl@0
|
162 |
case EMatchOutputDataFormat:
|
sl@0
|
163 |
if (parse->CompareOutputDataType(customMatch->OutputDataFormat()))
|
sl@0
|
164 |
{
|
sl@0
|
165 |
matchFound = ETrue;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
break;
|
sl@0
|
168 |
// check that the input and output data type is what we are looking for
|
sl@0
|
169 |
case EMatchInputAndOutputDataFormat:
|
sl@0
|
170 |
if (parse->CompareInputDataType(customMatch->InputDataFormat())
|
sl@0
|
171 |
&& parse->CompareOutputDataType(customMatch->OutputDataFormat()))
|
sl@0
|
172 |
{
|
sl@0
|
173 |
matchFound = ETrue;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
break;
|
sl@0
|
176 |
default:
|
sl@0
|
177 |
{
|
sl@0
|
178 |
//matchFound was initialised to EFalse, so fall through
|
sl@0
|
179 |
}
|
sl@0
|
180 |
}
|
sl@0
|
181 |
// if a match was found, it will be appended to the list returned by this method
|
sl@0
|
182 |
if (matchFound)
|
sl@0
|
183 |
{
|
sl@0
|
184 |
User::LeaveIfError(retList->Append(fullList[index]));
|
sl@0
|
185 |
}
|
sl@0
|
186 |
CleanupStack::PopAndDestroy(parse);
|
sl@0
|
187 |
} // end of for
|
sl@0
|
188 |
|
sl@0
|
189 |
CleanupStack::PopAndDestroy(customMatch);
|
sl@0
|
190 |
CleanupStack::Pop(2, retList);
|
sl@0
|
191 |
return retList;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
|