|
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 "omxilconfigmanager.h" |
|
29 #include <openmax/il/loader/omxilcomponentif.h> |
|
30 #include <openmax/il/loader/omxilsymbiancomponentif.h> |
|
31 #include "omxilclientclockport.h" |
|
32 |
|
33 #include "comxilvideoscheduler.h" |
|
34 #include "comxilvideoschedulerinputport.h" |
|
35 #include "comxilvideoscheduleroutputport.h" |
|
36 #include "comxilvideoschedulerpf.h" |
|
37 #include "omxilvideoscheduler.hrh" |
|
38 |
|
39 const OMX_U32 KInputPortIndex = 0; |
|
40 const OMX_U32 KOutputPortIndex = 1; |
|
41 const OMX_U32 KClockPortIndex = 2; |
|
42 |
|
43 _LIT8(KSymbianOmxILVideoSchedulerName, "OMX.SYMBIAN.VIDEO.VIDEOSCHEDULER"); |
|
44 _LIT8(KSymbianOmxILVideoSchedulerRole, "video_scheduler.binary"); |
|
45 |
|
46 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILVideoScheduler); |
|
47 |
|
48 OMX_ERRORTYPE SymbianErrorToOmx(TInt aError); |
|
49 |
|
50 // Component Entry Point |
|
51 OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent) |
|
52 { |
|
53 TInt err = COmxILVideoScheduler::CreateComponent(aComponent); |
|
54 return SymbianErrorToOmx(err); |
|
55 } |
|
56 |
|
57 TInt COmxILVideoScheduler::CreateComponent(OMX_HANDLETYPE aComponent) |
|
58 { |
|
59 COmxILVideoScheduler* self = new COmxILVideoScheduler(); |
|
60 |
|
61 if (!self) |
|
62 { |
|
63 return KErrNoMemory; |
|
64 } |
|
65 |
|
66 TRAPD(err, self->ConstructL(aComponent)); |
|
67 if(err) |
|
68 { |
|
69 delete self; |
|
70 } |
|
71 return err; |
|
72 } |
|
73 |
|
74 COmxILVideoScheduler::COmxILVideoScheduler() |
|
75 { |
|
76 // nothing to do |
|
77 } |
|
78 |
|
79 void COmxILVideoScheduler::ConstructL(OMX_HANDLETYPE hComponent) |
|
80 { |
|
81 // STEP 1: Initialize the data received from the IL Core |
|
82 ipHandle = static_cast<OMX_COMPONENTTYPE*>(hComponent); |
|
83 ipAppData = 0; |
|
84 ipCallbacks = 0; |
|
85 |
|
86 // STEP 2: Create the callback manager |
|
87 // In context callback manager is used since we need output buffers to be received at the sink |
|
88 // component immediately after we decide to send them. |
|
89 // Also, returning clock buffers imediately avoids clock buffer starvation |
|
90 ipCallbackManager = COmxILInContextCallbackManager::NewL(ipHandle, ipAppData, ipCallbacks); |
|
91 |
|
92 // STEP 3: Create the Processing Function... |
|
93 ipProcessingFunction = COmxILVideoSchedulerPF::NewL(*ipCallbackManager, *this, ipHandle); |
|
94 |
|
95 // STEP 4: Create Port manager... |
|
96 ipPortManager = COmxILPortManager::NewL( |
|
97 *ipProcessingFunction, // The component's processing function |
|
98 *ipCallbackManager, // The call back manager object |
|
99 TOmxILSpecVersion(), // OMX Version |
|
100 0, // The number of audio ports in this component |
|
101 0, // The starting audio port index |
|
102 0, // The number of image ports in this component |
|
103 0, // The starting image port index |
|
104 2, // The number of video ports in this component |
|
105 0, // The starting video port index |
|
106 1, // The number of other ports in this component |
|
107 2 // The starting other port index |
|
108 ); |
|
109 |
|
110 // create the input port |
|
111 AddInputVideoPortL(); |
|
112 AddOutputVideoPortL(); |
|
113 AddClockPortL(); |
|
114 |
|
115 // STEP 5: Create the non-port related configuration manager... |
|
116 RPointerArray<TDesC8> roleList; |
|
117 CleanupClosePushL(roleList); |
|
118 roleList.AppendL(&KSymbianOmxILVideoSchedulerRole); |
|
119 ipConfigManager = COmxILConfigManager::NewL( |
|
120 *ipPortManager, |
|
121 KSymbianOmxILVideoSchedulerName, |
|
122 TOmxILSpecVersion(), |
|
123 roleList); |
|
124 CleanupStack::PopAndDestroy(); |
|
125 |
|
126 // STEP 6: Create the FSM object... |
|
127 ipFsm = COmxILFsm::NewL(*this, *ipProcessingFunction, *ipPortManager, *ipConfigManager, *ipCallbackManager); |
|
128 |
|
129 // And finally, let's get everything started |
|
130 InitComponentL(); |
|
131 } |
|
132 |
|
133 COmxILVideoScheduler::~COmxILVideoScheduler() |
|
134 { |
|
135 delete ipProcessingFunction; |
|
136 delete ipCallbackManager; |
|
137 delete ipPortManager; |
|
138 delete iVideoOutputPort; |
|
139 delete iVideoInputPort; |
|
140 delete iClockPort; |
|
141 delete ipConfigManager; |
|
142 delete ipFsm; |
|
143 } |
|
144 |
|
145 void COmxILVideoScheduler::AddInputVideoPortL() |
|
146 { |
|
147 TOmxILSpecVersion specVersion; |
|
148 |
|
149 TOmxILCommonPortData portData( |
|
150 specVersion, |
|
151 KInputPortIndex, |
|
152 OMX_DirInput, |
|
153 1, // minimum number of buffers |
|
154 1, // minimum buffer size, in bytes |
|
155 OMX_PortDomainVideo, |
|
156 OMX_FALSE, // do not need contigious buffers |
|
157 1, // 1-byte alignment |
|
158 OMX_BufferSupplyInput, |
|
159 KOutputPortIndex); |
|
160 |
|
161 iVideoInputPort = COmxILVideoSchedulerInputPort::NewL(portData); |
|
162 |
|
163 User::LeaveIfError(ipPortManager->AddPort(iVideoInputPort, OMX_DirInput)); |
|
164 } |
|
165 |
|
166 void COmxILVideoScheduler::AddOutputVideoPortL() |
|
167 { |
|
168 TOmxILSpecVersion specVersion; |
|
169 |
|
170 TOmxILCommonPortData portData( |
|
171 specVersion, |
|
172 KOutputPortIndex, |
|
173 OMX_DirOutput, |
|
174 1, // minimum number of buffers |
|
175 1, // minimum buffer size, in bytes |
|
176 OMX_PortDomainVideo, |
|
177 OMX_FALSE, // do not need contigious buffers |
|
178 1, // 1-byte alignment |
|
179 OMX_BufferSupplyInput, |
|
180 COmxILPort::KBufferMarkPropagationPortNotNeeded); |
|
181 |
|
182 iVideoOutputPort = COmxILVideoSchedulerOutputPort::NewL(portData); |
|
183 |
|
184 User::LeaveIfError(ipPortManager->AddPort(iVideoOutputPort, OMX_DirOutput)); |
|
185 } |
|
186 |
|
187 void COmxILVideoScheduler::AddClockPortL() |
|
188 { |
|
189 TOmxILSpecVersion specVersion; |
|
190 |
|
191 TOmxILCommonPortData portData( |
|
192 specVersion, |
|
193 KClockPortIndex, |
|
194 OMX_DirInput, |
|
195 4, // minimum number of buffers |
|
196 sizeof(OMX_TIME_MEDIATIMETYPE), // minimum buffer size, in bytes |
|
197 OMX_PortDomainOther, |
|
198 OMX_TRUE, // contigious buffers |
|
199 4, // 4-byte alignment |
|
200 OMX_BufferSupplyOutput, |
|
201 COmxILPort::KBufferMarkPropagationPortNotNeeded); |
|
202 |
|
203 RArray<OMX_OTHER_FORMATTYPE> array; |
|
204 CleanupClosePushL(array); |
|
205 array.AppendL(OMX_OTHER_FormatTime); |
|
206 iClockPort = COmxILClientClockPort::NewL(portData, array); |
|
207 CleanupStack::PopAndDestroy(&array); |
|
208 |
|
209 User::LeaveIfError(ipPortManager->AddPort(iClockPort, OMX_DirInput)); |
|
210 } |
|
211 |
|
212 /** Returns the maximum number of buffers configured on a port. */ |
|
213 TUint32 COmxILVideoScheduler::BufferCount() const |
|
214 { |
|
215 // due to buffer copying we do not need the same number of buffers on each port, |
|
216 // so to be safe the maximum count is used when allocating queues. |
|
217 // when buffer sharing is added, the buffer counts must be checked to be the same on |
|
218 // the Loaded->Idle phase. |
|
219 TUint32 in = iVideoInputPort->BufferCount(); |
|
220 TUint32 out = iVideoOutputPort->BufferCount(); |
|
221 return in > out ? in : out; |
|
222 } |
|
223 |
|
224 OMX_ERRORTYPE COmxILVideoScheduler::MediaTimeRequest(TAny* apPrivate, OMX_TICKS aMediaTime, OMX_TICKS aOffset) |
|
225 { |
|
226 return iClockPort->MediaTimeRequest(apPrivate, aMediaTime, aOffset); |
|
227 } |
|
228 |
|
229 OMX_ERRORTYPE COmxILVideoScheduler::GetWallTime(OMX_TICKS& aWallTime) |
|
230 { |
|
231 return iClockPort->GetWallTime(aWallTime); |
|
232 } |
|
233 |
|
234 OMX_ERRORTYPE COmxILVideoScheduler::SetVideoStartTime(OMX_TICKS aStartTime) |
|
235 { |
|
236 return iClockPort->SetStartTime(aStartTime); |
|
237 } |
|
238 |
|
239 OMX_ERRORTYPE SymbianErrorToOmx(TInt aError) |
|
240 { |
|
241 switch(aError) |
|
242 { |
|
243 case KErrNone: |
|
244 return OMX_ErrorNone; |
|
245 case KErrNoMemory: |
|
246 return OMX_ErrorInsufficientResources; |
|
247 default: |
|
248 return OMX_ErrorUndefined; |
|
249 } |
|
250 } |