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