|
1 // Copyright (c) 2002-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". |
|
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 <w32std.h> |
|
20 #include <graphics/surface.h> |
|
21 #include <graphics/surfaceconfiguration.h> |
|
22 #include <mmf/common/mmfvideosurfacecustomcommands.h> |
|
23 #include <videoplayer.h> |
|
24 #include <mmf/plugin/mmfmediaclientextdisplayinterface.h> |
|
25 |
|
26 class MMMFSurfaceEventHandler; |
|
27 |
|
28 /** |
|
29 @internalTechnology |
|
30 @released |
|
31 |
|
32 */ |
|
33 NONSHARABLE_CLASS(CMediaClientVideoDisplayBody) : public CBase, public MExtDisplayConnectionProviderCallback |
|
34 { |
|
35 private: |
|
36 NONSHARABLE_CLASS(TWindowData) |
|
37 { |
|
38 public: |
|
39 TWindowData() : |
|
40 iWindow(NULL) |
|
41 { |
|
42 } |
|
43 |
|
44 TWindowData(const RWindowBase* aWindow) : |
|
45 iWindow(const_cast<RWindowBase*>(aWindow)) |
|
46 { |
|
47 } |
|
48 |
|
49 TWindowData(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aVideoExtent, |
|
50 TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, TAutoScaleType aAutoScaleType, |
|
51 TInt aHorizPos, TInt aVertPos,RWindow* aWindow2) : |
|
52 iWindow(const_cast<RWindowBase*>(aWindow)), |
|
53 iClipRect(aClipRect), |
|
54 iVideoExtent(aVideoExtent), |
|
55 iScaleWidth(aScaleWidth), |
|
56 iScaleHeight(aScaleHeight), |
|
57 iRotation(aRotation), |
|
58 iAutoScaleType(aAutoScaleType), |
|
59 iHorizPos(aHorizPos), |
|
60 iVertPos(aVertPos), |
|
61 iWindow2(aWindow2) |
|
62 { |
|
63 } |
|
64 |
|
65 RWindowBase* iWindow; |
|
66 TSurfaceConfiguration iSurfaceConfig; |
|
67 TRect iClipRect; |
|
68 TRect iVideoExtent; |
|
69 |
|
70 TReal32 iScaleWidth; |
|
71 TReal32 iScaleHeight; |
|
72 TVideoRotation iRotation; |
|
73 |
|
74 TAutoScaleType iAutoScaleType; |
|
75 TInt iHorizPos; |
|
76 TInt iVertPos; |
|
77 |
|
78 // iWindow2 is set when using CVideoPlayerUtility2. This is used to avoid |
|
79 // casting iWindow from RWindowBase* to RWindow*. |
|
80 RWindow* iWindow2; |
|
81 |
|
82 |
|
83 static TBool CompareByWsHandle(const TInt* aWsHandle, const TWindowData& aWindowData) |
|
84 { |
|
85 TBool ret = EFalse; |
|
86 if (aWsHandle) |
|
87 { |
|
88 ret = (*aWsHandle == aWindowData.iWindow->WsHandle()); |
|
89 } |
|
90 return ret; |
|
91 } |
|
92 }; |
|
93 public: |
|
94 |
|
95 static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId); |
|
96 static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio); |
|
97 |
|
98 ~CMediaClientVideoDisplayBody(); |
|
99 |
|
100 void AddDisplayL(MMMFSurfaceEventHandler& aEventHandler); |
|
101 void AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, |
|
102 TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, |
|
103 TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2); |
|
104 void RemoveDisplay(); |
|
105 TInt RemoveDisplayWindow(const RWindowBase& aWindow); |
|
106 |
|
107 TInt SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion); |
|
108 TInt SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio); |
|
109 void RemoveSurface(TBool aControllerEvent); |
|
110 void RemoveBackgroundSurface(TBool aTriggerRedraw); |
|
111 TInt RedrawWindows(const TRect& aCropRegion); |
|
112 |
|
113 void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion); |
|
114 void SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion); |
|
115 TVideoRotation RotationL(const RWindowBase& aWindow); |
|
116 void SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion); |
|
117 void GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage); |
|
118 |
|
119 void SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion); |
|
120 void SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion); |
|
121 void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion); |
|
122 void SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion); |
|
123 void SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion); |
|
124 |
|
125 void SetExternalDisplaySwitchingL(TBool aControl); |
|
126 |
|
127 private: |
|
128 |
|
129 CMediaClientVideoDisplayBody(TInt aDisplayId); |
|
130 CMediaClientVideoDisplayBody(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio); |
|
131 |
|
132 void ConstructL(); |
|
133 |
|
134 CFbsBitGc::TGraphicsOrientation ConvertRotation(TVideoRotation aRotation); |
|
135 |
|
136 RArray<CMediaClientVideoDisplayBody::TWindowData>& Windows(); |
|
137 TInt DisplayId() const; |
|
138 TBool IsUsed() const; |
|
139 static TInt CompareByDisplay(const TInt* aDisplayId, const CMediaClientVideoDisplayBody& aDisplay); |
|
140 static TInt Compare(const CMediaClientVideoDisplayBody& aLeft, const CMediaClientVideoDisplayBody& aRight); |
|
141 static CMediaClientVideoDisplayBody* FindDisplayWithWindowL(const RPointerArray<CMediaClientVideoDisplayBody>& aDisplays, const RWindowBase& aWindow); |
|
142 TBool IsSurfaceCreated() const; |
|
143 TInt SetBackgroundSurface(TWindowData& aWindowData, const TRect& aCropRegion); |
|
144 void CalculateExtentAndViewport(const TWindowData& aWindowData, TRect& aExtent, TRect& aViewport); |
|
145 TBool HasWindows() const; |
|
146 |
|
147 void CreateExtDisplayConnProvAndRemoveSurfaceL(TBool aRemoveBackgroundSurface); |
|
148 void RemoveExtDisplayConnProvAndRedrawL(); |
|
149 void RemoveExtDisplayConnProv(); |
|
150 void MedcpcExtDisplayCalculateExtentAndViewportL(TRect& aExtent, TRect& aViewport, TRect& aExternalDisplayRect); |
|
151 void MedcpcExtDisplayNotifyConnected(TBool aExtDisplayConnected); |
|
152 |
|
153 private: |
|
154 |
|
155 MMMFSurfaceEventHandler* iEventHandler; |
|
156 const TInt iDisplayId; |
|
157 TSurfaceId iSurfaceId; |
|
158 TRect iCropRect; |
|
159 TVideoAspectRatio iAspectRatio; |
|
160 RArray<TWindowData> iWindows; |
|
161 |
|
162 TRect iCropRegion; |
|
163 TBool iClientRequestedExtDisplaySwitching; |
|
164 CExtDisplayConnectionProviderInterface* iExtDisplayConnectionProvider; |
|
165 TBool iExtDisplayConnected; |
|
166 TBool iExtDisplaySwitchingSupported; |
|
167 |
|
168 friend class CVideoPlayerUtility::CBody; |
|
169 friend class CTestStepUnitMMFVidClient; |
|
170 }; |
|
171 |
|
172 #endif // MEDIACLIENTVIDEODISPLAYBODY_H |
|
173 |