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