author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:06:50 +0300 | |
branch | RCL_3 |
changeset 71 | d5e927d5853b |
parent 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 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 |
// Include Files |
|
20 |
#include <AccMonitorInfo.h> |
|
21 |
#include <AccMonitorCapabilities.h> |
|
22 |
#include "jdebug.h" |
|
23 |
#include "cmmasurfacewindow.h" |
|
24 |
#include "cmmaplayer.h" |
|
25 |
||
71
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
26 |
// Used for const. KMMAVideoPlayer |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
27 |
#include "cmmavideoplayer.h" |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
28 |
|
66 | 29 |
// Used for iDisplay member |
30 |
#include "mmmadisplay.h" |
|
31 |
||
32 |
EXPORT_C CMMASurfaceWindow* CMMASurfaceWindow::NewL( |
|
33 |
CMMAEventSource* aEventSource, |
|
34 |
CMMAPlayer* aPlayer, |
|
35 |
TBool aAVCableConnStatus) |
|
36 |
{ |
|
37 |
CMMASurfaceWindow* self = |
|
38 |
new(ELeave) CMMASurfaceWindow(aEventSource, |
|
39 |
aPlayer, |
|
40 |
aAVCableConnStatus); |
|
41 |
return self; |
|
42 |
} |
|
43 |
||
44 |
// Destructor (virtual by CBase) |
|
45 |
CMMASurfaceWindow::~CMMASurfaceWindow() |
|
46 |
{ |
|
47 |
// It's not allowed to delete any nonsharable object here. |
|
48 |
// This must be done in Destroy(). |
|
49 |
// If the iDisplay is set, |
|
50 |
// instance should be deleted by sending |
|
51 |
// event from UI to be received by MUiEventConsumer. |
|
52 |
} |
|
53 |
||
54 |
CMMASurfaceWindow::CMMASurfaceWindow( |
|
55 |
CMMAEventSource* aEventSource, |
|
56 |
CMMAPlayer* aPlayer, |
|
57 |
TBool aAVCableConnStatus): |
|
58 |
iEventSource(aEventSource), |
|
59 |
iPlayer(aPlayer), |
|
60 |
iVideoDisplayInitState(EUIResourcesAndSurfaceParametersNotSet), |
|
61 |
iAVCableConnected(aAVCableConnStatus) |
|
62 |
{ |
|
63 |
// Empty rect until video size is known |
|
64 |
iContentRect.SetRect(0, 0, 0, 0); |
|
65 |
iParentRect.SetRect(0, 0, 0, 0); |
|
66 |
iRWindowRect.SetRect(0, 0, 0, 0); |
|
67 |
} |
|
68 |
||
69 |
void CMMASurfaceWindow::SetDestinationBitmapL(CFbsBitmap* /*aBitmap*/) |
|
70 |
{ |
|
71 |
// Ignored, this window will not be used for actual drawing |
|
72 |
} |
|
73 |
||
74 |
void CMMASurfaceWindow::DrawFrameL(const CFbsBitmap* /*aBitmap*/) |
|
75 |
{ |
|
76 |
// Ignored, this window will not be used for actual drawing |
|
77 |
} |
|
78 |
||
79 |
void CMMASurfaceWindow::SetDrawRectThread(const TRect& aRect) |
|
80 |
{ |
|
81 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRectThread TL %d %d", |
|
82 |
aRect.iTl.iX, aRect.iTl.iY); |
|
83 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRectThread BR %d %d", |
|
84 |
aRect.iBr.iX, aRect.iBr.iY); |
|
85 |
||
86 |
iContentRect = aRect; |
|
87 |
TInt error = StaticRedrawVideo(*this); |
|
88 |
if (KErrNone != error) |
|
89 |
{ |
|
90 |
DEBUG_INT("MID::CMMASurfaceWindow::SetDrawRectThread, StaticRedrawVideo error = %d", error); |
|
91 |
} |
|
92 |
} |
|
93 |
||
94 |
void CMMASurfaceWindow::SetRWindowRect(const TRect& aRect, |
|
95 |
MMMADisplay::TThreadType aThreadType) |
|
96 |
{ |
|
97 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetRWindowRect TL %d %d", |
|
98 |
aRect.iTl.iX, aRect.iTl.iY); |
|
99 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetRWindowRect BR %d %d", |
|
100 |
aRect.iBr.iX, aRect.iBr.iY); |
|
101 |
||
102 |
if (iRWindowRect == aRect) |
|
103 |
{ |
|
104 |
return; |
|
105 |
} |
|
106 |
||
107 |
iRWindowRect = aRect; |
|
108 |
||
109 |
if (MMMADisplay::EMmaThread == aThreadType) |
|
110 |
{ |
|
111 |
if (iDisplay) |
|
112 |
{ |
|
113 |
iDisplay->UIGetCallback(*this, |
|
114 |
CMMASurfaceWindow::ESetClipRect); |
|
115 |
} |
|
116 |
} |
|
117 |
else if (MMMADisplay::EUiThread == aThreadType) |
|
118 |
{ |
|
119 |
TInt error = SetClipRect(); |
|
120 |
if (KErrNone != error) |
|
121 |
{ |
|
122 |
DEBUG_INT("MID::CMMASurfaceWindow::SetRWindowRect, error = %d", error); |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
||
127 |
TInt CMMASurfaceWindow::SetClipRect() |
|
128 |
{ |
|
129 |
DEBUG("MID::CMMASurfaceWindow::SetClipRect"); |
|
130 |
||
131 |
// CMediaClientVideoDisplay expects client to RemoveDisplayWindow |
|
132 |
// and AddDisplayWindow again everytime when RWindow rect changes. |
|
133 |
// If audio/video cable is connected do not reposition the video, |
|
134 |
// this is done to prevent video playback pause. |
|
135 |
if (iMediaClientVideoDisplay && iWindow && !iAVCableConnected) |
|
136 |
{ |
|
137 |
iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow); |
|
138 |
||
139 |
TRect contentRect; |
|
140 |
if (iVisible) |
|
141 |
{ |
|
142 |
contentRect = iContentRect; |
|
143 |
} |
|
144 |
else |
|
145 |
{ |
|
146 |
TRect emptyRect(0,0,0,0); |
|
147 |
contentRect = emptyRect; |
|
148 |
} |
|
149 |
||
150 |
// align parent rect with respect to RWindow |
|
151 |
TRect relativeParentRect; |
|
152 |
relativeParentRect = iParentRect; |
|
153 |
relativeParentRect.Move(-iRWindowRect.iTl); |
|
154 |
||
155 |
// setting video draw rect and adjusting it to window |
|
156 |
TRect drawRect = contentRect; |
|
157 |
drawRect.Move(relativeParentRect.iTl); |
|
158 |
||
159 |
TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height()); |
|
160 |
TRAPD(error, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, |
|
161 |
clipRect, // new clip rect |
|
162 |
iVideoCropRegion, |
|
163 |
drawRect, // video extent |
|
164 |
0.0f, // ignore |
|
165 |
0.0f, // ignore |
|
166 |
EVideoRotationNone, |
|
167 |
EAutoScaleBestFit, |
|
168 |
EHorizontalAlignCenter, |
|
169 |
EVerticalAlignCenter, |
|
170 |
(RWindow*)iWindow)); |
|
171 |
||
172 |
return error; |
|
173 |
} |
|
174 |
return KErrNone; |
|
175 |
} |
|
176 |
||
177 |
void CMMASurfaceWindow::SetDrawRect(const TRect& aRect) |
|
178 |
{ |
|
179 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRect TL %d %d", |
|
180 |
aRect.iTl.iX, aRect.iTl.iY); |
|
181 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetDrawRect BR %d %d", |
|
182 |
aRect.iBr.iX, aRect.iBr.iY); |
|
183 |
||
184 |
iContentRect = aRect; |
|
185 |
if (iDisplay) |
|
186 |
{ |
|
187 |
iDisplay->UIGetCallback(*this, |
|
188 |
CMMASurfaceWindow::ESetDrawRect); |
|
189 |
} |
|
190 |
} |
|
191 |
||
192 |
TInt CMMASurfaceWindow::StaticRedrawVideo(CMMASurfaceWindow& aSurfaceWindow) |
|
193 |
{ |
|
194 |
TRAPD(error, aSurfaceWindow.RedrawVideoL()); |
|
195 |
return error; |
|
196 |
} |
|
197 |
||
198 |
void CMMASurfaceWindow::RedrawVideoL() |
|
199 |
{ |
|
200 |
if (!iMediaClientVideoDisplay) |
|
201 |
{ |
|
202 |
DEBUG("MID::CMMASurfaceWindow::RedrawVideoL: no MediaClientVideoDisplay set, aborting -"); |
|
203 |
return; |
|
204 |
} |
|
205 |
||
206 |
if (iWindow) |
|
207 |
{ |
|
208 |
TRect contentRect; |
|
209 |
if (iVisible) |
|
210 |
{ |
|
211 |
contentRect = iContentRect; |
|
212 |
} |
|
213 |
else |
|
214 |
{ |
|
215 |
TRect emptyRect(0,0,0,0); |
|
216 |
contentRect = emptyRect; |
|
217 |
} |
|
218 |
||
219 |
// align parent rect with respect to RWindow |
|
220 |
TRect relativeParentRect; |
|
221 |
relativeParentRect = iParentRect; |
|
222 |
relativeParentRect.Move(-iRWindowRect.iTl); |
|
223 |
||
224 |
// setting video draw rect and adjusting it to window |
|
225 |
TRect drawRect = contentRect; |
|
226 |
drawRect.Move(relativeParentRect.iTl); |
|
227 |
||
228 |
DEBUG_INT4("MID::CMMASurfaceWindow::RedrawVideoL: drawRect tl %d,%d br %d,%d", |
|
229 |
drawRect.iTl.iX,drawRect.iTl.iY,drawRect.iBr.iX,drawRect.iBr.iY); |
|
230 |
||
231 |
iMediaClientVideoDisplay->SetVideoExtentL(*iWindow, |
|
232 |
drawRect, |
|
233 |
iVideoCropRegion); |
|
234 |
||
235 |
DEBUG("MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows()"); |
|
236 |
||
237 |
iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion); |
|
238 |
((RWindow*)iWindow)->Invalidate(); |
|
239 |
} |
|
240 |
} |
|
241 |
||
242 |
const TRect& CMMASurfaceWindow::DrawRect() |
|
243 |
{ |
|
244 |
return iContentRect; |
|
245 |
} |
|
246 |
||
247 |
TSize CMMASurfaceWindow::WindowSize() |
|
248 |
{ |
|
249 |
return iParentRect.Size(); |
|
250 |
} |
|
251 |
||
252 |
void CMMASurfaceWindow::SetPosition(const TPoint& aPosition) |
|
253 |
{ |
|
254 |
SetDrawRectThread(TRect(aPosition, iContentRect.Size())); |
|
255 |
} |
|
256 |
||
257 |
TBool CMMASurfaceWindow::IsVisible() const |
|
258 |
{ |
|
259 |
DEBUG_INT("MID::CMMASurfaceWindow::IsVisible %d ", iVisible); |
|
260 |
return iVisible; |
|
261 |
} |
|
262 |
||
263 |
void CMMASurfaceWindow::SetVisible(TBool aVisible, TBool aUseEventServer) |
|
264 |
{ |
|
265 |
DEBUG_INT("MID::CMMASurfaceWindow::SetVisible aVisible %d", aVisible); |
|
266 |
RPointerArray< CMMAPlayer > players = iEventSource->Players(); |
|
267 |
||
268 |
if (players.Find(iPlayer) != KErrNotFound) |
|
269 |
{ |
|
270 |
DEBUG("MID::CMMASurfaceWindow::SetVisible : Player found"); |
|
271 |
if (aVisible != iVisible) |
|
272 |
{ |
|
273 |
DEBUG("MID::CMMASurfaceWindow::SetVisible: Changed visibility"); |
|
274 |
iVisible = aVisible; |
|
275 |
||
276 |
if (aUseEventServer) |
|
277 |
{ |
|
278 |
TInt error = StaticRedrawVideo(*this); |
|
279 |
if (KErrNone != error) |
|
280 |
{ |
|
281 |
DEBUG_INT("MID::CMMASurfaceWindow::SetVisible, StaticRedrawVideo error = %d", error); |
|
282 |
} |
|
283 |
} |
|
284 |
else // in MMA thread, so switch to UI thread |
|
285 |
{ |
|
286 |
if (iDisplay) |
|
287 |
{ |
|
288 |
iDisplay->UIGetCallback(*this, |
|
289 |
CMMASurfaceWindow::ESetDrawRect); |
|
290 |
} |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
295 |
||
296 |
void CMMASurfaceWindow::SetWindowRect(const TRect& aRect,MMMADisplay::TThreadType /*aThreadType*/) |
|
297 |
{ |
|
298 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetWindowRect aRect TL %d %d", |
|
299 |
aRect.iTl.iX, aRect.iTl.iY); |
|
300 |
DEBUG_INT2("MID::CMMASurfaceWindow::SetWindowRect aRect BR %d %d", |
|
301 |
aRect.iBr.iX, aRect.iBr.iY); |
|
302 |
||
303 |
iParentRect = aRect; |
|
304 |
} |
|
305 |
||
306 |
void CMMASurfaceWindow::SetVideoCropRegion(const TRect& aRect) |
|
307 |
{ |
|
308 |
// video size |
|
309 |
iVideoCropRegion = aRect; |
|
310 |
} |
|
311 |
||
312 |
const TRect& CMMASurfaceWindow::WindowRect() |
|
313 |
{ |
|
314 |
return iParentRect; |
|
315 |
} |
|
316 |
||
317 |
void CMMASurfaceWindow::ContainerDestroyed() |
|
318 |
{ |
|
319 |
// We are in UI thread context now. |
|
320 |
CleanVideoDisplay(); |
|
321 |
} |
|
322 |
||
323 |
EXPORT_C void CMMASurfaceWindow::SetDisplay(MMMADisplay *aDisplay) |
|
324 |
{ |
|
325 |
DEBUG("MID::CMMASurfaceWindow::SetDisplay +"); |
|
326 |
||
327 |
if (iDisplay != aDisplay) |
|
328 |
{ |
|
329 |
if (iDisplay) |
|
330 |
{ |
|
331 |
// Clear the resources created within the old Display |
|
332 |
iDisplay->UIGetCallback( |
|
333 |
*this, CMMASurfaceWindow::ECleanVideoDisplay); |
|
334 |
} |
|
335 |
||
336 |
// Set the new Display |
|
337 |
iDisplay = aDisplay; |
|
338 |
||
339 |
if (iDisplay) |
|
340 |
{ |
|
341 |
// Get a DSA resources for the new Display |
|
342 |
iDisplay->UIGetDSAResources(*this, MMMADisplay::EMmaThread); |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
DEBUG("MID::CMMASurfaceWindow::SetDisplay -"); |
|
347 |
} |
|
348 |
||
349 |
void CMMASurfaceWindow::ContainerSet() |
|
350 |
{ |
|
351 |
// We are in UI thread now |
|
352 |
||
353 |
// Container was probably not set when |
|
354 |
// iDisplay was set, |
|
355 |
// we can now try get the DSA stuff again |
|
356 |
if (iDisplay) |
|
357 |
{ |
|
358 |
// Get a DSA stuff for the new Display |
|
359 |
iDisplay->UIGetDSAResources(*this, MMMADisplay::EUiThread); |
|
360 |
} |
|
361 |
} |
|
362 |
||
363 |
void CMMASurfaceWindow::Destroy() |
|
364 |
{ |
|
365 |
DEBUG("MID::CMMASurfaceWindow::Destroy"); |
|
366 |
// Delete itself |
|
367 |
delete this; |
|
368 |
} |
|
369 |
||
370 |
void CMMASurfaceWindow::MdcDSAResourcesCallback( |
|
371 |
RWsSession &aWs, |
|
372 |
CWsScreenDevice &aScreenDevice, |
|
373 |
RWindowBase &aWindow) |
|
374 |
{ |
|
375 |
DEBUG("MID::CMMASurfaceWindow::MdcDSAResourcesCallback"); |
|
376 |
||
377 |
// We are in UI thread context now. |
|
378 |
iWs = &aWs; |
|
379 |
iScreenDevice = &aScreenDevice; |
|
380 |
iWindow = &aWindow; |
|
381 |
||
382 |
switch (iVideoDisplayInitState) |
|
383 |
{ |
|
384 |
case EUIResourcesAndSurfaceParametersNotSet: |
|
385 |
{ |
|
386 |
iVideoDisplayInitState = |
|
387 |
EUIResourcesSetAndSurfaceParametersNotSet; |
|
388 |
} |
|
389 |
break; |
|
390 |
case ESurfaceParametersSetAndUIResourcesNotSet: |
|
391 |
{ |
|
392 |
iVideoDisplayInitState = |
|
393 |
EUIResourcesAndSurfaceParametersSet; |
|
394 |
} |
|
395 |
break; |
|
396 |
// can not occur |
|
397 |
case EUIResourcesSetAndSurfaceParametersNotSet: |
|
398 |
case EUIResourcesAndSurfaceParametersSet: |
|
399 |
default: |
|
400 |
{ |
|
401 |
__ASSERT_DEBUG(EFalse, User::Invariant()); |
|
402 |
} |
|
403 |
break; |
|
404 |
} |
|
405 |
||
406 |
if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet) |
|
407 |
{ |
|
408 |
TRAPD(error, InitVideoDisplayL()); |
|
409 |
if (KErrNone != error) |
|
410 |
{ |
|
411 |
DEBUG_INT("MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error); |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
||
416 |
void CMMASurfaceWindow::MdcUICallback(TInt aCallbackId) |
|
417 |
{ |
|
418 |
// We are in UI thread context now. |
|
419 |
DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback CallbackId = %d", aCallbackId); |
|
420 |
||
421 |
TInt error = KErrNone; |
|
422 |
switch (aCallbackId) |
|
423 |
{ |
|
424 |
case ESetClipRect: |
|
425 |
{ |
|
426 |
error = SetClipRect(); |
|
427 |
DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback,SetClipRect error = %d", error); |
|
428 |
} |
|
429 |
break; |
|
430 |
case ERemoveSurface: |
|
431 |
{ |
|
432 |
DoRemoveSurface(); |
|
433 |
} |
|
434 |
break; |
|
435 |
case ESetDrawRect: |
|
436 |
{ |
|
437 |
error = StaticRedrawVideo(*this); |
|
438 |
DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback,StaticRedrawVideo error = %d", error); |
|
439 |
} |
|
440 |
break; |
|
441 |
case EInitVideoDisplay: |
|
442 |
{ |
|
443 |
TRAP(error, InitVideoDisplayL()); |
|
444 |
DEBUG_INT("MID::CMMASurfaceWindow::MdcUICallback,InitVideoDisplayL error = %d", error); |
|
445 |
} |
|
446 |
break; |
|
447 |
case ESetChangedSurfaceParameters: |
|
448 |
{ |
|
449 |
DoSetChangedSurfaceParameters(); |
|
450 |
} |
|
451 |
break; |
|
452 |
case EResetSurfaceParameters: |
|
453 |
{ |
|
454 |
DoResetSurfaceParameters(); |
|
455 |
} |
|
456 |
break; |
|
457 |
case ECleanVideoDisplay: |
|
458 |
{ |
|
459 |
CleanVideoDisplay(); |
|
460 |
} |
|
461 |
break; |
|
462 |
case EDestroyWindow: |
|
463 |
{ |
|
464 |
Destroy(); |
|
465 |
} |
|
466 |
break; |
|
467 |
default: |
|
468 |
{ |
|
469 |
__ASSERT_DEBUG(EFalse, User::Invariant()); |
|
470 |
} |
|
471 |
break; |
|
472 |
} |
|
473 |
} |
|
474 |
||
475 |
EXPORT_C void CMMASurfaceWindow::SetSurfaceParameters(const TSurfaceId& aSurfaceId, |
|
476 |
const TRect& aCropRect, |
|
477 |
const TVideoAspectRatio& aPixelAspectRatio) |
|
478 |
{ |
|
479 |
iSurfaceId = aSurfaceId; |
|
480 |
iCropRect = aCropRect; |
|
481 |
iPixelAspectRatio = aPixelAspectRatio; |
|
482 |
||
483 |
switch (iVideoDisplayInitState) |
|
484 |
{ |
|
485 |
case EUIResourcesAndSurfaceParametersNotSet: |
|
486 |
{ |
|
487 |
iVideoDisplayInitState = |
|
488 |
ESurfaceParametersSetAndUIResourcesNotSet; |
|
489 |
} |
|
490 |
break; |
|
491 |
case EUIResourcesSetAndSurfaceParametersNotSet: |
|
492 |
{ |
|
493 |
iVideoDisplayInitState = |
|
494 |
EUIResourcesAndSurfaceParametersSet; |
|
495 |
} |
|
496 |
break; |
|
497 |
// control reaches below two switch cases when |
|
498 |
// playback is looped using setLoopCount() in java. |
|
499 |
case ESurfaceParametersSetAndUIResourcesNotSet: |
|
500 |
{ |
|
501 |
} |
|
502 |
break; |
|
503 |
// update surface parameters and return with out calling |
|
504 |
// InitVideoDisplayL again. |
|
505 |
case EUIResourcesAndSurfaceParametersSet: |
|
506 |
{ |
|
507 |
iDisplay->UIGetCallback(*this, CMMASurfaceWindow::EResetSurfaceParameters); |
|
508 |
return; |
|
509 |
} |
|
510 |
// break; not reachable |
|
511 |
default: // can not occur |
|
512 |
{ |
|
513 |
__ASSERT_DEBUG(EFalse, User::Invariant()); |
|
514 |
} |
|
515 |
break; |
|
516 |
} |
|
517 |
||
518 |
if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet) |
|
519 |
{ |
|
520 |
iDisplay->UIGetCallback(*this, CMMASurfaceWindow::EInitVideoDisplay); |
|
521 |
} |
|
522 |
} |
|
523 |
||
524 |
EXPORT_C void CMMASurfaceWindow::SetChangedSurfaceParameters(const TSurfaceId& aSurfaceId, |
|
525 |
const TRect& aCropRect, |
|
526 |
const TVideoAspectRatio& aPixelAspectRatio) |
|
527 |
{ |
|
528 |
iSurfaceId = aSurfaceId; |
|
529 |
iCropRect = aCropRect; |
|
530 |
iPixelAspectRatio = aPixelAspectRatio; |
|
531 |
||
532 |
if (iDisplay) |
|
533 |
{ |
|
534 |
iDisplay->UIGetCallback(*this, CMMASurfaceWindow::ESetChangedSurfaceParameters); |
|
535 |
} |
|
536 |
} |
|
537 |
||
538 |
EXPORT_C void CMMASurfaceWindow::RemoveSurface() |
|
539 |
{ |
|
540 |
if (iDisplay) |
|
541 |
{ |
|
542 |
iDisplay->UIGetCallback(*this, |
|
543 |
CMMASurfaceWindow::ERemoveSurface); |
|
544 |
} |
|
545 |
} |
|
546 |
||
547 |
void CMMASurfaceWindow::DoRemoveSurface() |
|
548 |
{ |
|
549 |
if (iMediaClientVideoDisplay) |
|
550 |
{ |
|
551 |
iMediaClientVideoDisplay->RemoveSurface(); |
|
552 |
DEBUG("MID::CMMASurfaceWindow::DoRemoveSurface, Surface Removed"); |
|
553 |
} |
|
554 |
} |
|
555 |
||
556 |
void CMMASurfaceWindow::DoResetSurfaceParameters() |
|
557 |
{ |
|
558 |
__ASSERT_DEBUG((iMediaClientVideoDisplay != NULL), User::Invariant()); |
|
559 |
||
560 |
if (iMediaClientVideoDisplay) |
|
561 |
{ |
|
562 |
TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId, |
|
563 |
iCropRect, |
|
564 |
iPixelAspectRatio, |
|
565 |
iVideoCropRegion); |
|
566 |
||
567 |
DEBUG_INT("MID::CMMASurfaceWindow::DoResetSurfaceParameters,SurfaceCreated error = %d", error); |
|
568 |
||
569 |
iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion); |
|
570 |
} |
|
571 |
} |
|
572 |
||
573 |
void CMMASurfaceWindow::DoSetChangedSurfaceParameters() |
|
574 |
{ |
|
575 |
if (iMediaClientVideoDisplay) |
|
576 |
{ |
|
577 |
TInt error = iMediaClientVideoDisplay->SurfaceParametersChanged(iSurfaceId, |
|
578 |
iCropRect, |
|
579 |
iPixelAspectRatio); |
|
580 |
||
581 |
DEBUG_INT("MID::CMMASurfaceWindow::DoSetChangedSurfaceParameters,SurfaceParametersChanged, error = %d", error); |
|
582 |
||
583 |
iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion); |
|
584 |
} |
|
585 |
} |
|
586 |
||
587 |
void CMMASurfaceWindow::InitVideoDisplayL() |
|
588 |
{ |
|
589 |
if (iVideoDisplayInitState != EUIResourcesAndSurfaceParametersSet) |
|
590 |
{ |
|
591 |
User::Leave(KErrNotReady); |
|
592 |
} |
|
593 |
||
594 |
// check that this is the first time we are creating instance. |
|
595 |
if (iMediaClientVideoDisplay) |
|
596 |
{ |
|
597 |
__ASSERT_DEBUG(EFalse, User::Invariant()); |
|
598 |
} |
|
599 |
||
600 |
iMediaClientVideoDisplay = |
|
601 |
CMediaClientVideoDisplay::NewL(iScreenDevice->GetScreenNumber(), |
|
602 |
iSurfaceId, |
|
603 |
iCropRect, |
|
604 |
iPixelAspectRatio); |
|
605 |
||
606 |
TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId, |
|
607 |
iCropRect, |
|
608 |
iPixelAspectRatio, |
|
609 |
iVideoCropRegion); |
|
610 |
||
611 |
DEBUG_INT("MID::CMMASurfaceWindow::InitVideoDisplayL error = %d", error); |
|
612 |
User::LeaveIfError(error); |
|
613 |
||
614 |
TRect contentRect; |
|
615 |
if (iVisible) |
|
616 |
{ |
|
617 |
contentRect = iContentRect; |
|
618 |
} |
|
619 |
else |
|
620 |
{ |
|
621 |
TRect emptyRect(0,0,0,0); |
|
622 |
contentRect = emptyRect; |
|
623 |
} |
|
624 |
||
625 |
// align parent rect with respect to RWindow |
|
626 |
TRect relativeParentRect; |
|
627 |
relativeParentRect = iParentRect; |
|
628 |
relativeParentRect.Move(-iRWindowRect.iTl); |
|
629 |
||
630 |
// setting video draw rect and adjusting it to window |
|
631 |
TRect drawRect = contentRect; |
|
632 |
drawRect.Move(relativeParentRect.iTl); |
|
633 |
||
634 |
TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height()); |
|
635 |
iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, |
|
636 |
clipRect, |
|
637 |
iVideoCropRegion, |
|
638 |
drawRect, // video extent |
|
639 |
0.0f, // ignore |
|
640 |
0.0f, // ignore |
|
641 |
EVideoRotationNone, |
|
642 |
EAutoScaleBestFit, |
|
643 |
EHorizontalAlignCenter, |
|
644 |
EVerticalAlignCenter, |
|
645 |
(RWindow*)iWindow); |
|
646 |
||
647 |
DEBUG("MID::CMMASurfaceWindow::InitVideoDisplayL -"); |
|
648 |
} |
|
649 |
||
650 |
void CMMASurfaceWindow::CleanVideoDisplay() |
|
651 |
{ |
|
652 |
DEBUG("MID::CMMASurfaceWindow::CleanVideoDisplay +"); |
|
653 |
||
654 |
SetVisible(EFalse, ETrue); |
|
655 |
if (iMediaClientVideoDisplay) |
|
656 |
{ |
|
657 |
if (iWindow) |
|
658 |
{ |
|
659 |
iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow); |
|
660 |
} |
|
661 |
iMediaClientVideoDisplay->RemoveSurface(); |
|
662 |
delete iMediaClientVideoDisplay; |
|
663 |
||
664 |
iMediaClientVideoDisplay = NULL; |
|
665 |
iWindow = NULL; |
|
666 |
iScreenDevice = NULL; |
|
667 |
iWs = NULL; |
|
668 |
} |
|
669 |
||
670 |
DEBUG("MID::CMMASurfaceWindow::CleanVideoDisplay -"); |
|
671 |
} |
|
672 |
||
673 |
EXPORT_C void CMMASurfaceWindow::SetAVCableConnStatus(TBool aStatus) |
|
674 |
{ |
|
675 |
iAVCableConnected = aStatus; |
|
676 |
if (iDisplay && !iAVCableConnected) |
|
677 |
{ |
|
678 |
iDisplay->UIGetCallback(*this, |
|
679 |
CMMASurfaceWindow::ESetClipRect); |
|
680 |
} |
|
681 |
} |
|
682 |
||
71
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
683 |
TInt CMMASurfaceWindow::PlayerState() |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
684 |
{ |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
685 |
return iPlayer->State(); |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
686 |
} |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
687 |
|
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
688 |
TBool CMMASurfaceWindow::IsVideoPlayer() |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
689 |
{ |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
690 |
return (iPlayer->Type()== KMMAVideoPlayer); |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
691 |
} |
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
692 |
|
d5e927d5853b
Revision: v2.2.11
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
693 |
|
66 | 694 |
// END OF FILE |