|
1 // Copyright (c) 2006-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 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "tsu_mdf_omxvorbiscodecs_omx.h" |
|
22 #include <openmax/il/khronos/v1_x/OMX_Core.h> |
|
23 #include <mmf/server/mmfhwdevicesetup.h> |
|
24 #include <mdf/mdfpuconfig.h> |
|
25 #include "PU/decoder/vorbisdecoderprocessingunit.h" |
|
26 #include "PU/vorbisprocessingunituids.hrh" |
|
27 // for the bitrate custom interface |
|
28 #include <mmf/server/devsoundstandardcustominterfaces.h> |
|
29 |
|
30 #include <e32debug.h> |
|
31 |
|
32 // |
|
33 // RTestStepOmxVorbisCodecOmx |
|
34 // general tests relating to OpenMax layer |
|
35 |
|
36 /** |
|
37 * Constructor |
|
38 */ |
|
39 RTestStepOmxVorbisCodecOmx::RTestStepOmxVorbisCodecOmx() |
|
40 { |
|
41 iTestStepName = _L("MM-MDF-OMXVORBISCODECS-U-0020-HP"); |
|
42 iHeapSize = KTestHeapSize; |
|
43 } |
|
44 |
|
45 /** |
|
46 * @see MMdfProcessingUnitObserver |
|
47 */ |
|
48 void RTestStepOmxVorbisCodecOmx::InitializeComplete(const CMdfProcessingUnit* /* aPu */, TInt /* aErrorCode */) |
|
49 { |
|
50 } |
|
51 |
|
52 /** |
|
53 * @see MMdfProcessingUnitObserver |
|
54 */ |
|
55 void RTestStepOmxVorbisCodecOmx::ExecuteComplete(const CMdfProcessingUnit* /* aPu */, TInt /* aErrorCode */) |
|
56 { |
|
57 } |
|
58 |
|
59 /** |
|
60 * Do the test step |
|
61 */ |
|
62 TVerdict RTestStepOmxVorbisCodecOmx::DoTestStepL() |
|
63 { |
|
64 // *** TO DO |
|
65 // (Mip/Mop)Configure / GetConfig() are largely stubbed for both PU and |
|
66 // input / output ports in the Vorbis PU. |
|
67 // This ought to be fixed. |
|
68 |
|
69 iVerdict = EPass; |
|
70 |
|
71 CMdfProcessingUnit* theDecPu=NULL; |
|
72 CMdfProcessingUnit* theEncPu=NULL; |
|
73 |
|
74 _LIT8(KTestGarbage, "I am Garbage"); |
|
75 |
|
76 const TDesC8& testGarbageDes = KTestGarbage; |
|
77 const MMdfProcessingUnitObserver* garbageObs = NULL; |
|
78 |
|
79 // NB we *deliberately* use an unsafe cast |
|
80 garbageObs = (const MMdfProcessingUnitObserver*)&testGarbageDes; |
|
81 |
|
82 TInt err = OMX_Init(); |
|
83 if(err != KErrNone) |
|
84 { |
|
85 ERR_PRINTF1(_L("Error - couldn't initialise OpenMax")); |
|
86 return EFail; |
|
87 } |
|
88 |
|
89 TRAPD(err1, theDecPu = CMdfProcessingUnit::NewL(TUid::Uid(KUidVorbisDecoderPU) )); |
|
90 if(err1 == KErrNone) |
|
91 { |
|
92 err1 = theDecPu->Create(*garbageObs); |
|
93 } |
|
94 |
|
95 TRAPD(err2, theEncPu = CMdfProcessingUnit::NewL(TUid::Uid(KUidVorbisEncoderPU) )); |
|
96 if(err2 == KErrNone) |
|
97 { |
|
98 err2 = theEncPu->Create(*garbageObs); |
|
99 } |
|
100 |
|
101 if(err1 || err2) |
|
102 { |
|
103 ERR_PRINTF1(_L("Error - couldn't initialise PUs (1)")); |
|
104 delete theDecPu; |
|
105 delete theEncPu; |
|
106 OMX_Deinit(); |
|
107 REComSession::FinalClose(); |
|
108 return EFail; |
|
109 } |
|
110 |
|
111 // re-initialise using ourselves as observer |
|
112 delete theDecPu; |
|
113 delete theEncPu; |
|
114 TRAP(err1, theDecPu = CMdfProcessingUnit::NewL(TUid::Uid(KUidVorbisDecoderPU) )); |
|
115 if(err1 == KErrNone) |
|
116 { |
|
117 err1 = theDecPu->Create(*this); |
|
118 } |
|
119 |
|
120 TRAP(err2, theEncPu = CMdfProcessingUnit::NewL(TUid::Uid(KUidVorbisEncoderPU) )); |
|
121 if(err2 == KErrNone) |
|
122 { |
|
123 err2 = theEncPu->Create(*this); |
|
124 } |
|
125 |
|
126 if(err1 || err2) |
|
127 { |
|
128 ERR_PRINTF1(_L("Error - couldn't initialise PUs (2)")); |
|
129 delete theDecPu; |
|
130 delete theEncPu; |
|
131 OMX_Deinit(); |
|
132 REComSession::FinalClose(); |
|
133 return EFail; |
|
134 } |
|
135 |
|
136 RPointerArray<MMdfInputPort> ipa; |
|
137 RPointerArray<MMdfOutputPort> opa; |
|
138 |
|
139 // decoder |
|
140 if(theDecPu) |
|
141 { |
|
142 MMdfInputPort* inputPort = NULL; |
|
143 MMdfOutputPort* outputPort = NULL; |
|
144 |
|
145 err1 = theDecPu->GetInputPorts(ipa); |
|
146 if(err1 == KErrNone && ipa.Count()) |
|
147 { |
|
148 inputPort = ipa[0]; |
|
149 } |
|
150 err2 = theDecPu->GetOutputPorts(opa); |
|
151 if(err2 == KErrNone && opa.Count()) |
|
152 { |
|
153 outputPort = opa[0]; |
|
154 } |
|
155 |
|
156 if(!inputPort || !outputPort) |
|
157 { |
|
158 ERR_PRINTF1(_L("Error - couldn't get input/output ports")); |
|
159 iVerdict = EFail; |
|
160 } |
|
161 else |
|
162 { |
|
163 // set port observers |
|
164 inputPort->MipSetObserver(*this); |
|
165 outputPort->MopSetObserver(*this); |
|
166 |
|
167 // configure |
|
168 TTaskConfig config; |
|
169 config.iRate = 0; |
|
170 config.iStereoMode = 0; |
|
171 TPuTaskConfig puConfig2(config); |
|
172 err = theDecPu->Configure(puConfig2); |
|
173 if(err) |
|
174 { |
|
175 ERR_PRINTF1(_L("Error - couldn't configure PU")); |
|
176 iVerdict = EFail; |
|
177 } |
|
178 err = theDecPu->GetConfig(puConfig2); |
|
179 if(err) |
|
180 { |
|
181 ERR_PRINTF1(_L("Error - couldn't get PU configuration")); |
|
182 iVerdict = EFail; |
|
183 } |
|
184 |
|
185 // create / free buffers |
|
186 CMMFBuffer* inputBuffer = NULL; |
|
187 CMMFBuffer* outputBuffer = NULL; |
|
188 |
|
189 // try and create oversized buffers |
|
190 inputBuffer = inputPort->MipCreateBuffer(20480000); |
|
191 if(inputBuffer) |
|
192 { |
|
193 ERR_PRINTF1(_L("Error - oversize buffer creation was non-null")); |
|
194 iVerdict = EFail; |
|
195 } |
|
196 outputBuffer = outputPort->MopCreateBuffer(0); |
|
197 if(outputBuffer) |
|
198 { |
|
199 ERR_PRINTF1(_L("Error - zero buffer creation was non-null")); |
|
200 iVerdict = EFail; |
|
201 } |
|
202 |
|
203 TUint32 inputBufSize = 2048; |
|
204 inputBufSize = inputPort->MipBufferSize(); |
|
205 inputBuffer = inputPort->MipCreateBuffer(inputBufSize); |
|
206 outputBuffer = outputPort->MopCreateBuffer(inputBufSize); |
|
207 if(!inputBuffer || !outputBuffer) |
|
208 { |
|
209 ERR_PRINTF1(_L("Error - failed to create input or output buffer")); |
|
210 iVerdict = EFail; |
|
211 } |
|
212 |
|
213 // direct port config |
|
214 err = inputPort->MipConfigure(puConfig2); |
|
215 if(err) |
|
216 { |
|
217 ERR_PRINTF1(_L("Error - couldn't configure input port")); |
|
218 iVerdict = EFail; |
|
219 } |
|
220 err = inputPort->MipGetConfig(puConfig2); |
|
221 if(err) |
|
222 { |
|
223 ERR_PRINTF1(_L("Error - couldn't get input port configuration")); |
|
224 iVerdict = EFail; |
|
225 } |
|
226 err = outputPort->MopConfigure(puConfig2); |
|
227 if(err) |
|
228 { |
|
229 ERR_PRINTF1(_L("Error - couldn't configure output port")); |
|
230 iVerdict = EFail; |
|
231 } |
|
232 err = outputPort->MopGetConfig(puConfig2); |
|
233 if(err) |
|
234 { |
|
235 ERR_PRINTF1(_L("Error - couldn't get output port configuration")); |
|
236 iVerdict = EFail; |
|
237 } |
|
238 |
|
239 // --- get state |
|
240 theDecPu->State(); |
|
241 |
|
242 // try and initialize twice; try and execute twice |
|
243 |
|
244 theDecPu->Initialize(); |
|
245 theDecPu->Initialize(); |
|
246 |
|
247 theDecPu->Execute(); |
|
248 theDecPu->Execute(); |
|
249 |
|
250 // try and action the ports when we're not running |
|
251 // NB we should give some delay here so we don't free them before |
|
252 // they are actioned |
|
253 theDecPu->Pause(); |
|
254 inputPort->MipWriteData(*inputBuffer); |
|
255 outputPort->MopReadData(*outputBuffer); |
|
256 User::After(2000000L); |
|
257 |
|
258 theDecPu->Stop(); |
|
259 inputPort->MipWriteData(*inputBuffer); |
|
260 outputPort->MopReadData(*outputBuffer); |
|
261 User::After(2000000L); |
|
262 |
|
263 err = inputPort->MipFreeBuffer(inputBuffer); |
|
264 err += outputPort->MopFreeBuffer(outputBuffer); |
|
265 if(err) |
|
266 { |
|
267 ERR_PRINTF1(_L("Error - couldn't free input/output buffer")); |
|
268 iVerdict = EFail; |
|
269 } |
|
270 |
|
271 opa.Close(); |
|
272 ipa.Close(); |
|
273 } |
|
274 } |
|
275 |
|
276 // encoder |
|
277 if(theEncPu) |
|
278 { |
|
279 MMdfInputPort* inputPort = NULL; |
|
280 MMdfOutputPort* outputPort = NULL; |
|
281 |
|
282 err1 = theEncPu->GetInputPorts(ipa); |
|
283 if(err1 == KErrNone && ipa.Count()) |
|
284 { |
|
285 inputPort = ipa[0]; |
|
286 } |
|
287 err2 = theEncPu->GetOutputPorts(opa); |
|
288 if(err2 == KErrNone && opa.Count()) |
|
289 { |
|
290 outputPort = opa[0]; |
|
291 } |
|
292 |
|
293 if(!inputPort || !outputPort) |
|
294 { |
|
295 ERR_PRINTF1(_L("Error - couldn't get input/output ports")); |
|
296 iVerdict = EFail; |
|
297 } |
|
298 else |
|
299 { |
|
300 |
|
301 // configure |
|
302 TTaskConfig config; |
|
303 config.iRate = 0; |
|
304 config.iStereoMode = 0; |
|
305 TPuTaskConfig puConfig2(config); |
|
306 err = theEncPu->Configure(puConfig2); |
|
307 if(err) |
|
308 { |
|
309 ERR_PRINTF1(_L("Error - couldn't configure PU")); |
|
310 iVerdict = EFail; |
|
311 } |
|
312 err = theEncPu->GetConfig(puConfig2); |
|
313 if(err) |
|
314 { |
|
315 ERR_PRINTF1(_L("Error - couldn't get PU configuration")); |
|
316 iVerdict = EFail; |
|
317 } |
|
318 |
|
319 // create / free buffers |
|
320 CMMFBuffer* inputBuffer = NULL; |
|
321 CMMFBuffer* outputBuffer = NULL; |
|
322 |
|
323 // try and create oversized buffers |
|
324 inputBuffer = inputPort->MipCreateBuffer(20480000); |
|
325 if(inputBuffer) |
|
326 { |
|
327 ERR_PRINTF1(_L("Error - oversize buffer creation was non-null")); |
|
328 iVerdict = EFail; |
|
329 } |
|
330 outputBuffer = outputPort->MopCreateBuffer(0); |
|
331 if(outputBuffer) |
|
332 { |
|
333 ERR_PRINTF1(_L("Error - zero buffer creation was non-null")); |
|
334 iVerdict = EFail; |
|
335 } |
|
336 |
|
337 TUint32 inputBufSize = 2048; |
|
338 inputBufSize = inputPort->MipBufferSize(); |
|
339 inputBuffer = inputPort->MipCreateBuffer(inputBufSize); |
|
340 outputBuffer = outputPort->MopCreateBuffer(inputBufSize); |
|
341 if(!inputBuffer || !outputBuffer) |
|
342 { |
|
343 ERR_PRINTF1(_L("Error - failed to create input or output buffer")); |
|
344 iVerdict = EFail; |
|
345 } |
|
346 |
|
347 // direct port config |
|
348 err = inputPort->MipConfigure(puConfig2); |
|
349 if(err) |
|
350 { |
|
351 ERR_PRINTF1(_L("Error - couldn't configure input port")); |
|
352 iVerdict = EFail; |
|
353 } |
|
354 err = inputPort->MipGetConfig(puConfig2); |
|
355 if(err) |
|
356 { |
|
357 ERR_PRINTF1(_L("Error - couldn't get input port configuration")); |
|
358 iVerdict = EFail; |
|
359 } |
|
360 err = outputPort->MopConfigure(puConfig2); |
|
361 if(err) |
|
362 { |
|
363 ERR_PRINTF1(_L("Error - couldn't configure output port")); |
|
364 iVerdict = EFail; |
|
365 } |
|
366 err = outputPort->MopGetConfig(puConfig2); |
|
367 if(err) |
|
368 { |
|
369 ERR_PRINTF1(_L("Error - couldn't get output port configuration")); |
|
370 iVerdict = EFail; |
|
371 } |
|
372 |
|
373 // --- get state |
|
374 theEncPu->State(); |
|
375 |
|
376 // try and initialize twice; try and execute twice |
|
377 |
|
378 theEncPu->Initialize(); |
|
379 theEncPu->Initialize(); |
|
380 |
|
381 theEncPu->Execute(); |
|
382 theEncPu->Execute(); |
|
383 |
|
384 // try and action the ports when we're not running |
|
385 // NB we should give some delay here so we don't free them before |
|
386 // they are actioned |
|
387 |
|
388 // *** there is a problem with this at the moment - |
|
389 // VorbisEncoder will kern-exec:3 when passed garbage data |
|
390 // directly. To be resolved before this test goes back in. |
|
391 /* |
|
392 CMMFDataBuffer* dataBuffer = static_cast<CMMFDataBuffer*>(inputBuffer); |
|
393 TUint8* data_pointer = const_cast<TUint8*>(dataBuffer->Data().Ptr()); |
|
394 memset(data_pointer, 0, dataBuffer->Data().MaxLength()); |
|
395 dataBuffer = static_cast<CMMFDataBuffer*>(outputBuffer); |
|
396 data_pointer = const_cast<TUint8*>(dataBuffer->Data().Ptr()); |
|
397 memset(data_pointer, 0, dataBuffer->Data().MaxLength()); |
|
398 |
|
399 theEncPu->Pause(); |
|
400 inputPort->MipWriteData(*inputBuffer); |
|
401 outputPort->MopReadData(*outputBuffer); |
|
402 User::After(2000000L); |
|
403 */ |
|
404 |
|
405 err = inputPort->MipFreeBuffer(inputBuffer); |
|
406 err += outputPort->MopFreeBuffer(outputBuffer); |
|
407 if(err) |
|
408 { |
|
409 ERR_PRINTF1(_L("Error - couldn't free input/output buffer")); |
|
410 iVerdict = EFail; |
|
411 } |
|
412 |
|
413 opa.Close(); |
|
414 ipa.Close(); |
|
415 } |
|
416 } |
|
417 |
|
418 delete theDecPu; |
|
419 delete theEncPu; |
|
420 OMX_Deinit(); |
|
421 REComSession::FinalClose(); |
|
422 return iVerdict; |
|
423 } |
|
424 |
|
425 // end |