|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include "omxilincontextcallbackmanager.h" |
|
25 #include "omxilportmanager.h" |
|
26 #include "omxilspecversion.h" |
|
27 #include "omxilfsm.h" |
|
28 #include <openmax/il/loader/omxilcomponentif.h> |
|
29 #include <openmax/il/loader/omxilsymbiancomponentif.h> |
|
30 |
|
31 #include "comxilclockcomponent.h" |
|
32 #include "comxilclockoutputport.h" |
|
33 #include "comxilclockprocessingfunction.h" |
|
34 #include "comxilclockconfigmanager.h" |
|
35 #include "clockpanics.h" |
|
36 #include "omxilclock.hrh" |
|
37 |
|
38 _LIT8(KSymbianOmxILClockNameDes, KCompNameSymbianOmxILClock); |
|
39 _LIT8(KSymbianOmxILClockRoleDes, KRoleSymbianOmxILClock); |
|
40 |
|
41 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILClock); |
|
42 |
|
43 OMX_ERRORTYPE SymbianErrorToOmx(TInt aError); |
|
44 |
|
45 // Component Entry Point |
|
46 OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent) |
|
47 { |
|
48 TInt err = COmxILClockComponent::CreateComponent(aComponent); |
|
49 return SymbianErrorToOmx(err); |
|
50 } |
|
51 |
|
52 TInt COmxILClockComponent::CreateComponent(OMX_HANDLETYPE hComponent) |
|
53 { |
|
54 COmxILClockComponent* self = new COmxILClockComponent(); |
|
55 |
|
56 if (!self) |
|
57 { |
|
58 return KErrNoMemory; |
|
59 } |
|
60 |
|
61 TRAPD(error, self->ConstructL(hComponent)); |
|
62 if(error != KErrNone) |
|
63 { |
|
64 delete self; |
|
65 } |
|
66 return error; |
|
67 } |
|
68 |
|
69 COmxILClockComponent::COmxILClockComponent() |
|
70 { |
|
71 // nothing to do |
|
72 } |
|
73 |
|
74 void COmxILClockComponent::ConstructL(OMX_HANDLETYPE hComponent) |
|
75 { |
|
76 ipHandle = static_cast<OMX_COMPONENTTYPE*>(hComponent); |
|
77 |
|
78 // use synchronous callback manager since BufferDoneNotifications must be serviced at precise times |
|
79 ipCallbackManager = COmxILInContextCallbackManager::NewL(ipHandle, ipAppData, ipCallbacks); |
|
80 |
|
81 ipProcessingFunction = COmxILClockProcessingFunction::NewL(*ipCallbackManager, *this); |
|
82 |
|
83 ipPortManager = COmxILPortManager::NewL( |
|
84 *ipProcessingFunction, // The component's processing function |
|
85 *ipCallbackManager, // The call back manager object |
|
86 TOmxILSpecVersion(), // OMX Version |
|
87 0, // The number of audio ports in this component |
|
88 0, // The starting audio port index |
|
89 0, // The number of image ports in this component |
|
90 0, // The starting image port index |
|
91 0, // The number of video ports in this component |
|
92 0, // The starting video port index |
|
93 KNumPorts, // The number of other ports in this component |
|
94 0, // The starting other port index |
|
95 OMX_FALSE // Process the time port buffer as usual in port manager |
|
96 ); |
|
97 |
|
98 |
|
99 RPointerArray<TDesC8> roleList; |
|
100 CleanupClosePushL(roleList); |
|
101 roleList.AppendL(&KSymbianOmxILClockRoleDes); |
|
102 COmxILClockConfigManager* configManager = COmxILClockConfigManager::NewL(*ipPortManager, KSymbianOmxILClockNameDes, |
|
103 TOmxILSpecVersion(), roleList, *(static_cast<COmxILClockProcessingFunction*>(ipProcessingFunction))); |
|
104 ipConfigManager = configManager; |
|
105 CleanupStack::PopAndDestroy(&roleList); |
|
106 |
|
107 for(TInt portIndex = 0; portIndex < KNumPorts; portIndex++) |
|
108 { |
|
109 AddPortL(); |
|
110 } |
|
111 |
|
112 ipFsm = COmxILFsm::NewL(*this, *ipProcessingFunction, *ipPortManager, *ipConfigManager, *ipCallbackManager); |
|
113 |
|
114 InitComponentL(); |
|
115 } |
|
116 |
|
117 COmxILClockComponent::~COmxILClockComponent() |
|
118 { |
|
119 delete ipConfigManager; |
|
120 delete ipProcessingFunction; |
|
121 delete ipPortManager; |
|
122 delete ipFsm; |
|
123 delete ipCallbackManager; |
|
124 iPorts.ResetAndDestroy(); |
|
125 } |
|
126 |
|
127 void COmxILClockComponent::AddPortL() |
|
128 { |
|
129 TOmxILSpecVersion omxIlVersion; |
|
130 TOmxILCommonPortData portData( |
|
131 omxIlVersion, |
|
132 iPorts.Count(), // port index |
|
133 OMX_DirOutput, |
|
134 4, // minimum number of buffers |
|
135 sizeof(OMX_TIME_MEDIATIMETYPE), // minimum buffer size, in bytes |
|
136 OMX_PortDomainOther, |
|
137 OMX_FALSE, // do not need contigious buffers |
|
138 1, // byte alignment |
|
139 // Clock being buffer supplier allows it to send notifications to clients without |
|
140 // waiting for clients to pass their buffers after a state transition |
|
141 OMX_BufferSupplyOutput, |
|
142 COmxILPort::KBufferMarkPropagationPortNotNeeded |
|
143 ); |
|
144 |
|
145 RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats; |
|
146 |
|
147 CleanupClosePushL(supportedOtherFormats); |
|
148 supportedOtherFormats.AppendL(OMX_OTHER_FormatTime); |
|
149 |
|
150 COmxILClockOutputPort* port = COmxILClockOutputPort::NewL(portData, supportedOtherFormats, |
|
151 *(static_cast<COmxILClockProcessingFunction*>(ipProcessingFunction))); |
|
152 |
|
153 CleanupStack::PushL(port); |
|
154 iPorts.AppendL(port); |
|
155 CleanupStack::Pop(port); |
|
156 |
|
157 CleanupStack::PopAndDestroy(&supportedOtherFormats); |
|
158 User::LeaveIfError(ipPortManager->AddPort(port, OMX_DirOutput)); |
|
159 } |
|
160 |
|
161 /** |
|
162 * Returns true iff the specified port is currently enabled. |
|
163 */ |
|
164 TBool COmxILClockComponent::PortEnabled(TInt aPortIndex) const |
|
165 { |
|
166 return iPorts[aPortIndex]->IsEnabled(); |
|
167 } |
|
168 |
|
169 /** |
|
170 * Returns the number of buffers as configured in the port definition. |
|
171 */ |
|
172 TInt COmxILClockComponent::PortBufferCount(TInt aPortIndex) const |
|
173 { |
|
174 return iPorts[aPortIndex]->BufferCount(); |
|
175 } |
|
176 |
|
177 OMX_ERRORTYPE SymbianErrorToOmx(TInt aError) |
|
178 { |
|
179 switch(aError) |
|
180 { |
|
181 case KErrNone: |
|
182 return OMX_ErrorNone; |
|
183 case KErrNoMemory: |
|
184 return OMX_ErrorInsufficientResources; |
|
185 case KErrArgument: |
|
186 return OMX_ErrorUnsupportedSetting; |
|
187 case KErrNotSupported: |
|
188 return OMX_ErrorUnsupportedIndex; |
|
189 case KErrNotReady: |
|
190 return OMX_ErrorIncorrectStateOperation; |
|
191 default: |
|
192 #ifdef _DEBUG |
|
193 // Panic in a debug build. It will make people think about how the error should be handled. |
|
194 Panic(EUndefinedErrorCode); |
|
195 #endif |
|
196 return OMX_ErrorUndefined; |
|
197 } |
|
198 } |