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