Update contrib.
1 // Copyright (c) 2004-2010 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.
22 #include "DRMTestVidPlayer.h"
23 #include "rightsdatabase.h"
25 using namespace ContentAccess;
27 const TInt KFrameWidth = 100;
28 const TInt KFrameHeight = 50;
29 const TInt KDefaultRightsID = 1;
30 const TInt KDefaultRightsCount = 2;
31 const TInt KZeroRightsCount = 0;
33 TAny GetDriveName(TDes& aFileName)
37 #elif defined(__MARM__) || defined(__X86GCC__)
38 #ifdef __TEST_FILES_ON_C_DRIVE__
42 #endif // __TEST_FILES_ON_C_DRIVE__
48 * Static constructor for CTestStepVidPlayerDRMGetFrame.
51 * @return "CTestStepVidPlayerDRMGetFrame*"
52 * The constructed CTestStepVidPlayerDRMGetFrame
58 CTestStepVidPlayerDRMGetFrame::CTestStepVidPlayerDRMGetFrame(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
59 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
62 CTestStepVidPlayerDRMGetFrame* CTestStepVidPlayerDRMGetFrame::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
64 CTestStepVidPlayerDRMGetFrame* self = new (ELeave) CTestStepVidPlayerDRMGetFrame(aTestName,aSectName,aKeyName);
69 void CTestStepVidPlayerDRMGetFrame::MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError)
74 if (aFrame.Handle() == NULL || aFrame.SizeInPixels() != TSize(KFrameWidth,KFrameHeight) )
75 iError = KErrArgument;
79 INFO_PRINTF1(_L("MvpuoFrameReady: GetFrameL() COMPLETED OK"));
82 CActiveScheduler::Stop();
86 * Load and initialise an audio file.
88 TVerdict CTestStepVidPlayerDRMGetFrame::DoTestStepL()
91 iError = KErrTimedOut;
93 INFO_PRINTF1(_L("Test : Video Player DRM GetFrame"));
97 if(!GetStringFromConfig(iSectName,iKeyName,filename))
103 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
104 delete rights; // the database will now be reset and have no entries in it
106 TRect rect, clipRect;
107 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
108 EMdaPriorityPreferenceTimeAndQuality,
109 iWs, *iScreen, *iWindow, rect, clipRect);
110 CleanupStack::PushL(player);
112 TRAP(iError,player->OpenFileL(filename));
114 if(iError == KErrNone)
116 // Wait for initialisation callback
117 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
118 CActiveScheduler::Start();
121 if (iError == KErrNone && player != NULL)
124 CActiveScheduler::Start();
128 if (iError == KErrNone && player != NULL)
129 ret = DoTestL(player);
131 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
132 CleanupStack::PopAndDestroy(player);
133 if(iError != KErrNone)
134 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
138 TVerdict CTestStepVidPlayerDRMGetFrame::DoTestL(CVideoPlayerUtility* aPlayer)
140 TVerdict ret = EFail;
142 iError = KErrTimedOut;
143 aPlayer->GetFrameL(EColor16M, EView);
144 INFO_PRINTF1(_L("CVideoPlayerUtility: Getting Frame from file"));
145 // Wait for init callback
146 CActiveScheduler::Start();
147 if(iError == KErrNone)
159 * Static constructor for CTestStepVidPlayerDRMGetFrameProtected.
162 * @return "CTestStepVidPlayerDRMGetFrameProtected*"
163 * The constructed CTestStepVidPlayerDRMGetFrameProtected
169 CTestStepVidPlayerDRMGetFrameProtected::CTestStepVidPlayerDRMGetFrameProtected(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
170 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
173 CTestStepVidPlayerDRMGetFrameProtected* CTestStepVidPlayerDRMGetFrameProtected::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
175 CTestStepVidPlayerDRMGetFrameProtected* self = new (ELeave) CTestStepVidPlayerDRMGetFrameProtected(aTestName,aSectName,aKeyName);
180 void CTestStepVidPlayerDRMGetFrameProtected::MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError)
183 if (iError == KErrNone)
185 if (aFrame.Handle() == NULL || aFrame.SizeInPixels() != TSize(KFrameWidth,KFrameHeight) )
186 iError = KErrArgument;
190 INFO_PRINTF1(_L("MvpuoFrameReady: GetFrameL() COMPLETED OK"));
193 CActiveScheduler::Stop();
197 * Load and initialise an audio file.
199 TVerdict CTestStepVidPlayerDRMGetFrameProtected::DoTestStepL()
201 TVerdict ret = EFail;
202 iError = KErrTimedOut;
204 INFO_PRINTF1(_L("Test : Video Player DRM GetFrame"));
208 if(!GetStringFromConfig(iSectName,iKeyName,filename))
209 return EInconclusive;
214 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
215 CleanupStack::PushL(rights);
216 rights->AddRightsL(KDefaultRightsID,KZeroRightsCount); // add rights count
217 CleanupStack::PopAndDestroy(rights); // cleanup rights object
220 TRect rect, clipRect;
221 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
222 EMdaPriorityPreferenceTimeAndQuality,
223 iWs, *iScreen, *iWindow, rect, clipRect);
224 CleanupStack::PushL(player);
225 TMMFileSource fs(filename, KDefaultContentObject, EPeek);
226 TRAP(iError,player->OpenFileL(fs));
228 if(iError == KErrNone)
230 // Wait for initialisation callback
231 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
232 CActiveScheduler::Start();
235 if (iError == KErrNone && player != NULL)
238 CActiveScheduler::Start();
242 if (iError == KErrNone && player != NULL)
243 ret = DoTestL(player);
245 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
246 CleanupStack::PopAndDestroy(player);
247 if(iError != KErrNone)
248 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
252 TVerdict CTestStepVidPlayerDRMGetFrameProtected::DoTestL(CVideoPlayerUtility* aPlayer)
254 TVerdict ret = EFail;
256 iError = KErrTimedOut;
257 //set rights count to zero
258 aPlayer->GetFrameL(EColor16M, EView);
259 INFO_PRINTF1(_L("CVideoPlayerUtility: Getting Frame from file"));
260 // Wait for init callback
261 CActiveScheduler::Start();
262 if(iError == KErrCANoPermission)
273 * Static constructor for CTestStepVidPlayerDRMPlayNoRights.
276 * @return "CTestStepVidPlayerDRMPlayNoRights*"
277 * The constructed CTestStepVidPlayerDRMPlayNoRights
283 CTestStepVidPlayerDRMPlayNoRights::CTestStepVidPlayerDRMPlayNoRights(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
284 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
287 CTestStepVidPlayerDRMPlayNoRights* CTestStepVidPlayerDRMPlayNoRights::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
289 CTestStepVidPlayerDRMPlayNoRights* self = new (ELeave) CTestStepVidPlayerDRMPlayNoRights(aTestName,aSectName,aKeyName);
294 * Load and initialise an audio file.
296 TVerdict CTestStepVidPlayerDRMPlayNoRights::DoTestStepL()
298 TVerdict ret = EFail;
299 iError = KErrTimedOut;
301 INFO_PRINTF1(_L("Test : Video Player - Open File with no rights"));
304 if(!GetStringFromConfig(iSectName,iKeyName,filename))
305 return EInconclusive;
311 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
312 delete rights; // the database will now be reset and have no entries in it
314 TRect rect, clipRect;
315 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
316 EMdaPriorityPreferenceTimeAndQuality,
317 iWs, *iScreen, *iWindow, rect, clipRect);
318 CleanupStack::PushL(player);
319 TRAP(iError,player->OpenFileL(filename));
320 if (iError != KErrNone)
322 ERR_PRINTF2( _L("OpenFileL() left with %d, expecting"),iError);
323 CleanupStack::PopAndDestroy(player);
326 CActiveScheduler::Start();
328 if(iError == KErrCANoRights)
331 INFO_PRINTF1(_L("Expected failure with KErrCANoRights"));
334 ERR_PRINTF3( _L("CVideoPlayerUtility received error %d, expecting"),iError, KErrCANoRights );
335 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
337 CleanupStack::PopAndDestroy(player);
341 TVerdict CTestStepVidPlayerDRMPlayNoRights::DoTestL(CVideoPlayerUtility* aPlayer)
343 TVerdict ret = EFail;
345 iError = KErrTimedOut;
347 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
348 // Wait for init callback
349 CActiveScheduler::Start();
350 if(iError == KErrNone)
361 * Static constructor for CTestStepVidPlayerDRMPlayRights.
364 * @return "CTestStepVidPlayerDRMPlayRights*"
365 * The constructed CTestStepVidPlayerDRMPlayRights
371 CTestStepVidPlayerDRMPlayRights::CTestStepVidPlayerDRMPlayRights(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
372 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
375 CTestStepVidPlayerDRMPlayRights* CTestStepVidPlayerDRMPlayRights::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
377 CTestStepVidPlayerDRMPlayRights* self = new (ELeave) CTestStepVidPlayerDRMPlayRights(aTestName,aSectName,aKeyName);
382 * Load and initialise an audio file.
384 TVerdict CTestStepVidPlayerDRMPlayRights::DoTestStepL()
386 TVerdict ret = EFail;
387 iError = KErrTimedOut;
389 INFO_PRINTF1(_L("Test : Video Player - File"));
392 if(!GetStringFromConfig(iSectName,iKeyName,filename))
393 return EInconclusive;
399 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
400 CleanupStack::PushL(rights);
401 rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count
402 CleanupStack::PopAndDestroy(rights); // cleanup rights object
404 TRect rect, clipRect;
405 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
406 EMdaPriorityPreferenceTimeAndQuality,
407 iWs, *iScreen, *iWindow, rect, clipRect);
408 CleanupStack::PushL(player);
409 TRAP(iError,player->OpenFileL(filename));
411 if(iError == KErrNone)
413 // Wait for initialisation callback
414 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
415 CActiveScheduler::Start();
418 if (iError == KErrNone && player != NULL)
421 CActiveScheduler::Start();
425 if (iError == KErrNone && player != NULL)
426 ret = DoTestL(player);
428 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
429 CleanupStack::PopAndDestroy(player);
430 if(iError != KErrNone)
431 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
435 TVerdict CTestStepVidPlayerDRMPlayRights::DoTestL(CVideoPlayerUtility* aPlayer)
437 TVerdict ret = EFail;
439 iError = KErrTimedOut;
441 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
442 // Wait for init callback
443 CActiveScheduler::Start();
444 if(iError == KErrNone)