|
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 "omxilfilesink.h" |
|
32 #include "omxilfilesinkprocessingfunction.h" |
|
33 #include "omxilfilesinkconfigmanager.h" |
|
34 #include "omxilfilesink.hrh" |
|
35 |
|
36 |
|
37 #ifdef OMXIL_AUDIO_FILESINK |
|
38 #include "omxilaudiofilesinkopb0port.h" |
|
39 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.AUDIO.FILESINK"); |
|
40 _LIT8(KNokiaOMXFileSinkRole, "audio_writer.binary"); |
|
41 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILAudioFileSink); |
|
42 |
|
43 #elif defined(OMXIL_VIDEO_FILESINK) |
|
44 #include "omxilvideofilesinkopb0port.h" |
|
45 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.VIDEO.FILESINK"); |
|
46 _LIT8(KNokiaOMXFileSinkRole, "video_writer.binary"); |
|
47 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILVideoFileSink); |
|
48 |
|
49 #elif defined(OMXIL_IMAGE_FILESINK) |
|
50 #include "omxilimagefilesinkopb0port.h" |
|
51 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.IMAGE.FILESINK"); |
|
52 _LIT8(KNokiaOMXFileSinkRole, "image_writer.binary"); |
|
53 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILImageFileSink); |
|
54 |
|
55 #elif defined(OMXIL_OTHER_FILESINK) |
|
56 #include "omxilotherfilesinkopb0port.h" |
|
57 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.OTHER.FILESINK"); |
|
58 _LIT8(KNokiaOMXFileSinkRole, "other_writer.binary"); |
|
59 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILOtherFileSink); |
|
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, COmxILFileSink::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 COmxILFileSink::CreateComponentL(OMX_HANDLETYPE aComponent) |
|
87 { |
|
88 COmxILFileSink* self = new (ELeave) COmxILFileSink(); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(aComponent); |
|
91 CleanupStack::Pop(self); |
|
92 } |
|
93 |
|
94 COmxILFileSink::COmxILFileSink() |
|
95 { |
|
96 // nothing to do |
|
97 } |
|
98 |
|
99 COmxILFileSink::~COmxILFileSink() |
|
100 { |
|
101 delete ipCallbackManager; |
|
102 delete ipProcessingFunction; |
|
103 delete ipPortManager; |
|
104 delete iOPB0Port; |
|
105 delete ipConfigManager; |
|
106 delete ipFsm; |
|
107 } |
|
108 |
|
109 void COmxILFileSink::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 sink-specific Processing Function... |
|
120 ipProcessingFunction = COmxILFileSinkProcessingFunction::NewL(*ipCallbackManager); |
|
121 |
|
122 // STEP 4: Create Port manager... |
|
123 |
|
124 #ifdef OMXIL_AUDIO_FILESINK |
|
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_FILESINK) |
|
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_FILESINK) |
|
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_FILESINK) |
|
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 Sink component port... |
|
187 iOPB0Port = ConstructOPB0PortL(); |
|
188 |
|
189 // STEP 6: Add to the port manager... |
|
190 User::LeaveIfError(ipPortManager->AddPort(iOPB0Port, OMX_DirInput)); |
|
191 |
|
192 // STEP 7: Create the non-port related configuration manager... |
|
193 RPointerArray<TDesC8> componentRoles; |
|
194 CleanupClosePushL(componentRoles); |
|
195 |
|
196 componentRoles.AppendL(&KNokiaOMXFileSinkRole); |
|
197 ipConfigManager = COmxILFileSinkConfigManager::NewL( |
|
198 *ipPortManager, |
|
199 KNokiaOMXFileSinkComponentName, |
|
200 TOmxILVersion(KComponentVersionMajor, |
|
201 KComponentVersionMinor, |
|
202 KComponentVersionRevision, |
|
203 KComponentVersionStep), |
|
204 componentRoles, |
|
205 *ipProcessingFunction); |
|
206 |
|
207 CleanupStack::PopAndDestroy(&componentRoles); |
|
208 |
|
209 // STEP 8: Create the FSM object... |
|
210 ipFsm = COmxILFsm::NewL(*this, *ipProcessingFunction, *ipPortManager, *ipConfigManager, *ipCallbackManager); |
|
211 |
|
212 // STEP 9: Finally, let's get everything started |
|
213 InitComponentL(); |
|
214 } |
|
215 |
|
216 COmxILPort* COmxILFileSink::ConstructOPB0PortL() const |
|
217 { |
|
218 OMX_U32 thisPortIndex = 0; |
|
219 //const TUint32 KBufferAlignment = 4; |
|
220 #ifdef OMXIL_AUDIO_FILESINK |
|
221 RArray<OMX_AUDIO_CODINGTYPE> supportedAudioFormats; |
|
222 CleanupClosePushL(supportedAudioFormats); |
|
223 supportedAudioFormats.AppendL(OMX_AUDIO_CodingUnused); |
|
224 COmxILAudioFileSinkOPB0Port* opb0Port = COmxILAudioFileSinkOPB0Port::NewL( |
|
225 TOmxILCommonPortData ( |
|
226 TOmxILSpecVersion(), // OMX specification version information |
|
227 thisPortIndex, // Port number the structure applies to |
|
228 OMX_DirInput, // Direction of this port |
|
229 KMinBuffers, // The minimum number of buffers this port requires |
|
230 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
231 OMX_PortDomainAudio, // Domain of the port |
|
232 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
233 0, // Buffer aligment requirements |
|
234 OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports |
|
235 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
236 supportedAudioFormats, |
|
237 *ipProcessingFunction); |
|
238 CleanupStack::PopAndDestroy(&supportedAudioFormats); |
|
239 return opb0Port; |
|
240 |
|
241 #elif defined(OMXIL_VIDEO_FILESINK) |
|
242 RArray<OMX_VIDEO_CODINGTYPE> supportedVideoFormats; |
|
243 CleanupClosePushL(supportedVideoFormats); |
|
244 RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats; |
|
245 CleanupClosePushL(supportedColourFormats); |
|
246 COmxILVideoFileSinkOPB0Port* opb0Port = COmxILVideoFileSinkOPB0Port::NewL( |
|
247 TOmxILCommonPortData ( |
|
248 TOmxILSpecVersion(), // OMX specification version information |
|
249 thisPortIndex, // Port number the structure applies to |
|
250 OMX_DirInput, // Direction of this port |
|
251 KMinBuffers, // The minimum number of buffers this port requires |
|
252 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
253 OMX_PortDomainVideo, // Domain of the port |
|
254 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
255 0, // Buffer aligment requirements |
|
256 OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports |
|
257 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
258 supportedVideoFormats, |
|
259 supportedColourFormats, |
|
260 *ipProcessingFunction); |
|
261 CleanupStack::PopAndDestroy(2); |
|
262 return opb0Port; |
|
263 |
|
264 #elif defined(OMXIL_IMAGE_FILESINK) |
|
265 RArray<OMX_IMAGE_CODINGTYPE> supportedImageFormats; |
|
266 CleanupClosePushL(supportedImageFormats); |
|
267 RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats; |
|
268 CleanupClosePushL(supportedColourFormats); |
|
269 COmxILImageFileSinkOPB0Port* opb0Port = COmxILImageFileSinkOPB0Port::NewL( |
|
270 TOmxILCommonPortData ( |
|
271 TOmxILSpecVersion(), // OMX specification version information |
|
272 thisPortIndex, // Port number the structure applies to |
|
273 OMX_DirInput, // Direction of this port |
|
274 KMinBuffers, // The minimum number of buffers this port requires |
|
275 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
276 OMX_PortDomainImage, // Domain of the port |
|
277 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
278 0, // Buffer aligment requirements |
|
279 OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports |
|
280 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
281 supportedImageFormats, |
|
282 supportedColourFormats, |
|
283 *ipProcessingFunction); |
|
284 CleanupStack::PopAndDestroy(2); |
|
285 return opb0Port; |
|
286 |
|
287 #elif defined(OMXIL_OTHER_FILESINK) |
|
288 RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats; |
|
289 CleanupClosePushL(supportedOtherFormats); |
|
290 supportedOtherFormats.AppendL(OMX_OTHER_FormatBinary); |
|
291 COmxILOtherFileSinkOPB0Port* opb0Port = COmxILOtherFileSinkOPB0Port::NewL( |
|
292 TOmxILCommonPortData ( |
|
293 TOmxILSpecVersion(), // OMX specification version information |
|
294 thisPortIndex, // Port number the structure applies to |
|
295 OMX_DirInput, // Direction of this port |
|
296 KMinBuffers, // The minimum number of buffers this port requires |
|
297 KMinBufferSize, // Minimum size, in bytes, for buffers to be used for this port |
|
298 OMX_PortDomainOther, // Domain of the port |
|
299 OMX_FALSE, // Buffers contiguous requirement (true or false) |
|
300 0, // Buffer aligment requirements |
|
301 OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports |
|
302 COmxILPort::KBufferMarkPropagationPortNotNeeded), |
|
303 supportedOtherFormats, |
|
304 *ipProcessingFunction); |
|
305 CleanupStack::PopAndDestroy(&supportedOtherFormats); |
|
306 return opb0Port; |
|
307 |
|
308 #endif |
|
309 } |