34 const TReal32 KTRANSITIONEFFECTCNT = 8; |
33 const TReal32 KTRANSITIONEFFECTCNT = 8; |
35 |
34 |
36 _LIT( KAspectRatioFile, "c:\\private\\200159b2\\mpxvideoplayer_aspect_ratio.dat" ); |
35 _LIT( KAspectRatioFile, "c:\\private\\200159b2\\mpxvideoplayer_aspect_ratio.dat" ); |
37 |
36 |
38 |
37 |
39 CVideoPlaybackDisplayHandler::CVideoPlaybackDisplayHandler( MMPXPlaybackUtility* aPlayUtil, |
38 CVideoPlaybackDisplayHandler::CVideoPlaybackDisplayHandler( CMPXVideoViewWrapper* aViewWrapper ) |
40 CMPXVideoViewWrapper* aViewWrapper ) |
39 : iTransitionEffectCnt( 0 ) |
41 : iPlaybackUtility( aPlayUtil ) |
|
42 , iTransitionEffectCnt( 0 ) |
|
43 , iViewWrapper( aViewWrapper ) |
40 , iViewWrapper( aViewWrapper ) |
44 , iScaleWidth( 100.0f ) |
41 , iScaleWidth( 100.0f ) |
45 , iScaleHeight( 100.0f ) |
42 , iScaleHeight( 100.0f ) |
46 , iHorizontalPosition( EHorizontalAlignCenter ) |
43 , iHorizontalPosition( EHorizontalAlignCenter ) |
47 , iVerticalPosition( EVerticalAlignCenter ) |
44 , iVerticalPosition( EVerticalAlignCenter ) |
111 // |
107 // |
112 void CVideoPlaybackDisplayHandler::CreateDisplayWindowL( |
108 void CVideoPlaybackDisplayHandler::CreateDisplayWindowL( |
113 RWsSession& /*aWs*/, |
109 RWsSession& /*aWs*/, |
114 CWsScreenDevice& aScreenDevice, |
110 CWsScreenDevice& aScreenDevice, |
115 RWindow& aWin, |
111 RWindow& aWin, |
116 TRect aDisplayRect ) |
112 TRect aDisplayRect, |
|
113 VideoPlaybackViewFileDetails* aFileDetails ) |
117 { |
114 { |
118 MPX_ENTER_EXIT(_L("CVideoPlaybackDisplayHandler::CreateDisplayWindowL()")); |
115 MPX_ENTER_EXIT(_L("CVideoPlaybackDisplayHandler::CreateDisplayWindowL()")); |
|
116 |
|
117 iFileDetails = aFileDetails; |
|
118 |
|
119 // |
|
120 // get window aspect ratio |
|
121 // if device is in landscape mode, width > height |
|
122 // if device is in portrait mode, width < height |
|
123 // |
|
124 TReal32 width = (TReal32) aDisplayRect.Width(); |
|
125 TReal32 height = (TReal32) aDisplayRect.Height(); |
|
126 iDisplayAspectRatio = (width > height)? (width / height) : (height / width); |
119 |
127 |
120 if ( ! iVideoContainer ) |
128 if ( ! iVideoContainer ) |
121 { |
129 { |
122 iVideoContainer = new ( ELeave ) CVideoContainer(); |
130 iVideoContainer = new ( ELeave ) CVideoContainer(); |
123 iVideoContainer->ConstructL(); |
131 iVideoContainer->ConstructL(); |
124 iVideoContainer->SetRect( aDisplayRect ); |
132 iVideoContainer->SetRect( aDisplayRect ); |
125 } |
133 } |
126 |
134 |
127 RWindowBase *videoWindow = iVideoContainer->DrawableWindow(); |
135 RWindowBase *videoWindow = iVideoContainer->DrawableWindow(); |
|
136 ((RWindow*)videoWindow )->SetBackgroundColor( KRgbBlack ); |
|
137 |
128 videoWindow->SetOrdinalPosition( -1 ); |
138 videoWindow->SetOrdinalPosition( -1 ); |
129 (&aWin)->SetOrdinalPosition( 0 ); |
139 (&aWin)->SetOrdinalPosition( 0 ); |
130 |
140 |
131 MPX_DEBUG(_L("VideoWindow ordinal position is: %d"), videoWindow->OrdinalPosition()); |
141 MPX_DEBUG(_L("VideoWindow ordinal position is: %d"), videoWindow->OrdinalPosition()); |
132 MPX_DEBUG(_L("UiWindow ordinal position is: %d"), (&aWin)->OrdinalPosition()); |
142 MPX_DEBUG(_L("UiWindow ordinal position is: %d"), (&aWin)->OrdinalPosition()); |
217 |
227 |
218 return aspectRatio; |
228 return aspectRatio; |
219 } |
229 } |
220 |
230 |
221 // ------------------------------------------------------------------------------------------------- |
231 // ------------------------------------------------------------------------------------------------- |
222 // CVideoPlaybackDisplayHandler::SetDefaultAspectRatioL |
232 // CVideoPlaybackDisplayHandler::CalculateAspectRatioL |
223 // ------------------------------------------------------------------------------------------------- |
233 // ------------------------------------------------------------------------------------------------- |
224 // |
234 // |
225 TInt CVideoPlaybackDisplayHandler::SetDefaultAspectRatioL( |
235 TInt CVideoPlaybackDisplayHandler::CalculateAspectRatioL() |
226 VideoPlaybackViewFileDetails* aFileDetails, TReal32 aDisplayAspectRatio ) |
236 { |
227 { |
237 MPX_ENTER_EXIT(_L("CVideoPlaybackDisplayHandler::CalculateAspectRatioL()")); |
228 MPX_ENTER_EXIT(_L("CVideoPlaybackDisplayHandler::SetDefaultAspectRatioL()")); |
|
229 |
238 |
230 TInt newAspectRatio = EMMFNatural; |
239 TInt newAspectRatio = EMMFNatural; |
231 |
240 |
232 if ( aFileDetails->mVideoHeight > 0 && aFileDetails->mVideoWidth > 0 ) |
241 if ( iFileDetails->mVideoHeight > 0 && iFileDetails->mVideoWidth > 0 ) |
233 { |
242 { |
234 TMMFScalingType scalingType = EMMFNatural; |
243 TMMFScalingType scalingType = EMMFNatural; |
235 |
244 |
236 TReal32 videoAspectRatio = (TReal32)aFileDetails->mVideoWidth / |
245 TReal32 videoAspectRatio = (TReal32)iFileDetails->mVideoWidth / |
237 (TReal32)aFileDetails->mVideoHeight; |
246 (TReal32)iFileDetails->mVideoHeight; |
|
247 // |
|
248 // If the pixel aspect ratio is valid, use it to modify the videoAspectRatio |
|
249 // |
|
250 if ( iAspectRatio.iDenominator ) |
|
251 { |
|
252 MPX_DEBUG(_L("VideoPlaybackDisplayHandler::CalculateAspectRatioL() iAspectRatio = (%d,%d)"), |
|
253 iAspectRatio.iNumerator, iAspectRatio.iDenominator ); |
|
254 |
|
255 TReal32 par = (TReal32)iAspectRatio.iNumerator / (TReal32)iAspectRatio.iDenominator; |
|
256 videoAspectRatio *= par; |
|
257 } |
238 |
258 |
239 TInt cnt = iAspectRatioArray.Count(); |
259 TInt cnt = iAspectRatioArray.Count(); |
240 TInt i = 0; |
260 TInt i = 0; |
241 |
261 |
242 // |
262 // |
243 // check whether dat file has the information about (videoRatio + screenRatio) |
263 // check whether dat file has the information about (videoRatio + screenRatio) |
244 // |
264 // |
245 for ( ; i < cnt ; i++ ) |
265 for ( ; i < cnt ; i++ ) |
246 { |
266 { |
247 if ( iAspectRatioArray[i].videoRatio == videoAspectRatio && |
267 if ( IsAspectRatioEqual( iAspectRatioArray[i].videoRatio, videoAspectRatio ) && |
248 iAspectRatioArray[i].screenRatio == aDisplayAspectRatio && |
268 IsAspectRatioEqual( iAspectRatioArray[i].screenRatio, iDisplayAspectRatio ) && |
249 ( scalingType = iAspectRatioArray[i].scalingType ) > 0 ) |
269 ( scalingType = iAspectRatioArray[i].scalingType ) > 0 ) |
250 { |
270 { |
251 break; |
271 break; |
252 } |
272 } |
253 } |
273 } |
254 |
274 |
255 // |
275 // |
256 // if can't find out match aspect ratio in dat file, |
276 // if can't find out match aspect ratio in dat file, |
257 // choose the scaling type through the rule |
277 // choose the scaling type through the rule |
258 // aspectRatioDiff = videoAspectRatio - aDisplayAspectRatio |
278 // aspectRatioDiff = videoAspectRatio - iDisplayAspectRatio |
259 // aspectRatioDiff == 0 ==> natural |
279 // aspectRatioDiff >= - 0.00001 and <= 0.00001 ==> natural |
260 // aspectRatioDiff > 0.1 ==> zoom |
280 // aspectRatioDiff > 0.1 ==> zoom |
261 // aspectRatioDiff < - 0.3 ==> natural |
281 // aspectRatioDiff < - 0.3 ==> natural |
262 // aspectRatioDiff >= - 0.3 and <= 0.1 ==> stretch |
282 // aspectRatioDiff >= - 0.3 and <= 0.1 ==> stretch |
|
283 // |
|
284 // -0.3 -0.00001 0.00001 0.1 |
|
285 // ------------------------------------------------------------ |
|
286 // Natural | Stretch | Natural | Stretch | Zoom |
263 // |
287 // |
264 |
288 |
265 if ( i == cnt ) |
289 if ( i == cnt ) |
266 { |
290 { |
267 if ( videoAspectRatio - aDisplayAspectRatio > 0.1 ) |
291 TReal32 aspectRatioDiff = videoAspectRatio - iDisplayAspectRatio; |
|
292 |
|
293 MPX_DEBUG(_L("VideoPlaybackDisplayHandler::CalculateAspectRatioL() videoAspectRatio = d,iDisplayAspectRatio = %d)"), |
|
294 videoAspectRatio, iDisplayAspectRatio ); |
|
295 |
|
296 if ( IsAspectRatioEqual( videoAspectRatio, iDisplayAspectRatio ) ) |
|
297 { |
|
298 scalingType = EMMFNatural; |
|
299 } |
|
300 else if ( aspectRatioDiff > 0.1 ) |
268 { |
301 { |
269 scalingType = EMMFZoom; |
302 scalingType = EMMFZoom; |
270 } |
303 } |
271 else if ( ( videoAspectRatio != aDisplayAspectRatio ) && |
304 else if ( aspectRatioDiff > - 0.3 ) |
272 ( videoAspectRatio - aDisplayAspectRatio > (- 0.3) ) ) |
|
273 { |
305 { |
274 scalingType = EMMFStretch; |
306 scalingType = EMMFStretch; |
275 } |
307 } |
276 |
308 |
277 TMPXAspectRatio ratio; |
309 TMPXAspectRatio ratio; |
278 |
310 |
279 ratio.videoRatio = videoAspectRatio; |
311 ratio.videoRatio = videoAspectRatio; |
280 ratio.screenRatio = aDisplayAspectRatio; |
312 ratio.screenRatio = iDisplayAspectRatio; |
281 ratio.scalingType = scalingType; |
313 ratio.scalingType = scalingType; |
282 |
314 |
283 iAspectRatioArray.Append( ratio ); |
315 iAspectRatioArray.Append( ratio ); |
284 } |
316 } |
|
317 |
|
318 iFileDetails->mAspectRatioChangeable = |
|
319 ! IsAspectRatioEqual( videoAspectRatio, iDisplayAspectRatio ); |
285 |
320 |
286 iCurrentIndexForAspectRatio = i; |
321 iCurrentIndexForAspectRatio = i; |
287 |
322 |
288 TMPXVideoPlaybackCommand aspectRatioCmd = EPbCmdNaturalAspectRatio; |
323 TMPXVideoPlaybackCommand aspectRatioCmd = EPbCmdNaturalAspectRatio; |
289 |
324 |
483 { |
518 { |
484 MPX_ENTER_EXIT(_L("CVideoPlaybackDisplayHandler::SetVideoRectL()")); |
519 MPX_ENTER_EXIT(_L("CVideoPlaybackDisplayHandler::SetVideoRectL()")); |
485 |
520 |
486 if ( iVideoDisplay ) |
521 if ( iVideoDisplay ) |
487 { |
522 { |
488 iVideoDisplay->SetVideoExtentL( *iWindowBase, aRect, TRect( iWindowBase->Size() ) ); |
523 TRect temp = aRect; |
|
524 |
|
525 MPX_DEBUG(_L("CVideoPlaybackDisplayHandler::SetVideoRectL() origianl rect %d %d %d %d"), |
|
526 temp.iTl.iX, temp.iTl.iY, temp.iBr.iX, temp.iBr.iY ); |
|
527 |
|
528 // |
|
529 // Need to transform based on rotation clockwise |
|
530 // since the input rect is based on orbit orientation(which can be landscape or potrait) |
|
531 // and the video surface is always in device orientation(can't be changed by anything). |
|
532 // If iRotation is EVideoRotationNone, |
|
533 // we don't need to transfrom the rect since video and ui surfaces are in same orietation. |
|
534 // but if iRotation is not EVideoRotationNone, |
|
535 // we need to transform the rect based on clockwise. |
|
536 // |
|
537 switch( iRotation ) |
|
538 { |
|
539 case EVideoRotationClockwise90: |
|
540 { |
|
541 int screenWidth = iWindowBase->Size().iWidth; |
|
542 |
|
543 temp = TRect( screenWidth - aRect.iBr.iY, |
|
544 aRect.iTl.iX, |
|
545 screenWidth - aRect.iTl.iY, |
|
546 aRect.iBr.iX ); |
|
547 break; |
|
548 } |
|
549 } |
|
550 |
|
551 MPX_DEBUG(_L("CVideoPlaybackDisplayHandler::SetVideoRectL() transformed rect %d %d %d %d"), |
|
552 temp.iTl.iX, temp.iTl.iY, temp.iBr.iX, temp.iBr.iY ); |
|
553 |
|
554 iVideoDisplay->SetVideoExtentL( *iWindowBase, temp, iCropRect ); |
489 } |
555 } |
490 } |
556 } |
491 |
557 |
492 // ------------------------------------------------------------------------------------------------- |
558 // ------------------------------------------------------------------------------------------------- |
493 // CVideoPlaybackDisplayHandler::AddDisplayWindowL() |
559 // CVideoPlaybackDisplayHandler::AddDisplayWindowL() |