os/graphics/graphicstest/uibench/s60/src/tests_ui_video/tuiandvideo.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @test
    22  @internalComponent - Internal Symbian test code 
    23 */
    24 
    25 #ifndef __TUIANDVIDEO_H__
    26 #define __TUIANDVIDEO_H__
    27 
    28 #include <coecntrl.h> 
    29 #include <coeaui.h>
    30 #include <eikenv.h>
    31 
    32 #include "te_conestepbase.h"
    33 
    34 _LIT(KTUiAndVideo,"tuiandvideo");
    35 
    36 #include <coecntrl.h>
    37 
    38 #include <eikenv.h>
    39 #include <eikappui.h>
    40 #include <eikapp.h>
    41 #include <eikdoc.h>
    42 //#include <eikmenup.h>
    43 //#include <eikon.hrh>
    44 //#include <eikon.rsg>
    45 #include <apgcli.h>
    46 #include <videoplayer2.h>
    47 
    48 class CTestAppView;
    49 class CVideoPane;
    50 class CTUiAndVideoAppUi;
    51 
    52 /**
    53 Helper class to manage commands between test framework and test thread.
    54 */
    55 class CCommandSink : public CActive
    56 {
    57 public:
    58 	CCommandSink(CTestAppView* aTestView);
    59 	~CCommandSink();
    60 	void Init(RThread* aTargetThread, TRequestStatus* aTargetStatus);
    61 	
    62 protected:
    63 	void DoCancel();
    64 	
    65 private:
    66 	void RunL();
    67 	
    68 	CTestAppView* 	iTestView;
    69 	TRequestStatus* iTargetStatus; 
    70 	RThread* 		iTargetThread;
    71 	TUint32 		iState;
    72 };
    73 
    74 
    75 class CTUiAndVideo : public CTe_ConeStepBase
    76 	{
    77 public:
    78 	CTUiAndVideo();
    79 
    80 private:
    81 	// From CTestStep
    82 	virtual TVerdict doTestStepL();
    83 	virtual void InitUIL(CCoeEnv* aCoeEnv);
    84 	void IssueCommand (TUint aCommand);
    85 	void StepState (TUint aNextState, TUint aPause);
    86 
    87 private:
    88 	CTUiAndVideoAppUi* iAppUi;
    89 	TRequestStatus iTestState;
    90 	};
    91 
    92 //************************************************************************************************************
    93 //** Application UI
    94 //************************************************************************************************************
    95 
    96 class CTUiAndVideoAppUi : public CEikAppUi, public MVideoPlayerUtilityObserver
    97 	{
    98 public:
    99 	void ConstructL(TRequestStatus iCommandSource);
   100 	~CTUiAndVideoAppUi();
   101 
   102 public: // from MVIdeoPlayerUtilityObserver
   103 	void MvpuoOpenComplete(TInt aError);
   104 	void MvpuoPrepareComplete(TInt aError);
   105 	void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError);
   106 	void MvpuoPlayComplete(TInt aError);
   107 	void MvpuoEvent(const TMMFEvent &aEvent);
   108 
   109 private:
   110 	// from CEikAppUi
   111 	void HandleCommandL(TInt aCommand);	
   112 	void HandleForegroundEventL(TBool aForeground);
   113 	static TInt BackgroundCallBack(TAny* aSelf);
   114 	static TInt UIMoverCallBack(TAny* aSelf);
   115 	void SetPos();
   116 	void BringToForeground();
   117 	static TInt PlayTimerCallBack(TAny* aSelf);
   118 
   119 public:
   120 	void Bounce (TBool aBounce);
   121 	void Jump   (TBool aJump);
   122 	
   123 	TInt PopulateDirFilesL(const TDesC& aDir);
   124 	void OpenSelectedFileL(const TDesC& aFile);
   125 	TInt PlayNextFileL();
   126 	TInt PlayPreviousFileL();
   127 	void LogError(const TDesC& aFileName, const TDesC& aErrorMsg);
   128 	TRequestStatus* CommandSink ();
   129 	TBool iInitialised;
   130 	
   131 private:
   132 	CCommandSink* iCommandSink;
   133 	CTestAppView* iAppView;
   134 	CVideoPlayerUtility2* iLoadingPlayer;
   135 	CPeriodic* iIdleTimer;
   136 	CPeriodic* iUIMover;
   137 	CPeriodic* iPlayTimer;
   138 	CDir* iDirList;
   139 	TInt iCurrentIndex;
   140 	TFileName iCurrentFile;
   141 	};
   142 
   143 
   144 
   145 //************************************************************************************************************
   146 //** View class
   147 //************************************************************************************************************
   148 
   149 class CTestAppView : public CCoeControl, public MCoeControlObserver
   150 	{
   151 public:
   152 	static CTestAppView* NewL(const TRect& aWindowedRect);
   153 	~CTestAppView();
   154 	RWindow& TheWindow();
   155 	const RWindow& TheWindow() const { return const_cast<CTestAppView*>(this)->TheWindow(); }
   156 	void EnableVideo(CVideoPlayerUtility2*& aPlayer);
   157 	void DisableVideo();
   158 	TRect VideoPaneRect() const;
   159 	
   160 	void SetRunMode (TUint32 aMode);
   161 	
   162 	void PlayVideo();
   163 	void PauseVideo();
   164 	void StopVideo();
   165 	void PlayComplete(TInt aError);
   166 	void SetPos(TPoint* aPos);
   167 private:
   168 	CTestAppView();
   169 	void ConstructL(const TRect& aRect);
   170 	void SetVideoSize(CVideoPlayerUtility2& aVideo) const;
   171 	void UpdateButtonState();
   172 	void PlayPrevious();
   173 	void PlayNext();
   174 private: // from MCoeControlObserver
   175 	void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType);
   176 
   177 private: // from CCoeControl
   178 	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   179 	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);    
   180 	void SizeChanged(); 
   181 	void Draw(const TRect& aRect) const;
   182 
   183 private:	
   184 	TPoint iVidPos;
   185 	TPoint iIncrement;
   186 	TPoint iDirection;
   187 	TInt32 iRunMode;
   188 	
   189 	TRect iWindowedViewRect;
   190 	TSize iNativeVideoSize;
   191 	TPoint iPointerDownPos;
   192 	TTime iPointerDownTime;
   193 	CVideoPlayerUtility2* iCurrentPlayer;
   194 	TBool iIsPlaying;
   195 private:
   196 	CFbsBitmap* iBkgrdImage;
   197 	CFbsBitmap* iBkgrdMask;
   198 private:
   199 	CVideoPane* iVideoPane;
   200 	
   201 	enum
   202 		{
   203 		KFourButtonControlID,
   204 		KThreeButtonControlID,
   205 		KVideoControlID
   206 		};
   207 	};
   208 
   209 enum TButtonPaneAction
   210 	{
   211 	KButtonEventNotInit = -2,
   212 	KButtonEventDoNothing = -1,
   213 	KButtonEventDoPlayPause = 10,
   214 	KButtonEventDoBackward,
   215 	KButtonEventDoForward,
   216 	KButtonEventDoOpenFile
   217 	};
   218 
   219 
   220 //************************************************************************************************************
   221 //** CVideoPane class - place 'video' window
   222 //************************************************************************************************************
   223 
   224 class CVideoPane : public CCoeControl
   225 	{
   226 public:
   227 	~CVideoPane();
   228 	CVideoPane();
   229 	void ConstructL(CCoeControl& aParent);
   230 	RWindow& TheWindow() { return Window(); }
   231 	const RWindow& TheWindow() const { return const_cast<CVideoPane*>(this)->TheWindow(); }
   232 	TBool IsVideoPanePointerEvent();
   233 	void BlackoutPane();
   234 	void SetVideoUseRect(const TRect& aRect);
   235 	void EnableSubtitle(CVideoPlayerUtility2* aSubtitlePlayer);
   236 private: // from CCoeControl
   237 	void SizeChanged();
   238 	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   239 	void Draw(const TRect& aRect) const;
   240 private:
   241 	TBool iIsVideoPanePointerEvent;
   242 	TRect iVideoUseRect;
   243 private:
   244 	CVideoPlayerUtility2* iSubtitlePlayer;
   245 	};
   246 
   247 #endif