os/mm/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplay.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <mediaclientvideodisplay.h>
    17 #include "mediaclientvideodisplaybody.h"
    18 
    19 
    20 /**
    21 Constructs and initialises a new instance of the client video data to display image 
    22 on window or graphics surface.
    23 
    24 The function leaves if the video display object cannot be created.
    25 
    26 @param aDisplayId
    27 		A display ID.
    28 		
    29 @return A pointer to the new video display object.
    30 */
    31 
    32 EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId)
    33 	{
    34 	CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay();
    35 	CleanupStack::PushL(self);
    36 	self->ConstructL(aDisplayId);
    37 	CleanupStack::Pop(self);
    38 	return self;
    39 	}
    40 
    41 /**
    42 Constructs and initialises a new instance of the client video data to display image 
    43 on window or graphics surface.
    44 
    45 The function leaves if the video display object cannot be created.
    46 
    47 @param aDisplayId
    48 		A display ID.
    49 		
    50 @param	aSurfaceId
    51 		The surface that has been created.
    52 		
    53 @param  aCropRect
    54 		The dimensions of the crop rectangle, relative to the video image.
    55 
    56 @param  aAspectRatio
    57        	The pixel aspect ratio to display video picture.
    58        	
    59 @return A pointer to the new video display object.
    60 */
    61 
    62 EXPORT_C CMediaClientVideoDisplay* CMediaClientVideoDisplay::NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
    63 	{
    64 	CMediaClientVideoDisplay* self = new (ELeave) CMediaClientVideoDisplay();
    65 	CleanupStack::PushL(self);
    66 	self->ConstructL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio);
    67 	CleanupStack::Pop(self);
    68 	return self;
    69 	}
    70 
    71 CMediaClientVideoDisplay::CMediaClientVideoDisplay()
    72 	{	
    73 	}
    74 
    75 
    76 void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId)
    77 	{
    78 	iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, ETrue);
    79 	}
    80 
    81 void CMediaClientVideoDisplay::ConstructL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
    82 	{
    83 	iBody = CMediaClientVideoDisplayBody::NewL(aDisplayId, aSurfaceId, aCropRect, aAspectRatio, ETrue);
    84 	}
    85 
    86 /**
    87 Destructor.
    88 
    89 Releases resources owned by the object prior to its destruction.
    90 */
    91 	
    92 EXPORT_C CMediaClientVideoDisplay::~CMediaClientVideoDisplay()
    93 	{
    94 	delete iBody;
    95 	}
    96 
    97 /**
    98 Adds a new window for displaying the video picture. 
    99 	
   100 @param  aWindow
   101        	The display window.
   102 
   103 @param  aClipRect
   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.
   107 
   108 @param  aCropRegion
   109 		The dimensions of the crop region, relative to the video image.
   110 		
   111 @param  aVideoExtent
   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.
   115 
   116 @param  aScaleWidth       	
   117        	Scaling the width of the video frame.
   118 
   119 @param  aScaleHeight       	
   120        	Scaling the height of the video frame.
   121 
   122 @param  aRotation       	
   123        	The desired rotation to apply in 90 degree increments.
   124 
   125 @param  aAutoScaleType       	
   126        	Automatic scaling type.
   127 
   128 @param  aHorizPos       	
   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.
   132 
   133 @param  aVertPos       	
   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.
   137 
   138 @param  aWindow2
   139        	The display window, aWindow2 is used when using CVideoPlayerUtility2. This is used to avoid 
   140 		casting iWindow from RWindowBase* to RWindow*.
   141      	       	       	       	
   142 */
   143 	
   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)
   147 	{
   148 	iBody->AddDisplayWindowL(aWindow, aClipRect, aCropRegion, aVideoExtent, aScaleWidth, aScaleHeight, aRotation,aAutoScaleType, aHorizPos, aVertPos, aWindow2); 															 															
   149 	}
   150 
   151 /**
   152 Removes a window that is currently being used to display the video picture. The window must
   153 have previously been added with AddDisplayWindowL(). 
   154 
   155 Note Depending on underlying implementation it may also remove any graphics resources associated
   156 with video playback on this window. 
   157 
   158 Note removing the last window on a display will deregister the display
   159 	
   160 @param  aWindow
   161        	The display window.
   162 
   163 @return The window position that has been removed.
   164 
   165 */
   166 
   167 EXPORT_C TInt CMediaClientVideoDisplay::RemoveDisplayWindow(const RWindowBase& aWindow)
   168 	{
   169 	return iBody->RemoveDisplayWindow(aWindow);
   170 	}
   171 
   172 /**
   173 Must be called when a Surface has been Created.
   174 
   175 @param	aSurfaceId
   176 		The surface that has been created.
   177 		
   178 @param  aCropRect
   179 		The dimensions of the crop rectangle, relative to the video image.
   180 
   181 @param  aAspectRatio
   182        	The pixel aspect ratio to display video picture.
   183 
   184 @param  aCropRegion
   185 		The dimensions of the crop region, relative to the video image.
   186 		
   187 @return KErrNone is succesfully created, otherwise returns system wide error.
   188 
   189 */
   190 
   191 EXPORT_C TInt CMediaClientVideoDisplay::SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion)
   192 	{
   193 	return iBody->SurfaceCreated(aSurfaceId, aCropRect, aAspectRatio, aCropRegion);
   194 	}
   195 
   196 /**
   197 Must be called when the current surface is no longer being used.
   198 
   199 */
   200 	
   201 EXPORT_C void CMediaClientVideoDisplay::RemoveSurface()
   202 	{
   203 	iBody->RemoveSurface(ETrue);
   204 	}
   205 
   206 /** 
   207 
   208 Must be called when the video surface parameters have been changed.
   209 
   210 @param	aSurfaceId
   211 		The surface to be created for composition.
   212 		
   213 @param  aCropRect
   214 		The dimensions of the crop rectangle, relative to the video image.
   215 
   216 @param  aAspectRatio
   217        	The pixel aspect ratio to display video picture.
   218 
   219 @return KErrNone is succesfully created, otherwise returns KErrInUse if surface is not created.
   220 
   221 */
   222 
   223 EXPORT_C TInt CMediaClientVideoDisplay::SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
   224 	{
   225 	return iBody->SurfaceParametersChanged(aSurfaceId, aCropRect, aAspectRatio);
   226 	}
   227 
   228 /**
   229 Redraw all the windows with new crop region.
   230 	
   231 @param  aCropRegion
   232 		The dimensions of the crop region, relative to the video image.
   233 
   234 @return KErrNone is succesfully created, otherwise returns system wide error.
   235 */	
   236 
   237 EXPORT_C TInt CMediaClientVideoDisplay::RedrawWindows(const TRect& aCropRegion)
   238 	{
   239 	return iBody->RedrawWindows(aCropRegion);
   240 	}
   241 
   242 /** 
   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
   246 parameters.
   247 
   248 Not all video controller support automatic scaling. 
   249 
   250 This function quits or exits leaving any of the system wide error codes.
   251 Common error codes are listed below.
   252 
   253 @param  aWindow
   254        	The display window
   255 
   256 @param  aAutoScaleType       	
   257        	Automatic scaling type
   258 
   259 @param  aHorizPos       	
   260        	Video picture horizontal position, relative to the video window. 
   261        	
   262 @param  aVertPos       	
   263        	Video picture vertical position, relative to the video window. 
   264 
   265 @param  aCropRegion
   266 		The dimensions of the crop region, relative to the video image.
   267  
   268 @leave Leaves with system wide error code.
   269 */
   270 
   271 EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
   272 	{
   273 	iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos, aCropRegion);
   274 	}
   275 
   276 /**
   277 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
   278 
   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.
   282 
   283 @param aWindow 
   284 		Window to set rotation for.
   285 
   286 @param aRotation 
   287 		The video rotation to use for aWindow.
   288 
   289 @param  aCropRegion
   290 		The dimensions of the crop region, relative to the video image.
   291  
   292 */	
   293 
   294 EXPORT_C void CMediaClientVideoDisplay::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion)
   295 	{
   296 	iBody->SetRotationL(aWindow, aRotation, aCropRegion);
   297 	}
   298 
   299 /**
   300 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
   301 
   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.
   305 
   306 @param aRotation 
   307 		The video rotation to use for aWindow.
   308 
   309 @param  aCropRegion
   310 		The dimensions of the crop region, relative to the video image.
   311  
   312 */
   313 
   314 EXPORT_C void CMediaClientVideoDisplay::SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion)
   315 	{
   316 	iBody->SetRotationL(aRotation, aCropRegion);
   317 	}
   318 
   319 /**
   320 Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2.
   321 
   322 @param aWindow 
   323 		Window to retrieve rotation for.
   324 		
   325 @return The video rotation.
   326 
   327 */	
   328 
   329 EXPORT_C TVideoRotation CMediaClientVideoDisplay::RotationL(const RWindowBase& aWindow)
   330 	{
   331 	return iBody->RotationL(aWindow);
   332 	}
   333 
   334 /**
   335 Scales the video image to a specified percentage of its original size within the window. 
   336 
   337 @param aWindow 
   338 		Window to set scale factor for.
   339 		
   340 @param aWidthPercentage
   341         The percentage (100 = original size) to be used to scale the width of the video image
   342         
   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.
   346         
   347 @param  aCropRegion
   348 		The dimensions of the crop region, relative to the video image.
   349 
   350 @see CVideoPlayerUtility2::SetScaleFactorL
   351 */
   352 	
   353 EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
   354 	{
   355 	iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage, aCropRegion);
   356 	}
   357 
   358 /**
   359 Scales the video image to a specified percentage of its original size within the window. 
   360 
   361 @param aWidthPercentage
   362         The percentage (100 = original size) to be used to scale the width of the video image
   363         
   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.
   367 
   368 @param  aCropRegion
   369 		The dimensions of the crop region, relative to the video image.
   370 		
   371 @see CVideoPlayerUtility2::SetScaleFactorL
   372 */
   373 	
   374 EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
   375 	{
   376 	iBody->SetScaleFactorL(aWidthPercentage, aHeightPercentage, aCropRegion);
   377 	}
   378 
   379 /**
   380 Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2.
   381 
   382 @param aWindow 
   383 		Window to retrieve scale factor for.
   384 		
   385 @param aWidthPercentage
   386         On function return, contains the current scaling percentage applied to the width of the
   387         video image (100 = original size).
   388         
   389 @param aHeightPercentage
   390         On function return, contains the current scaling percentage applied to the height
   391         of the video image (100 = original size).
   392         
   393 @see CVideoPlayerUtility2::GetScaleFactorL
   394 */
   395 	
   396 EXPORT_C void CMediaClientVideoDisplay::GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage)
   397 	{
   398 	iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage);
   399 	}
   400 
   401 /** 
   402 Set video automatic scaling.
   403 
   404 @param  aHorizPos       	
   405        	Video picture horizontal position, relative to the video window. 
   406        	
   407 @param  aVertPos       	
   408        	Video picture vertical position, relative to the video window. 
   409 
   410 @param  aCropRegion
   411 		The dimensions of the crop region, relative to the video image.
   412 
   413 @see CVideoPlayerUtility2::SetAutoScaleL
   414 
   415 */	
   416 
   417 EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
   418 	{
   419 	iBody->SetAutoScaleL(aScaleType, aHorizPos, aVertPos, aCropRegion);
   420 	}
   421 
   422 /**
   423 Sets the window clipping rectangle, relative to the window. 
   424 
   425 @param	aWindow
   426 		Window to set clipping rectangle for.
   427 		
   428 @param  aWindowClipRect
   429        	The window server session for this window.
   430        	
   431 @param  aCropRegion
   432 		The dimensions of the crop region, relative to the video image.
   433 
   434 @see CVideoPlayerUtility2::SetWindowClipRectL
   435 
   436 */
   437 
   438 EXPORT_C void CMediaClientVideoDisplay::SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion)
   439 	{
   440 	iBody->SetWindowClipRectL(aWindow, aWindowClipRect, aCropRegion);
   441 	}
   442 
   443 /**
   444 Sets the video extent on the screen, relative to the window. 
   445 
   446 @param  aWindow
   447 		Window to set video extent for.
   448 		
   449 @param  aVideoExtent
   450        	The new video extent, relative to the video window.
   451 
   452 @param  aCropRegion
   453 		The dimensions of the crop region, relative to the video image.
   454       	
   455 @see CVideoPlayerUtility2::SetWindowClipRectL
   456 */
   457 		
   458 EXPORT_C void CMediaClientVideoDisplay::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion)
   459 	{
   460 	iBody->SetVideoExtentL(aWindow, aVideoExtent, aCropRegion);
   461 	}
   462 
   463 /**
   464 Enables automatic switching of surface to/from external display when it is connected/disconnected from the device.
   465 
   466 To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady.
   467 
   468 @param  aEnable
   469         ETrue to enable. EFalse to disable.
   470 @leave  KErrNotSupported Device does not support external displays
   471 @leave  KErrNotReady CActiveScheduler is not installed
   472 */
   473 
   474 EXPORT_C void CMediaClientVideoDisplay::SetExternalDisplaySwitchingL(TBool aControl)
   475     {
   476     iBody->SetExternalDisplaySwitchingL(aControl);
   477     }