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