First public contribution.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "../TestDevVideoPlayTestData.h"
19 _LIT(KDevVideoDecoderPanicCategory, "DevVideoDecoder");
20 void DevVideoDecoderPanic(TInt aReason)
22 User::Panic(KDevVideoDecoderPanicCategory, aReason);
25 CMMFVideoDecodeHwDevice* CMMFTestVideoDecodeHwDevice::NewL(TAny* /*aInitParams*/)
27 CMMFTestVideoDecodeHwDevice* s = new(ELeave) CMMFTestVideoDecodeHwDevice;
28 return (STATIC_CAST(CMMFVideoDecodeHwDevice*, s));
31 CMMFTestVideoDecodeHwDevice::CMMFTestVideoDecodeHwDevice()
32 :iExtensionUid(KUidDevVideoPlayHwDeviceExtensionScanCopy)
36 CMMFTestVideoDecodeHwDevice::~CMMFTestVideoDecodeHwDevice()
38 // destroy objects in RArray
39 for (TInt i = 0; i < iVidFormats.Count(); i++)
41 delete iVidFormats[i];
47 iPictureRates.Reset();
48 iPictureRates.Close();
50 iCombinations.Reset();
51 iCombinations.Close();
53 iPostProcVidFormats.Reset();
54 iPostProcVidFormats.Close();
56 iScaleFactors.Reset();
57 iScaleFactors.Close();
59 delete iBufferDataArea;
62 TAny* CMMFTestVideoDecodeHwDevice::CustomInterface(TUid aInterface)
64 if (aInterface == KUidCustomInterfaceOne)
66 return this;//just want to return something non-null!
68 else if (aInterface == iExtensionUid)
70 return static_cast<MMMFVideoPlayHwDeviceExtensionScanCopy*>(this);
78 // post processor info may be obtained from this plugin or the post processor plugin
79 CPostProcessorInfo* CMMFTestVideoDecodeHwDevice::PostProcessorInfoLC()
81 // construct array of test types
82 for (TUint i = 0; i < KTestPostProcInfoCount; i++)
84 // append the video formats
85 TUncompressedVideoFormat vid = KTestPostProcInfoFormatArray[i];
86 User::LeaveIfError(iPostProcVidFormats.Append(vid));
88 // append the combinations
89 TUint32 comb = KTestPostProcInfoCombsArray[i];
90 User::LeaveIfError(iCombinations.Append(comb));
92 // append the scale factors
93 TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
94 User::LeaveIfError(iScaleFactors.Append(scale));
97 // construct the video decoder info object
98 CPostProcessorInfo* info = CPostProcessorInfo::NewL( KUidDevVideoTestDecodeHwDevice,
99 KTestPostProcInfoManufacturer,
100 KTestPostProcInfoIdentifier,
101 TVersion(KTestPostProcInfoVersionMaj,
102 KTestPostProcInfoVersionMin,
103 KTestPostProcInfoVersionBuild),
104 iPostProcVidFormats.Array(),
105 iCombinations.Array(),
106 ETrue, // accelerated
107 ETrue, // direct display support
108 KTestPostProcInfoYuvToRgbCaps,
109 KTestPostProcInfoRotations,
111 iScaleFactors.Array(),
112 ETrue, // anti-aliasing
113 KTestDecoderInfoISInfo );
114 CleanupStack::PushL(info);
119 void CMMFTestVideoDecodeHwDevice::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats)
121 // append in order 1, 2, 3
122 User::LeaveIfError(aFormats.Append(KTestVidFormat1));
123 User::LeaveIfError(aFormats.Append(KTestVidFormat2));
124 User::LeaveIfError(aFormats.Append(KTestVidFormat3));
127 void CMMFTestVideoDecodeHwDevice::SetOutputFormatL(const TUncompressedVideoFormat &aFormat)
129 if (!(aFormat == KTestVidFormat1))
130 User::Leave(KErrCorrupt);
133 void CMMFTestVideoDecodeHwDevice::SetPostProcessTypesL(TUint32 aPostProcCombination)
135 if (!(aPostProcCombination == KTestProcessType1))
136 User::Leave(KErrCorrupt);
139 void CMMFTestVideoDecodeHwDevice::SetInputCropOptionsL(const TRect& aRect)
141 TRect testRect(KTestInputCropRectA, KTestInputCropRectB, KTestInputCropRectC, KTestInputCropRectD);
142 if (!(aRect == testRect))
143 User::Leave(KErrCorrupt);
146 void CMMFTestVideoDecodeHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
148 // check options first
149 if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb1))
150 User::Leave(KErrCorrupt);
153 if ( !(CompareYuvFormats(aYuvFormat, KTestYuvFormat1)) ||
154 !(aRgbFormat == KTestRgbFormat1) )
155 User::Leave(KErrCorrupt);
158 void CMMFTestVideoDecodeHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions)
160 if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb1))
161 User::Leave(KErrCorrupt);
164 void CMMFTestVideoDecodeHwDevice::SetRotateOptionsL(TRotationType aRotationType)
166 if (!(aRotationType == KTestRotate1))
167 User::Leave(KErrCorrupt);
170 void CMMFTestVideoDecodeHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
172 TSize testScale(KTestScaleX, KTestScaleY);
173 if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
174 User::Leave(KErrCorrupt);
177 void CMMFTestVideoDecodeHwDevice::SetOutputCropOptionsL(const TRect& aRect)
179 TRect testRect(KTestOutputCropRectA, KTestOutputCropRectB, KTestOutputCropRectC, KTestOutputCropRectD);
180 if (!(aRect == testRect))
181 User::Leave(KErrCorrupt);
184 void CMMFTestVideoDecodeHwDevice::SetPostProcSpecificOptionsL(const TDesC8& aOptions)
186 if (!(aOptions == KTestPostProcOptions1))
187 User::Leave(KErrCorrupt);
190 void CMMFTestVideoDecodeHwDevice::SetClockSource(MMMFClockSource* aClock)
192 __ASSERT_ALWAYS(aClock, DevVideoDecoderPanic(EDecoderPanicClockSource));
194 // call Time() to check that clock can be used
195 TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
196 currTime = aClock->Time();
199 void CMMFTestVideoDecodeHwDevice::SetVideoDestScreenL(TBool /*aScreen*/)
203 void CMMFTestVideoDecodeHwDevice::Initialize()
205 iProxy->MdvppInitializeComplete(this, KErrNone);
208 void CMMFTestVideoDecodeHwDevice::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& aClipRegion)
210 TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
211 TRegionFix<1> dsaReg(dsaRect);
213 // probably no need to check aScreenDevice
214 if ( /*!(&aScreenDevice) || */!(dsaRect == aVideoRect) ||
215 !(dsaReg.BoundingRect() == aClipRegion.BoundingRect()) )
216 User::Leave(KErrNotSupported);
219 void CMMFTestVideoDecodeHwDevice::SetScreenClipRegion(const TRegion& aRegion)
221 TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
222 TRegionFix<1> dsaReg(dsaRect);
224 __ASSERT_ALWAYS(dsaReg.BoundingRect() == aRegion.BoundingRect(),
225 DevVideoDecoderPanic(EDecoderPanicScreenClipRegion));
228 void CMMFTestVideoDecodeHwDevice::SetPauseOnClipFail(TBool aPause)
230 __ASSERT_ALWAYS(aPause, DevVideoDecoderPanic(EDecoderPanicPauseClipFail));
233 void CMMFTestVideoDecodeHwDevice::AbortDirectScreenAccess()
235 // do something here?
238 TBool CMMFTestVideoDecodeHwDevice::IsPlaying()
243 void CMMFTestVideoDecodeHwDevice::Redraw()
245 // do something here?
248 void CMMFTestVideoDecodeHwDevice::Start()
253 void CMMFTestVideoDecodeHwDevice::Stop()
258 void CMMFTestVideoDecodeHwDevice::Pause()
263 void CMMFTestVideoDecodeHwDevice::Resume()
268 void CMMFTestVideoDecodeHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
270 if (aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPositionFatal))
272 iProxy->MdvppFatalError(this, KErrDied);
276 __ASSERT_ALWAYS(aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPosition), DevVideoDecoderPanic(EDecoderPanicSetPosition));
280 void CMMFTestVideoDecodeHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp)
282 __ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoDecoderPanic(EDecoderPanicFreezePicture));
285 void CMMFTestVideoDecodeHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp)
287 __ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoDecoderPanic(EDecoderPanicReleaseFreeze));
290 TTimeIntervalMicroSeconds CMMFTestVideoDecodeHwDevice::PlaybackPosition()
292 return TTimeIntervalMicroSeconds(KTestPlayPosition);
295 TUint CMMFTestVideoDecodeHwDevice::PictureBufferBytes()
297 return KTestPictureBytes;
300 void CMMFTestVideoDecodeHwDevice::GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters)
302 aCounters = GetTestPictureCounters();
305 void CMMFTestVideoDecodeHwDevice::SetComplexityLevel(TUint aLevel)
307 __ASSERT_ALWAYS(aLevel == KTestComplexityLevel1, DevVideoDecoderPanic(EDecoderPanicComplexityLevel));
310 TUint CMMFTestVideoDecodeHwDevice::NumComplexityLevels()
312 return KTestNumComplexityLevels1;
315 void CMMFTestVideoDecodeHwDevice::GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo)
317 __ASSERT_ALWAYS(aLevel == KTestComplexityLevel1, DevVideoDecoderPanic(EDecoderPanicComplexityLevelInfo));
319 aInfo = GetTestLevelInfo(aLevel);
322 void CMMFTestVideoDecodeHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
326 TBool CMMFTestVideoDecodeHwDevice::GetSnapshotL(TPictureData& /*aPictureData*/, const TUncompressedVideoFormat& /*aFormat*/)
331 // this method should be called on the post processor not on the decoder
332 // ending up here is a programming error and hence a PANIC condition
333 void CMMFTestVideoDecodeHwDevice::GetTimedSnapshotL(TPictureData* /*aPictureData*/, const TUncompressedVideoFormat& /*aFormat*/, const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/)
335 DevVideoDecoderPanic(EDecoderPanicTimedSnapshot);
338 // this method should be called on the post processor not on the decoder
339 // ending up here is a programming error and hence a PANIC condition
340 void CMMFTestVideoDecodeHwDevice::GetTimedSnapshotL(TPictureData* /*aPictureData*/, const TUncompressedVideoFormat& /*aFormat*/, const TPictureId& /*aPictureId*/)
342 DevVideoDecoderPanic(EDecoderPanicTimedSnapshotId);
345 // this method should be called on the post processor not on the decoder
346 // ending up here is a programming error and hence a PANIC condition
347 void CMMFTestVideoDecodeHwDevice::CancelTimedSnapshot()
349 DevVideoDecoderPanic(EDecoderPanicCancelTimedSnapshot);
352 // this method should be called on the post processor not on the decoder
353 // ending up here is a programming error and hence a PANIC condition
354 void CMMFTestVideoDecodeHwDevice::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& /*aFormats*/)
356 DevVideoDecoderPanic(EDecoderPanicSupportedSnapshotFormats);
359 void CMMFTestVideoDecodeHwDevice::InputEnd()
361 iProxy->MdvppStreamEnd();
364 CVideoDecoderInfo* CMMFTestVideoDecodeHwDevice::VideoDecoderInfoLC()
366 // construct array of test types
367 for (TUint i = 0; i < KTestDecoderInfoCount; i++)
369 // construct the video types for iVidTypes
370 CCompressedVideoFormat* vid = NULL;
371 TPtrC8 mimeType = KTestDecoderInfoMimeArray[i];
372 vid = GetTestCVFormatL(mimeType);
373 CleanupStack::PushL(vid);
374 User::LeaveIfError(iVidFormats.Append(vid));
375 CleanupStack::Pop(vid); // CCompressedVideo object is destroyed in destructor
377 // append the max picture rates
378 TPictureRateAndSize rate;
379 GetTestEncoderInfoRate(i, rate);
380 User::LeaveIfError(iPictureRates.Append(rate));
383 // construct the video decoder info object
384 CVideoDecoderInfo* vInfo = CVideoDecoderInfo::NewL(
385 KUidDevVideoTestDecodeHwDevice,
386 KTestDecoderInfoManufacturer,
387 KTestDecoderInfoIdentifier,
388 TVersion(KTestDecoderInfoVersionMaj, KTestDecoderInfoVersionMin, KTestDecoderInfoVersionBuild),
390 ETrue, // accelerated
391 ETrue, // supports direct display
392 TSize(KTestDecoderInfoMaxSizeX,KTestDecoderInfoMaxSizeY),
393 KMaxTUint, //aMaxBitrate
394 iPictureRates.Array(),
395 ETrue, // aSupportsPictureLoss
396 EFalse, // aSupportsSliceLoss
397 KTestDecoderInfoCSInfo,
398 KTestDecoderInfoISInfo );
399 CleanupStack::PushL(vInfo);
400 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
401 vInfo->AddSupportedScreenL(KDecoderDefaultScreenNumber);
402 vInfo->AddSupportedScreenL(KDecoderSecondaryScreenNumber);
404 vInfo->SetSupportsContentProtected(ETrue);
409 TVideoPictureHeader* CMMFTestVideoDecodeHwDevice::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TVideoInputBuffer* aDataUnit)
411 // check KTestDataUnitType, KTestDataUnitEncap
412 if ((aDataUnitType != KTestDataUnitType) ||
413 (aEncapsulation != KTestDataUnitEncap) ||
414 (aDataUnit->iOptions != KTestInputBufferOptions) )
416 User::Leave(KErrCorrupt);
419 // repackage picture header
420 iPictureHeader.iOptions = KTestPictureHeaderOptions;
421 iPictureHeader.iPresentationTimestamp = aDataUnit->iPresentationTimestamp;
422 iPictureHeader.iOptional = &(aDataUnit->iData);
423 return &iPictureHeader;
426 void CMMFTestVideoDecodeHwDevice::ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader)
428 TTimeIntervalMicroSeconds testTime(KTestInputBufferTimestamp);
430 // check the picture header
431 if ( (aVideoPictureHeader.iOptions != KTestPictureHeaderOptions)
432 ||(!(aVideoPictureHeader.iPresentationTimestamp == testTime))
433 ||(!(*(aVideoPictureHeader.iOptional) == KTestInputBufferData())))
435 User::Leave(KErrCorrupt);
438 iPictureHeader = aVideoPictureHeader;
441 void CMMFTestVideoDecodeHwDevice::ReturnHeader(TVideoPictureHeader* aHeader)
443 __ASSERT_ALWAYS(aHeader, DevVideoDecoderPanic(EDecoderPanicPictureHeader));
444 __ASSERT_ALWAYS(aHeader->iOptions == KTestPictureHeaderOptions, DevVideoDecoderPanic(EDecoderPanicPictureHeaderOptions));
445 __ASSERT_ALWAYS(aHeader->iPresentationTimestamp == TTimeIntervalMicroSeconds(KTestPictureHeaderTimestamp), DevVideoDecoderPanic(EDecoderPanicPictureHeaderTimestamp));
448 void CMMFTestVideoDecodeHwDevice::SetInputFormatL(const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder)
450 // check expected parameters - TClasses first
451 if (!((aDataUnitType == KTestUnitType1) && (aEncapsulation == KTestEncapType1) && (aDataInOrder)))
452 User::Leave(KErrCorrupt);
454 // construct a temporary compressed video class [will leave on error]
455 CCompressedVideoFormat *compVideo = GetTestCVFormatL(KTestMimeType1);
456 CleanupStack::PushL(compVideo);
458 // compare to received class
459 if (!(aFormat == *compVideo))
460 User::Leave(KErrCorrupt);
462 // destroy temporary class
463 CleanupStack::PopAndDestroy(compVideo);
466 void CMMFTestVideoDecodeHwDevice::SynchronizeDecoding(TBool aSynchronize)
468 __ASSERT_ALWAYS(aSynchronize, DevVideoDecoderPanic(EDecoderPanicSynchronizeDecoding));
471 void CMMFTestVideoDecodeHwDevice::SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions)
473 CMMFDevVideoPlay::TBufferOptions buffOptions = GetTestBufferOptions();
475 if (!CompareBufferOptions(aOptions, buffOptions))
476 User::Leave(KErrCorrupt);
479 void CMMFTestVideoDecodeHwDevice::GetBufferOptions(CMMFDevVideoPlay::TBufferOptions& aOptions)
481 aOptions = GetTestBufferOptions();
484 void CMMFTestVideoDecodeHwDevice::SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams)
486 __ASSERT_ALWAYS(aHrdVbvSpec == KTestHrdVbvSpec, DevVideoDecoderPanic(EDecoderPanicHrdVbvSpec));
487 __ASSERT_ALWAYS(aHrdVbvParams == KTestHrdVbvParams, DevVideoDecoderPanic(EDecoderPanicHrdVbvParams));
490 void CMMFTestVideoDecodeHwDevice::SetOutputDevice(CMMFVideoPostProcHwDevice* /*aDevice*/)
494 TTimeIntervalMicroSeconds CMMFTestVideoDecodeHwDevice::DecodingPosition()
496 return TTimeIntervalMicroSeconds(KTestDecodePosition);
499 TUint CMMFTestVideoDecodeHwDevice::PreDecoderBufferBytes()
501 return KTestPreDecoderBytes;
504 void CMMFTestVideoDecodeHwDevice::GetBitstreamCounters(CMMFDevVideoPlay::TBitstreamCounters& aCounters)
506 aCounters = GetTestBitstreamCounters();
509 TUint CMMFTestVideoDecodeHwDevice::NumFreeBuffers()
511 return KTestNumFreeBuffers;
514 TVideoInputBuffer* CMMFTestVideoDecodeHwDevice::GetBufferL(TUint aBufferSize)
516 if (!iBufferDataArea)
518 TPtrC8 testBufferString(KTestBufferString);
519 iBufferDataArea = testBufferString.AllocL();
522 TPtr8 dataAreaPtr = iBufferDataArea->Des();
523 TInt reqBufferSize = aBufferSize;
524 if (reqBufferSize > dataAreaPtr.MaxLength())
525 User::Leave(KErrTooBig);
527 // initialize iInputBuffer with test data
528 iInputBuffer.iOptions = KTestBufferOptions;
529 iInputBuffer.iDecodingTimestamp = aBufferSize;
530 iInputBuffer.iData.Set(dataAreaPtr);
532 // call new buffer callback
533 iProxy->MdvppNewBuffers();
535 return &iInputBuffer;
538 void CMMFTestVideoDecodeHwDevice::WriteCodedDataL(TVideoInputBuffer* aBuffer)
540 TTimeIntervalMicroSeconds testTime(KTestBufferSize);
542 // check received buffer against test data
543 if (!(aBuffer->iOptions == KTestBufferOptions) ||
544 !(aBuffer->iDecodingTimestamp == testTime) ||
545 !(aBuffer->iData == KTestBufferString))
547 User::Leave(KErrCorrupt);
551 void CMMFTestVideoDecodeHwDevice::WriteCodedDataL(TVideoInputBuffer* aBuffer, TFramePortion aPortion)
553 TTimeIntervalMicroSeconds testTime(KTestBufferSize);
555 // check received buffer against test data
556 if ((aPortion != EFramePortionEndFragment) ||
557 !(aBuffer->iOptions == KTestBufferOptions) ||
558 !(aBuffer->iDecodingTimestamp == testTime) ||
559 !(aBuffer->iData == KTestBufferString))
561 User::Leave(KErrCorrupt);
565 void CMMFTestVideoDecodeHwDevice::ScanAndCopyCodedDataL(TPtr8 aCodedData, TVideoInputBuffer* aBuffer, TInt& aConsumed, TFramePortion aPortion)
567 //compare ptr data to test data
568 if ((aPortion != EFramePortionEndFragment) ||
569 (aCodedData != KTestBufferString))
571 User::Leave(KErrCorrupt);
573 //copy data into buffer
574 aBuffer->iData.Set(aCodedData);
575 aConsumed = aBuffer->iData.Length();
578 void CMMFTestVideoDecodeHwDevice::CommitL()
582 void CMMFTestVideoDecodeHwDevice::Revert()
586 void CMMFTestVideoDecodeHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy)
588 ASSERT(iProxy == NULL);