|
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 /** |
|
19 * @file |
|
20 * @internalTechnology |
|
21 */ |
|
22 |
|
23 #include "omxilport.h" |
|
24 |
|
25 #include "omxilfsm.h" |
|
26 #include "omxilportmanager.h" |
|
27 #include "omxilcallbackmanager.h" |
|
28 #include "omxilspecversion.h" |
|
29 #include <openmax/il/loader/omxilsymbiancomponentif.h> |
|
30 |
|
31 #include "omxilfilesource.h" |
|
32 #include "omxilotherfilesourceopb0port.h" |
|
33 #include "omxilfilesourceprocessingfunction.h" |
|
34 #include "omxilfilesourceconfigmanager.h" |
|
35 #include "omxilfilesource.hrh" |
|
36 |
|
37 #ifdef OMXIL_AUDIO_FILESOURCE |
|
38 #include "omxilaudiofilesourceopb0port.h" |
|
39 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.AUDIO.FILESOURCE"); |
|
40 _LIT8(KNokiaOMXFileSourceRole, "audio_reader.binary"); |
|
41 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILAudioFileSource); |
|
42 |
|
43 #elif defined(OMXIL_VIDEO_FILESOURCE) |
|
44 #include "omxilvideofilesourceopb0port.h" |
|
45 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.VIDEO.FILESOURCE"); |
|
46 _LIT8(KNokiaOMXFileSourceRole, "video_reader.binary"); |
|
47 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILVideoFileSource); |
|
48 |
|
49 #elif defined(OMXIL_IMAGE_FILESOURCE) |
|
50 #include "omxilimagefilesourceopb0port.h" |
|
51 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.IMAGE.FILESOURCE"); |
|
52 _LIT8(KNokiaOMXFileSourceRole, "image_reader.binary"); |
|
53 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILImageFileSource); |
|
54 |
|
55 #elif defined(OMXIL_OTHER_FILESOURCE) |
|
56 #include "omxilotherfilesourceopb0port.h" |
|
57 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.OTHER.FILESOURCE"); |
|
58 _LIT8(KNokiaOMXFileSourceRole, "other_reader.binary"); |
|
59 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILOtherFileSource); |
|
60 |
|
61 #endif |
|
62 |
|
63 const TUint8 KComponentVersionMajor = 1; |
|
64 const TUint8 KComponentVersionMinor = 1; |
|
65 const TUint8 KComponentVersionRevision = 0; |
|
66 const TUint8 KComponentVersionStep = 0; |
|
67 |
|
68 static const TInt KMinBuffers = 1; |
|
69 static const TInt KMinBufferSize = 15360; |
|
70 |
|
71 |
|
72 // Component Entry Point |
|
73 OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent) |
|
74 { |
|
75 TRAPD(err, COmxILFileSource::CreateComponentL(aComponent)); |
|
76 if (err == KErrNone) |
|
77 { |
|
78 return OMX_ErrorNone; |
|
79 } |
|
80 else |
|
81 { |
|
82 return err == KErrNoMemory ? OMX_ErrorInsufficientResources : OMX_ErrorUndefined; |
|
83 } |
|
84 } |
|
85 |
|
86 void COmxILFileSource::CreateComponentL(OMX_HANDLETYPE aComponent) |
|
87 { |
|
88 COmxILFileSource* self = new (ELeave) COmxILFileSource(); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(aComponent); |
|
91 CleanupStack::Pop(self); |
|
92 } |
|
93 |
|
94 COmxILFileSource::COmxILFileSource() |
|
95 { |
|
96 // nothing to do |
|
97 } |
|
98 |
|
99 COmxILFileSource::~COmxILFileSource() |
|
100 { |
|
101 delete ipCallbackManager; |
|
102 delete ipProcessingFunction; |
|
103 delete ipPortManager; |
|
104 delete iOPB0Port; |
|
105 delete ipConfigManager; |
|
106 delete ipFsm; |
|
107 } |
|
108 |
|
109 void COmxILFileSource::ConstructL(OMX_HANDLETYPE aComponent) |
|
110 { |
|
111 // STEP 1: Initialize the data received from the IL Core |
|
112 ipHandle = static_cast<OMX_COMPONENTTYPE*>(aComponent); |
|
113 ipAppData = 0; |
|
114 ipCallbacks = 0; |
|
115 |
|
116 // STEP 2: Create the call backs manager... |
|
117 ipCallbackManager = COmxILCallbackManager::NewL(ipHandle, ipAppData, ipCallbacks); |
|
118 |
|
119 // STEP 3: Create the file source-specific Processing Function... |
|
120 ipProcessingFunction = COmxILFileSourceProcessingFunction::NewL(*ipCallbackManager); |
|
121 |
|
122 // STEP 4: Create Port manager... |
|
123 |
|
124 #ifdef OMXIL_AUDIO_FILESOURCE |
|
125 ipPortManager = COmxILPortManager::NewL( |
|
126 *ipProcessingFunction, // The component's processing function |
|
127 *ipCallbackManager, // The call back manager object |
|
128 TOmxILSpecVersion(), // OMX Version |
|
129 1, // The number of audio ports in this component |
|
130 0, // The starting audio port index |
|
131 0, // The number of image ports in this component |
|
132 0, // The starting image port index |
|
133 0, // The number of video ports in this component |
|
134 0, // The starting video port index |
|
135 0, // The number of other ports in this component |
|
136 0 // The starting other port index |
|
137 ); |
|
138 |
|
139 #elif defined(OMXIL_VIDEO_FILESOURCE) |
|
140 ipPortManager = COmxILPortManager::NewL( |
|
141 *ipProcessingFunction, // The component's processing function |
|
142 *ipCallbackManager, // The call back manager object |
|
143 TOmxILSpecVersion(), // OMX Version |
|
144 0, // The number of audio ports in this component |
|
145 0, // The starting audio port index |
|
146 0, // The number of image ports in this component |
|
147 0, // The starting image port index |
|
148 1, // The number of video ports in this component |
|
149 0, // The starting video port index |
|
150 0, // The number of other ports in this component |
|
151 0 // The starting other port index |
|
152 ); |
|
153 |
|
154 #elif defined(OMXIL_IMAGE_FILESOURCE) |
|
155 ipPortManager = COmxILPortManager::NewL( |
|
156 *ipProcessingFunction, // The component's processing function |
|
157 *ipCallbackManager, // The call back manager object |
|
158 TOmxILSpecVersion(), // OMX Version |
|
159 0, // The number of audio ports in this component |
|
160 0, // The starting audio port index |
|
161 1, // The number of image ports in this component |
|
162 0, // The starting image port index |
|
163 0, // The number of video ports in this component |
|
164 0, // The starting video port index |
|
165 0, // The number of other ports in this component |
|
166 0 // The starting other port index |
|
167 ); |
|
168 |
|
169 |
|
170 #elif defined(OMXIL_OTHER_FILESOURCE) |
|
171 ipPortManager = COmxILPortManager::NewL( |
|
172 *ipProcessingFunction, // The component's processing function |
|
173 *ipCallbackManager, // The call back manager object |
|
174 TOmxILSpecVersion(), // OMX Version |
|
175 0, // The number of audio ports in this component |
|
176 0, // The starting audio port index |
|
177 0, // The number of image ports in this component |
|
178 0, // The starting image port index |
|
179 0, // The number of video ports in this component |
|
180 0, // The starting video port index |
|
181 1, // The number of other ports in this component |
|
182 0 // The starting other port index |
|
183 ); |
|
184 #endif |
|
185 |
|
186 // STEP 5: Create the File Source component port... |
|
187 iOPB0Port = ConstructOPB0PortL(); |
|
188 |
|
189 // STEP 6: Add to the port manager... |
|
190 User::LeaveIfError(ipPortManager->AddPort(iOPB0Port, OMX_DirOutput)); |
|
191 |
|
192 // STEP 7: Create the non-port related configuration manager... |
|
193 RPointerArray<TDesC8> componentRoles; |
|
194 CleanupClosePushL(componentRoles); |
|
195 componentRoles.AppendL(&KNokiaOMXFileSourceRole); |
|
196 ipConfigManager = COmxILFileSourceConfigManager::NewL( |
|
197 *ipPortManager, |
|
198 KNokiaOMXFileSourceComponentName, |
|
199 TOmxILVersion(KComponentVersionMajor, |
|
200 KComponentVersionMinor, |
|
201 KComponentVersionRevision, |
|
202 KComponentVersionStep), |
|
203 componentRoles, |
|
204 *ipProcessingFunction); |
|
205 |
|
206 CleanupStack::PopAndDestroy(&componentRoles); |
|
207 |
|
208 // STEP 8: Create the FSM object... |
|
209 ipFsm = COmxILFsm::NewL(*this, *ipProcessingFunction, *ipPortManager, *ipConfigManager, *ipCallbackManager); |
|
210 |
|
211 // STEP 9: Finally, let's get everything started |
|
212 InitComponentL(); |
|
213 } |
|
214 |
|
215 COmxILPort* COmxILFileSource::ConstructOPB0PortL() const |
|
216 { |
|
217 OMX_U32 thisPortIndex = 0; |
|
218 #ifdef OMXIL_AUDIO_FILESOURCE |
|
219 RArray<OMX_AUDIO_CODINGTYPE> supportedAudioFormats; |
|
220 CleanupClosePushL(supportedAudioFormats); |
|
221 supportedAudioFormats.AppendL(OMX_AUDIO_CodingUnused); |
|
222 COmxILAudioFileSourceOPB0Port* opb0Port = COmxILAudioFileSourceOPB0Port::NewL( |
|
223 TOmxILCommonPortData ( |
|
224 TOmxILSpecVersion(), // OMX specification version information |
|
225 thisPortIndex, // Port number the structure applies to |
|
226 OMX_DirOutput, // Direction of this port |
|
227 KMinBuffers, // The minimum number of buffers this port requires |
|
228 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
229 OMX_PortDomainAudio, // Domain of the port |
|
230 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
231 0, // Buffer aligment requirements |
|
232 OMX_BufferSupplyUnspecified, // supplier preference when tunneling between two ports |
|
233 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
234 supportedAudioFormats, |
|
235 *ipProcessingFunction); |
|
236 CleanupStack::PopAndDestroy(&supportedAudioFormats); |
|
237 return opb0Port; |
|
238 #elif defined(OMXIL_VIDEO_FILESOURCE) |
|
239 RArray<OMX_VIDEO_CODINGTYPE> supportedVideoFormats; |
|
240 CleanupClosePushL(supportedVideoFormats); |
|
241 RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats; |
|
242 CleanupClosePushL(supportedColourFormats); |
|
243 COmxILVideoFileSourceOPB0Port* opb0Port = COmxILVideoFileSourceOPB0Port::NewL( |
|
244 TOmxILCommonPortData ( |
|
245 TOmxILSpecVersion(), // OMX specification version information |
|
246 thisPortIndex, // Port number the structure applies to |
|
247 OMX_DirOutput, // Direction of this port |
|
248 KMinBuffers, // The minimum number of buffers this port requires |
|
249 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
250 OMX_PortDomainVideo, // Domain of the port |
|
251 OMX_FALSE,//OMX_TRUE, // Buffers contiguous requirement (true or false) |
|
252 0,//KBufferAlignment, // Buffer aligment requirements |
|
253 OMX_BufferSupplyUnspecified, // supplier preference when tunneling between two ports |
|
254 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
255 supportedVideoFormats, |
|
256 supportedColourFormats, |
|
257 *ipProcessingFunction); |
|
258 CleanupStack::PopAndDestroy(2); |
|
259 return opb0Port; |
|
260 #elif defined(OMXIL_IMAGE_FILESOURCE) |
|
261 |
|
262 RArray<OMX_IMAGE_CODINGTYPE> supportedImageFormats; |
|
263 CleanupClosePushL(supportedImageFormats); |
|
264 RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats; |
|
265 CleanupClosePushL(supportedColourFormats); |
|
266 COmxILImageFileSourceOPB0Port* opb0Port = COmxILImageFileSourceOPB0Port::NewL( |
|
267 TOmxILCommonPortData ( |
|
268 TOmxILSpecVersion(), // OMX specification version information |
|
269 thisPortIndex, // Port number the structure applies to |
|
270 OMX_DirOutput, // Direction of this port |
|
271 KMinBuffers, // The minimum number of buffers this port requires |
|
272 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
273 OMX_PortDomainImage, // Domain of the port |
|
274 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
275 0, // Buffer aligment requirements |
|
276 OMX_BufferSupplyUnspecified, // supplier preference when tunneling between two ports |
|
277 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
278 supportedImageFormats, |
|
279 supportedColourFormats, |
|
280 *ipProcessingFunction); |
|
281 CleanupStack::PopAndDestroy(2); |
|
282 return opb0Port; |
|
283 |
|
284 #elif defined(OMXIL_OTHER_FILESOURCE) |
|
285 RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats; |
|
286 |
|
287 CleanupClosePushL(supportedOtherFormats); |
|
288 supportedOtherFormats.AppendL(OMX_OTHER_FormatBinary); |
|
289 |
|
290 COmxILOtherFileSourceOPB0Port* opb0Port = COmxILOtherFileSourceOPB0Port::NewL( |
|
291 TOmxILCommonPortData ( |
|
292 TOmxILSpecVersion(), // OMX specification version information |
|
293 thisPortIndex, // Port number the structure applies to |
|
294 OMX_DirOutput, // Direction of this port |
|
295 KMinBuffers, // The minimum number of buffers this port requires |
|
296 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
297 OMX_PortDomainOther, // Domain of the port |
|
298 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
299 0, // Buffer aligment requirements |
|
300 OMX_BufferSupplyUnspecified, // supplier preference when tunneling between two ports |
|
301 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
302 supportedOtherFormats, |
|
303 *ipProcessingFunction); |
|
304 |
|
305 CleanupStack::PopAndDestroy(&supportedOtherFormats); |
|
306 return opb0Port; |
|
307 #endif |
|
308 } |