sl@0
|
1 |
// Copyright (c) 2003-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 "devvideointernal.h"
|
sl@0
|
17 |
#ifdef SYMBIAN_MULTIMEDIA_CODEC_API
|
sl@0
|
18 |
#include <mdf/codecapiresolverdata.h>
|
sl@0
|
19 |
#include <mdf/codecapiuids.hrh>
|
sl@0
|
20 |
#include <mdf/codecapiresolver.hrh>
|
sl@0
|
21 |
#include <mm/mmpluginutils.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "videoplayhwdevice.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
void DevVideoUtilities::FindVideoDecoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC();
|
sl@0
|
28 |
customMatchData->SetMatchType(EMatchInputDataFormat);
|
sl@0
|
29 |
customMatchData->SetImplementationType(TUid::Uid(KUidVideoDecoder));
|
sl@0
|
30 |
// string value of the input source data
|
sl@0
|
31 |
customMatchData->SetInputDataL(aMimeType);
|
sl@0
|
32 |
|
sl@0
|
33 |
HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data"
|
sl@0
|
34 |
MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation));
|
sl@0
|
35 |
CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
|
sl@0
|
39 |
void DevVideoUtilities::FindVideoEncoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC();
|
sl@0
|
42 |
customMatchData->SetMatchType(EMatchOutputDataFormat);
|
sl@0
|
43 |
customMatchData->SetImplementationType(TUid::Uid(KUidVideoEncoder));
|
sl@0
|
44 |
// string value of the input source data
|
sl@0
|
45 |
customMatchData->SetOutputDataL(aMimeType);
|
sl@0
|
46 |
|
sl@0
|
47 |
HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data"
|
sl@0
|
48 |
MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation));
|
sl@0
|
49 |
CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
void DevVideoUtilities::CreatePuListL(RImplInfoPtrArray& aImplInfoArray)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
// we can use REComSession::ListImplementationsL() straight, and skip the sort step of MmPluginUtils
|
sl@0
|
55 |
// 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
|
56 |
aImplInfoArray.Reset();
|
sl@0
|
57 |
REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray);
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
const CImplementationInformation* DevVideoUtilities::FindPu(const RImplInfoPtrArray& aImplInfoArray, TUid aPuUid)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
CImplementationInformation* info = NULL;
|
sl@0
|
64 |
for (TInt i=0;i<aImplInfoArray.Count() && info == NULL;i++)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
if (aImplInfoArray[i]->ImplementationUid() == aPuUid)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
info = aImplInfoArray[i];
|
sl@0
|
69 |
}
|
sl@0
|
70 |
}
|
sl@0
|
71 |
return info;
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
#endif // SYMBIAN_MULTIMEDIA_CODEC_API
|
sl@0
|
75 |
|
sl@0
|
76 |
TInt DevVideoUtilities::ConvertTextToTUint32(const TDesC8& aData, TUint32& aNumber)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
// Work out whether aData is in hex or not by looking for an 0x at the beginning
|
sl@0
|
79 |
TInt error = KErrNone;
|
sl@0
|
80 |
|
sl@0
|
81 |
_LIT8(K0x, "0x");
|
sl@0
|
82 |
if (aData.FindF(K0x) == 0)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
// Data is in hex
|
sl@0
|
85 |
// Discard the '0x'
|
sl@0
|
86 |
TLex8 lex(aData.Right(aData.Length() - K0x().Length()));
|
sl@0
|
87 |
error = lex.Val(aNumber, EHex);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
else
|
sl@0
|
90 |
{
|
sl@0
|
91 |
// Assume aData is in decimal
|
sl@0
|
92 |
TLex8 lex(aData);
|
sl@0
|
93 |
error = lex.Val(aNumber, EDecimal);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
return error;
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
void DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(const RImplInfoPtrArray& aPlugins, TUint32 aReqPrePostProcType, RArray<TUid>& aMatchingPlugins)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
aMatchingPlugins.Reset();
|
sl@0
|
102 |
|
sl@0
|
103 |
TInt count = aPlugins.Count();
|
sl@0
|
104 |
for (TInt i=0; i<count; i++)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
const CImplementationInformation* plugin = aPlugins[i];
|
sl@0
|
107 |
TUint32 pluginPostProcType = 0;
|
sl@0
|
108 |
TInt error = ConvertTextToTUint32(plugin->OpaqueData(), pluginPostProcType);
|
sl@0
|
109 |
if (error == KErrNone)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
// Check the plugin has at least the pre/post processing capabilities demanded by the client
|
sl@0
|
112 |
if ((pluginPostProcType & aReqPrePostProcType) == aReqPrePostProcType)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
User::LeaveIfError(aMatchingPlugins.Append(plugin->ImplementationUid()));
|
sl@0
|
115 |
}
|
sl@0
|
116 |
}
|
sl@0
|
117 |
else if (error == KErrCorrupt)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
// In debug mode leave, in release mode just swallow the error since we
|
sl@0
|
120 |
// don't want to allow broken plugins to prevent other plugins being recognised.
|
sl@0
|
121 |
#ifdef _DEBUG
|
sl@0
|
122 |
User::Leave(error);
|
sl@0
|
123 |
#endif //_DEBUG
|
sl@0
|
124 |
}
|
sl@0
|
125 |
else
|
sl@0
|
126 |
{
|
sl@0
|
127 |
User::Leave(error);
|
sl@0
|
128 |
}
|
sl@0
|
129 |
}
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
void DevVideoUtilities::SelectPluginBasedOnMatchType(const TDesC8& aMatchType, RImplInfoPtrArray& aImplInfoArray)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
// In this function if allowing wildcards then TDesC8::Match is used which returns
|
sl@0
|
135 |
// the position of the match or KErrNotFound
|
sl@0
|
136 |
// If not allowing wildcards then TDesC8::Compare is used which returns a TInt which
|
sl@0
|
137 |
// indicates if one descriptor is bigger than the other (0 if they are identical)
|
sl@0
|
138 |
TBool matchResult = ETrue;
|
sl@0
|
139 |
|
sl@0
|
140 |
if(aMatchType.Length() == 0)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
return;
|
sl@0
|
143 |
}
|
sl@0
|
144 |
else
|
sl@0
|
145 |
{
|
sl@0
|
146 |
TInt count = aImplInfoArray.Count();
|
sl@0
|
147 |
|
sl@0
|
148 |
_LIT8(KdataSeparator, "||");
|
sl@0
|
149 |
const TInt separatorLength = KdataSeparator().Length();
|
sl@0
|
150 |
|
sl@0
|
151 |
for (TInt index = 0; index < count;)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
CImplementationInformation* plugin = aImplInfoArray[index];
|
sl@0
|
154 |
const TDesC8& mimeType = plugin->DataType();
|
sl@0
|
155 |
|
sl@0
|
156 |
// Look for the section separator marker '||'
|
sl@0
|
157 |
TInt separatorPos = mimeType.Find(KdataSeparator);
|
sl@0
|
158 |
|
sl@0
|
159 |
if(separatorPos == KErrNotFound)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
matchResult = aMatchType.MatchF(mimeType) != KErrNotFound;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
else
|
sl@0
|
164 |
{
|
sl@0
|
165 |
// Find the first section, up to the separator
|
sl@0
|
166 |
TPtrC8 dataSection = mimeType.Left(separatorPos);
|
sl@0
|
167 |
TPtrC8 remainingData = mimeType.Mid(separatorPos + separatorLength);
|
sl@0
|
168 |
|
sl@0
|
169 |
// Match against each section in turn
|
sl@0
|
170 |
while(separatorPos != KErrNotFound)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
matchResult = aMatchType.MatchF(dataSection) != KErrNotFound;
|
sl@0
|
173 |
|
sl@0
|
174 |
// If we found it then no need to continue, so return
|
sl@0
|
175 |
if(matchResult)
|
sl@0
|
176 |
break;
|
sl@0
|
177 |
|
sl@0
|
178 |
// Move on to the next section
|
sl@0
|
179 |
separatorPos = remainingData.Find(KdataSeparator);
|
sl@0
|
180 |
if(separatorPos != KErrNotFound)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
dataSection.Set(remainingData.Left(separatorPos));
|
sl@0
|
183 |
remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
|
sl@0
|
184 |
}
|
sl@0
|
185 |
else
|
sl@0
|
186 |
{
|
sl@0
|
187 |
dataSection.Set(remainingData);
|
sl@0
|
188 |
}
|
sl@0
|
189 |
} // end of while
|
sl@0
|
190 |
|
sl@0
|
191 |
// Check the final part
|
sl@0
|
192 |
matchResult = aMatchType.MatchF(dataSection) != KErrNotFound;
|
sl@0
|
193 |
|
sl@0
|
194 |
} //end of else
|
sl@0
|
195 |
|
sl@0
|
196 |
// if a match was found increment the array,
|
sl@0
|
197 |
// otherwise remove the element from the array
|
sl@0
|
198 |
if (matchResult)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
index++;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
else
|
sl@0
|
203 |
{
|
sl@0
|
204 |
delete aImplInfoArray[index];
|
sl@0
|
205 |
aImplInfoArray.Remove(index);
|
sl@0
|
206 |
count--;
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
} //end of for
|
sl@0
|
210 |
}
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
|