mmlibs/mmfw/src/Client/Video/mediaclientvideodisplay.cpp
changeset 0 40261b775718
child 7 94dbab0a2133
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2002-2009 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);
       
    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);
       
    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 removing the last window on a display will deregister the display
       
   156 	
       
   157 @param  aWindow
       
   158        	The display window.
       
   159 
       
   160 @return The window position that has been removed.
       
   161 
       
   162 */
       
   163 
       
   164 EXPORT_C TInt CMediaClientVideoDisplay::RemoveDisplayWindow(const RWindowBase& aWindow)
       
   165 	{
       
   166 	return iBody->RemoveDisplayWindow(aWindow);
       
   167 	}
       
   168 
       
   169 /**
       
   170 Must be called when a Surface has been Created.
       
   171 
       
   172 @param	aSurfaceId
       
   173 		The surface that has been created.
       
   174 		
       
   175 @param  aCropRect
       
   176 		The dimensions of the crop rectangle, relative to the video image.
       
   177 
       
   178 @param  aAspectRatio
       
   179        	The pixel aspect ratio to display video picture.
       
   180 
       
   181 @param  aCropRegion
       
   182 		The dimensions of the crop region, relative to the video image.
       
   183 		
       
   184 @return KErrNone is succesfully created, otherwise returns system wide error.
       
   185 
       
   186 */
       
   187 
       
   188 EXPORT_C TInt CMediaClientVideoDisplay::SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion)
       
   189 	{
       
   190 	return iBody->SurfaceCreated(aSurfaceId, aCropRect, aAspectRatio, aCropRegion);
       
   191 	}
       
   192 
       
   193 /**
       
   194 Must be called when the current surface is no longer being used.
       
   195 
       
   196 */
       
   197 	
       
   198 EXPORT_C void CMediaClientVideoDisplay::RemoveSurface()
       
   199 	{
       
   200 	iBody->RemoveSurface(ETrue);
       
   201 	}
       
   202 
       
   203 /** 
       
   204 
       
   205 Must be called when the video surface parameters have been changed.
       
   206 
       
   207 @param	aSurfaceId
       
   208 		The surface to be created for composition.
       
   209 		
       
   210 @param  aCropRect
       
   211 		The dimensions of the crop rectangle, relative to the video image.
       
   212 
       
   213 @param  aAspectRatio
       
   214        	The pixel aspect ratio to display video picture.
       
   215 
       
   216 @return KErrNone is succesfully created, otherwise returns KErrInUse if surface is not created.
       
   217 
       
   218 */
       
   219 
       
   220 EXPORT_C TInt CMediaClientVideoDisplay::SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio)
       
   221 	{
       
   222 	return iBody->SurfaceParametersChanged(aSurfaceId, aCropRect, aAspectRatio);
       
   223 	}
       
   224 
       
   225 /**
       
   226 Redraw all the windows with new crop region.
       
   227 	
       
   228 @param  aCropRegion
       
   229 		The dimensions of the crop region, relative to the video image.
       
   230 
       
   231 @return KErrNone is succesfully created, otherwise returns system wide error.
       
   232 */	
       
   233 
       
   234 EXPORT_C TInt CMediaClientVideoDisplay::RedrawWindows(const TRect& aCropRegion)
       
   235 	{
       
   236 	return iBody->RedrawWindows(aCropRegion);
       
   237 	}
       
   238 
       
   239 /** 
       
   240 Set video automatic scaling. When automatic scaling is active, the
       
   241 video picture is scaled automatically to match the video window,
       
   242 based on the scaling type, and positioned according to the
       
   243 parameters.
       
   244 
       
   245 Not all video controller support automatic scaling. 
       
   246 
       
   247 This function quits or exits leaving any of the system wide error codes.
       
   248 Common error codes are listed below.
       
   249 
       
   250 @param  aWindow
       
   251        	The display window
       
   252 
       
   253 @param  aAutoScaleType       	
       
   254        	Automatic scaling type
       
   255 
       
   256 @param  aHorizPos       	
       
   257        	Video picture horizontal position, relative to the video window. 
       
   258        	
       
   259 @param  aVertPos       	
       
   260        	Video picture vertical position, relative to the video window. 
       
   261 
       
   262 @param  aCropRegion
       
   263 		The dimensions of the crop region, relative to the video image.
       
   264  
       
   265 @leave Leaves with system wide error code.
       
   266 */
       
   267 
       
   268 EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
       
   269 	{
       
   270 	iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos, aCropRegion);
       
   271 	}
       
   272 
       
   273 /**
       
   274 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
       
   275 
       
   276 The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL. 
       
   277 Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
       
   278 made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
       
   279 
       
   280 @param aWindow 
       
   281 		Window to set rotation for.
       
   282 
       
   283 @param aRotation 
       
   284 		The video rotation to use for aWindow.
       
   285 
       
   286 @param  aCropRegion
       
   287 		The dimensions of the crop region, relative to the video image.
       
   288  
       
   289 */	
       
   290 
       
   291 EXPORT_C void CMediaClientVideoDisplay::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion)
       
   292 	{
       
   293 	iBody->SetRotationL(aWindow, aRotation, aCropRegion);
       
   294 	}
       
   295 
       
   296 /**
       
   297 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
       
   298 
       
   299 The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL. 
       
   300 Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
       
   301 made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
       
   302 
       
   303 @param aRotation 
       
   304 		The video rotation to use for aWindow.
       
   305 
       
   306 @param  aCropRegion
       
   307 		The dimensions of the crop region, relative to the video image.
       
   308  
       
   309 */
       
   310 
       
   311 EXPORT_C void CMediaClientVideoDisplay::SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion)
       
   312 	{
       
   313 	iBody->SetRotationL(aRotation, aCropRegion);
       
   314 	}
       
   315 
       
   316 /**
       
   317 Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2.
       
   318 
       
   319 @param aWindow 
       
   320 		Window to retrieve rotation for.
       
   321 		
       
   322 @return The video rotation.
       
   323 
       
   324 */	
       
   325 
       
   326 EXPORT_C TVideoRotation CMediaClientVideoDisplay::RotationL(const RWindowBase& aWindow)
       
   327 	{
       
   328 	return iBody->RotationL(aWindow);
       
   329 	}
       
   330 
       
   331 /**
       
   332 Scales the video image to a specified percentage of its original size within the window. 
       
   333 
       
   334 @param aWindow 
       
   335 		Window to set scale factor for.
       
   336 		
       
   337 @param aWidthPercentage
       
   338         The percentage (100 = original size) to be used to scale the width of the video image
       
   339         
       
   340 @param aHeightPercentage
       
   341         The percentage (100 = original size) to be used to scale the height of the video image. 
       
   342         If this is not equal to aWidthPercentage then the image may be distorted.
       
   343         
       
   344 @param  aCropRegion
       
   345 		The dimensions of the crop region, relative to the video image.
       
   346 
       
   347 @see CVideoPlayerUtility2::SetScaleFactorL
       
   348 */
       
   349 	
       
   350 EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
       
   351 	{
       
   352 	iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage, aCropRegion);
       
   353 	}
       
   354 
       
   355 /**
       
   356 Scales the video image to a specified percentage of its original size within the window. 
       
   357 
       
   358 @param aWidthPercentage
       
   359         The percentage (100 = original size) to be used to scale the width of the video image
       
   360         
       
   361 @param aHeightPercentage
       
   362         The percentage (100 = original size) to be used to scale the height of the video image. 
       
   363         If this is not equal to aWidthPercentage then the image may be distorted.
       
   364 
       
   365 @param  aCropRegion
       
   366 		The dimensions of the crop region, relative to the video image.
       
   367 		
       
   368 @see CVideoPlayerUtility2::SetScaleFactorL
       
   369 */
       
   370 	
       
   371 EXPORT_C void CMediaClientVideoDisplay::SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion)
       
   372 	{
       
   373 	iBody->SetScaleFactorL(aWidthPercentage, aHeightPercentage, aCropRegion);
       
   374 	}
       
   375 
       
   376 /**
       
   377 Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2.
       
   378 
       
   379 @param aWindow 
       
   380 		Window to retrieve scale factor for.
       
   381 		
       
   382 @param aWidthPercentage
       
   383         On function return, contains the current scaling percentage applied to the width of the
       
   384         video image (100 = original size).
       
   385         
       
   386 @param aHeightPercentage
       
   387         On function return, contains the current scaling percentage applied to the height
       
   388         of the video image (100 = original size).
       
   389         
       
   390 @see CVideoPlayerUtility2::GetScaleFactorL
       
   391 */
       
   392 	
       
   393 EXPORT_C void CMediaClientVideoDisplay::GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage)
       
   394 	{
       
   395 	iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage);
       
   396 	}
       
   397 
       
   398 /** 
       
   399 Set video automatic scaling.
       
   400 
       
   401 @param  aHorizPos       	
       
   402        	Video picture horizontal position, relative to the video window. 
       
   403        	
       
   404 @param  aVertPos       	
       
   405        	Video picture vertical position, relative to the video window. 
       
   406 
       
   407 @param  aCropRegion
       
   408 		The dimensions of the crop region, relative to the video image.
       
   409 
       
   410 @see CVideoPlayerUtility2::SetAutoScaleL
       
   411 
       
   412 */	
       
   413 
       
   414 EXPORT_C void CMediaClientVideoDisplay::SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion)
       
   415 	{
       
   416 	iBody->SetAutoScaleL(aScaleType, aHorizPos, aVertPos, aCropRegion);
       
   417 	}
       
   418 
       
   419 /**
       
   420 Sets the window clipping rectangle, relative to the window. 
       
   421 
       
   422 @param	aWindow
       
   423 		Window to set clipping rectangle for.
       
   424 		
       
   425 @param  aWindowClipRect
       
   426        	The window server session for this window.
       
   427        	
       
   428 @param  aCropRegion
       
   429 		The dimensions of the crop region, relative to the video image.
       
   430 
       
   431 @see CVideoPlayerUtility2::SetWindowClipRectL
       
   432 
       
   433 */
       
   434 
       
   435 EXPORT_C void CMediaClientVideoDisplay::SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion)
       
   436 	{
       
   437 	iBody->SetWindowClipRectL(aWindow, aWindowClipRect, aCropRegion);
       
   438 	}
       
   439 
       
   440 /**
       
   441 Sets the video extent on the screen, relative to the window. 
       
   442 
       
   443 @param  aWindow
       
   444 		Window to set video extent for.
       
   445 		
       
   446 @param  aVideoExtent
       
   447        	The new video extent, relative to the video window.
       
   448 
       
   449 @param  aCropRegion
       
   450 		The dimensions of the crop region, relative to the video image.
       
   451       	
       
   452 @see CVideoPlayerUtility2::SetWindowClipRectL
       
   453 */
       
   454 		
       
   455 EXPORT_C void CMediaClientVideoDisplay::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion)
       
   456 	{
       
   457 	iBody->SetVideoExtentL(aWindow, aVideoExtent, aCropRegion);
       
   458 	}
       
   459 
       
   460 /**
       
   461 Enables automatic switching of surface to/from external display when it is connected/disconnected from the device.
       
   462 
       
   463 To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady.
       
   464 
       
   465 @param  aEnable
       
   466         ETrue to enable. EFalse to disable.
       
   467 @leave  KErrNotSupported Device does not support external displays
       
   468 @leave  KErrNotReady CActiveScheduler is not installed
       
   469 */
       
   470 
       
   471 EXPORT_C void CMediaClientVideoDisplay::SetExternalDisplaySwitchingL(TBool aControl)
       
   472     {
       
   473     iBody->SetExternalDisplaySwitchingL(aControl);
       
   474     }