os/mm/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef MEDIACLIENTVIDEODISPLAYBODY_H
    17 #define MEDIACLIENTVIDEODISPLAYBODY_H
    18 
    19 #include "mediaclientextdisplayhandler.h"
    20 #include "mediaclientwseventobserver.h"
    21 #include <graphics/surface.h>
    22 #include <graphics/surfaceconfiguration.h>
    23 #include <mmf/common/mmfvideosurfacecustomcommands.h>
    24 #include <videoplayer.h>
    25 #include <mmf/plugin/mmfmediaclientextdisplayinterface.h>
    26 
    27 class MMMFSurfaceEventHandler;
    28 class CMediaClientPolicyServerClient;
    29 
    30 /**
    31 @internalTechnology
    32 @released
    33 
    34 */
    35 NONSHARABLE_CLASS(CMediaClientVideoDisplayBody) : public CBase, public MExtDisplayConnectionProviderCallback,
    36 public MMediaClientWsEventObserverCallback
    37 	{
    38 private:
    39 	NONSHARABLE_CLASS(TWindowData)
    40 		{
    41 	public:
    42 		TWindowData() :
    43 		   	iWindow(NULL)
    44 			{
    45 			}
    46 		
    47 		TWindowData(const RWindowBase* aWindow) :
    48 			iWindow(const_cast<RWindowBase*>(aWindow))
    49 			{
    50 			}
    51 				
    52 		TWindowData(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aVideoExtent,
    53 					TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, TAutoScaleType aAutoScaleType,
    54 					TInt aHorizPos, TInt aVertPos,RWindow* aWindow2) :
    55 			iWindow(const_cast<RWindowBase*>(aWindow)),
    56 			iClipRect(aClipRect),
    57 			iVideoExtent(aVideoExtent),
    58 			iScaleWidth(aScaleWidth),
    59 			iScaleHeight(aScaleHeight),
    60 			iRotation(aRotation),
    61 			iAutoScaleType(aAutoScaleType),
    62 			iHorizPos(aHorizPos),
    63 			iVertPos(aVertPos),
    64 			iWindow2(aWindow2)
    65 			{
    66 			}
    67 		
    68 		RWindowBase* iWindow;
    69 		TSurfaceConfiguration iSurfaceConfig;
    70 		TRect iClipRect;
    71 		TRect iVideoExtent;
    72 				
    73 		TReal32 iScaleWidth;
    74 		TReal32 iScaleHeight;
    75 		TVideoRotation iRotation;
    76 			
    77 		TAutoScaleType iAutoScaleType;
    78 		TInt iHorizPos;
    79 		TInt iVertPos;
    80 		
    81 		// iWindow2 is set when using CVideoPlayerUtility2.  This is used to avoid 
    82 		// casting iWindow from RWindowBase* to RWindow*.
    83 		RWindow* iWindow2;
    84 		
    85 
    86 		static TBool CompareByWsHandle(const TInt* aWsHandle, const TWindowData& aWindowData)
    87 			{
    88 			TBool ret = EFalse;
    89 			if (aWsHandle)
    90 				{
    91 				ret = (*aWsHandle == aWindowData.iWindow->WsHandle());
    92 				}
    93 			return ret;
    94 			}
    95 		};
    96 public:
    97 
    98 	static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, TBool aExtDisplaySwitchingControl);
    99 	static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, TBool aExtDisplaySwitchingControl);
   100 	
   101 	~CMediaClientVideoDisplayBody();
   102 	
   103 	void AddDisplayL(MMMFSurfaceEventHandler& aEventHandler);
   104 	void AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent,
   105 							TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation,
   106 							TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2);
   107 	void UpdateDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, 
   108                             TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, 
   109                             TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2);
   110 	void RemoveDisplay();
   111 	TInt RemoveDisplayWindow(const RWindowBase& aWindow);
   112 	
   113 	TInt SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion);
   114 	TInt SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio);
   115 	void RemoveSurface(TBool aControllerEvent);
   116 	void RemoveBackgroundSurface(TBool aTriggerRedraw);
   117 	TInt RedrawWindows(const TRect& aCropRegion);
   118 		
   119 	void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion);
   120 	void SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion);
   121 	TVideoRotation RotationL(const RWindowBase& aWindow);
   122 	void SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion);
   123 	void GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage);
   124 
   125 	void SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion);
   126 	void SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion);
   127 	void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion);
   128 	void SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion);
   129 	void SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion);
   130 	
   131 	void SetExternalDisplaySwitchingL(TBool aControl);
   132 	
   133 private:
   134 	
   135 	CMediaClientVideoDisplayBody(TInt aDisplayId);
   136 	CMediaClientVideoDisplayBody(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect,	TVideoAspectRatio aAspectRatio);
   137 	
   138 	void ConstructL(TBool aExtDisplaySwitchingControl);
   139 	
   140 	CFbsBitGc::TGraphicsOrientation ConvertRotation(TVideoRotation aRotation);
   141 	
   142 	RArray<CMediaClientVideoDisplayBody::TWindowData>& Windows();
   143 	TInt DisplayId() const;
   144 	TBool IsUsed() const;
   145 	static TInt CompareByDisplay(const TInt* aDisplayId, const CMediaClientVideoDisplayBody& aDisplay);
   146 	static TInt Compare(const CMediaClientVideoDisplayBody& aLeft, const CMediaClientVideoDisplayBody& aRight);
   147 	static CMediaClientVideoDisplayBody* FindDisplayWithWindowL(const RPointerArray<CMediaClientVideoDisplayBody>& aDisplays, const RWindowBase& aWindow);
   148 	TBool IsSurfaceCreated() const;
   149 	TInt SetBackgroundSurface(TWindowData& aWindowData, const TRect& aCropRegion);
   150 	TBool HasWindows() const;
   151 	
   152     void UpdateCropRegionL(const TRect& aCropRegion, TInt aPos, TBool aRedrawIndividualWindow);
   153     void CreateExtDisplayPluginL();
   154     void RemoveExtDisplayPlugin();
   155     void CreateExtDisplayHandlerL();
   156     void RemoveExtDisplayHandler();
   157     void SetWindowArrayPtr2Client();
   158     void SetWindowArrayPtr2Ext();
   159     void SwitchSurface();
   160     void UpdateFocus();
   161 	TBool IsRotationValid(TVideoRotation aVideoRotation);
   162 	TBool IsAutoScaleTypeValid(TAutoScaleType aAutoScaleType);
   163 	TBool SurfaceCropRectChangeRequiresRedraw(TRect aOldSurfaceCropRect, TRect aNewSurfaceCropRect, TRect aClientCropRegion);
   164 	TBool ClientCropRegionChangeRequiresRedraw(TRect aOldClientCropRegion, TRect aNewClientCropRegion, TRect aSurfaceCropRect);
   165 	TBool IntersectionAreaChanged(TRect aOldRect, TRect aNewRect, TRect aOtherRect);
   166 	void UpdateDeltaForExtDisplay(TReal32 aViewportAspect, const TRect& aVideoExtent, TInt& aDeltaHeight, TInt& aDeltaWidth);
   167 	TBool IsWideScreenL();
   168 	TAutoScaleType ExtDisplayAutoScaleTypeL();
   169 	
   170     // MExtDisplayConnectionProviderCallback
   171     void MedcpcExtDisplayNotifyConnected(TExtDisplayConnectionProviderConnType aExtDisplayConnType);
   172 
   173     // MMediaClientWsEventObserverCallback
   174     void MmcweoFocusWindowGroupChanged();
   175     TBool MmcweoIgnoreProcess(TSecureId aId);
   176     
   177 #ifdef MEDIA_CLIENT_SURFACE_NOT_REMOVED_FROM_CLIENT_WINDOW
   178     void HideAllClientWindows();
   179     TInt HideWindow(RWindowBase* aWindow);
   180     void SetHiddenBackgroundSurfaceOnAllClientWindows();
   181     TInt SetHiddenBackgroundSurfaceOnClientWindow(TWindowData& aWindowData);
   182 #endif
   183     
   184 private:
   185 
   186     MMMFSurfaceEventHandler* iEventHandler;
   187 	const TInt iDisplayId;
   188 	TSurfaceId iSurfaceId;
   189 	TRect iCropRect;
   190 	TVideoAspectRatio iAspectRatio;
   191 	
   192 	RArray<TWindowData> iClientWindows;
   193 	RArray<TWindowData> iExtDisplayWindows;
   194 	RArray<TWindowData>* iWindowsArrayPtr;
   195 	TBool iSwitchedToExternalDisplay;
   196 	
   197 	TRect iCropRegion;
   198 	TBool iClientRequestedExtDisplaySwitching;
   199 	CExtDisplayConnectionProviderInterface* iExtDisplayConnectionProvider;
   200 	CMediaClientExtDisplayHandler* iExtDisplayHandler;
   201 	CMediaClientWsEventObserver* iWsEventObserver;
   202 	TBool iClientWindowIsInFocus;
   203     TBool iExtDisplayConnected;
   204     TBool iExtDisplaySwitchingSupported;
   205     TExtDisplayConnectionProviderConnType iExtDisplayConnType;
   206     
   207     CMediaClientPolicyServerClient* iServerClient;
   208     
   209 	friend class CVideoPlayerUtility::CBody;	
   210 	friend class CTestStepUnitMMFVidClient;
   211 	};
   212 
   213 #endif // MEDIACLIENTVIDEODISPLAYBODY_H
   214