1 /* |
|
2 * Copyright (c) 2002-2007 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: This class implements MMMADisplayWindow functionality |
|
15 * in graphics surface based displays for Helix engine. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef CMMASURFACEWINDOW_H |
|
20 #define CMMASURFACEWINDOW_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <w32std.h> |
|
25 //#include <reflcdui.h> |
|
26 #include <graphics/surface.h> |
|
27 #include <mmf/common/mmfvideosurfacecustomcommands.h> |
|
28 #include <mediaclientvideodisplay.h> |
|
29 |
|
30 #include <e32std.h> |
|
31 #include <mmf/common/mmfstandardcustomcommands.h> |
|
32 #include "mmmadisplaywindow.h" |
|
33 #include "mmafunctionserver.h" |
|
34 #include "cmmaplayer.h" |
|
35 #include "cmmacanvasdisplay.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class RWsSession; |
|
39 class CWsScreenDevice; |
|
40 class RWindowBase; |
|
41 class MMMADisplay; |
|
42 |
|
43 // CONSTANTS |
|
44 const TInt KMMAVideoMinDimension = 32; // minimum video width and height |
|
45 |
|
46 // CLASS DECLARATION |
|
47 /** |
|
48 * This class implements MMMADisplayWindow functionality |
|
49 * in video display to graphics surface based displays for Helix engine. |
|
50 */ |
|
51 NONSHARABLE_CLASS(CMMASurfaceWindow): public CBase, |
|
52 public MMMADisplayWindow/*, |
|
53 public MUiEventConsumer*/ |
|
54 { |
|
55 public: |
|
56 /** |
|
57 * indicates what method needs to be called in UI thread context. |
|
58 */ |
|
59 enum TUiCallbackType |
|
60 { |
|
61 ERemoveSurface = 1, |
|
62 ESetDrawRect, |
|
63 EInitVideoDisplay, |
|
64 EResetSurfaceParameters, |
|
65 ESetChangedSurfaceParameters, |
|
66 ECleanVideoDisplay, |
|
67 EDestroyWindow |
|
68 }; |
|
69 |
|
70 private: |
|
71 /** |
|
72 * indicates different video display initialization states |
|
73 * |
|
74 * video display state transition can happen in following order: |
|
75 * 1. when MIDlet code is: |
|
76 * Player player = Manager.createPlayer(..); |
|
77 * player.realize(); |
|
78 * VideoControl vc = (VideoControl)player.getControl("VideoControl"); |
|
79 * vc.initDisplayMode(..); |
|
80 * player.start(); |
|
81 * |
|
82 * EUIResourcesAndSurfaceParametersNotSet |
|
83 * EUIResourcesSetAndSurfaceParametersNotSet |
|
84 * EUIResourcesAndSurfaceParametersSet |
|
85 * |
|
86 * OR |
|
87 * |
|
88 * 2. when MIDlet code is: |
|
89 * Player player = Manager.createPlayer(..); |
|
90 * player.start(); |
|
91 * VideoControl vc = (VideoControl)player.getControl("VideoControl"); |
|
92 * vc.initDisplayMode(..); |
|
93 * |
|
94 * EUIResourcesAndSurfaceParametersNotSet |
|
95 * ESurfaceParametersSetAndUIResourcesNotSet |
|
96 * EUIResourcesAndSurfaceParametersSet |
|
97 * |
|
98 * InitVideoDisplayL() should be called only after EUIResourcesAndSurfaceParametersSet |
|
99 * state is reached. ie both UI resources and surface parameters becomes available. |
|
100 * |
|
101 * 3. for below mentioned MIDlet code case: |
|
102 * Player player = Manager.createPlayer(..); |
|
103 * player.start(); // state transition is |
|
104 * |
|
105 * EUIResourcesAndSurfaceParametersNotSet |
|
106 * ESurfaceParametersSetAndUIResourcesNotSet |
|
107 * note that InitVideoDisplayL() is not called and video is not displayed in this case. |
|
108 */ |
|
109 enum TVideoDisplayInitState |
|
110 { |
|
111 /** |
|
112 * indicates ui resources and surface parameters are not yet set. |
|
113 * UI resources are RWindowBase, CWsScreenDevice and RWsSession. |
|
114 * Surface parameters are TSurfaceId, TRect and TVideoAspectRatio. |
|
115 */ |
|
116 EUIResourcesAndSurfaceParametersNotSet = 1, |
|
117 /** |
|
118 * indicates UI resources are set and surface parameters not yet set. |
|
119 * UI resources are set when initDisplayMode() is called and RWindow becomes available. |
|
120 */ |
|
121 EUIResourcesSetAndSurfaceParametersNotSet, |
|
122 /** |
|
123 * indicates UI resources are not yet set and surface parameters are set. |
|
124 * Surface parameters are set when player.start() is called. |
|
125 */ |
|
126 ESurfaceParametersSetAndUIResourcesNotSet, |
|
127 /** |
|
128 * indicates UI resources and surface parameters are set. |
|
129 */ |
|
130 EUIResourcesAndSurfaceParametersSet |
|
131 }; |
|
132 |
|
133 public: // Constructors and destructors |
|
134 static CMMASurfaceWindow* NewL( |
|
135 MMAFunctionServer* aEventSource, |
|
136 CMMAPlayer* aPlayer); |
|
137 |
|
138 virtual ~CMMASurfaceWindow(); |
|
139 |
|
140 private: // Constructors and destructors |
|
141 CMMASurfaceWindow( |
|
142 MMAFunctionServer* aEventSource, |
|
143 CMMAPlayer* aPlayer); |
|
144 |
|
145 public: // Methods derived from MMMADisplayWindow |
|
146 void SetDestinationBitmapL(CFbsBitmap* aBitmap); |
|
147 void DrawFrameL(const CFbsBitmap* aBitmap); |
|
148 void SetDrawRect(const TRect& aRect); |
|
149 void SetDrawRectThread(const TRect& aRect); |
|
150 const TRect& DrawRect(); |
|
151 TSize WindowSize(); |
|
152 void SetPosition(const TPoint& aPosition); |
|
153 void SetVisible(TBool aVisible, TBool aUseEventServer = ETrue); |
|
154 void SetWindowRect(const TRect& aRect,MMMADisplay::TThreadType aThreadType); |
|
155 void SetVideoCropRegion(const TRect& aRect); |
|
156 void SetRWindowRect(const TRect& aRect, MMMADisplay::TThreadType aThreadType); |
|
157 const TRect& WindowRect(); |
|
158 void ContainerDestroyed(); |
|
159 void ContainerSet(); |
|
160 /* |
|
161 public: // from base class MUiEventConsumer |
|
162 void MdcDSAResourcesCallback(RWsSession &aWs, |
|
163 CWsScreenDevice &aScreenDevice, |
|
164 RWindowBase &aWindow); |
|
165 |
|
166 */ |
|
167 void UICallback(TInt aCallbackId); |
|
168 public: |
|
169 virtual void ProcureWindowResourcesFromQWidget(RWsSession * aWs, |
|
170 CWsScreenDevice* aScreenDevice, |
|
171 RWindowBase* aWindow); |
|
172 |
|
173 virtual CMMAPlayer* UiPlayer(); |
|
174 |
|
175 public: // New methods |
|
176 TBool IsVisible() const; |
|
177 void SetDisplay(MMMADisplay *aDisplay); |
|
178 |
|
179 /** |
|
180 * copies surface paramaters and intializes video display if |
|
181 * RWindow is already set, ie if intDisplayMode already called in midlet. |
|
182 * invokes InitVideoDisplayL() in UI thread context. |
|
183 * |
|
184 * @params aSurfaceId, aCropRect, aPixelAspectRatio surface paramaters. |
|
185 */ |
|
186 void SetSurfaceParameters(const TSurfaceId& aSurfaceId, |
|
187 const TRect& aCropRect, |
|
188 const TVideoAspectRatio& aPixelAspectRatio); |
|
189 |
|
190 /** |
|
191 * invokes DoRemoveSurface() in UI thread context. |
|
192 */ |
|
193 void RemoveSurface(); |
|
194 |
|
195 /** |
|
196 * updates members variables with new surface parameters and invokes |
|
197 * DoSetChangedSurfaceParameters() in UI thread context. |
|
198 * |
|
199 * @params aSurfaceId, aCropRect, aPixelAspectRatio surface paramaters. |
|
200 */ |
|
201 void SetChangedSurfaceParameters(const TSurfaceId& aSurfaceId, |
|
202 const TRect& aCropRect, |
|
203 const TVideoAspectRatio& aPixelAspectRatio); |
|
204 |
|
205 private: // New methods |
|
206 /** |
|
207 * scales video to the required size. |
|
208 * This method must always be executed in UI-Thread context. |
|
209 * |
|
210 * @param aRect rectangular size to which the video has to be scaled. |
|
211 */ |
|
212 void ScaleVideoL(const TRect& aRect); |
|
213 |
|
214 /** |
|
215 * starts video rendering to a graphics surface. |
|
216 * restarts video rendering to a graphics surafce with changed parameters. |
|
217 * This method must always be executed in UI-Thread context. |
|
218 */ |
|
219 void RedrawVideoL(); |
|
220 |
|
221 /** |
|
222 * utility function to invoke RedrawVideoL() function with in a TRAP harness. |
|
223 * |
|
224 * @param aSurfaceWindow reference to CMMASurfaceWindow instance on which RedrawVideoL() |
|
225 * has to be invoked |
|
226 * @return TInt Symbian OS error code, KErrNone if no error |
|
227 */ |
|
228 static TInt StaticRedrawVideo(CMMASurfaceWindow& aSurfaceWindow); |
|
229 |
|
230 /** |
|
231 * creates new instance of CMediaClientVideoDisplay and intializes it with |
|
232 * surfaces and windows. |
|
233 * This method must always be executed in UI-Thread context. |
|
234 */ |
|
235 void InitVideoDisplayL(); |
|
236 |
|
237 /** |
|
238 * updates CMediaClientVideoDisplay instance with new surface parameters. |
|
239 * This method must always be executed in UI-Thread context. |
|
240 */ |
|
241 void DoSetChangedSurfaceParameters(); |
|
242 |
|
243 /** |
|
244 * resets CMediaClientVideoDisplay instance with new surface parameters. |
|
245 * This method must always be executed in UI-Thread context. |
|
246 */ |
|
247 void DoResetSurfaceParameters(); |
|
248 |
|
249 /** |
|
250 * Removes Surface from RWindow |
|
251 * This method must always be executed in UI-Thread context. |
|
252 */ |
|
253 void DoRemoveSurface(); |
|
254 |
|
255 /** |
|
256 * removes surfaces and windows from CMediaClientVideoDisplay instance |
|
257 * and deletes the instance. |
|
258 * This method must always be executed in UI-Thread context. |
|
259 */ |
|
260 void CleanVideoDisplay(); |
|
261 |
|
262 /** |
|
263 * Deletes this object. |
|
264 * |
|
265 * @since S60 v5.2 |
|
266 */ |
|
267 void Destroy(); |
|
268 |
|
269 private: // Data |
|
270 /** |
|
271 * drawing area where video is rendered. |
|
272 */ |
|
273 TRect iContentRect; |
|
274 |
|
275 /** |
|
276 * parent rectangle used for positioning contentRect. |
|
277 */ |
|
278 TRect iParentRect; |
|
279 |
|
280 /** |
|
281 * Symbian RWindow rect |
|
282 */ |
|
283 TRect iRWindowRect; |
|
284 |
|
285 /** |
|
286 * not owned, used for switching from UI thread to MMA thread |
|
287 */ |
|
288 MMAFunctionServer* iEventSource; |
|
289 |
|
290 /** |
|
291 * We must depend on player's state because direct screen access may |
|
292 * not be resumed before player is started. |
|
293 * not owned. |
|
294 */ |
|
295 CMMAPlayer* iPlayer; |
|
296 |
|
297 /** |
|
298 * crop rectangle of video |
|
299 */ |
|
300 TRect iVideoCropRegion; |
|
301 |
|
302 /** |
|
303 * owned, used for video display on surface |
|
304 * this instance is created & accessed in UI thread only. |
|
305 */ |
|
306 CMediaClientVideoDisplay* iMediaClientVideoDisplay; |
|
307 |
|
308 /** |
|
309 * Display instance used to invoke UI callbacks. |
|
310 * Not owned. |
|
311 */ |
|
312 MMMADisplay* iDisplay; |
|
313 |
|
314 /** |
|
315 * Window server session used by UI thread. |
|
316 * Adjustable and usable from UI thread only. |
|
317 * Not owned. |
|
318 */ |
|
319 RWsSession* iWs; |
|
320 |
|
321 /** |
|
322 * Screen device used by UI thread. |
|
323 * Adjustable and usable from UI thread only. |
|
324 * Not owned. |
|
325 */ |
|
326 CWsScreenDevice* iScreenDevice; |
|
327 |
|
328 /** |
|
329 * Window where video is displayed. |
|
330 * Adjustable and usable from UI thread only. |
|
331 * From UI thread. |
|
332 * Not owned. |
|
333 */ |
|
334 RWindowBase* iWindow; |
|
335 |
|
336 /** |
|
337 * The surface to be created for composition. |
|
338 */ |
|
339 TSurfaceId iSurfaceId; |
|
340 |
|
341 /** |
|
342 * The dimensions of the crop rectangle, relative to the video image. |
|
343 */ |
|
344 TRect iCropRect; |
|
345 |
|
346 /** |
|
347 * The pixel aspect ratio to display video picture. |
|
348 */ |
|
349 TVideoAspectRatio iPixelAspectRatio; |
|
350 |
|
351 /** |
|
352 * indicates the video display initialization state. |
|
353 * |
|
354 */ |
|
355 TVideoDisplayInitState iVideoDisplayInitState; |
|
356 |
|
357 /** |
|
358 * Indicates if content need to be drawn. |
|
359 */ |
|
360 TBool iVisible; |
|
361 |
|
362 }; |
|
363 |
|
364 #endif // CMMASURFACEWINDOW_H |
|