1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplay.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,477 @@
1.4 +// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <mediaclientvideodisplay.h>
1.20 +#include "mediaclientvideodisplaybody.h"
1.21 +
1.22 +
1.23 +/**
1.24 +Constructs and initialises a new instance of the client video data to display image
1.25 +on window or graphics surface.
1.26 +
1.27 +The function leaves if the video display object cannot be created.
1.28 +
1.29 +@param aDisplayId
1.30 + A display ID.
1.31 +
1.32 +@return A pointer to the new video display object.
1.33 +*/
1.34 +
1.35 +EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId)
1.36 + {
1.37 + CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay();
1.38 + CleanupStack::PushL(self);
1.39 + self->ConstructL(aDisplayId);
1.40 + CleanupStack::Pop(self);
1.41 + return self;
1.42 + }
1.43 +
1.44 +/**
1.45 +Constructs and initialises a new instance of the client video data to display image
1.46 +on window or graphics surface.
1.47 +
1.48 +The function leaves if the video display object cannot be created.
1.49 +
1.50 +@param aDisplayId
1.51 + A display ID.
1.52 +
1.53 +@param aSurfaceId
1.54 + The surface that has been created.
1.55 +
1.56 +@param aCropRect
1.57 + The dimensions of the crop rectangle, relative to the video image.
1.58 +
1.59 +@param aAspectRatio
1.60 + The pixel aspect ratio to display video picture.
1.61 +
1.62 +@return A pointer to the new video display object.
1.63 +*/
1.64 +
1.65 +EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
1.66 + {
1.67 + CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay();
1.68 + CleanupStack::PushL(self);
1.69 + self->ConstructL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio);
1.70 + CleanupStack::Pop(self);
1.71 + return self;
1.72 + }
1.73 +
1.74 +CMediaClientVideoDisplay::CMediaClientVideoDisplay()
1.75 + {
1.76 + }
1.77 +
1.78 +
1.79 +void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId)
1.80 + {
1.81 + iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, ETrue);
1.82 + }
1.83 +
1.84 +void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
1.85 + {
1.86 + iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio, ETrue);
1.87 + }
1.88 +
1.89 +/**
1.90 +Destructor.
1.91 +
1.92 +Releases resources owned by the object prior to its destruction.
1.93 +*/
1.94 +
1.95 +EXPORT_C CMediaClientVideoDisplay::~CMediaClientVideoDisplay()
1.96 + {
1.97 + delete iBody;
1.98 + }
1.99 +
1.100 +/**
1.101 +Adds a new window for displaying the video picture.
1.102 +
1.103 +@param aWindow
1.104 + The display window.
1.105 +
1.106 +@param aClipRect
1.107 + Window clipping rectangle, relative to the window. The clipping rectangle specifies
1.108 + the part of the window used for video display. The rectangle must be contained
1.109 + completely within the window.
1.110 +
1.111 +@param aCropRegion
1.112 + The dimensions of the crop region, relative to the video image.
1.113 +
1.114 +@param aVideoExtent
1.115 + Video extent on the screen, relative to the window. Video picture position within
1.116 + the extent depends on the scaled picture and content alignment or offset. The video
1.117 + extent can be partially or completely outside the window.
1.118 +
1.119 +@param aScaleWidth
1.120 + Scaling the width of the video frame.
1.121 +
1.122 +@param aScaleHeight
1.123 + Scaling the height of the video frame.
1.124 +
1.125 +@param aRotation
1.126 + The desired rotation to apply in 90 degree increments.
1.127 +
1.128 +@param aAutoScaleType
1.129 + Automatic scaling type.
1.130 +
1.131 +@param aHorizPos
1.132 + Video picture horizontal position, relative to the video window. The value can be either
1.133 + a pixel offset (positive or negative) from the top left corner of the window to the top left
1.134 + corner of the picture, or an alignment constant from enum THorizontalAlign.
1.135 +
1.136 +@param aVertPos
1.137 + Video picture vertical position, relative to the video window. The value can be either a pixel
1.138 + offset (positive or negative) from the top left corner of the window to the top left corner of
1.139 + the picture, or an alignment constant from enum TVerticalAlign.
1.140 +
1.141 +@param aWindow2
1.142 + The display window, aWindow2 is used when using CVideoPlayerUtility2. This is used to avoid
1.143 + casting iWindow from RWindowBase* to RWindow*.
1.144 +
1.145 +*/
1.146 +
1.147 +EXPORT_C void CMediaClientVideoDisplay::AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent,
1.148 + TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation,
1.149 + TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2)
1.150 + {
1.151 + iBody->AddDisplayWindowL(aWindow, aClipRect, aCropRegion, aVideoExtent, aScaleWidth, aScaleHeight, aRotation,aAutoScaleType, aHorizPos, aVertPos, aWindow2);
1.152 + }
1.153 +
1.154 +/**
1.155 +Removes a window that is currently being used to display the video picture. The window must
1.156 +have previously been added with AddDisplayWindowL().
1.157 +
1.158 +Note Depending on underlying implementation it may also remove any graphics resources associated
1.159 +with video playback on this window.
1.160 +
1.161 +Note removing the last window on a display will deregister the display
1.162 +
1.163 +@param aWindow
1.164 + The display window.
1.165 +
1.166 +@return The window position that has been removed.
1.167 +
1.168 +*/
1.169 +
1.170 +EXPORT_C TInt CMediaClientVideoDisplay::RemoveDisplayWindow(const RWindowBase& aWindow)
1.171 + {
1.172 + return iBody->RemoveDisplayWindow(aWindow);
1.173 + }
1.174 +
1.175 +/**
1.176 +Must be called when a Surface has been Created.
1.177 +
1.178 +@param aSurfaceId
1.179 + The surface that has been created.
1.180 +
1.181 +@param aCropRect
1.182 + The dimensions of the crop rectangle, relative to the video image.
1.183 +
1.184 +@param aAspectRatio
1.185 + The pixel aspect ratio to display video picture.
1.186 +
1.187 +@param aCropRegion
1.188 + The dimensions of the crop region, relative to the video image.
1.189 +
1.190 +@return KErrNone is succesfully created, otherwise returns system wide error.
1.191 +
1.192 +*/
1.193 +
1.194 +EXPORT_C TInt CMediaClientVideoDisplay::SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion)
1.195 + {
1.196 + return iBody->SurfaceCreated(aSurfaceId, aCropRect, aAspectRatio, aCropRegion);
1.197 + }
1.198 +
1.199 +/**
1.200 +Must be called when the current surface is no longer being used.
1.201 +
1.202 +*/
1.203 +
1.204 +EXPORT_C void CMediaClientVideoDisplay::RemoveSurface()
1.205 + {
1.206 + iBody->RemoveSurface(ETrue);
1.207 + }
1.208 +
1.209 +/**
1.210 +
1.211 +Must be called when the video surface parameters have been changed.
1.212 +
1.213 +@param aSurfaceId
1.214 + The surface to be created for composition.
1.215 +
1.216 +@param aCropRect
1.217 + The dimensions of the crop rectangle, relative to the video image.
1.218 +
1.219 +@param aAspectRatio
1.220 + The pixel aspect ratio to display video picture.
1.221 +
1.222 +@return KErrNone is succesfully created, otherwise returns KErrInUse if surface is not created.
1.223 +
1.224 +*/
1.225 +
1.226 +EXPORT_C TInt CMediaClientVideoDisplay::SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
1.227 + {
1.228 + return iBody->SurfaceParametersChanged(aSurfaceId, aCropRect, aAspectRatio);
1.229 + }
1.230 +
1.231 +/**
1.232 +Redraw all the windows with new crop region.
1.233 +
1.234 +@param aCropRegion
1.235 + The dimensions of the crop region, relative to the video image.
1.236 +
1.237 +@return KErrNone is succesfully created, otherwise returns system wide error.
1.238 +*/
1.239 +
1.240 +EXPORT_C TInt CMediaClientVideoDisplay::RedrawWindows(const TRect& aCropRegion)
1.241 + {
1.242 + return iBody->RedrawWindows(aCropRegion);
1.243 + }
1.244 +
1.245 +/**
1.246 +Set video automatic scaling. When automatic scaling is active, the
1.247 +video picture is scaled automatically to match the video window,
1.248 +based on the scaling type, and positioned according to the
1.249 +parameters.
1.250 +
1.251 +Not all video controller support automatic scaling.
1.252 +
1.253 +This function quits or exits leaving any of the system wide error codes.
1.254 +Common error codes are listed below.
1.255 +
1.256 +@param aWindow
1.257 + The display window
1.258 +
1.259 +@param aAutoScaleType
1.260 + Automatic scaling type
1.261 +
1.262 +@param aHorizPos
1.263 + Video picture horizontal position, relative to the video window.
1.264 +
1.265 +@param aVertPos
1.266 + Video picture vertical position, relative to the video window.
1.267 +
1.268 +@param aCropRegion
1.269 + The dimensions of the crop region, relative to the video image.
1.270 +
1.271 +@leave Leaves with system wide error code.
1.272 +*/
1.273 +
1.274 +EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
1.275 + {
1.276 + iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos, aCropRegion);
1.277 + }
1.278 +
1.279 +/**
1.280 +Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
1.281 +
1.282 +The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL.
1.283 +Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
1.284 +made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
1.285 +
1.286 +@param aWindow
1.287 + Window to set rotation for.
1.288 +
1.289 +@param aRotation
1.290 + The video rotation to use for aWindow.
1.291 +
1.292 +@param aCropRegion
1.293 + The dimensions of the crop region, relative to the video image.
1.294 +
1.295 +*/
1.296 +
1.297 +EXPORT_C void CMediaClientVideoDisplay::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion)
1.298 + {
1.299 + iBody->SetRotationL(aWindow, aRotation, aCropRegion);
1.300 + }
1.301 +
1.302 +/**
1.303 +Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
1.304 +
1.305 +The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL.
1.306 +Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
1.307 +made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
1.308 +
1.309 +@param aRotation
1.310 + The video rotation to use for aWindow.
1.311 +
1.312 +@param aCropRegion
1.313 + The dimensions of the crop region, relative to the video image.
1.314 +
1.315 +*/
1.316 +
1.317 +EXPORT_C void CMediaClientVideoDisplay::SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion)
1.318 + {
1.319 + iBody->SetRotationL(aRotation, aCropRegion);
1.320 + }
1.321 +
1.322 +/**
1.323 +Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2.
1.324 +
1.325 +@param aWindow
1.326 + Window to retrieve rotation for.
1.327 +
1.328 +@return The video rotation.
1.329 +
1.330 +*/
1.331 +
1.332 +EXPORT_C TVideoRotation CMediaClientVideoDisplay::RotationL(const RWindowBase& aWindow)
1.333 + {
1.334 + return iBody->RotationL(aWindow);
1.335 + }
1.336 +
1.337 +/**
1.338 +Scales the video image to a specified percentage of its original size within the window.
1.339 +
1.340 +@param aWindow
1.341 + Window to set scale factor for.
1.342 +
1.343 +@param aWidthPercentage
1.344 + The percentage (100 = original size) to be used to scale the width of the video image
1.345 +
1.346 +@param aHeightPercentage
1.347 + The percentage (100 = original size) to be used to scale the height of the video image.
1.348 + If this is not equal to aWidthPercentage then the image may be distorted.
1.349 +
1.350 +@param aCropRegion
1.351 + The dimensions of the crop region, relative to the video image.
1.352 +
1.353 +@see CVideoPlayerUtility2::SetScaleFactorL
1.354 +*/
1.355 +
1.356 +EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
1.357 + {
1.358 + iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage, aCropRegion);
1.359 + }
1.360 +
1.361 +/**
1.362 +Scales the video image to a specified percentage of its original size within the window.
1.363 +
1.364 +@param aWidthPercentage
1.365 + The percentage (100 = original size) to be used to scale the width of the video image
1.366 +
1.367 +@param aHeightPercentage
1.368 + The percentage (100 = original size) to be used to scale the height of the video image.
1.369 + If this is not equal to aWidthPercentage then the image may be distorted.
1.370 +
1.371 +@param aCropRegion
1.372 + The dimensions of the crop region, relative to the video image.
1.373 +
1.374 +@see CVideoPlayerUtility2::SetScaleFactorL
1.375 +*/
1.376 +
1.377 +EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
1.378 + {
1.379 + iBody->SetScaleFactorL(aWidthPercentage, aHeightPercentage, aCropRegion);
1.380 + }
1.381 +
1.382 +/**
1.383 +Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2.
1.384 +
1.385 +@param aWindow
1.386 + Window to retrieve scale factor for.
1.387 +
1.388 +@param aWidthPercentage
1.389 + On function return, contains the current scaling percentage applied to the width of the
1.390 + video image (100 = original size).
1.391 +
1.392 +@param aHeightPercentage
1.393 + On function return, contains the current scaling percentage applied to the height
1.394 + of the video image (100 = original size).
1.395 +
1.396 +@see CVideoPlayerUtility2::GetScaleFactorL
1.397 +*/
1.398 +
1.399 +EXPORT_C void CMediaClientVideoDisplay::GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage)
1.400 + {
1.401 + iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage);
1.402 + }
1.403 +
1.404 +/**
1.405 +Set video automatic scaling.
1.406 +
1.407 +@param aHorizPos
1.408 + Video picture horizontal position, relative to the video window.
1.409 +
1.410 +@param aVertPos
1.411 + Video picture vertical position, relative to the video window.
1.412 +
1.413 +@param aCropRegion
1.414 + The dimensions of the crop region, relative to the video image.
1.415 +
1.416 +@see CVideoPlayerUtility2::SetAutoScaleL
1.417 +
1.418 +*/
1.419 +
1.420 +EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
1.421 + {
1.422 + iBody->SetAutoScaleL(aScaleType, aHorizPos, aVertPos, aCropRegion);
1.423 + }
1.424 +
1.425 +/**
1.426 +Sets the window clipping rectangle, relative to the window.
1.427 +
1.428 +@param aWindow
1.429 + Window to set clipping rectangle for.
1.430 +
1.431 +@param aWindowClipRect
1.432 + The window server session for this window.
1.433 +
1.434 +@param aCropRegion
1.435 + The dimensions of the crop region, relative to the video image.
1.436 +
1.437 +@see CVideoPlayerUtility2::SetWindowClipRectL
1.438 +
1.439 +*/
1.440 +
1.441 +EXPORT_C void CMediaClientVideoDisplay::SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion)
1.442 + {
1.443 + iBody->SetWindowClipRectL(aWindow, aWindowClipRect, aCropRegion);
1.444 + }
1.445 +
1.446 +/**
1.447 +Sets the video extent on the screen, relative to the window.
1.448 +
1.449 +@param aWindow
1.450 + Window to set video extent for.
1.451 +
1.452 +@param aVideoExtent
1.453 + The new video extent, relative to the video window.
1.454 +
1.455 +@param aCropRegion
1.456 + The dimensions of the crop region, relative to the video image.
1.457 +
1.458 +@see CVideoPlayerUtility2::SetWindowClipRectL
1.459 +*/
1.460 +
1.461 +EXPORT_C void CMediaClientVideoDisplay::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion)
1.462 + {
1.463 + iBody->SetVideoExtentL(aWindow, aVideoExtent, aCropRegion);
1.464 + }
1.465 +
1.466 +/**
1.467 +Enables automatic switching of surface to/from external display when it is connected/disconnected from the device.
1.468 +
1.469 +To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady.
1.470 +
1.471 +@param aEnable
1.472 + ETrue to enable. EFalse to disable.
1.473 +@leave KErrNotSupported Device does not support external displays
1.474 +@leave KErrNotReady CActiveScheduler is not installed
1.475 +*/
1.476 +
1.477 +EXPORT_C void CMediaClientVideoDisplay::SetExternalDisplaySwitchingL(TBool aControl)
1.478 + {
1.479 + iBody->SetExternalDisplaySwitchingL(aControl);
1.480 + }