|
1 /* |
|
2 * Copyright (c) 2009 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: Implementation of video playback display handler |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 28 % |
|
19 |
|
20 #include <sysutil.h> |
|
21 #include <s32file.h> |
|
22 #include <mpxcommand.h> |
|
23 #include <mpxcommandgeneraldefs.h> |
|
24 #include <mpxplaybackutility.h> |
|
25 #include <mpxvideoplaybackdefs.h> |
|
26 |
|
27 #include "videocontainer.h" |
|
28 #include "mpxvideoviewwrapper.h" |
|
29 #include "mpxvideoplaybackdisplayhandler.h" |
|
30 #include "mpxvideoregion.h" |
|
31 #include "videoplaybackviewfiledetails.h" |
|
32 |
|
33 const TInt KVIDEORESIZINGREPEATRATE = 50000; |
|
34 const TReal32 KTRANSITIONEFFECTCNT = 8; |
|
35 |
|
36 _LIT( KAspectRatioFile, "c:\\private\\200159b2\\mpxvideoplayer_aspect_ratio.dat" ); |
|
37 |
|
38 |
|
39 CMPXVideoPlaybackDisplayHandler::CMPXVideoPlaybackDisplayHandler( MMPXPlaybackUtility* aPlayUtil, |
|
40 CMPXVideoViewWrapper* aViewWrapper ) |
|
41 : iPlaybackUtility( aPlayUtil ) |
|
42 , iTransitionEffectCnt( 0 ) |
|
43 , iViewWrapper( aViewWrapper ) |
|
44 , iScaleWidth( 100.0f ) |
|
45 , iScaleHeight( 100.0f ) |
|
46 , iHorizontalPosition( EHorizontalAlignCenter ) |
|
47 , iVerticalPosition( EVerticalAlignCenter ) |
|
48 , iRotation( EVideoRotationNone ) |
|
49 , iAutoScale( EAutoScaleBestFit ) |
|
50 { |
|
51 } |
|
52 |
|
53 CMPXVideoPlaybackDisplayHandler::~CMPXVideoPlaybackDisplayHandler() |
|
54 { |
|
55 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::~CMPXVideoPlaybackDisplayHandler()")); |
|
56 |
|
57 MPX_TRAPD( error, SaveAspectRatioL() ); |
|
58 |
|
59 if ( iResizingTimer ) |
|
60 { |
|
61 iResizingTimer->Cancel(); |
|
62 delete iResizingTimer; |
|
63 iResizingTimer = NULL; |
|
64 } |
|
65 |
|
66 iAspectRatioArray.Close(); |
|
67 |
|
68 if ( iVideoDisplay ) |
|
69 { |
|
70 SurfaceRemoved(); |
|
71 |
|
72 delete iVideoDisplay; |
|
73 iVideoDisplay = NULL; |
|
74 } |
|
75 |
|
76 if ( iVideoContainer ) |
|
77 { |
|
78 delete iVideoContainer; |
|
79 iVideoContainer = NULL; |
|
80 } |
|
81 } |
|
82 |
|
83 CMPXVideoPlaybackDisplayHandler* |
|
84 CMPXVideoPlaybackDisplayHandler::NewL( MMPXPlaybackUtility* aPlayUtil, |
|
85 CMPXVideoViewWrapper* aViewWrapper ) |
|
86 { |
|
87 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::NewL()")); |
|
88 |
|
89 CMPXVideoPlaybackDisplayHandler* self = |
|
90 new(ELeave) CMPXVideoPlaybackDisplayHandler( aPlayUtil, aViewWrapper ); |
|
91 |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL(); |
|
94 CleanupStack::Pop(); |
|
95 return self; |
|
96 } |
|
97 |
|
98 // ------------------------------------------------------------------------------------------------- |
|
99 // CMPXVideoPlaybackDisplayHandler::ConstructL() |
|
100 // ------------------------------------------------------------------------------------------------- |
|
101 // |
|
102 void CMPXVideoPlaybackDisplayHandler::ConstructL() |
|
103 { |
|
104 iResizingTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
105 LoadAspectRatioL(); |
|
106 } |
|
107 |
|
108 // ------------------------------------------------------------------------------------------------- |
|
109 // CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL() |
|
110 // ------------------------------------------------------------------------------------------------- |
|
111 // |
|
112 void CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL( |
|
113 RWsSession& /*aWs*/, |
|
114 CWsScreenDevice& aScreenDevice, |
|
115 RWindow& aWin, |
|
116 TRect aDisplayRect ) |
|
117 { |
|
118 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()")); |
|
119 |
|
120 if ( ! iVideoContainer ) |
|
121 { |
|
122 iVideoContainer = new ( ELeave ) CVideoContainer(); |
|
123 iVideoContainer->ConstructL(); |
|
124 iVideoContainer->SetRect( aDisplayRect ); |
|
125 } |
|
126 |
|
127 RWindowBase *videoWindow = iVideoContainer->DrawableWindow(); |
|
128 videoWindow->SetOrdinalPosition( -1 ); |
|
129 (&aWin)->SetOrdinalPosition( 0 ); |
|
130 |
|
131 MPX_DEBUG(_L("VideoWindow ordinal position is: %d"), videoWindow->OrdinalPosition()); |
|
132 MPX_DEBUG(_L("UiWindow ordinal position is: %d"), (&aWin)->OrdinalPosition()); |
|
133 |
|
134 AddDisplayWindowL( aScreenDevice, *videoWindow, (RWindow*)videoWindow ); |
|
135 } |
|
136 |
|
137 // ------------------------------------------------------------------------------------------------- |
|
138 // CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow() |
|
139 // ------------------------------------------------------------------------------------------------- |
|
140 // |
|
141 void CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow() |
|
142 { |
|
143 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()")); |
|
144 |
|
145 if ( iVideoDisplay ) |
|
146 { |
|
147 SurfaceRemoved(); |
|
148 delete iVideoDisplay; |
|
149 iVideoDisplay = NULL; |
|
150 } |
|
151 |
|
152 if ( iVideoContainer ) |
|
153 { |
|
154 delete iVideoContainer; |
|
155 iVideoContainer = NULL; |
|
156 } |
|
157 |
|
158 iSurfaceId = TSurfaceId::CreateNullId(); |
|
159 } |
|
160 |
|
161 // ------------------------------------------------------------------------------------------------- |
|
162 // CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL() |
|
163 // ------------------------------------------------------------------------------------------------- |
|
164 // |
|
165 void CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL( CMPXMessage* aMessage ) |
|
166 { |
|
167 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessage()")); |
|
168 |
|
169 TMPXVideoDisplayCommand message = |
|
170 ( *(aMessage->Value<TMPXVideoDisplayCommand>(KMPXMediaVideoDisplayCommand)) ); |
|
171 |
|
172 MPX_DEBUG( |
|
173 _L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL() message = %d"), message ); |
|
174 |
|
175 switch ( message ) |
|
176 { |
|
177 case EPbMsgVideoSurfaceCreated: |
|
178 { |
|
179 SurfaceCreatedL( aMessage ); |
|
180 break; |
|
181 } |
|
182 case EPbMsgVideoSurfaceChanged: |
|
183 { |
|
184 SurfaceChangedL( aMessage ); |
|
185 break; |
|
186 } |
|
187 case EPbMsgVideoSurfaceRemoved: |
|
188 { |
|
189 SurfaceRemoved(); |
|
190 break; |
|
191 } |
|
192 } |
|
193 } |
|
194 |
|
195 |
|
196 // ------------------------------------------------------------------------------------------------- |
|
197 // CMPXVideoPlaybackDisplayHandler::SetAspectRatioL() |
|
198 // ------------------------------------------------------------------------------------------------- |
|
199 // |
|
200 TInt CMPXVideoPlaybackDisplayHandler::SetAspectRatioL( TMPXVideoPlaybackCommand aCmd ) |
|
201 { |
|
202 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::SetAspectRatioL()")); |
|
203 |
|
204 TInt aspectRatio; |
|
205 |
|
206 aspectRatio = SetNgaAspectRatioL( aCmd ); |
|
207 |
|
208 // |
|
209 // Update the aspect ratio in the array |
|
210 // |
|
211 TInt count = iAspectRatioArray.Count(); |
|
212 |
|
213 if ( count > 0 && count > iCurrentIndexForAspectRatio ) |
|
214 { |
|
215 iAspectRatioArray[iCurrentIndexForAspectRatio].scalingType = (TMMFScalingType)aspectRatio; |
|
216 } |
|
217 |
|
218 return aspectRatio; |
|
219 } |
|
220 |
|
221 // ------------------------------------------------------------------------------------------------- |
|
222 // CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL |
|
223 // ------------------------------------------------------------------------------------------------- |
|
224 // |
|
225 TInt CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL( |
|
226 VideoPlaybackViewFileDetails* aFileDetails, TReal32 aDisplayAspectRatio ) |
|
227 { |
|
228 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL()")); |
|
229 |
|
230 TInt newAspectRatio = EMMFNatural; |
|
231 |
|
232 if ( aFileDetails->mVideoHeight > 0 && aFileDetails->mVideoWidth > 0 ) |
|
233 { |
|
234 TMMFScalingType scalingType = EMMFNatural; |
|
235 |
|
236 TReal32 videoAspectRatio = (TReal32)aFileDetails->mVideoWidth / |
|
237 (TReal32)aFileDetails->mVideoHeight; |
|
238 |
|
239 TInt cnt = iAspectRatioArray.Count(); |
|
240 TInt i = 0; |
|
241 |
|
242 // |
|
243 // check whether dat file has the information about (videoRatio + screenRatio) |
|
244 // |
|
245 for ( ; i < cnt ; i++ ) |
|
246 { |
|
247 if ( iAspectRatioArray[i].videoRatio == videoAspectRatio && |
|
248 iAspectRatioArray[i].screenRatio == aDisplayAspectRatio && |
|
249 ( scalingType = iAspectRatioArray[i].scalingType ) > 0 ) |
|
250 { |
|
251 break; |
|
252 } |
|
253 } |
|
254 |
|
255 // |
|
256 // if can't find out match aspect ratio in dat file, |
|
257 // choose the scaling type through the rule |
|
258 // aspectRatioDiff = videoAspectRatio - aDisplayAspectRatio |
|
259 // aspectRatioDiff == 0 ==> natural |
|
260 // aspectRatioDiff > 0.1 ==> zoom |
|
261 // aspectRatioDiff < - 0.3 ==> natural |
|
262 // aspectRatioDiff >= - 0.3 and <= 0.1 ==> stretch |
|
263 // |
|
264 |
|
265 if ( i == cnt ) |
|
266 { |
|
267 if ( videoAspectRatio - aDisplayAspectRatio > 0.1 ) |
|
268 { |
|
269 scalingType = EMMFZoom; |
|
270 } |
|
271 else if ( ( videoAspectRatio != aDisplayAspectRatio ) && |
|
272 ( videoAspectRatio - aDisplayAspectRatio > (- 0.3) ) ) |
|
273 { |
|
274 scalingType = EMMFStretch; |
|
275 } |
|
276 |
|
277 TMPXAspectRatio ratio; |
|
278 |
|
279 ratio.videoRatio = videoAspectRatio; |
|
280 ratio.screenRatio = aDisplayAspectRatio; |
|
281 ratio.scalingType = scalingType; |
|
282 |
|
283 iAspectRatioArray.Append( ratio ); |
|
284 } |
|
285 |
|
286 iCurrentIndexForAspectRatio = i; |
|
287 |
|
288 TMPXVideoPlaybackCommand aspectRatioCmd = EPbCmdNaturalAspectRatio; |
|
289 |
|
290 if ( scalingType == EMMFZoom ) |
|
291 { |
|
292 aspectRatioCmd = EPbCmdZoomAspectRatio; |
|
293 } |
|
294 else if ( scalingType == EMMFStretch ) |
|
295 { |
|
296 aspectRatioCmd = EPbCmdStretchAspectRatio; |
|
297 } |
|
298 |
|
299 newAspectRatio = SetAspectRatioL( aspectRatioCmd ); |
|
300 } |
|
301 |
|
302 return newAspectRatio; |
|
303 } |
|
304 |
|
305 // ------------------------------------------------------------------------------------------------- |
|
306 // CMPXVideoPlaybackDisplayHandler::SaveAspectRatioL |
|
307 // ------------------------------------------------------------------------------------------------- |
|
308 // |
|
309 void CMPXVideoPlaybackDisplayHandler::SaveAspectRatioL() |
|
310 { |
|
311 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SaveAspectRatioL")); |
|
312 |
|
313 RFs fs; |
|
314 TInt err = fs.Connect(); |
|
315 CleanupClosePushL<RFs>( fs ); |
|
316 |
|
317 TBool canSave = EFalse; |
|
318 |
|
319 TRAP_IGNORE( canSave = ! SysUtil::FFSSpaceBelowCriticalLevelL( |
|
320 &fs, sizeof(TMPXAspectRatio) * iAspectRatioArray.Count()) ); |
|
321 |
|
322 if ( canSave ) |
|
323 { |
|
324 // save list to disk |
|
325 RFileWriteStream out; |
|
326 |
|
327 TInt err( out.Replace( fs, KAspectRatioFile, EFileWrite ) ); |
|
328 |
|
329 if ( err == KErrPathNotFound ) |
|
330 { |
|
331 fs.MkDirAll( KAspectRatioFile ); |
|
332 err = out.Create( fs, KAspectRatioFile, EFileWrite ); |
|
333 } |
|
334 |
|
335 if ( ! err ) |
|
336 { |
|
337 TInt cnt = iAspectRatioArray.Count(); |
|
338 |
|
339 MPX_TRAP( err, |
|
340 { |
|
341 for ( TInt i = 0 ; i < cnt ; i++ ) |
|
342 { |
|
343 //Save (videoRatio + screenRatio + scalingType) |
|
344 out.WriteReal32L( iAspectRatioArray[i].videoRatio ); |
|
345 out.WriteReal32L( iAspectRatioArray[i].screenRatio ); |
|
346 out.WriteInt8L( iAspectRatioArray[i].scalingType ); |
|
347 } |
|
348 } ); |
|
349 |
|
350 out.Close(); |
|
351 } |
|
352 } |
|
353 |
|
354 CleanupStack::PopAndDestroy(); |
|
355 } |
|
356 |
|
357 // ------------------------------------------------------------------------------------------------- |
|
358 // CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL |
|
359 // ------------------------------------------------------------------------------------------------- |
|
360 // |
|
361 void CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL() |
|
362 { |
|
363 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL()")); |
|
364 |
|
365 RFs fs; |
|
366 RFileReadStream in; |
|
367 |
|
368 TInt err = fs.Connect(); |
|
369 CleanupClosePushL<RFs>( fs ); |
|
370 |
|
371 if ( ! err && in.Open( fs, KAspectRatioFile, EFileRead ) == KErrNone ) |
|
372 { |
|
373 TMPXAspectRatio ratio; |
|
374 |
|
375 MPX_TRAP( err, |
|
376 { |
|
377 for ( err = KErrNone ; err == KErrNone ; ) |
|
378 { |
|
379 // |
|
380 // Read (videoRatio + screenRatio + scalingType) |
|
381 // |
|
382 ratio.videoRatio = in.ReadReal32L(); |
|
383 ratio.screenRatio = in.ReadReal32L(); |
|
384 ratio.scalingType = (TMMFScalingType)in.ReadInt8L(); |
|
385 |
|
386 iAspectRatioArray.Append( ratio ); |
|
387 } |
|
388 } ); |
|
389 |
|
390 in.Close(); |
|
391 } |
|
392 |
|
393 CleanupStack::PopAndDestroy(); |
|
394 } |
|
395 |
|
396 // ------------------------------------------------------------------------------------------------- |
|
397 // CMPXVideoPlaybackDisplayHandler::UpdateVideoRectL() |
|
398 // ------------------------------------------------------------------------------------------------- |
|
399 // |
|
400 void CMPXVideoPlaybackDisplayHandler::UpdateVideoRectL( TRect aClipRect, TBool transitionEffect ) |
|
401 { |
|
402 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::UpdateVideoRectL()")); |
|
403 |
|
404 if ( transitionEffect ) |
|
405 { |
|
406 iTlXDiff = (TReal32)( iWindowRect.iTl.iX - aClipRect.iTl.iX ) / KTRANSITIONEFFECTCNT; |
|
407 iTlYDiff = (TReal32)( iWindowRect.iTl.iY - aClipRect.iTl.iY ) / KTRANSITIONEFFECTCNT; |
|
408 iBrXDiff = (TReal32)( iWindowRect.iBr.iX - aClipRect.iBr.iX ) / KTRANSITIONEFFECTCNT; |
|
409 iBrYDiff = (TReal32)( iWindowRect.iBr.iY - aClipRect.iBr.iY ) / KTRANSITIONEFFECTCNT; |
|
410 |
|
411 if ( iResizingTimer->IsActive() ) |
|
412 { |
|
413 iResizingTimer->Cancel(); |
|
414 } |
|
415 |
|
416 iResizingTimer->Start( |
|
417 0, |
|
418 KVIDEORESIZINGREPEATRATE, |
|
419 TCallBack( CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL, this ) ); |
|
420 } |
|
421 else |
|
422 { |
|
423 SetVideoRectL( aClipRect ); |
|
424 |
|
425 iWindowRect = aClipRect; |
|
426 |
|
427 iViewWrapper->UpdateVideoRectDone(); |
|
428 } |
|
429 } |
|
430 |
|
431 // ------------------------------------------------------------------------------------------------- |
|
432 // CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL() |
|
433 // ------------------------------------------------------------------------------------------------- |
|
434 // |
|
435 TInt CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL( TAny* aPtr ) |
|
436 { |
|
437 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL()")); |
|
438 |
|
439 static_cast<CMPXVideoPlaybackDisplayHandler*>(aPtr)->CalculateVideoRectL(); |
|
440 |
|
441 return KErrNone; |
|
442 } |
|
443 |
|
444 // ------------------------------------------------------------------------------------------------- |
|
445 // CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() |
|
446 // ------------------------------------------------------------------------------------------------- |
|
447 // |
|
448 void CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() |
|
449 { |
|
450 iTransitionEffectCnt++; |
|
451 |
|
452 TRect windowRect( (TInt)( (TReal32)iWindowRect.iTl.iX - iTlXDiff * (TReal32)iTransitionEffectCnt ), |
|
453 (TInt)( (TReal32)iWindowRect.iTl.iY - iTlYDiff * (TReal32)iTransitionEffectCnt ), |
|
454 (TInt)( (TReal32)iWindowRect.iBr.iX - iBrXDiff * (TReal32)iTransitionEffectCnt ), |
|
455 (TInt)( (TReal32)iWindowRect.iBr.iY - iBrYDiff * (TReal32)iTransitionEffectCnt ) ); |
|
456 |
|
457 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() %d %d %d %d"), |
|
458 windowRect.iTl.iX, windowRect.iTl.iY, windowRect.iBr.iX, windowRect.iBr.iY ); |
|
459 |
|
460 SetVideoRectL( windowRect ); |
|
461 |
|
462 if ( iTransitionEffectCnt >= KTRANSITIONEFFECTCNT ) |
|
463 { |
|
464 iTransitionEffectCnt = 0; |
|
465 iWindowRect = windowRect; |
|
466 |
|
467 if ( iResizingTimer->IsActive() ) |
|
468 { |
|
469 iResizingTimer->Cancel(); |
|
470 } |
|
471 |
|
472 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() Done")); |
|
473 |
|
474 iViewWrapper->UpdateVideoRectDone(); |
|
475 } |
|
476 } |
|
477 |
|
478 // ------------------------------------------------------------------------------------------------- |
|
479 // CMPXVideoPlaybackDisplayHandler::SetVideoRectL() |
|
480 // ------------------------------------------------------------------------------------------------- |
|
481 // |
|
482 void CMPXVideoPlaybackDisplayHandler::SetVideoRectL( TRect aRect ) |
|
483 { |
|
484 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetVideoRectL()")); |
|
485 |
|
486 if ( iVideoDisplay ) |
|
487 { |
|
488 iVideoDisplay->SetVideoExtentL( *iWindowBase, aRect, TRect( iWindowBase->Size() ) ); |
|
489 } |
|
490 } |
|
491 |
|
492 // ------------------------------------------------------------------------------------------------- |
|
493 // CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() |
|
494 // ------------------------------------------------------------------------------------------------- |
|
495 // |
|
496 void CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL( CWsScreenDevice& aScreenDevice, |
|
497 RWindowBase& aWindowBase, |
|
498 RWindow* aWin ) |
|
499 { |
|
500 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL()")); |
|
501 |
|
502 iWindowBase = &aWindowBase; |
|
503 |
|
504 TInt displayId = aScreenDevice.GetScreenNumber(); |
|
505 |
|
506 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() displayId %d"), displayId); |
|
507 |
|
508 CMediaClientVideoDisplay* tempDisplay = iVideoDisplay; |
|
509 |
|
510 iVideoDisplay = CMediaClientVideoDisplay::NewL( displayId ); |
|
511 |
|
512 delete tempDisplay; |
|
513 |
|
514 TRect cropRect = TRect( aWin->Size() ); |
|
515 |
|
516 // |
|
517 // If RWindow is still in potrait, rotate surface to play a video in landscape |
|
518 // |
|
519 if ( cropRect.Width() < cropRect.Height() ) |
|
520 { |
|
521 iRotation = EVideoRotationClockwise90; |
|
522 } |
|
523 |
|
524 iWindowRect = cropRect; |
|
525 |
|
526 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() cropRect (%d, %d), (%d, %d)"), |
|
527 cropRect.iTl.iX, cropRect.iTl.iY, cropRect.iBr.iX, cropRect.iBr.iY); |
|
528 |
|
529 MPX_TRAPD( dispError, |
|
530 iVideoDisplay->AddDisplayWindowL( iWindowBase, |
|
531 cropRect, |
|
532 cropRect, |
|
533 cropRect, |
|
534 iScaleWidth, |
|
535 iScaleHeight, |
|
536 iRotation, |
|
537 iAutoScale, |
|
538 iHorizontalPosition, |
|
539 iVerticalPosition, |
|
540 aWin ); |
|
541 ); |
|
542 |
|
543 MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() Display Added")); |
|
544 // |
|
545 // Check if surface was created before window was ready |
|
546 // |
|
547 if ( iSurfaceCached ) |
|
548 { |
|
549 iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect ); |
|
550 |
|
551 iSurfaceCached = EFalse; |
|
552 |
|
553 // |
|
554 // Let ControlsController know that we get the surface. |
|
555 // |
|
556 iViewWrapper->SurfacedAttached( true ); |
|
557 } |
|
558 } |
|
559 |
|
560 // ------------------------------------------------------------------------------------------------- |
|
561 // CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL() |
|
562 // ------------------------------------------------------------------------------------------------- |
|
563 // |
|
564 void CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL( CMPXMessage* aMessage ) |
|
565 { |
|
566 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL()")); |
|
567 |
|
568 TSurfaceId oldSurfaceId = iSurfaceId; |
|
569 |
|
570 // |
|
571 // Extract the surface parameters from the message |
|
572 // |
|
573 iSurfaceId = aMessage->ValueTObjectL<TSurfaceId>( KMPXMediaVideoDisplayTSurfaceId ); |
|
574 iCropRect = aMessage->ValueTObjectL<TRect>( KMPXMediaVideoDisplayCropRect ); |
|
575 iAspectRatio = aMessage->ValueTObjectL<TVideoAspectRatio>( KMPXMediaVideoDisplayAspectRatio ); |
|
576 |
|
577 if ( iVideoDisplay ) |
|
578 { |
|
579 // |
|
580 // Remove old surface if one exists |
|
581 // |
|
582 if ( ! oldSurfaceId.IsNull() ) |
|
583 { |
|
584 iVideoDisplay->RemoveSurface(); |
|
585 } |
|
586 |
|
587 // |
|
588 // Add new surface |
|
589 // |
|
590 iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect ); |
|
591 |
|
592 // |
|
593 // Let ControlsController know that we get the surface. |
|
594 // |
|
595 iViewWrapper->SurfacedAttached( true ); |
|
596 } |
|
597 else |
|
598 { |
|
599 // |
|
600 // Video display has not been created yet, save surface information to create |
|
601 // the surface when the display is created |
|
602 // |
|
603 iSurfaceCached = ETrue; |
|
604 } |
|
605 } |
|
606 |
|
607 // ------------------------------------------------------------------------------------------------- |
|
608 // CMPXVideoPlaybackDisplayHandler::SurfaceChangedL() |
|
609 // ------------------------------------------------------------------------------------------------- |
|
610 // |
|
611 void CMPXVideoPlaybackDisplayHandler::SurfaceChangedL( CMPXMessage* aMessage ) |
|
612 { |
|
613 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceChangedL()")); |
|
614 |
|
615 // |
|
616 // Extract the surface parameters from the message |
|
617 // |
|
618 iSurfaceId = aMessage->ValueTObjectL<TSurfaceId>( KMPXMediaVideoDisplayTSurfaceId ); |
|
619 iCropRect = aMessage->ValueTObjectL<TRect>( KMPXMediaVideoDisplayCropRect ); |
|
620 iAspectRatio = aMessage->ValueTObjectL<TVideoAspectRatio>( KMPXMediaVideoDisplayAspectRatio ); |
|
621 |
|
622 if ( iVideoDisplay ) |
|
623 { |
|
624 // |
|
625 // Add new surface |
|
626 // |
|
627 iVideoDisplay->SurfaceParametersChanged( iSurfaceId, iCropRect, iAspectRatio ); |
|
628 |
|
629 iVideoDisplay->RedrawWindows( iCropRect ); |
|
630 } |
|
631 } |
|
632 |
|
633 // ------------------------------------------------------------------------------------------------- |
|
634 // CMPXVideoPlaybackDisplayHandler::SurfaceRemoved() |
|
635 // ------------------------------------------------------------------------------------------------- |
|
636 // |
|
637 void CMPXVideoPlaybackDisplayHandler::SurfaceRemoved() |
|
638 { |
|
639 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceRemoved()")); |
|
640 |
|
641 // |
|
642 // Let ControlsController know that we get the surface. |
|
643 // |
|
644 iViewWrapper->SurfacedAttached( false ); |
|
645 |
|
646 if ( iVideoDisplay ) |
|
647 { |
|
648 iVideoDisplay->RemoveSurface(); |
|
649 } |
|
650 |
|
651 iSurfaceId = TSurfaceId::CreateNullId(); |
|
652 } |
|
653 |
|
654 // ------------------------------------------------------------------------------------------------- |
|
655 // CMPXVideoPlaybackDisplayHandler::SetNgaAspectRatioL() |
|
656 // ------------------------------------------------------------------------------------------------- |
|
657 // |
|
658 TInt CMPXVideoPlaybackDisplayHandler::SetNgaAspectRatioL( TMPXVideoPlaybackCommand aCmd ) |
|
659 { |
|
660 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetNgaAspectRatioL()")); |
|
661 |
|
662 TInt aspectRatio = EMMFNatural; |
|
663 |
|
664 switch ( aCmd ) |
|
665 { |
|
666 case EPbCmdNaturalAspectRatio: |
|
667 { |
|
668 iAutoScale = EAutoScaleBestFit; |
|
669 aspectRatio = EMMFNatural; |
|
670 break; |
|
671 } |
|
672 case EPbCmdZoomAspectRatio: |
|
673 { |
|
674 iAutoScale = EAutoScaleClip; |
|
675 aspectRatio = EMMFZoom; |
|
676 break; |
|
677 } |
|
678 case EPbCmdStretchAspectRatio: |
|
679 { |
|
680 iAutoScale = EAutoScaleStretch; |
|
681 aspectRatio = EMMFStretch; |
|
682 break; |
|
683 } |
|
684 } |
|
685 |
|
686 if ( iVideoDisplay && ! iSurfaceId.IsNull() ) |
|
687 { |
|
688 iVideoDisplay->SetAutoScaleL( iAutoScale, |
|
689 iHorizontalPosition, |
|
690 iVerticalPosition, |
|
691 iCropRect ); |
|
692 } |
|
693 |
|
694 return aspectRatio; |
|
695 } |
|
696 |
|
697 // End of File |