|
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 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <mmf/server/mmfbuffer.h> |
|
22 #include <mmf/server/mmfdatabuffer.h> |
|
23 |
|
24 #include <ecom/ecom.h> |
|
25 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
26 #include <openmax/il/loader/omxilcomponentif.h> |
|
27 |
|
28 #include "log.h" |
|
29 #include "tsu_omxil_component_base.h" |
|
30 |
|
31 |
|
32 const TInt CCallbackHandler::KMaxMsgQueueEntries; |
|
33 |
|
34 |
|
35 CAacTestFile* |
|
36 CAacTestFile::NewL() |
|
37 { |
|
38 DEBUG_PRINTF(_L8("CAacTestFile::NewL")); |
|
39 CAacTestFile* self = new (ELeave) CAacTestFile(); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 void |
|
47 CAacTestFile::ConstructL() |
|
48 { |
|
49 DEBUG_PRINTF(_L8("CAacTestFile::ConstructL")); |
|
50 } |
|
51 |
|
52 CAacTestFile::CAacTestFile() : |
|
53 iSourceFile(0), |
|
54 iSourceFileReadPos(0), |
|
55 iFinished(EFalse) |
|
56 { |
|
57 DEBUG_PRINTF(_L8("CAacTestFile::CAacTestFile")); |
|
58 } |
|
59 |
|
60 CAacTestFile::~CAacTestFile() |
|
61 { |
|
62 DEBUG_PRINTF(_L8("CAacTestFile::~CAacTestFile")); |
|
63 |
|
64 delete iSourceFile; |
|
65 |
|
66 } |
|
67 |
|
68 TInt |
|
69 CAacTestFile::ReadTestFileInBuffer(const TDesC& aFileName) |
|
70 { |
|
71 DEBUG_PRINTF(_L8("CAacTestFile::ReadTestFileInBuffer")); |
|
72 |
|
73 RFs fs; |
|
74 TInt err; |
|
75 err = fs.Connect(); |
|
76 |
|
77 if (err != KErrNone) |
|
78 { |
|
79 return err; |
|
80 } |
|
81 |
|
82 RFile file; |
|
83 err = file.Open(fs, aFileName, EFileRead); |
|
84 |
|
85 if (err == KErrNone) |
|
86 { |
|
87 TInt size; |
|
88 err = file.Size(size); |
|
89 if (err == KErrNone) |
|
90 { |
|
91 iSourceFile = HBufC8::NewMax(size); |
|
92 if(!iSourceFile) |
|
93 { |
|
94 return KErrNoMemory; |
|
95 } |
|
96 TPtr8 ptr = iSourceFile->Des(); |
|
97 file.Read(ptr,size); |
|
98 file.Close(); |
|
99 } |
|
100 fs.Close(); |
|
101 } |
|
102 |
|
103 return err; |
|
104 |
|
105 } |
|
106 |
|
107 |
|
108 void |
|
109 CAacTestFile::ReadNextBuffer(CMMFBuffer& aDataBuffer) |
|
110 { |
|
111 DEBUG_PRINTF(_L8("CAacTestFile::ReadNextBuffer")); |
|
112 |
|
113 CMMFDataBuffer* pDataBuffer = static_cast<CMMFDataBuffer*>(&aDataBuffer); |
|
114 while (ETrue) |
|
115 { |
|
116 // check if finished |
|
117 if (iFinished) |
|
118 { |
|
119 DEBUG_PRINTF(_L8("CAacTestFile::ReadNextBuffer : File finished")); |
|
120 pDataBuffer->Data().Zero(); |
|
121 return; |
|
122 } |
|
123 |
|
124 TInt srcLength = iSourceFile->Size(); |
|
125 if (iSourceFileReadPos < srcLength) |
|
126 { |
|
127 TInt size = srcLength; |
|
128 if (size > pDataBuffer->Data().MaxLength()) |
|
129 { |
|
130 size = pDataBuffer->Data().MaxLength(); |
|
131 } |
|
132 Mem::Copy((TAny*)pDataBuffer->Data().Ptr(), (TAny*)iSourceFile->Mid(iSourceFileReadPos).Ptr(), size); |
|
133 pDataBuffer->Data().SetLength(size); |
|
134 iSourceFileReadPos += size; |
|
135 DEBUG_PRINTF2(_L8("CAacTestFile::ReadNextBuffer : data read = [%d] bytes"), iSourceFileReadPos); |
|
136 DEBUG_PRINTF2(_L8("CAacTestFile::ReadNextBuffer : pDataBuffer->BufferSize = [%u] bytes"), pDataBuffer->BufferSize()); |
|
137 if (iSourceFileReadPos >= srcLength) |
|
138 { |
|
139 DEBUG_PRINTF(_L8("CAacTestFile::ReadNextBuffer : end of data")); |
|
140 pDataBuffer->SetLastBuffer(ETrue); |
|
141 iFinished = ETrue; |
|
142 } |
|
143 return; |
|
144 |
|
145 } |
|
146 else |
|
147 { |
|
148 // no more data |
|
149 DEBUG_PRINTF(_L8("CAacTestFile::ReadNextBuffer : end of data")); |
|
150 iFinished = ETrue; |
|
151 return; |
|
152 } |
|
153 } |
|
154 } |
|
155 |
|
156 void |
|
157 CAacTestFile::ResetPos() |
|
158 { |
|
159 iSourceFileReadPos = 0; |
|
160 iFinished = EFalse; |
|
161 } |
|
162 |
|
163 TInt |
|
164 CAacTestFile::GetPos() |
|
165 { |
|
166 return iSourceFileReadPos; |
|
167 } |
|
168 |
|
169 |
|
170 CAacOutputTestFile* |
|
171 CAacOutputTestFile::NewL() |
|
172 { |
|
173 DEBUG_PRINTF(_L8("CAacOutputTestFile::NewL")); |
|
174 CAacOutputTestFile* self = new (ELeave) CAacOutputTestFile(); |
|
175 CleanupStack::PushL(self); |
|
176 self->ConstructL(); |
|
177 CleanupStack::Pop(self); |
|
178 return self; |
|
179 } |
|
180 |
|
181 void |
|
182 CAacOutputTestFile::ConstructL() |
|
183 { |
|
184 DEBUG_PRINTF(_L8("CAacOutputTestFile::ConstructL")); |
|
185 } |
|
186 |
|
187 CAacOutputTestFile::CAacOutputTestFile() : |
|
188 iFileServerSession(), |
|
189 iOutputFile(), |
|
190 iWrittenDataTotal(0), |
|
191 iBuffersWrittenCount(0) |
|
192 { |
|
193 DEBUG_PRINTF(_L8("CAacOutputTestFile::CAacOutputTestFile")); |
|
194 } |
|
195 |
|
196 CAacOutputTestFile::~CAacOutputTestFile() |
|
197 { |
|
198 DEBUG_PRINTF(_L8("CAacOutputTestFile::~CAacOutputTestFile")); |
|
199 } |
|
200 |
|
201 TInt |
|
202 CAacOutputTestFile::SetUpOutputFile(const TDesC& aFileName) |
|
203 { |
|
204 DEBUG_PRINTF(_L8("CAacOutputTestFile::SetUpOutputFile")); |
|
205 |
|
206 TInt err; |
|
207 |
|
208 err = iFileServerSession.Connect(); |
|
209 |
|
210 if (err != KErrNone) |
|
211 { |
|
212 return err; |
|
213 } |
|
214 |
|
215 err = iOutputFile.Create(iFileServerSession, |
|
216 aFileName, |
|
217 EFileWrite|EFileShareExclusive); |
|
218 if(err != KErrNone) |
|
219 { |
|
220 err = iOutputFile.Replace(iFileServerSession, |
|
221 aFileName, |
|
222 EFileWrite|EFileShareExclusive); |
|
223 } |
|
224 return err; |
|
225 |
|
226 } |
|
227 |
|
228 TInt |
|
229 CAacOutputTestFile::WriteDataToFile(const CMMFBuffer& aDataBuffer) |
|
230 { |
|
231 DEBUG_PRINTF(_L8("CAacOutputTestFile::WriteDataToFile")); |
|
232 |
|
233 const CMMFDataBuffer& dataBuffer = static_cast<const CMMFDataBuffer&>(aDataBuffer); |
|
234 const TDesC8& data = dataBuffer.Data(); |
|
235 |
|
236 TInt err = KErrNone; |
|
237 err = iOutputFile.Write(data); |
|
238 if(err != KErrNone) |
|
239 { |
|
240 return err; |
|
241 } |
|
242 // keep record of amount of data and the number of buffers written out |
|
243 iWrittenDataTotal += data.Size(); |
|
244 iBuffersWrittenCount++; |
|
245 |
|
246 DEBUG_PRINTF2(_L8("CAacOutputTestFile::WriteDataToFile : data.Size()[%d]"), data.Size()); |
|
247 DEBUG_PRINTF2(_L8("CAacOutputTestFile::WriteDataToFile : iWrittenDataTotal[%d]"), iWrittenDataTotal); |
|
248 DEBUG_PRINTF2(_L8("CAacOutputTestFile::WriteDataToFile : iBuffersWrittenCount[%d]"), iBuffersWrittenCount); |
|
249 |
|
250 return err; |
|
251 |
|
252 } |
|
253 |
|
254 |
|
255 TInt |
|
256 CAacOutputTestFile::AddWavHeader() |
|
257 { |
|
258 DEBUG_PRINTF(_L8("CAacOutputTestFile::AddWavHeader")); |
|
259 |
|
260 TInt err; |
|
261 RFs fs; |
|
262 err = fs.Connect(); |
|
263 |
|
264 if (err != KErrNone) |
|
265 { |
|
266 return err; |
|
267 } |
|
268 |
|
269 RFile file; |
|
270 err = file.Open(fs, KAacDecoderOutputTestFile, EFileRead); |
|
271 if (err != KErrNone) |
|
272 { |
|
273 return err; |
|
274 } |
|
275 |
|
276 TInt size; |
|
277 err = file.Size(size); |
|
278 if (err != KErrNone) |
|
279 { |
|
280 return err; |
|
281 } |
|
282 |
|
283 HBufC8* rawDecFile = HBufC8::NewMax(size); |
|
284 if(!rawDecFile) |
|
285 { |
|
286 return KErrNoMemory; |
|
287 } |
|
288 |
|
289 TPtr8 ptr = rawDecFile->Des(); |
|
290 file.Read(ptr,size); |
|
291 file.Close(); |
|
292 |
|
293 // add headers |
|
294 err = file.Replace(fs, KAacDecoderOutputTestFile, EFileWrite); |
|
295 if (err != KErrNone) |
|
296 { |
|
297 return err; |
|
298 } |
|
299 |
|
300 // this is canonical WAV file format header |
|
301 TInt32 chunkSize = size + KTestWavFormatPCMChunkHeaderSize; |
|
302 TInt32 subchunk1size = KTestWavFormatPCMSubchunk1Size; |
|
303 TInt16 audioFormat = KTestAudioFormatPCM; |
|
304 TInt16 numChannels = KTestNumChannels; |
|
305 TInt32 sampleRate = KTestSampleRate; |
|
306 TInt16 bitsPerSample = KTestBitsPerSample; |
|
307 TInt32 byteRate = sampleRate * numChannels * (bitsPerSample / 8); |
|
308 TInt16 blockAlign = numChannels * (bitsPerSample / 8); |
|
309 TInt32 subchunk2size = size; |
|
310 |
|
311 file.Write(_L8("RIFF")); |
|
312 { TPtrC8 buf((TText8*)&chunkSize,sizeof(TInt32)); file.Write(buf); } |
|
313 file.Write(_L8("WAVEfmt ")); |
|
314 { TPtrC8 buf((TText8*)&subchunk1size,sizeof(TInt32)); file.Write(buf); } |
|
315 { TPtrC8 buf((TText8*)&audioFormat,sizeof(TInt16)); file.Write(buf); } |
|
316 { TPtrC8 buf((TText8*)&numChannels,sizeof(TInt16)); file.Write(buf); } |
|
317 { TPtrC8 buf((TText8*)&sampleRate,sizeof(TInt32)); file.Write(buf); } |
|
318 { TPtrC8 buf((TText8*)&byteRate,sizeof(TInt32)); file.Write(buf); } |
|
319 { TPtrC8 buf((TText8*)&blockAlign,sizeof(TInt16)); file.Write(buf); } |
|
320 { TPtrC8 buf((TText8*)&bitsPerSample,sizeof(TInt16)); file.Write(buf); } |
|
321 file.Write(_L8("data")); |
|
322 { TPtrC8 buf((TText8*)&subchunk2size,sizeof(TInt32)); file.Write(buf); } |
|
323 file.Write(ptr,size); |
|
324 |
|
325 // store file size |
|
326 file.Size(iWrittenDataTotal); |
|
327 |
|
328 file.Close(); |
|
329 fs.Close(); |
|
330 |
|
331 delete rawDecFile; |
|
332 |
|
333 return KErrNone; |
|
334 |
|
335 } |
|
336 |
|
337 void |
|
338 CAacOutputTestFile::CloseOutputFile() |
|
339 { |
|
340 DEBUG_PRINTF(_L8("CAacOutputTestFile::CloseOutputFile")); |
|
341 |
|
342 iOutputFile.Close(); |
|
343 iFileServerSession.Close(); |
|
344 |
|
345 } |
|
346 |
|
347 // |
|
348 // CUtilityTimer |
|
349 // |
|
350 CUtilityTimer* |
|
351 CUtilityTimer::NewL(TTimeIntervalMicroSeconds32& aDelay, |
|
352 MTimerObserver& aObserver) |
|
353 { |
|
354 CUtilityTimer* self = new (ELeave) CUtilityTimer(aObserver); |
|
355 CleanupStack::PushL(self); |
|
356 self->ConstructL(aDelay); |
|
357 CleanupStack::Pop(self); |
|
358 return self; |
|
359 } |
|
360 |
|
361 void |
|
362 CUtilityTimer::ConstructL(TTimeIntervalMicroSeconds32& aDelay) |
|
363 { |
|
364 CTimer::ConstructL(); |
|
365 |
|
366 iDelay = aDelay; |
|
367 CActiveScheduler::Add(this); |
|
368 } |
|
369 |
|
370 CUtilityTimer::~CUtilityTimer() |
|
371 { |
|
372 Cancel(); |
|
373 } |
|
374 |
|
375 void |
|
376 CUtilityTimer::InitializeTimer() |
|
377 { |
|
378 // Request another wait - assume not active |
|
379 CTimer::After(iDelay); |
|
380 } |
|
381 |
|
382 void |
|
383 CUtilityTimer::RunL() |
|
384 { |
|
385 if (iStatus.Int() == KErrNone) |
|
386 iObserver.TimerExpired(); |
|
387 } |
|
388 |
|
389 void |
|
390 CUtilityTimer::DoCancel() |
|
391 { |
|
392 } |
|
393 |
|
394 |
|
395 CUtilityTimer::CUtilityTimer(MTimerObserver& aObserver) : |
|
396 CTimer(CActive::EPriorityUserInput), |
|
397 iObserver(aObserver) |
|
398 { |
|
399 } |
|
400 |
|
401 // |
|
402 // CCallbackHandler |
|
403 // |
|
404 CCallbackHandler* |
|
405 CCallbackHandler::NewL(RAsyncTestStepOmxILComponentBase& aDecoderTest) |
|
406 { |
|
407 DEBUG_PRINTF(_L8("CCallbackHandler::NewL")); |
|
408 |
|
409 CCallbackHandler* self = new (ELeave) CCallbackHandler(aDecoderTest); |
|
410 CleanupStack::PushL(self); |
|
411 self->ConstructL(); |
|
412 CleanupStack::Pop(self); |
|
413 return self; |
|
414 |
|
415 } |
|
416 |
|
417 |
|
418 void |
|
419 CCallbackHandler::ConstructL() |
|
420 { |
|
421 DEBUG_PRINTF(_L8("CCallbackHandler::ConstructL")); |
|
422 |
|
423 OMX_CALLBACKTYPE h = |
|
424 { |
|
425 CCallbackHandler::EventHandler, |
|
426 CCallbackHandler::EmptyBufferDone, |
|
427 CCallbackHandler::FillBufferDone |
|
428 }; |
|
429 |
|
430 iHandle = h; |
|
431 CActiveScheduler::Add(this); |
|
432 |
|
433 User::LeaveIfError(iMsgQueue.CreateLocal(KMaxMsgQueueEntries)); |
|
434 iMsgQueue.NotifyDataAvailable(iStatus); |
|
435 SetActive(); |
|
436 |
|
437 } |
|
438 |
|
439 CCallbackHandler::CCallbackHandler(RAsyncTestStepOmxILComponentBase& aDecoderTest) |
|
440 : CActive(EPriorityNormal), |
|
441 iDecoderTest(aDecoderTest) |
|
442 { |
|
443 DEBUG_PRINTF(_L8("CCallbackHandler::CCallbackHandler")); |
|
444 } |
|
445 |
|
446 |
|
447 CCallbackHandler::operator OMX_CALLBACKTYPE*() |
|
448 { |
|
449 DEBUG_PRINTF(_L8("CCallbackHandler::operator OMX_CALLBACKTYPE*")); |
|
450 |
|
451 return &iHandle; |
|
452 |
|
453 } |
|
454 |
|
455 |
|
456 void |
|
457 CCallbackHandler::RunL() |
|
458 { |
|
459 DEBUG_PRINTF(_L8("CCallbackHandler::RunL")); |
|
460 |
|
461 TOmxMessage msg; |
|
462 while (iMsgQueue.Receive(msg)==KErrNone) |
|
463 { |
|
464 switch (msg.iType) |
|
465 { |
|
466 case EEmptyBufferCallback: |
|
467 { |
|
468 iDecoderTest.DoEmptyBufferDoneL(msg.iComponent, |
|
469 msg.iBuffer); |
|
470 } |
|
471 break; |
|
472 case EFillBufferCallback: |
|
473 { |
|
474 iDecoderTest.DoFillBufferDoneL(msg.iComponent, |
|
475 msg.iBuffer); |
|
476 } |
|
477 break; |
|
478 case EEventCallback: |
|
479 { |
|
480 iDecoderTest.DoEventHandlerL(msg.iComponent, |
|
481 msg.iEventParams.iEvent, |
|
482 msg.iEventParams.iData1, |
|
483 msg.iEventParams.iData2, |
|
484 msg.iEventParams.iExtra); |
|
485 } |
|
486 break; |
|
487 default: |
|
488 { |
|
489 // This is an invalid state |
|
490 ASSERT(EFalse); |
|
491 } |
|
492 }; |
|
493 } |
|
494 |
|
495 // setup for next callbacks |
|
496 iStatus = KRequestPending; |
|
497 iMsgQueue.NotifyDataAvailable(iStatus); |
|
498 SetActive(); |
|
499 |
|
500 } |
|
501 |
|
502 CCallbackHandler::~CCallbackHandler() |
|
503 { |
|
504 DEBUG_PRINTF(_L8("CCallbackHandler::~CCallbackHandler")); |
|
505 |
|
506 Cancel(); |
|
507 iMsgQueue.Close(); |
|
508 |
|
509 } |
|
510 |
|
511 |
|
512 void |
|
513 CCallbackHandler::DoCancel() |
|
514 { |
|
515 DEBUG_PRINTF(_L8("CCallbackHandler::DoCancel")); |
|
516 |
|
517 if (iMsgQueue.Handle()) |
|
518 { |
|
519 iMsgQueue.CancelDataAvailable(); |
|
520 } |
|
521 |
|
522 } |
|
523 |
|
524 OMX_ERRORTYPE |
|
525 CCallbackHandler::FillBufferDone(OMX_HANDLETYPE aComponent, |
|
526 TAny* aAppData, |
|
527 OMX_BUFFERHEADERTYPE* aBuffer) |
|
528 { |
|
529 DEBUG_PRINTF(_L8("CCallbackHandler::FillBufferDone")); |
|
530 |
|
531 return static_cast<CCallbackHandler*>(aAppData)->DoFillBufferDone(aComponent, aBuffer); |
|
532 |
|
533 } |
|
534 |
|
535 OMX_ERRORTYPE |
|
536 CCallbackHandler::EmptyBufferDone(OMX_HANDLETYPE aComponent, |
|
537 TAny* aAppData, |
|
538 OMX_BUFFERHEADERTYPE* aBuffer) |
|
539 { |
|
540 DEBUG_PRINTF(_L8("CCallbackHandler::EmptyBufferDone")); |
|
541 |
|
542 return static_cast<CCallbackHandler*>(aAppData)->DoEmptyBufferDone(aComponent, aBuffer); |
|
543 |
|
544 } |
|
545 |
|
546 OMX_ERRORTYPE |
|
547 CCallbackHandler::EventHandler(OMX_HANDLETYPE aComponent, |
|
548 TAny* aAppData, |
|
549 OMX_EVENTTYPE aEvent, |
|
550 TUint32 aData1, |
|
551 TUint32 aData2, |
|
552 TAny* aExtra) |
|
553 { |
|
554 DEBUG_PRINTF4(_L8("CCallbackHandler::EventHandler : EVENT[%d] Data1[%d] Data2[%d]"), aExtra, aData1, aData2); |
|
555 |
|
556 CCallbackHandler::TEventParams eventParams; |
|
557 eventParams.iEvent = aEvent; |
|
558 eventParams.iData1 = aData1; |
|
559 eventParams.iData2 = aData2; |
|
560 eventParams.iExtra = aExtra; |
|
561 return static_cast<CCallbackHandler*>(aAppData)->DoEventHandler(aComponent, eventParams); |
|
562 |
|
563 } |
|
564 |
|
565 OMX_ERRORTYPE |
|
566 CCallbackHandler::DoFillBufferDone(OMX_HANDLETYPE aComponent, |
|
567 OMX_BUFFERHEADERTYPE* aBuffer) |
|
568 { |
|
569 DEBUG_PRINTF(_L8("CCallbackHandler::DoFillBufferDone")); |
|
570 |
|
571 TOmxMessage message; |
|
572 message.iType = EFillBufferCallback; |
|
573 message.iComponent = aComponent; |
|
574 message.iBuffer = aBuffer; |
|
575 return RAsyncTestStepOmxILComponentBase::ConvertSymbianErrorType( |
|
576 iMsgQueue.Send(message)); |
|
577 |
|
578 } |
|
579 |
|
580 OMX_ERRORTYPE |
|
581 CCallbackHandler::DoEmptyBufferDone(OMX_HANDLETYPE aComponent, |
|
582 OMX_BUFFERHEADERTYPE* aBuffer) |
|
583 { |
|
584 DEBUG_PRINTF(_L8("CCallbackHandler::DoEmptyBufferDone")); |
|
585 |
|
586 TOmxMessage message; |
|
587 message.iType = EEmptyBufferCallback; |
|
588 message.iComponent = aComponent; |
|
589 message.iBuffer = aBuffer; |
|
590 return RAsyncTestStepOmxILComponentBase::ConvertSymbianErrorType( |
|
591 iMsgQueue.Send(message)); |
|
592 |
|
593 } |
|
594 |
|
595 OMX_ERRORTYPE |
|
596 CCallbackHandler::DoEventHandler(OMX_HANDLETYPE aComponent, |
|
597 TEventParams aEventParams) |
|
598 { |
|
599 DEBUG_PRINTF(_L8("CCallbackHandler::DoEventHandler")); |
|
600 |
|
601 TOmxMessage message; |
|
602 message.iType = EEventCallback; |
|
603 message.iComponent = aComponent; |
|
604 message.iEventParams = aEventParams; |
|
605 return RAsyncTestStepOmxILComponentBase::ConvertSymbianErrorType( |
|
606 iMsgQueue.Send(message)); |
|
607 |
|
608 } |
|
609 |
|
610 // |
|
611 // RAsyncTestStepOmxILComponentBase |
|
612 // |
|
613 RAsyncTestStepOmxILComponentBase::RAsyncTestStepOmxILComponentBase(const TDesC& aTestName, TInt aComponentUid) |
|
614 : |
|
615 iComponentUid(), |
|
616 ipKickoffAOp(0), |
|
617 ipKickoffStop(0), |
|
618 ipCOmxILComponent(0), |
|
619 ipCallbackHandler(0), |
|
620 ipTestFile(0), |
|
621 iTestFileName(KAacDecoderTestFile()), |
|
622 ipCompHandle(0) |
|
623 { |
|
624 DEBUG_PRINTF2(_L8("RAsyncTestStepOmxILComponentBase::RAsyncTestStepOmxILComponentBase: UID[%X]"), aComponentUid); |
|
625 iTestStepName = aTestName; |
|
626 iComponentUid = aComponentUid; |
|
627 // Default heap size is 32K. Increased to avoid the KErrNoMemory for this test step. |
|
628 iHeapSize = KTestHeapSize; |
|
629 |
|
630 } |
|
631 |
|
632 RAsyncTestStepOmxILComponentBase::~RAsyncTestStepOmxILComponentBase() |
|
633 { |
|
634 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::~RAsyncTestStepOmxILComponentBase")); |
|
635 // nothing here just yet |
|
636 } |
|
637 |
|
638 void |
|
639 RAsyncTestStepOmxILComponentBase::PrintOmxState(OMX_STATETYPE aOmxState) |
|
640 { |
|
641 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::PrintOmxState")); |
|
642 |
|
643 switch(aOmxState) |
|
644 { |
|
645 case OMX_StateInvalid: |
|
646 { |
|
647 INFO_PRINTF1(_L("OMX STATE : OMX_StateInvalid")); |
|
648 } |
|
649 break; |
|
650 case OMX_StateLoaded: |
|
651 { |
|
652 INFO_PRINTF1(_L("OMX STATE : OMX_StateLoaded")); |
|
653 } |
|
654 break; |
|
655 case OMX_StateIdle: |
|
656 { |
|
657 INFO_PRINTF1(_L("OMX STATE : OMX_StateIdle")); |
|
658 } |
|
659 break; |
|
660 case OMX_StateExecuting: |
|
661 { |
|
662 INFO_PRINTF1(_L("OMX STATE : OMX_StateExecuting")); |
|
663 } |
|
664 break; |
|
665 case OMX_StatePause: |
|
666 { |
|
667 INFO_PRINTF1(_L("OMX STATE : OMX_StatePause")); |
|
668 } |
|
669 break; |
|
670 case OMX_StateWaitForResources: |
|
671 { |
|
672 INFO_PRINTF1(_L("OMX STATE : OMX_StateWaitForResources")); |
|
673 } |
|
674 break; |
|
675 default: |
|
676 { |
|
677 INFO_PRINTF1(_L("OMX STATE : Wrong state found")); |
|
678 } |
|
679 }; |
|
680 |
|
681 } |
|
682 |
|
683 OMX_ERRORTYPE |
|
684 RAsyncTestStepOmxILComponentBase::ConvertSymbianErrorType(TInt aError) |
|
685 { |
|
686 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::ConvertSymbianErrorType")); |
|
687 |
|
688 OMX_ERRORTYPE err = OMX_ErrorNone; |
|
689 switch (aError) |
|
690 { |
|
691 case KErrNone: |
|
692 err = OMX_ErrorNone; |
|
693 break; |
|
694 case KErrNoMemory: |
|
695 err = OMX_ErrorInsufficientResources; |
|
696 break; |
|
697 case KErrGeneral: |
|
698 break; |
|
699 default: |
|
700 err = OMX_ErrorUndefined; |
|
701 } |
|
702 return err; |
|
703 |
|
704 } |
|
705 |
|
706 |
|
707 /** |
|
708 This method is used at the beginning of the test, and initialises the |
|
709 asynchronous calls that will be activated once the call returns. The |
|
710 ActiveScheduler is active at this point. If this test leaves, then |
|
711 StopTest() will be called with the leave value, so implicitly the test |
|
712 stops. |
|
713 |
|
714 */ |
|
715 void |
|
716 RAsyncTestStepOmxILComponentBase::KickoffTestL() |
|
717 { |
|
718 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::KickoffTestL")); |
|
719 |
|
720 __MM_HEAP_MARK; |
|
721 |
|
722 // Set up an asynchronous call |
|
723 TCallBack callback (ComponentBaseCallBack, this); |
|
724 delete ipKickoffAOp; |
|
725 ipKickoffAOp = NULL; |
|
726 ipKickoffAOp = |
|
727 new (ELeave) CAsyncCallBack (callback, CActive::EPriorityLow); |
|
728 // Queues this active object to be run once. |
|
729 ipKickoffAOp->Call(); |
|
730 |
|
731 } |
|
732 |
|
733 TInt |
|
734 RAsyncTestStepOmxILComponentBase::ComponentBaseCallBack(TAny* aPtr) |
|
735 { |
|
736 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::ComponentBaseCallBack")); |
|
737 |
|
738 RAsyncTestStepOmxILComponentBase* self = static_cast<RAsyncTestStepOmxILComponentBase*> (aPtr); |
|
739 self->DoComponentBaseCallBack(); |
|
740 return KErrNone; |
|
741 |
|
742 } |
|
743 |
|
744 void |
|
745 RAsyncTestStepOmxILComponentBase::DoComponentBaseCallBack() |
|
746 { |
|
747 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::DoComponentBaseCallBack")); |
|
748 |
|
749 TRAPD(err, ipCOmxILComponent = |
|
750 COmxILComponentIf::CreateImplementationL(TUid::Uid(iComponentUid))); |
|
751 |
|
752 //return StopTest(err, EFail); |
|
753 if (err != KErrNone) |
|
754 { |
|
755 INFO_PRINTF2(_L("RAsyncTestStepOmxILComponentBase::DoComponentBaseCallBack : err [%d]"), err); |
|
756 if (KErrNotFound == err) |
|
757 { |
|
758 INFO_PRINTF1(_L("DoComponentBaseCallBack : CreateImplementationL returned KErrNotFound")); |
|
759 // PacketVideo's AAC decoder libraries only provided for UDEB |
|
760 #ifndef _DEBUG |
|
761 INFO_PRINTF1(_L("IMPORTANT NOTE : THIS SUITE CAN ONLY BE RUN IN UDEB MODE")); |
|
762 INFO_PRINTF1(_L("IMPORTANT NOTE : PACKETVIDEO'S AAC DECODER LIBRARY ONLY AVAILABLE IN UDEB MODE")); |
|
763 #endif |
|
764 } |
|
765 return StopTest(err, EFail); |
|
766 } |
|
767 |
|
768 ipCompHandle = static_cast<OMX_COMPONENTTYPE*>(ipCOmxILComponent->Handle()); |
|
769 if (!ipCompHandle) |
|
770 { |
|
771 return StopTest(KErrGeneral, EFail); |
|
772 } |
|
773 |
|
774 TRAP(err, ipCallbackHandler = CCallbackHandler::NewL(*this)); |
|
775 if (err != KErrNone) |
|
776 { |
|
777 return StopTest(err, EFail); |
|
778 } |
|
779 |
|
780 TRAP(err, ipTestFile = CAacTestFile::NewL()); |
|
781 if (err != KErrNone) |
|
782 { |
|
783 return StopTest(err, EFail); |
|
784 } |
|
785 |
|
786 err = ipTestFile->ReadTestFileInBuffer(iTestFileName); |
|
787 if (err != KErrNone) |
|
788 { |
|
789 return StopTest(err, EFail); |
|
790 } |
|
791 |
|
792 TRAP(err, ipOutputTestFile = CAacOutputTestFile::NewL()); |
|
793 if (err != KErrNone) |
|
794 { |
|
795 return StopTest(err, EFail); |
|
796 } |
|
797 |
|
798 err = ipOutputTestFile->SetUpOutputFile(KAacDecoderOutputTestFile); |
|
799 if (err != KErrNone) |
|
800 { |
|
801 return StopTest(err, EFail); |
|
802 } |
|
803 |
|
804 |
|
805 } |
|
806 |
|
807 TInt |
|
808 RAsyncTestStepOmxILComponentBase::StopTestCallBack(TAny* aPtr) |
|
809 { |
|
810 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::StopTestCallBack")); |
|
811 RAsyncTestStepOmxILComponentBase* self = |
|
812 static_cast<RAsyncTestStepOmxILComponentBase*> (aPtr); |
|
813 self->DoStopTestCallBack(); |
|
814 return KErrNone; |
|
815 } |
|
816 |
|
817 void |
|
818 RAsyncTestStepOmxILComponentBase::DoStopTestCallBack() |
|
819 { |
|
820 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::DoStopTestCallBack")); |
|
821 |
|
822 StopTest(); |
|
823 |
|
824 } |
|
825 |
|
826 |
|
827 void |
|
828 RAsyncTestStepOmxILComponentBase::CloseTest() |
|
829 { |
|
830 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::CloseTest")); |
|
831 |
|
832 if (ipCompHandle) |
|
833 { |
|
834 ipCompHandle->ComponentDeInit(ipCompHandle); |
|
835 } |
|
836 delete ipCOmxILComponent; |
|
837 ipCOmxILComponent = 0; |
|
838 ipCompHandle = 0; |
|
839 |
|
840 delete ipKickoffAOp; // no need to Cancel |
|
841 ipKickoffAOp = 0; |
|
842 |
|
843 delete ipCallbackHandler; |
|
844 ipCallbackHandler = 0; |
|
845 |
|
846 delete ipTestFile; |
|
847 ipTestFile = 0; |
|
848 |
|
849 if (ipOutputTestFile) |
|
850 { |
|
851 ipOutputTestFile->CloseOutputFile(); |
|
852 // We ignore here this error... |
|
853 TInt err = ipOutputTestFile->AddWavHeader(); |
|
854 delete ipOutputTestFile; |
|
855 ipOutputTestFile = 0; |
|
856 } |
|
857 |
|
858 REComSession::FinalClose(); |
|
859 __MM_HEAP_MARKEND; |
|
860 |
|
861 } |
|
862 |
|
863 void |
|
864 RAsyncTestStepOmxILComponentBase::DoFillBufferDoneL(OMX_HANDLETYPE /* aComponent */, |
|
865 OMX_BUFFERHEADERTYPE* /* aBuffer */) |
|
866 { |
|
867 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::DoFillBufferDoneL")); |
|
868 // By default, no callback expected here... |
|
869 return StopTest(KErrGeneral, EFail); |
|
870 } |
|
871 |
|
872 void |
|
873 RAsyncTestStepOmxILComponentBase::DoEmptyBufferDoneL(OMX_HANDLETYPE /* aComponent */, |
|
874 OMX_BUFFERHEADERTYPE* /* aBuffer */) |
|
875 { |
|
876 DEBUG_PRINTF(_L8("RAsyncTestStepOmxILComponentBase::DoEmptyBufferDoneL")); |
|
877 // By default, no callback expected here... |
|
878 return StopTest(KErrGeneral, EFail); |
|
879 } |