1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/ControllerFramework/mmfvideosurfacecustomcommands.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,180 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "mmfvideosurfacecustomcommands.h"
1.20 +
1.21 +/**
1.22 +@internalTechnology
1.23 +@prototype
1.24 +
1.25 +Class used when sending custom commands from the client API
1.26 +to the video surface controller to get or set the video configuration.
1.27 +*/
1.28 +class TMMFVideoSurfaceConfig
1.29 + {
1.30 +public:
1.31 + /**
1.32 + The surface ID for the display.
1.33 + */
1.34 + TSurfaceId iSurfaceId;
1.35 + /**
1.36 + The crop region currently applied to the image.
1.37 + */
1.38 + TRect iCropRectangle;
1.39 + /**
1.40 + The video picture pixel aspect ratio.
1.41 + */
1.42 + TVideoAspectRatio iPixelAspectRatio;
1.43 + };
1.44 +
1.45 +/**
1.46 +@internalComponent
1.47 +*/
1.48 +enum TMMFVideoPlaySurfaceSupportMessages
1.49 + {
1.50 + EMMFVideoPlaySurfaceSupportUseSurfaces,
1.51 + EMMFVideoPlaySurfaceSupportGetSurfaceParameters,
1.52 + EMMFVideoPlaySurfaceSupportSurfaceRemoved
1.53 + };
1.54 +
1.55 +EXPORT_C RMMFVideoPlaySurfaceSupportCustomCommands::RMMFVideoPlaySurfaceSupportCustomCommands(RMMFController& aController) :
1.56 + RMMFCustomCommandsBase(aController, KUidInterfaceMMFVideoPlaySurfaceSupport)
1.57 + {
1.58 + }
1.59 +
1.60 +EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::UseSurfaces() const
1.61 + {
1.62 + return iController.CustomCommandSync(iDestinationPckg,
1.63 + EMMFVideoPlaySurfaceSupportUseSurfaces,
1.64 + KNullDesC8,
1.65 + KNullDesC8);
1.66 + }
1.67 +
1.68 +EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::GetSurfaceParameters(TSurfaceId& aSurfaceId,
1.69 + TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio) const
1.70 + {
1.71 + TPckgBuf<TMMFVideoSurfaceConfig> configPackage;
1.72 +
1.73 + TInt err = iController.CustomCommandSync(iDestinationPckg,
1.74 + EMMFVideoPlaySurfaceSupportGetSurfaceParameters,
1.75 + KNullDesC8,
1.76 + KNullDesC8,
1.77 + configPackage);
1.78 +
1.79 + if (!err)
1.80 + {
1.81 + aSurfaceId = configPackage().iSurfaceId;
1.82 + aCropRect = configPackage().iCropRectangle;
1.83 + aPixelAspectRatio = configPackage().iPixelAspectRatio;
1.84 + }
1.85 + return err;
1.86 + }
1.87 +
1.88 +EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::SurfaceRemoved(TSurfaceId& aSurfaceId) const
1.89 + {
1.90 + TPckgBuf<TMMFVideoSurfaceConfig> configPackage;
1.91 +
1.92 + configPackage().iSurfaceId = aSurfaceId;
1.93 +
1.94 + return iController.CustomCommandSync(iDestinationPckg,
1.95 + EMMFVideoPlaySurfaceSupportSurfaceRemoved,
1.96 + configPackage,
1.97 + KNullDesC8);
1.98 + }
1.99 +
1.100 +EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser* CMMFVideoPlaySurfaceSupportCustomCommandParser::NewL(
1.101 + MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor)
1.102 + {
1.103 + return new(ELeave) CMMFVideoPlaySurfaceSupportCustomCommandParser(aImplementor);
1.104 + }
1.105 +
1.106 +EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser::~CMMFVideoPlaySurfaceSupportCustomCommandParser()
1.107 + {
1.108 + }
1.109 +
1.110 +CMMFVideoPlaySurfaceSupportCustomCommandParser::CMMFVideoPlaySurfaceSupportCustomCommandParser(
1.111 + MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor) :
1.112 + CMMFCustomCommandParserBase(KUidInterfaceMMFVideoPlaySurfaceSupport),
1.113 + iImplementor(aImplementor)
1.114 + {
1.115 + }
1.116 +
1.117 +void CMMFVideoPlaySurfaceSupportCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
1.118 + {
1.119 + if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFVideoPlaySurfaceSupport)
1.120 + {
1.121 + TRAPD(error, DoHandleRequestL(aMessage));
1.122 + if (error != KErrNone)
1.123 + {
1.124 + aMessage.Complete(error);
1.125 + }
1.126 + }
1.127 + else
1.128 + {
1.129 + aMessage.Complete(KErrNotSupported);
1.130 + }
1.131 + }
1.132 +
1.133 +void CMMFVideoPlaySurfaceSupportCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
1.134 + {
1.135 + // Keep the same style of the implemetation for future maintainance and flexibility in
1.136 + // case of the asynchronous event.
1.137 + TBool complete = ETrue;
1.138 + switch (aMessage.Function())
1.139 + {
1.140 + case EMMFVideoPlaySurfaceSupportUseSurfaces:
1.141 + complete = DoUseSurfacesL(aMessage);
1.142 + break;
1.143 + case EMMFVideoPlaySurfaceSupportGetSurfaceParameters:
1.144 + complete = DoGetSurfaceParametersL(aMessage);
1.145 + break;
1.146 + case EMMFVideoPlaySurfaceSupportSurfaceRemoved:
1.147 + complete = DoSurfaceRemovedL(aMessage);
1.148 + break;
1.149 +
1.150 + default:
1.151 + User::Leave(KErrNotSupported);
1.152 + break;
1.153 + }
1.154 + if (complete)
1.155 + {
1.156 + aMessage.Complete(KErrNone);
1.157 + }
1.158 + }
1.159 +
1.160 +TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoUseSurfacesL(TMMFMessage& /*aMessage*/)
1.161 + {
1.162 + iImplementor.MvpssUseSurfacesL();
1.163 + return ETrue;
1.164 + }
1.165 +
1.166 +TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoGetSurfaceParametersL(TMMFMessage& aMessage)
1.167 + {
1.168 + TPckgBuf<TMMFVideoSurfaceConfig> pckg;
1.169 + iImplementor.MvpssGetSurfaceParametersL(pckg().iSurfaceId, pckg().iCropRectangle, pckg().iPixelAspectRatio );
1.170 + aMessage.WriteDataToClientL(pckg);
1.171 + return ETrue;
1.172 + }
1.173 +
1.174 +TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoSurfaceRemovedL(TMMFMessage& aMessage)
1.175 + {
1.176 + TPckgBuf<TMMFVideoSurfaceConfig> pckg;
1.177 +
1.178 + aMessage.ReadData1FromClientL(pckg);
1.179 + iImplementor.MvpssSurfaceRemovedL(pckg().iSurfaceId);
1.180 + return ETrue;
1.181 + }
1.182 +
1.183 +