os/mm/mmlibs/mmfw/src/ControllerFramework/mmfvideosurfacecustomcommands.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 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 "mmfvideosurfacecustomcommands.h"
sl@0
    17
sl@0
    18
/**
sl@0
    19
@internalTechnology
sl@0
    20
@prototype
sl@0
    21
sl@0
    22
Class used when sending custom commands from the client API
sl@0
    23
to the video surface controller to get or set the video configuration.
sl@0
    24
*/
sl@0
    25
class TMMFVideoSurfaceConfig
sl@0
    26
	{
sl@0
    27
public:
sl@0
    28
	/**
sl@0
    29
	The surface ID for the display.
sl@0
    30
	*/
sl@0
    31
	TSurfaceId					iSurfaceId;
sl@0
    32
	/**
sl@0
    33
	The crop region currently applied to the image.
sl@0
    34
	*/
sl@0
    35
	TRect						iCropRectangle;
sl@0
    36
	/**
sl@0
    37
	The video picture pixel aspect ratio.
sl@0
    38
	*/
sl@0
    39
	TVideoAspectRatio			iPixelAspectRatio;
sl@0
    40
	};
sl@0
    41
	
sl@0
    42
/**
sl@0
    43
@internalComponent
sl@0
    44
*/
sl@0
    45
enum TMMFVideoPlaySurfaceSupportMessages
sl@0
    46
	{
sl@0
    47
	EMMFVideoPlaySurfaceSupportUseSurfaces,
sl@0
    48
	EMMFVideoPlaySurfaceSupportGetSurfaceParameters,
sl@0
    49
	EMMFVideoPlaySurfaceSupportSurfaceRemoved
sl@0
    50
	};
sl@0
    51
sl@0
    52
EXPORT_C RMMFVideoPlaySurfaceSupportCustomCommands::RMMFVideoPlaySurfaceSupportCustomCommands(RMMFController& aController) :
sl@0
    53
	RMMFCustomCommandsBase(aController, KUidInterfaceMMFVideoPlaySurfaceSupport)
sl@0
    54
	{
sl@0
    55
	}
sl@0
    56
sl@0
    57
EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::UseSurfaces() const
sl@0
    58
	{
sl@0
    59
	return iController.CustomCommandSync(iDestinationPckg,
sl@0
    60
										EMMFVideoPlaySurfaceSupportUseSurfaces,
sl@0
    61
										KNullDesC8,
sl@0
    62
										KNullDesC8);
sl@0
    63
	}
sl@0
    64
sl@0
    65
EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::GetSurfaceParameters(TSurfaceId& aSurfaceId,
sl@0
    66
													TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio) const
sl@0
    67
	{
sl@0
    68
	TPckgBuf<TMMFVideoSurfaceConfig> configPackage;
sl@0
    69
	
sl@0
    70
	TInt err = iController.CustomCommandSync(iDestinationPckg, 
sl@0
    71
										 EMMFVideoPlaySurfaceSupportGetSurfaceParameters, 
sl@0
    72
										 KNullDesC8,
sl@0
    73
										 KNullDesC8,
sl@0
    74
										 configPackage);
sl@0
    75
sl@0
    76
	if (!err)
sl@0
    77
		{
sl@0
    78
		aSurfaceId = configPackage().iSurfaceId;
sl@0
    79
		aCropRect = configPackage().iCropRectangle;
sl@0
    80
		aPixelAspectRatio = configPackage().iPixelAspectRatio;
sl@0
    81
		}
sl@0
    82
	return err;
sl@0
    83
	}
sl@0
    84
sl@0
    85
EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::SurfaceRemoved(TSurfaceId& aSurfaceId) const
sl@0
    86
	{
sl@0
    87
	TPckgBuf<TMMFVideoSurfaceConfig> configPackage;
sl@0
    88
	
sl@0
    89
	configPackage().iSurfaceId = aSurfaceId;
sl@0
    90
sl@0
    91
	return iController.CustomCommandSync(iDestinationPckg, 
sl@0
    92
										 EMMFVideoPlaySurfaceSupportSurfaceRemoved, 
sl@0
    93
										 configPackage,
sl@0
    94
										 KNullDesC8);
sl@0
    95
	}
sl@0
    96
sl@0
    97
EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser* CMMFVideoPlaySurfaceSupportCustomCommandParser::NewL(
sl@0
    98
													MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor)
sl@0
    99
	{
sl@0
   100
	return new(ELeave) CMMFVideoPlaySurfaceSupportCustomCommandParser(aImplementor);
sl@0
   101
	}
sl@0
   102
sl@0
   103
EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser::~CMMFVideoPlaySurfaceSupportCustomCommandParser()
sl@0
   104
	{
sl@0
   105
	}
sl@0
   106
sl@0
   107
CMMFVideoPlaySurfaceSupportCustomCommandParser::CMMFVideoPlaySurfaceSupportCustomCommandParser(
sl@0
   108
										MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor) :
sl@0
   109
	CMMFCustomCommandParserBase(KUidInterfaceMMFVideoPlaySurfaceSupport),
sl@0
   110
	iImplementor(aImplementor)
sl@0
   111
	{
sl@0
   112
	}
sl@0
   113
sl@0
   114
void CMMFVideoPlaySurfaceSupportCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
sl@0
   115
	{
sl@0
   116
	if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFVideoPlaySurfaceSupport)
sl@0
   117
		{
sl@0
   118
		TRAPD(error, DoHandleRequestL(aMessage));
sl@0
   119
		if (error != KErrNone)
sl@0
   120
			{
sl@0
   121
			aMessage.Complete(error);
sl@0
   122
			}
sl@0
   123
		}
sl@0
   124
	else
sl@0
   125
		{
sl@0
   126
		aMessage.Complete(KErrNotSupported);
sl@0
   127
		}
sl@0
   128
	}
sl@0
   129
sl@0
   130
void CMMFVideoPlaySurfaceSupportCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
sl@0
   131
	{
sl@0
   132
	// Keep the same style of the implemetation for future maintainance and flexibility in
sl@0
   133
	// case of the asynchronous event.	
sl@0
   134
	TBool complete = ETrue;
sl@0
   135
	switch (aMessage.Function())
sl@0
   136
		{
sl@0
   137
	case EMMFVideoPlaySurfaceSupportUseSurfaces:
sl@0
   138
		complete = DoUseSurfacesL(aMessage);
sl@0
   139
		break;
sl@0
   140
	case EMMFVideoPlaySurfaceSupportGetSurfaceParameters:
sl@0
   141
		complete = DoGetSurfaceParametersL(aMessage);
sl@0
   142
		break;
sl@0
   143
	case EMMFVideoPlaySurfaceSupportSurfaceRemoved:
sl@0
   144
		complete = DoSurfaceRemovedL(aMessage);
sl@0
   145
		break;
sl@0
   146
sl@0
   147
	default:
sl@0
   148
		User::Leave(KErrNotSupported);
sl@0
   149
		break;
sl@0
   150
		}
sl@0
   151
	if (complete)
sl@0
   152
		{
sl@0
   153
		aMessage.Complete(KErrNone);
sl@0
   154
		}
sl@0
   155
	}
sl@0
   156
sl@0
   157
TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoUseSurfacesL(TMMFMessage& /*aMessage*/)
sl@0
   158
	{
sl@0
   159
	iImplementor.MvpssUseSurfacesL();
sl@0
   160
	return ETrue;
sl@0
   161
	}
sl@0
   162
sl@0
   163
TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoGetSurfaceParametersL(TMMFMessage& aMessage)
sl@0
   164
	{
sl@0
   165
	TPckgBuf<TMMFVideoSurfaceConfig> pckg;
sl@0
   166
	iImplementor.MvpssGetSurfaceParametersL(pckg().iSurfaceId, pckg().iCropRectangle, pckg().iPixelAspectRatio );
sl@0
   167
	aMessage.WriteDataToClientL(pckg);
sl@0
   168
	return ETrue;
sl@0
   169
	}
sl@0
   170
sl@0
   171
TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoSurfaceRemovedL(TMMFMessage& aMessage)
sl@0
   172
	{
sl@0
   173
	TPckgBuf<TMMFVideoSurfaceConfig> pckg;
sl@0
   174
sl@0
   175
	aMessage.ReadData1FromClientL(pckg);
sl@0
   176
	iImplementor.MvpssSurfaceRemovedL(pckg().iSurfaceId);
sl@0
   177
	return ETrue;
sl@0
   178
	}
sl@0
   179
sl@0
   180