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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef MEDIACLIENTVIDEODISPLAYBODY_H
17 #define MEDIACLIENTVIDEODISPLAYBODY_H
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>
27 class MMMFSurfaceEventHandler;
28 class CMediaClientPolicyServerClient;
35 NONSHARABLE_CLASS(CMediaClientVideoDisplayBody) : public CBase, public MExtDisplayConnectionProviderCallback,
36 public MMediaClientWsEventObserverCallback
39 NONSHARABLE_CLASS(TWindowData)
47 TWindowData(const RWindowBase* aWindow) :
48 iWindow(const_cast<RWindowBase*>(aWindow))
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)),
57 iVideoExtent(aVideoExtent),
58 iScaleWidth(aScaleWidth),
59 iScaleHeight(aScaleHeight),
61 iAutoScaleType(aAutoScaleType),
69 TSurfaceConfiguration iSurfaceConfig;
75 TVideoRotation iRotation;
77 TAutoScaleType iAutoScaleType;
81 // iWindow2 is set when using CVideoPlayerUtility2. This is used to avoid
82 // casting iWindow from RWindowBase* to RWindow*.
86 static TBool CompareByWsHandle(const TInt* aWsHandle, const TWindowData& aWindowData)
91 ret = (*aWsHandle == aWindowData.iWindow->WsHandle());
98 static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, TBool aExtDisplaySwitchingControl);
99 static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, TBool aExtDisplaySwitchingControl);
101 ~CMediaClientVideoDisplayBody();
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);
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);
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);
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);
131 void SetExternalDisplaySwitchingL(TBool aControl);
135 CMediaClientVideoDisplayBody(TInt aDisplayId);
136 CMediaClientVideoDisplayBody(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio);
138 void ConstructL(TBool aExtDisplaySwitchingControl);
140 CFbsBitGc::TGraphicsOrientation ConvertRotation(TVideoRotation aRotation);
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;
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();
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();
170 // MExtDisplayConnectionProviderCallback
171 void MedcpcExtDisplayNotifyConnected(TExtDisplayConnectionProviderConnType aExtDisplayConnType);
173 // MMediaClientWsEventObserverCallback
174 void MmcweoFocusWindowGroupChanged();
175 TBool MmcweoIgnoreProcess(TSecureId aId);
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);
186 MMMFSurfaceEventHandler* iEventHandler;
187 const TInt iDisplayId;
188 TSurfaceId iSurfaceId;
190 TVideoAspectRatio iAspectRatio;
192 RArray<TWindowData> iClientWindows;
193 RArray<TWindowData> iExtDisplayWindows;
194 RArray<TWindowData>* iWindowsArrayPtr;
195 TBool iSwitchedToExternalDisplay;
198 TBool iClientRequestedExtDisplaySwitching;
199 CExtDisplayConnectionProviderInterface* iExtDisplayConnectionProvider;
200 CMediaClientExtDisplayHandler* iExtDisplayHandler;
201 CMediaClientWsEventObserver* iWsEventObserver;
202 TBool iClientWindowIsInFocus;
203 TBool iExtDisplayConnected;
204 TBool iExtDisplaySwitchingSupported;
205 TExtDisplayConnectionProviderConnType iExtDisplayConnType;
207 CMediaClientPolicyServerClient* iServerClient;
209 friend class CVideoPlayerUtility::CBody;
210 friend class CTestStepUnitMMFVidClient;
213 #endif // MEDIACLIENTVIDEODISPLAYBODY_H