sl@0: // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "mediaclientvideodisplaybody.h" sl@0: sl@0: sl@0: /** sl@0: Constructs and initialises a new instance of the client video data to display image sl@0: on window or graphics surface. sl@0: sl@0: The function leaves if the video display object cannot be created. sl@0: sl@0: @param aDisplayId sl@0: A display ID. sl@0: sl@0: @return A pointer to the new video display object. sl@0: */ sl@0: sl@0: EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId) sl@0: { sl@0: CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aDisplayId); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: Constructs and initialises a new instance of the client video data to display image sl@0: on window or graphics surface. sl@0: sl@0: The function leaves if the video display object cannot be created. sl@0: sl@0: @param aDisplayId sl@0: A display ID. sl@0: sl@0: @param aSurfaceId sl@0: The surface that has been created. sl@0: sl@0: @param aCropRect sl@0: The dimensions of the crop rectangle, relative to the video image. sl@0: sl@0: @param aAspectRatio sl@0: The pixel aspect ratio to display video picture. sl@0: sl@0: @return A pointer to the new video display object. sl@0: */ sl@0: sl@0: EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio) sl@0: { sl@0: CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CMediaClientVideoDisplay::CMediaClientVideoDisplay() sl@0: { sl@0: } sl@0: sl@0: sl@0: void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId) sl@0: { sl@0: iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, ETrue); sl@0: } sl@0: sl@0: void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio) sl@0: { sl@0: iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio, ETrue); sl@0: } sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: Releases resources owned by the object prior to its destruction. sl@0: */ sl@0: sl@0: EXPORT_C CMediaClientVideoDisplay::~CMediaClientVideoDisplay() sl@0: { sl@0: delete iBody; sl@0: } sl@0: sl@0: /** sl@0: Adds a new window for displaying the video picture. sl@0: sl@0: @param aWindow sl@0: The display window. sl@0: sl@0: @param aClipRect sl@0: Window clipping rectangle, relative to the window. The clipping rectangle specifies sl@0: the part of the window used for video display. The rectangle must be contained sl@0: completely within the window. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @param aVideoExtent sl@0: Video extent on the screen, relative to the window. Video picture position within sl@0: the extent depends on the scaled picture and content alignment or offset. The video sl@0: extent can be partially or completely outside the window. sl@0: sl@0: @param aScaleWidth sl@0: Scaling the width of the video frame. sl@0: sl@0: @param aScaleHeight sl@0: Scaling the height of the video frame. sl@0: sl@0: @param aRotation sl@0: The desired rotation to apply in 90 degree increments. sl@0: sl@0: @param aAutoScaleType sl@0: Automatic scaling type. sl@0: sl@0: @param aHorizPos sl@0: Video picture horizontal position, relative to the video window. The value can be either sl@0: a pixel offset (positive or negative) from the top left corner of the window to the top left sl@0: corner of the picture, or an alignment constant from enum THorizontalAlign. sl@0: sl@0: @param aVertPos sl@0: Video picture vertical position, relative to the video window. The value can be either a pixel sl@0: offset (positive or negative) from the top left corner of the window to the top left corner of sl@0: the picture, or an alignment constant from enum TVerticalAlign. sl@0: sl@0: @param aWindow2 sl@0: The display window, aWindow2 is used when using CVideoPlayerUtility2. This is used to avoid sl@0: casting iWindow from RWindowBase* to RWindow*. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, sl@0: TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, sl@0: TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2) sl@0: { sl@0: iBody->AddDisplayWindowL(aWindow, aClipRect, aCropRegion, aVideoExtent, aScaleWidth, aScaleHeight, aRotation,aAutoScaleType, aHorizPos, aVertPos, aWindow2); sl@0: } sl@0: sl@0: /** sl@0: Removes a window that is currently being used to display the video picture. The window must sl@0: have previously been added with AddDisplayWindowL(). sl@0: sl@0: Note Depending on underlying implementation it may also remove any graphics resources associated sl@0: with video playback on this window. sl@0: sl@0: Note removing the last window on a display will deregister the display sl@0: sl@0: @param aWindow sl@0: The display window. sl@0: sl@0: @return The window position that has been removed. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C TInt CMediaClientVideoDisplay::RemoveDisplayWindow(const RWindowBase& aWindow) sl@0: { sl@0: return iBody->RemoveDisplayWindow(aWindow); sl@0: } sl@0: sl@0: /** sl@0: Must be called when a Surface has been Created. sl@0: sl@0: @param aSurfaceId sl@0: The surface that has been created. sl@0: sl@0: @param aCropRect sl@0: The dimensions of the crop rectangle, relative to the video image. sl@0: sl@0: @param aAspectRatio sl@0: The pixel aspect ratio to display video picture. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @return KErrNone is succesfully created, otherwise returns system wide error. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C TInt CMediaClientVideoDisplay::SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion) sl@0: { sl@0: return iBody->SurfaceCreated(aSurfaceId, aCropRect, aAspectRatio, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Must be called when the current surface is no longer being used. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::RemoveSurface() sl@0: { sl@0: iBody->RemoveSurface(ETrue); sl@0: } sl@0: sl@0: /** sl@0: sl@0: Must be called when the video surface parameters have been changed. sl@0: sl@0: @param aSurfaceId sl@0: The surface to be created for composition. sl@0: sl@0: @param aCropRect sl@0: The dimensions of the crop rectangle, relative to the video image. sl@0: sl@0: @param aAspectRatio sl@0: The pixel aspect ratio to display video picture. sl@0: sl@0: @return KErrNone is succesfully created, otherwise returns KErrInUse if surface is not created. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C TInt CMediaClientVideoDisplay::SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio) sl@0: { sl@0: return iBody->SurfaceParametersChanged(aSurfaceId, aCropRect, aAspectRatio); sl@0: } sl@0: sl@0: /** sl@0: Redraw all the windows with new crop region. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @return KErrNone is succesfully created, otherwise returns system wide error. sl@0: */ sl@0: sl@0: EXPORT_C TInt CMediaClientVideoDisplay::RedrawWindows(const TRect& aCropRegion) sl@0: { sl@0: return iBody->RedrawWindows(aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Set video automatic scaling. When automatic scaling is active, the sl@0: video picture is scaled automatically to match the video window, sl@0: based on the scaling type, and positioned according to the sl@0: parameters. sl@0: sl@0: Not all video controller support automatic scaling. sl@0: sl@0: This function quits or exits leaving any of the system wide error codes. sl@0: Common error codes are listed below. sl@0: sl@0: @param aWindow sl@0: The display window sl@0: sl@0: @param aAutoScaleType sl@0: Automatic scaling type sl@0: sl@0: @param aHorizPos sl@0: Video picture horizontal position, relative to the video window. sl@0: sl@0: @param aVertPos sl@0: Video picture vertical position, relative to the video window. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @leave Leaves with system wide error code. sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2. sl@0: sl@0: The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL. sl@0: Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been sl@0: made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL. sl@0: sl@0: @param aWindow sl@0: Window to set rotation for. sl@0: sl@0: @param aRotation sl@0: The video rotation to use for aWindow. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetRotationL(aWindow, aRotation, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2. sl@0: sl@0: The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL. sl@0: Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been sl@0: made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL. sl@0: sl@0: @param aRotation sl@0: The video rotation to use for aWindow. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetRotationL(aRotation, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2. sl@0: sl@0: @param aWindow sl@0: Window to retrieve rotation for. sl@0: sl@0: @return The video rotation. sl@0: sl@0: */ sl@0: sl@0: EXPORT_C TVideoRotation CMediaClientVideoDisplay::RotationL(const RWindowBase& aWindow) sl@0: { sl@0: return iBody->RotationL(aWindow); sl@0: } sl@0: sl@0: /** sl@0: Scales the video image to a specified percentage of its original size within the window. sl@0: sl@0: @param aWindow sl@0: Window to set scale factor for. sl@0: sl@0: @param aWidthPercentage sl@0: The percentage (100 = original size) to be used to scale the width of the video image sl@0: sl@0: @param aHeightPercentage sl@0: The percentage (100 = original size) to be used to scale the height of the video image. sl@0: If this is not equal to aWidthPercentage then the image may be distorted. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @see CVideoPlayerUtility2::SetScaleFactorL sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Scales the video image to a specified percentage of its original size within the window. sl@0: sl@0: @param aWidthPercentage sl@0: The percentage (100 = original size) to be used to scale the width of the video image sl@0: sl@0: @param aHeightPercentage sl@0: The percentage (100 = original size) to be used to scale the height of the video image. sl@0: If this is not equal to aWidthPercentage then the image may be distorted. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @see CVideoPlayerUtility2::SetScaleFactorL sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetScaleFactorL(aWidthPercentage, aHeightPercentage, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2. sl@0: sl@0: @param aWindow sl@0: Window to retrieve scale factor for. sl@0: sl@0: @param aWidthPercentage sl@0: On function return, contains the current scaling percentage applied to the width of the sl@0: video image (100 = original size). sl@0: sl@0: @param aHeightPercentage sl@0: On function return, contains the current scaling percentage applied to the height sl@0: of the video image (100 = original size). sl@0: sl@0: @see CVideoPlayerUtility2::GetScaleFactorL sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage) sl@0: { sl@0: iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage); sl@0: } sl@0: sl@0: /** sl@0: Set video automatic scaling. sl@0: sl@0: @param aHorizPos sl@0: Video picture horizontal position, relative to the video window. sl@0: sl@0: @param aVertPos sl@0: Video picture vertical position, relative to the video window. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @see CVideoPlayerUtility2::SetAutoScaleL sl@0: sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetAutoScaleL(aScaleType, aHorizPos, aVertPos, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Sets the window clipping rectangle, relative to the window. sl@0: sl@0: @param aWindow sl@0: Window to set clipping rectangle for. sl@0: sl@0: @param aWindowClipRect sl@0: The window server session for this window. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @see CVideoPlayerUtility2::SetWindowClipRectL sl@0: sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetWindowClipRectL(aWindow, aWindowClipRect, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Sets the video extent on the screen, relative to the window. sl@0: sl@0: @param aWindow sl@0: Window to set video extent for. sl@0: sl@0: @param aVideoExtent sl@0: The new video extent, relative to the video window. sl@0: sl@0: @param aCropRegion sl@0: The dimensions of the crop region, relative to the video image. sl@0: sl@0: @see CVideoPlayerUtility2::SetWindowClipRectL sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion) sl@0: { sl@0: iBody->SetVideoExtentL(aWindow, aVideoExtent, aCropRegion); sl@0: } sl@0: sl@0: /** sl@0: Enables automatic switching of surface to/from external display when it is connected/disconnected from the device. sl@0: sl@0: To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady. sl@0: sl@0: @param aEnable sl@0: ETrue to enable. EFalse to disable. sl@0: @leave KErrNotSupported Device does not support external displays sl@0: @leave KErrNotReady CActiveScheduler is not installed sl@0: */ sl@0: sl@0: EXPORT_C void CMediaClientVideoDisplay::SetExternalDisplaySwitchingL(TBool aControl) sl@0: { sl@0: iBody->SetExternalDisplaySwitchingL(aControl); sl@0: }