Update contrib.
1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <mediaclientvideodisplay.h>
17 #include "mediaclientvideodisplaybody.h"
21 Constructs and initialises a new instance of the client video data to display image
22 on window or graphics surface.
24 The function leaves if the video display object cannot be created.
29 @return A pointer to the new video display object.
32 EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId)
34 CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay();
35 CleanupStack::PushL(self);
36 self->ConstructL(aDisplayId);
37 CleanupStack::Pop(self);
42 Constructs and initialises a new instance of the client video data to display image
43 on window or graphics surface.
45 The function leaves if the video display object cannot be created.
51 The surface that has been created.
54 The dimensions of the crop rectangle, relative to the video image.
57 The pixel aspect ratio to display video picture.
59 @return A pointer to the new video display object.
62 EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
64 CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay();
65 CleanupStack::PushL(self);
66 self->ConstructL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio);
67 CleanupStack::Pop(self);
71 CMediaClientVideoDisplay::CMediaClientVideoDisplay()
76 void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId)
78 iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, ETrue);
81 void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
83 iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio, ETrue);
89 Releases resources owned by the object prior to its destruction.
92 EXPORT_C CMediaClientVideoDisplay::~CMediaClientVideoDisplay()
98 Adds a new window for displaying the video picture.
104 Window clipping rectangle, relative to the window. The clipping rectangle specifies
105 the part of the window used for video display. The rectangle must be contained
106 completely within the window.
109 The dimensions of the crop region, relative to the video image.
112 Video extent on the screen, relative to the window. Video picture position within
113 the extent depends on the scaled picture and content alignment or offset. The video
114 extent can be partially or completely outside the window.
117 Scaling the width of the video frame.
120 Scaling the height of the video frame.
123 The desired rotation to apply in 90 degree increments.
125 @param aAutoScaleType
126 Automatic scaling type.
129 Video picture horizontal position, relative to the video window. The value can be either
130 a pixel offset (positive or negative) from the top left corner of the window to the top left
131 corner of the picture, or an alignment constant from enum THorizontalAlign.
134 Video picture vertical position, relative to the video window. The value can be either a pixel
135 offset (positive or negative) from the top left corner of the window to the top left corner of
136 the picture, or an alignment constant from enum TVerticalAlign.
139 The display window, aWindow2 is used when using CVideoPlayerUtility2. This is used to avoid
140 casting iWindow from RWindowBase* to RWindow*.
144 EXPORT_C void CMediaClientVideoDisplay::AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent,
145 TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation,
146 TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2)
148 iBody->AddDisplayWindowL(aWindow, aClipRect, aCropRegion, aVideoExtent, aScaleWidth, aScaleHeight, aRotation,aAutoScaleType, aHorizPos, aVertPos, aWindow2);
152 Removes a window that is currently being used to display the video picture. The window must
153 have previously been added with AddDisplayWindowL().
155 Note Depending on underlying implementation it may also remove any graphics resources associated
156 with video playback on this window.
158 Note removing the last window on a display will deregister the display
163 @return The window position that has been removed.
167 EXPORT_C TInt CMediaClientVideoDisplay::RemoveDisplayWindow(const RWindowBase& aWindow)
169 return iBody->RemoveDisplayWindow(aWindow);
173 Must be called when a Surface has been Created.
176 The surface that has been created.
179 The dimensions of the crop rectangle, relative to the video image.
182 The pixel aspect ratio to display video picture.
185 The dimensions of the crop region, relative to the video image.
187 @return KErrNone is succesfully created, otherwise returns system wide error.
191 EXPORT_C TInt CMediaClientVideoDisplay::SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion)
193 return iBody->SurfaceCreated(aSurfaceId, aCropRect, aAspectRatio, aCropRegion);
197 Must be called when the current surface is no longer being used.
201 EXPORT_C void CMediaClientVideoDisplay::RemoveSurface()
203 iBody->RemoveSurface(ETrue);
208 Must be called when the video surface parameters have been changed.
211 The surface to be created for composition.
214 The dimensions of the crop rectangle, relative to the video image.
217 The pixel aspect ratio to display video picture.
219 @return KErrNone is succesfully created, otherwise returns KErrInUse if surface is not created.
223 EXPORT_C TInt CMediaClientVideoDisplay::SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
225 return iBody->SurfaceParametersChanged(aSurfaceId, aCropRect, aAspectRatio);
229 Redraw all the windows with new crop region.
232 The dimensions of the crop region, relative to the video image.
234 @return KErrNone is succesfully created, otherwise returns system wide error.
237 EXPORT_C TInt CMediaClientVideoDisplay::RedrawWindows(const TRect& aCropRegion)
239 return iBody->RedrawWindows(aCropRegion);
243 Set video automatic scaling. When automatic scaling is active, the
244 video picture is scaled automatically to match the video window,
245 based on the scaling type, and positioned according to the
248 Not all video controller support automatic scaling.
250 This function quits or exits leaving any of the system wide error codes.
251 Common error codes are listed below.
256 @param aAutoScaleType
257 Automatic scaling type
260 Video picture horizontal position, relative to the video window.
263 Video picture vertical position, relative to the video window.
266 The dimensions of the crop region, relative to the video image.
268 @leave Leaves with system wide error code.
271 EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
273 iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos, aCropRegion);
277 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
279 The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL.
280 Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
281 made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
284 Window to set rotation for.
287 The video rotation to use for aWindow.
290 The dimensions of the crop region, relative to the video image.
294 EXPORT_C void CMediaClientVideoDisplay::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion)
296 iBody->SetRotationL(aWindow, aRotation, aCropRegion);
300 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
302 The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL.
303 Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
304 made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
307 The video rotation to use for aWindow.
310 The dimensions of the crop region, relative to the video image.
314 EXPORT_C void CMediaClientVideoDisplay::SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion)
316 iBody->SetRotationL(aRotation, aCropRegion);
320 Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2.
323 Window to retrieve rotation for.
325 @return The video rotation.
329 EXPORT_C TVideoRotation CMediaClientVideoDisplay::RotationL(const RWindowBase& aWindow)
331 return iBody->RotationL(aWindow);
335 Scales the video image to a specified percentage of its original size within the window.
338 Window to set scale factor for.
340 @param aWidthPercentage
341 The percentage (100 = original size) to be used to scale the width of the video image
343 @param aHeightPercentage
344 The percentage (100 = original size) to be used to scale the height of the video image.
345 If this is not equal to aWidthPercentage then the image may be distorted.
348 The dimensions of the crop region, relative to the video image.
350 @see CVideoPlayerUtility2::SetScaleFactorL
353 EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
355 iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage, aCropRegion);
359 Scales the video image to a specified percentage of its original size within the window.
361 @param aWidthPercentage
362 The percentage (100 = original size) to be used to scale the width of the video image
364 @param aHeightPercentage
365 The percentage (100 = original size) to be used to scale the height of the video image.
366 If this is not equal to aWidthPercentage then the image may be distorted.
369 The dimensions of the crop region, relative to the video image.
371 @see CVideoPlayerUtility2::SetScaleFactorL
374 EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
376 iBody->SetScaleFactorL(aWidthPercentage, aHeightPercentage, aCropRegion);
380 Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2.
383 Window to retrieve scale factor for.
385 @param aWidthPercentage
386 On function return, contains the current scaling percentage applied to the width of the
387 video image (100 = original size).
389 @param aHeightPercentage
390 On function return, contains the current scaling percentage applied to the height
391 of the video image (100 = original size).
393 @see CVideoPlayerUtility2::GetScaleFactorL
396 EXPORT_C void CMediaClientVideoDisplay::GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage)
398 iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage);
402 Set video automatic scaling.
405 Video picture horizontal position, relative to the video window.
408 Video picture vertical position, relative to the video window.
411 The dimensions of the crop region, relative to the video image.
413 @see CVideoPlayerUtility2::SetAutoScaleL
417 EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
419 iBody->SetAutoScaleL(aScaleType, aHorizPos, aVertPos, aCropRegion);
423 Sets the window clipping rectangle, relative to the window.
426 Window to set clipping rectangle for.
428 @param aWindowClipRect
429 The window server session for this window.
432 The dimensions of the crop region, relative to the video image.
434 @see CVideoPlayerUtility2::SetWindowClipRectL
438 EXPORT_C void CMediaClientVideoDisplay::SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion)
440 iBody->SetWindowClipRectL(aWindow, aWindowClipRect, aCropRegion);
444 Sets the video extent on the screen, relative to the window.
447 Window to set video extent for.
450 The new video extent, relative to the video window.
453 The dimensions of the crop region, relative to the video image.
455 @see CVideoPlayerUtility2::SetWindowClipRectL
458 EXPORT_C void CMediaClientVideoDisplay::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion)
460 iBody->SetVideoExtentL(aWindow, aVideoExtent, aCropRegion);
464 Enables automatic switching of surface to/from external display when it is connected/disconnected from the device.
466 To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady.
469 ETrue to enable. EFalse to disable.
470 @leave KErrNotSupported Device does not support external displays
471 @leave KErrNotReady CActiveScheduler is not installed
474 EXPORT_C void CMediaClientVideoDisplay::SetExternalDisplaySwitchingL(TBool aControl)
476 iBody->SetExternalDisplaySwitchingL(aControl);