|
1 // Copyright (c) 2008-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 /** |
|
18 @file |
|
19 @internalComponent |
|
20 */ |
|
21 |
|
22 #include <e32cmn.h> |
|
23 #include <openmax/il/khronos/v1_x/OMX_Core.h> |
|
24 |
|
25 #include "log.h" |
|
26 #include "omxilconfigmanager.h" |
|
27 #include "omxilportmanager.h" |
|
28 #include "omxilspecversion.h" |
|
29 #include "omxilutil.h" |
|
30 |
|
31 |
|
32 // NOTE: OMX_UUIDTYPE[128] is defined in OMX_Types.h |
|
33 #define KMAX_UUIDTYPE_SIZE 128 |
|
34 |
|
35 EXPORT_C COmxILConfigManager* |
|
36 COmxILConfigManager::NewL( |
|
37 COmxILPortManager& aPortManager, |
|
38 const TDesC8& aComponentName, |
|
39 const OMX_VERSIONTYPE& aComponentVersion, |
|
40 const RPointerArray<TDesC8>& aComponentRoleList) |
|
41 { |
|
42 DEBUG_PRINTF(_L8("COmxILConfigManager::NewL")); |
|
43 __ASSERT_DEBUG(aComponentName.Length() && aComponentRoleList.Count(), |
|
44 User::Panic(KOmxILConfigManagerPanicCategory, 1)); |
|
45 |
|
46 COmxILConfigManager* self = new (ELeave)COmxILConfigManager(aPortManager); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(aComponentName, |
|
49 aComponentVersion, |
|
50 aComponentRoleList); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 |
|
54 } |
|
55 |
|
56 EXPORT_C void |
|
57 COmxILConfigManager::ConstructL(const TDesC8& aComponentName, |
|
58 const OMX_VERSIONTYPE& aComponentVersion, |
|
59 const RPointerArray<TDesC8>& aComponentRoleList) |
|
60 { |
|
61 DEBUG_PRINTF(_L8("COmxILConfigManager::ConstructL")); |
|
62 |
|
63 iComponentName.CreateL(aComponentName, OMX_MAX_STRINGNAME_SIZE); |
|
64 iComponentName.PtrZ(); |
|
65 iComponentVersion.s = aComponentVersion.s; |
|
66 |
|
67 // Note that the first role in the list of roles becomes the default role |
|
68 // assumed by the component |
|
69 |
|
70 const TUint rolesCount = aComponentRoleList.Count(); |
|
71 for (TUint i=0; i<rolesCount; ++i) |
|
72 { |
|
73 iComponentRoleList.AppendL(aComponentRoleList[i]->AllocLC()); |
|
74 CleanupStack::Pop(); |
|
75 } |
|
76 |
|
77 |
|
78 InsertParamIndexL(OMX_IndexParamDisableResourceConcealment); |
|
79 InsertParamIndexL(OMX_IndexParamSuspensionPolicy); |
|
80 InsertParamIndexL(OMX_IndexParamStandardComponentRole); |
|
81 InsertParamIndexL(OMX_IndexParamPriorityMgmt); |
|
82 InsertConfigIndexL(OMX_IndexConfigPriorityMgmt); |
|
83 |
|
84 } |
|
85 |
|
86 EXPORT_C |
|
87 COmxILConfigManager::COmxILConfigManager(COmxILPortManager& aPortManager) |
|
88 : |
|
89 iPortManager(aPortManager), |
|
90 iComponentName(), |
|
91 iComponentRoleList(), |
|
92 iCurrentRoleIndex(0) |
|
93 |
|
94 { |
|
95 DEBUG_PRINTF(_L8("COmxILConfigManager::COmxILConfigManager")); |
|
96 |
|
97 iParamDisableResourceConcealment.nSize = sizeof(OMX_RESOURCECONCEALMENTTYPE); |
|
98 iParamDisableResourceConcealment.nVersion = TOmxILSpecVersion(); |
|
99 iParamDisableResourceConcealment.bResourceConcealmentForbidden = OMX_TRUE; |
|
100 |
|
101 iParamSuspensionPolicy.nSize = sizeof(OMX_PARAM_SUSPENSIONPOLICYTYPE); |
|
102 iParamSuspensionPolicy.nVersion = TOmxILSpecVersion(); |
|
103 iParamSuspensionPolicy.ePolicy = OMX_SuspensionDisabled; |
|
104 |
|
105 iConfigPriorityMgmt.nSize = sizeof(OMX_PRIORITYMGMTTYPE); |
|
106 iConfigPriorityMgmt.nVersion = TOmxILSpecVersion(); |
|
107 iConfigPriorityMgmt.nGroupPriority = 0; |
|
108 iConfigPriorityMgmt.nGroupID = 0; |
|
109 |
|
110 } |
|
111 |
|
112 EXPORT_C |
|
113 COmxILConfigManager::~COmxILConfigManager() |
|
114 { |
|
115 DEBUG_PRINTF(_L8("COmxILConfigManager::~COmxILConfigManager")); |
|
116 |
|
117 iComponentName.Close(); |
|
118 iComponentRoleList.ResetAndDestroy(); |
|
119 |
|
120 } |
|
121 |
|
122 EXPORT_C OMX_ERRORTYPE |
|
123 COmxILConfigManager::GetComponentVersion(OMX_STRING aComponentName, |
|
124 OMX_VERSIONTYPE* apComponentVersion, |
|
125 OMX_VERSIONTYPE* apSpecVersion, |
|
126 OMX_UUIDTYPE* apComponentUUID) const |
|
127 { |
|
128 DEBUG_PRINTF(_L8("COmxILConfigManager::GetComponentVersion")); |
|
129 |
|
130 TPtr8 name(reinterpret_cast<TUint8*>(aComponentName), |
|
131 OMX_MAX_STRINGNAME_SIZE); |
|
132 name.Copy(iComponentName); |
|
133 name.PtrZ(); |
|
134 |
|
135 (*apComponentVersion) = iComponentVersion; |
|
136 (*apSpecVersion) = TOmxILSpecVersion(); |
|
137 |
|
138 // Generate a component uuid |
|
139 TUint32 uid = reinterpret_cast<TUint32>(this); |
|
140 TPtr8 uidPtr(reinterpret_cast<TUint8*>(*apComponentUUID), |
|
141 KMAX_UUIDTYPE_SIZE); |
|
142 uidPtr = TPtr8(reinterpret_cast<TUint8*>(uid), sizeof(uid)); |
|
143 |
|
144 return OMX_ErrorNone; |
|
145 |
|
146 } |
|
147 |
|
148 EXPORT_C OMX_ERRORTYPE |
|
149 COmxILConfigManager::GetParameter(OMX_INDEXTYPE aParamIndex, |
|
150 TAny* apComponentParameterStructure) const |
|
151 { |
|
152 DEBUG_PRINTF(_L8("COmxILConfigManager::GetParameter")); |
|
153 |
|
154 TInt index = FindParamIndex(aParamIndex); |
|
155 if (KErrNotFound == index) |
|
156 { |
|
157 return OMX_ErrorUnsupportedIndex; |
|
158 } |
|
159 |
|
160 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
161 switch(aParamIndex) |
|
162 { |
|
163 case OMX_IndexParamStandardComponentRole: |
|
164 { |
|
165 if (OMX_ErrorNone != (omxRetValue = |
|
166 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
167 apComponentParameterStructure, |
|
168 sizeof(OMX_PARAM_COMPONENTROLETYPE)))) |
|
169 { |
|
170 return omxRetValue; |
|
171 } |
|
172 |
|
173 OMX_PARAM_COMPONENTROLETYPE* pComponentRole |
|
174 = static_cast<OMX_PARAM_COMPONENTROLETYPE*>( |
|
175 apComponentParameterStructure); |
|
176 |
|
177 // Here, the role returned must be the role that this component is |
|
178 // currently assuming |
|
179 TPtr8 role(reinterpret_cast<TUint8*>(pComponentRole->cRole), |
|
180 OMX_MAX_STRINGNAME_SIZE); |
|
181 |
|
182 role = *(iComponentRoleList[iCurrentRoleIndex]); |
|
183 role.PtrZ(); |
|
184 |
|
185 } |
|
186 break; |
|
187 |
|
188 case OMX_IndexParamDisableResourceConcealment: |
|
189 { |
|
190 if (OMX_ErrorNone != (omxRetValue = |
|
191 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
192 apComponentParameterStructure, |
|
193 sizeof(OMX_RESOURCECONCEALMENTTYPE)))) |
|
194 { |
|
195 return omxRetValue; |
|
196 } |
|
197 |
|
198 OMX_RESOURCECONCEALMENTTYPE* pResConceal |
|
199 = static_cast<OMX_RESOURCECONCEALMENTTYPE*>( |
|
200 apComponentParameterStructure); |
|
201 |
|
202 *pResConceal = iParamDisableResourceConcealment; |
|
203 |
|
204 } |
|
205 break; |
|
206 case OMX_IndexParamSuspensionPolicy: |
|
207 { |
|
208 if (OMX_ErrorNone != (omxRetValue = |
|
209 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
210 apComponentParameterStructure, |
|
211 sizeof(OMX_PARAM_SUSPENSIONPOLICYTYPE)))) |
|
212 { |
|
213 return omxRetValue; |
|
214 } |
|
215 |
|
216 OMX_PARAM_SUSPENSIONPOLICYTYPE* pSuspensionPolicy |
|
217 = static_cast<OMX_PARAM_SUSPENSIONPOLICYTYPE*>( |
|
218 apComponentParameterStructure); |
|
219 |
|
220 *pSuspensionPolicy = iParamSuspensionPolicy; |
|
221 |
|
222 } |
|
223 break; |
|
224 |
|
225 case OMX_IndexParamPriorityMgmt: |
|
226 { |
|
227 if (OMX_ErrorNone != (omxRetValue = |
|
228 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
229 apComponentParameterStructure, |
|
230 sizeof(OMX_PRIORITYMGMTTYPE)))) |
|
231 { |
|
232 return omxRetValue; |
|
233 } |
|
234 |
|
235 OMX_PRIORITYMGMTTYPE* pPriorityMgmt |
|
236 = static_cast<OMX_PRIORITYMGMTTYPE*>( |
|
237 apComponentParameterStructure); |
|
238 |
|
239 *pPriorityMgmt = iConfigPriorityMgmt; |
|
240 |
|
241 } |
|
242 break; |
|
243 |
|
244 default: |
|
245 { |
|
246 __ASSERT_ALWAYS(EFalse, |
|
247 User::Panic(KOmxILConfigManagerPanicCategory, 1)); |
|
248 } |
|
249 }; |
|
250 |
|
251 return OMX_ErrorNone; |
|
252 |
|
253 } |
|
254 |
|
255 EXPORT_C OMX_ERRORTYPE |
|
256 COmxILConfigManager::SetParameter(OMX_INDEXTYPE aParamIndex, |
|
257 const TAny* apComponentParameterStructure, |
|
258 OMX_BOOL aInitTime /* = OMX_TRUE */) |
|
259 { |
|
260 DEBUG_PRINTF(_L8("COmxILConfigManager::SetParameter")); |
|
261 |
|
262 TInt index = FindParamIndex(aParamIndex); |
|
263 if (KErrNotFound == index) |
|
264 { |
|
265 return OMX_ErrorUnsupportedIndex; |
|
266 } |
|
267 |
|
268 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
269 switch(aParamIndex) |
|
270 { |
|
271 case OMX_IndexParamStandardComponentRole: |
|
272 { |
|
273 if (!aInitTime) |
|
274 { |
|
275 return OMX_ErrorIncorrectStateOperation; |
|
276 } |
|
277 |
|
278 if (OMX_ErrorNone != (omxRetValue = |
|
279 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
280 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
281 sizeof(OMX_PARAM_COMPONENTROLETYPE)))) |
|
282 { |
|
283 return omxRetValue; |
|
284 } |
|
285 |
|
286 const OMX_PARAM_COMPONENTROLETYPE* pComponentRole |
|
287 = static_cast<const OMX_PARAM_COMPONENTROLETYPE*>( |
|
288 apComponentParameterStructure); |
|
289 |
|
290 TPtrC8 roleToFindPtr( |
|
291 static_cast<const TUint8*>(pComponentRole->cRole)); |
|
292 |
|
293 HBufC8* pRoleToFind = HBufC8::New(OMX_MAX_STRINGNAME_SIZE); |
|
294 if (!pRoleToFind) |
|
295 { |
|
296 return OMX_ErrorInsufficientResources; |
|
297 } |
|
298 *pRoleToFind = roleToFindPtr; |
|
299 |
|
300 TInt newRoleIndex = 0; |
|
301 if (KErrNotFound == |
|
302 (newRoleIndex = |
|
303 iComponentRoleList.Find(pRoleToFind, |
|
304 TIdentityRelation<HBufC8>( |
|
305 &COmxILConfigManager::CompareRoles)))) |
|
306 { |
|
307 delete pRoleToFind; |
|
308 return OMX_ErrorBadParameter; |
|
309 } |
|
310 |
|
311 if (*pRoleToFind != *(iComponentRoleList[iCurrentRoleIndex])) |
|
312 { |
|
313 // At this point, it is mandated that the component populates all |
|
314 // defaults according to the new role that has just been set by the |
|
315 // IL Client |
|
316 if (OMX_ErrorNone != |
|
317 (omxRetValue = |
|
318 iPortManager.ComponentRoleIndication(newRoleIndex))) |
|
319 { |
|
320 delete pRoleToFind; |
|
321 return omxRetValue; |
|
322 } |
|
323 |
|
324 iCurrentRoleIndex = newRoleIndex; |
|
325 |
|
326 } |
|
327 |
|
328 delete pRoleToFind; |
|
329 |
|
330 } |
|
331 break; |
|
332 |
|
333 case OMX_IndexParamDisableResourceConcealment: |
|
334 { |
|
335 if (!aInitTime) |
|
336 { |
|
337 return OMX_ErrorIncorrectStateOperation; |
|
338 } |
|
339 |
|
340 if (OMX_ErrorNone != (omxRetValue = |
|
341 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
342 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
343 sizeof(OMX_RESOURCECONCEALMENTTYPE)))) |
|
344 { |
|
345 return omxRetValue; |
|
346 } |
|
347 |
|
348 const OMX_RESOURCECONCEALMENTTYPE* pResConceal |
|
349 = static_cast<const OMX_RESOURCECONCEALMENTTYPE*>( |
|
350 apComponentParameterStructure); |
|
351 |
|
352 iParamDisableResourceConcealment = *pResConceal; |
|
353 |
|
354 } |
|
355 break; |
|
356 |
|
357 case OMX_IndexParamSuspensionPolicy: |
|
358 { |
|
359 if (!aInitTime) |
|
360 { |
|
361 return OMX_ErrorIncorrectStateOperation; |
|
362 } |
|
363 |
|
364 if (OMX_ErrorNone != (omxRetValue = |
|
365 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
366 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
367 sizeof(OMX_PARAM_SUSPENSIONPOLICYTYPE)))) |
|
368 { |
|
369 return omxRetValue; |
|
370 } |
|
371 |
|
372 const OMX_PARAM_SUSPENSIONPOLICYTYPE* pSuspensionPolicy |
|
373 = static_cast<const OMX_PARAM_SUSPENSIONPOLICYTYPE*>( |
|
374 apComponentParameterStructure); |
|
375 |
|
376 // OMX_SuspensionEnabled is the last of the supported values as of |
|
377 // v1.1.1 |
|
378 if (pSuspensionPolicy->ePolicy > OMX_SuspensionEnabled) |
|
379 { |
|
380 return OMX_ErrorBadParameter; |
|
381 } |
|
382 |
|
383 iParamSuspensionPolicy = *pSuspensionPolicy; |
|
384 |
|
385 } |
|
386 break; |
|
387 |
|
388 case OMX_IndexParamPriorityMgmt: |
|
389 { |
|
390 if (!aInitTime) |
|
391 { |
|
392 return OMX_ErrorIncorrectStateOperation; |
|
393 } |
|
394 |
|
395 if (OMX_ErrorNone != (omxRetValue = |
|
396 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
397 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
398 sizeof(OMX_PRIORITYMGMTTYPE)))) |
|
399 { |
|
400 return omxRetValue; |
|
401 } |
|
402 |
|
403 |
|
404 const OMX_PRIORITYMGMTTYPE* pPriorityMgmt |
|
405 = static_cast<const OMX_PRIORITYMGMTTYPE*>( |
|
406 apComponentParameterStructure); |
|
407 |
|
408 iConfigPriorityMgmt = *pPriorityMgmt; |
|
409 |
|
410 } |
|
411 break; |
|
412 |
|
413 default: |
|
414 { |
|
415 __ASSERT_ALWAYS(EFalse, |
|
416 User::Panic(KOmxILConfigManagerPanicCategory, 1)); |
|
417 } |
|
418 }; |
|
419 |
|
420 return OMX_ErrorNone; |
|
421 |
|
422 } |
|
423 |
|
424 EXPORT_C OMX_ERRORTYPE |
|
425 COmxILConfigManager::GetConfig(OMX_INDEXTYPE aConfigIndex, |
|
426 TAny* apComponentConfigStructure) const |
|
427 { |
|
428 DEBUG_PRINTF(_L8("COmxILConfigManager::GetConfig")); |
|
429 |
|
430 TInt index = FindConfigIndex(aConfigIndex); |
|
431 if (KErrNotFound == index) |
|
432 { |
|
433 return OMX_ErrorUnsupportedIndex; |
|
434 } |
|
435 |
|
436 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
437 switch(aConfigIndex) |
|
438 { |
|
439 case OMX_IndexConfigPriorityMgmt: |
|
440 { |
|
441 if (OMX_ErrorNone != (omxRetValue = |
|
442 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
443 apComponentConfigStructure, |
|
444 sizeof(OMX_PRIORITYMGMTTYPE)))) |
|
445 { |
|
446 return omxRetValue; |
|
447 } |
|
448 |
|
449 OMX_PRIORITYMGMTTYPE* pPriorityMgmt |
|
450 = static_cast<OMX_PRIORITYMGMTTYPE*>( |
|
451 apComponentConfigStructure); |
|
452 |
|
453 *pPriorityMgmt = iConfigPriorityMgmt; |
|
454 |
|
455 } |
|
456 break; |
|
457 default: |
|
458 { |
|
459 __ASSERT_ALWAYS(EFalse, |
|
460 User::Panic(KOmxILConfigManagerPanicCategory, 1)); |
|
461 } |
|
462 }; |
|
463 |
|
464 return OMX_ErrorNone; |
|
465 |
|
466 } |
|
467 |
|
468 EXPORT_C OMX_ERRORTYPE |
|
469 COmxILConfigManager::SetConfig(OMX_INDEXTYPE aConfigIndex, |
|
470 const TAny* apComponentConfigStructure) |
|
471 |
|
472 { |
|
473 DEBUG_PRINTF(_L8("COmxILConfigManager::SetConfig")); |
|
474 |
|
475 TInt index = FindConfigIndex(aConfigIndex); |
|
476 if (KErrNotFound == index) |
|
477 { |
|
478 return OMX_ErrorUnsupportedIndex; |
|
479 } |
|
480 |
|
481 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
482 switch(aConfigIndex) |
|
483 { |
|
484 case OMX_IndexConfigPriorityMgmt: |
|
485 { |
|
486 if (OMX_ErrorNone != |
|
487 (omxRetValue = |
|
488 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
489 const_cast<OMX_PTR>(apComponentConfigStructure), |
|
490 sizeof(OMX_PRIORITYMGMTTYPE)))) |
|
491 { |
|
492 return omxRetValue; |
|
493 } |
|
494 |
|
495 const OMX_PRIORITYMGMTTYPE* pPriorityMgmt |
|
496 = static_cast<const OMX_PRIORITYMGMTTYPE*>( |
|
497 apComponentConfigStructure); |
|
498 |
|
499 iConfigPriorityMgmt = *pPriorityMgmt; |
|
500 |
|
501 } |
|
502 break; |
|
503 default: |
|
504 { |
|
505 __ASSERT_ALWAYS(EFalse, |
|
506 User::Panic(KOmxILConfigManagerPanicCategory, 1)); |
|
507 } |
|
508 }; |
|
509 |
|
510 return OMX_ErrorNone; |
|
511 |
|
512 } |
|
513 |
|
514 EXPORT_C OMX_ERRORTYPE |
|
515 COmxILConfigManager::GetExtensionIndex( |
|
516 OMX_STRING /*aParameterName*/, |
|
517 OMX_INDEXTYPE* /*apIndexType*/) const |
|
518 { |
|
519 DEBUG_PRINTF(_L8("COmxILConfigManager::GetExtensionIndex")); |
|
520 |
|
521 // No custom index here for now... |
|
522 return OMX_ErrorUnsupportedIndex; |
|
523 } |
|
524 |
|
525 EXPORT_C OMX_ERRORTYPE |
|
526 COmxILConfigManager::ComponentRoleEnum(OMX_U8* aRole, |
|
527 OMX_U32 aIndex) const |
|
528 { |
|
529 DEBUG_PRINTF(_L8("COmxILConfigManager::ComponentRoleEnum")); |
|
530 |
|
531 // TWC:OpenmaxIL requires error code OMX_ErrorNoMore to be returned when no more roles |
|
532 if (aIndex >= iComponentRoleList.Count()) |
|
533 { |
|
534 return OMX_ErrorNoMore; |
|
535 } |
|
536 |
|
537 HBufC8* pRole = iComponentRoleList[aIndex]; |
|
538 |
|
539 TPtr8 role(reinterpret_cast<TUint8*>(aRole), |
|
540 OMX_MAX_STRINGNAME_SIZE); |
|
541 role = *pRole; |
|
542 role.PtrZ(); |
|
543 |
|
544 return OMX_ErrorNone; |
|
545 |
|
546 } |
|
547 |
|
548 TBool |
|
549 COmxILConfigManager::CompareRoles( |
|
550 const HBufC8& aRole1, const HBufC8& aRole2) |
|
551 { |
|
552 return (aRole1 == aRole2); |
|
553 } |