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(KDevVideoPostProcPanicCategory, "DevVideoPostProcessor");
20 void DevVideoPostProcPanic(TInt aReason)
22 User::Panic(KDevVideoPostProcPanicCategory, aReason);
25 CMMFVideoPostProcHwDevice* CMMFTestVideoPostProcHwDevice::NewL(TAny* /*aInitParams*/)
27 CMMFTestVideoPostProcHwDevice* s = new(ELeave) CMMFTestVideoPostProcHwDevice;
28 return (STATIC_CAST(CMMFVideoPostProcHwDevice*, s));
31 CMMFTestVideoPostProcHwDevice::CMMFTestVideoPostProcHwDevice()
35 CMMFTestVideoPostProcHwDevice::~CMMFTestVideoPostProcHwDevice()
37 iVideoPictures.Close();
42 iScaleFactors.Reset();
43 iScaleFactors.Close();
45 iCombinations.Reset();
46 iCombinations.Close();
49 TAny* CMMFTestVideoPostProcHwDevice::CustomInterface(TUid aInterface)
51 if (aInterface == KUidCustomInterfaceTwo)
53 return this;//just want to return something non-null!
61 CPostProcessorInfo* CMMFTestVideoPostProcHwDevice::PostProcessorInfoLC()
63 // construct array of test types
64 for (TUint i = 0; i < KTestPostProcInfoCount; i++)
66 // append the video formats
67 TUncompressedVideoFormat vid = KTestPostProcInfoFormatArray[i];
68 User::LeaveIfError(iVidFormats.Append(vid));
70 // append the combinations
71 TUint32 comb = KTestPostProcInfoCombsArray[i];
72 User::LeaveIfError(iCombinations.Append(comb));
74 // append the scale factors
75 TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
76 User::LeaveIfError(iScaleFactors.Append(scale));
79 // construct the video decoder info object
80 CPostProcessorInfo* vInfo = CPostProcessorInfo::NewL(
81 KUidDevVideoTestPostProcHwDevice,
82 KTestPostProcInfoManufacturer,
83 KTestPostProcInfoIdentifier,
84 TVersion(KTestPostProcInfoVersionMaj, KTestPostProcInfoVersionMin, KTestPostProcInfoVersionBuild),
86 iCombinations.Array(),
88 ETrue, // supports direct display
89 KTestPostProcInfoYuvToRgbCaps,
90 KTestPostProcInfoRotations,
92 iScaleFactors.Array(),
93 ETrue, // anti-aliasing
94 KTestPostProcInfoISInfo );
95 CleanupStack::PushL(vInfo);
96 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
97 vInfo->AddSupportedScreenL(KPostProcDefaultScreenNumber);
98 vInfo->AddSupportedScreenL(KPostProcSecondaryScreenNumber);
100 vInfo->SetSupportsContentProtected(ETrue);
104 void CMMFTestVideoPostProcHwDevice::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats)
106 // append in order 3, 2, 1
107 User::LeaveIfError(aFormats.Append(KTestVidFormat3));
108 User::LeaveIfError(aFormats.Append(KTestVidFormat2));
109 User::LeaveIfError(aFormats.Append(KTestVidFormat1));
112 void CMMFTestVideoPostProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat &aFormat)
114 if (!(aFormat == KTestVidFormat2))
115 User::Leave(KErrCorrupt);
118 void CMMFTestVideoPostProcHwDevice::SetPostProcessTypesL(TUint32 aPostProcCombination)
120 if (!(aPostProcCombination == KTestProcessType2))
121 User::Leave(KErrCorrupt);
124 void CMMFTestVideoPostProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
126 TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
127 if (!(aRect == testRect))
128 User::Leave(KErrCorrupt);
131 void CMMFTestVideoPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
133 // check options first
134 if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb2))
135 User::Leave(KErrCorrupt);
138 if ( !(CompareYuvFormats(aYuvFormat, KTestYuvFormat2)) ||
139 !(aRgbFormat == KTestRgbFormat2) )
140 User::Leave(KErrCorrupt);
143 void CMMFTestVideoPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions)
145 if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb2))
146 User::Leave(KErrCorrupt);
149 void CMMFTestVideoPostProcHwDevice::SetRotateOptionsL(TRotationType aRotationType)
151 if (!(aRotationType == KTestRotate2))
152 User::Leave(KErrCorrupt);
155 void CMMFTestVideoPostProcHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
157 TSize testScale(KTestScaleY, KTestScaleX);
158 if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
159 User::Leave(KErrCorrupt);
162 void CMMFTestVideoPostProcHwDevice::SetOutputCropOptionsL(const TRect& aRect)
164 TRect testRect(KTestOutputCropRectD, KTestOutputCropRectC, KTestOutputCropRectB, KTestOutputCropRectA);
165 if (!(aRect == testRect))
166 User::Leave(KErrCorrupt);
169 void CMMFTestVideoPostProcHwDevice::SetPostProcSpecificOptionsL(const TDesC8& aOptions)
171 if (!(aOptions == KTestPostProcOptions2))
172 User::Leave(KErrCorrupt);
175 void CMMFTestVideoPostProcHwDevice::SetClockSource(MMMFClockSource* aClock)
177 __ASSERT_ALWAYS(aClock, DevVideoPostProcPanic(EPostProcPanicClockSource));
179 // call Time() to check that clock can be used
180 TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
181 currTime = aClock->Time();
184 void CMMFTestVideoPostProcHwDevice::SetVideoDestScreenL(TBool aScreen)
188 // Must be normal devvideo test. Leave with special number to show we got the
190 User::Leave(KErrHardwareNotAvailable);
194 // Special test plugin feature: we're being told to start outputing
195 // video pictures up to DevVideo.
196 // Create 10 video pictures
197 iVideoPictures.Reset();
198 for (TInt i=0; i<10; i++)
200 // Create a video picture that only has a valid timestamp
201 TVideoPicture picture;
202 picture.iTimestamp = TTimeIntervalMicroSeconds(i);
203 picture.iOptions = TVideoPicture::ETimestamp;
204 User::LeaveIfError(iVideoPictures.Append(picture));
209 void CMMFTestVideoPostProcHwDevice::Initialize()
211 iProxy->MdvppInitializeComplete(this, KErrNone);
214 void CMMFTestVideoPostProcHwDevice::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& aClipRegion)
216 TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
217 TRegionFix<1> dsaReg(dsaRect);
219 // probably no need to check aScreenDevice
220 if ( /*!(&aScreenDevice) || */!(dsaRect == aVideoRect) ||
221 !(dsaReg.BoundingRect() == aClipRegion.BoundingRect()) )
222 User::Leave(KErrNotSupported);
226 void CMMFTestVideoPostProcHwDevice::SetScreenClipRegion(const TRegion& aRegion)
228 TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
229 TRegionFix<1> dsaReg(dsaRect);
231 __ASSERT_ALWAYS(dsaReg.BoundingRect() == aRegion.BoundingRect(),
232 DevVideoPostProcPanic(EPostProcPanicScreenClipRegion));
235 void CMMFTestVideoPostProcHwDevice::SetPauseOnClipFail(TBool aPause)
237 __ASSERT_ALWAYS(aPause, DevVideoPostProcPanic(EPostProcPanicPauseClipFail));
240 void CMMFTestVideoPostProcHwDevice::AbortDirectScreenAccess()
242 // do nothing - there is no way to check this
245 TBool CMMFTestVideoPostProcHwDevice::IsPlaying()
250 void CMMFTestVideoPostProcHwDevice::Redraw()
252 // do nothing - there is no way to check this
255 void CMMFTestVideoPostProcHwDevice::Start()
257 // set iIsPlaying flag
260 // if we're doing the picture tests, start sending pictures to DevVideo
261 if (iVideoPictures.Count() > 0)
263 iProxy->MdvppNewPicture(&(iVideoPictures[0]));
267 void CMMFTestVideoPostProcHwDevice::Stop()
272 void CMMFTestVideoPostProcHwDevice::Pause()
277 void CMMFTestVideoPostProcHwDevice::Resume()
282 void CMMFTestVideoPostProcHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
284 if (aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPositionFatal))
286 iProxy->MdvppFatalError(this, KErrDied);
290 __ASSERT_ALWAYS(aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicSetPosition));
294 void CMMFTestVideoPostProcHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp)
296 __ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicFreezePicture));
299 void CMMFTestVideoPostProcHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp)
301 __ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicReleaseFreeze));
304 TTimeIntervalMicroSeconds CMMFTestVideoPostProcHwDevice::PlaybackPosition()
306 return TTimeIntervalMicroSeconds(KTestPlayPosition);
309 TUint CMMFTestVideoPostProcHwDevice::PictureBufferBytes()
311 return KTestPictureBytes;
314 void CMMFTestVideoPostProcHwDevice::GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters)
316 aCounters = GetTestPictureCounters();
319 void CMMFTestVideoPostProcHwDevice::SetComplexityLevel(TUint aLevel)
321 __ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPostProcPanic(EPostProcPanicComplexityLevel));
324 TUint CMMFTestVideoPostProcHwDevice::NumComplexityLevels()
326 return KTestNumComplexityLevels2;
329 void CMMFTestVideoPostProcHwDevice::GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo)
331 __ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPostProcPanic(EPostProcPanicComplexityLevelInfo));
333 aInfo = GetTestLevelInfo(aLevel);;
336 void CMMFTestVideoPostProcHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
338 switch (iCurrentPicture)
341 // Send two more pictures
343 iProxy->MdvppNewPicture(&(iVideoPictures[1]));
345 iProxy->MdvppNewPicture(&(iVideoPictures[2]));
348 // Send three more pictures
350 iProxy->MdvppNewPicture(&(iVideoPictures[3]));
352 iProxy->MdvppNewPicture(&(iVideoPictures[4]));
354 iProxy->MdvppNewPicture(&(iVideoPictures[5]));
357 // Send the rest of the pictures
359 iProxy->MdvppNewPicture(&(iVideoPictures[6]));
361 iProxy->MdvppNewPicture(&(iVideoPictures[7]));
363 iProxy->MdvppNewPicture(&(iVideoPictures[8]));
365 iProxy->MdvppNewPicture(&(iVideoPictures[9]));
372 TBool CMMFTestVideoPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat)
376 if (aFormat.iDataFormat == EYuvRawData)
378 if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
381 aPictureData.iDataFormat = EYuvRawData;
382 aPictureData.iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
383 aPictureData.iRawData = NULL;
390 void CMMFTestVideoPostProcHwDevice::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp)
392 if ((aFormat.iDataFormat == EYuvRawData) && (aPresentationTimestamp == TTimeIntervalMicroSeconds(KTestSnapshotTimestamp)) )
394 if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
396 aPictureData->iDataFormat = EYuvRawData;
397 aPictureData->iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
398 aPictureData->iRawData = NULL;
400 // call the snapshot callback
401 iProxy->MdvppTimedSnapshotComplete(KErrNone, aPictureData, aPresentationTimestamp, iPictureId);
406 User::Leave(KErrCorrupt);
410 void CMMFTestVideoPostProcHwDevice::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId)
412 if ((aFormat.iDataFormat == EYuvRawData) &&
413 (aPictureId.iIdType == KTestSnapshotId.iIdType) &&
414 (aPictureId.iId == KTestSnapshotId.iId) )
416 if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
418 aPictureData->iDataFormat = EYuvRawData;
419 aPictureData->iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
420 aPictureData->iRawData = NULL;
422 iPictureTimestamp = 0;
424 // call the snapshot callback
425 iProxy->MdvppTimedSnapshotComplete(KErrNone, aPictureData, iPictureTimestamp, aPictureId);
430 User::Leave(KErrCorrupt);
434 void CMMFTestVideoPostProcHwDevice::CancelTimedSnapshot()
436 // call the snapshot callback with error
437 iProxy->MdvppTimedSnapshotComplete(KErrAbort, &iPictureData, iPictureTimestamp, iPictureId);
440 void CMMFTestVideoPostProcHwDevice::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats)
442 // append in order 3, 2, 1
443 User::LeaveIfError(aFormats.Append(KTestVidFormat1));
444 User::LeaveIfError(aFormats.Append(KTestVidFormat2));
445 User::LeaveIfError(aFormats.Append(KTestVidFormat3));
448 void CMMFTestVideoPostProcHwDevice::InputEnd()
450 iProxy->MdvppStreamEnd();
453 void CMMFTestVideoPostProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat)
455 if (!(aFormat == KTestVidFormat2))
457 User::Leave(KErrCorrupt);
461 void CMMFTestVideoPostProcHwDevice::SetInputDevice(CMMFVideoDecodeHwDevice* /*aDevice*/)
465 void CMMFTestVideoPostProcHwDevice::WritePictureL(TVideoPicture* aPicture)
467 iProxy->MdvppReturnPicture(aPicture);
470 void CMMFTestVideoPostProcHwDevice::CommitL()
474 void CMMFTestVideoPostProcHwDevice::Revert()
478 void CMMFTestVideoPostProcHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy)