Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "mmfvideosurfacecustomcommands.h"
22 Class used when sending custom commands from the client API
23 to the video surface controller to get or set the video configuration.
25 class TMMFVideoSurfaceConfig
29 The surface ID for the display.
31 TSurfaceId iSurfaceId;
33 The crop region currently applied to the image.
37 The video picture pixel aspect ratio.
39 TVideoAspectRatio iPixelAspectRatio;
45 enum TMMFVideoPlaySurfaceSupportMessages
47 EMMFVideoPlaySurfaceSupportUseSurfaces,
48 EMMFVideoPlaySurfaceSupportGetSurfaceParameters,
49 EMMFVideoPlaySurfaceSupportSurfaceRemoved
52 EXPORT_C RMMFVideoPlaySurfaceSupportCustomCommands::RMMFVideoPlaySurfaceSupportCustomCommands(RMMFController& aController) :
53 RMMFCustomCommandsBase(aController, KUidInterfaceMMFVideoPlaySurfaceSupport)
57 EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::UseSurfaces() const
59 return iController.CustomCommandSync(iDestinationPckg,
60 EMMFVideoPlaySurfaceSupportUseSurfaces,
65 EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::GetSurfaceParameters(TSurfaceId& aSurfaceId,
66 TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio) const
68 TPckgBuf<TMMFVideoSurfaceConfig> configPackage;
70 TInt err = iController.CustomCommandSync(iDestinationPckg,
71 EMMFVideoPlaySurfaceSupportGetSurfaceParameters,
78 aSurfaceId = configPackage().iSurfaceId;
79 aCropRect = configPackage().iCropRectangle;
80 aPixelAspectRatio = configPackage().iPixelAspectRatio;
85 EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::SurfaceRemoved(TSurfaceId& aSurfaceId) const
87 TPckgBuf<TMMFVideoSurfaceConfig> configPackage;
89 configPackage().iSurfaceId = aSurfaceId;
91 return iController.CustomCommandSync(iDestinationPckg,
92 EMMFVideoPlaySurfaceSupportSurfaceRemoved,
97 EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser* CMMFVideoPlaySurfaceSupportCustomCommandParser::NewL(
98 MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor)
100 return new(ELeave) CMMFVideoPlaySurfaceSupportCustomCommandParser(aImplementor);
103 EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser::~CMMFVideoPlaySurfaceSupportCustomCommandParser()
107 CMMFVideoPlaySurfaceSupportCustomCommandParser::CMMFVideoPlaySurfaceSupportCustomCommandParser(
108 MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor) :
109 CMMFCustomCommandParserBase(KUidInterfaceMMFVideoPlaySurfaceSupport),
110 iImplementor(aImplementor)
114 void CMMFVideoPlaySurfaceSupportCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
116 if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFVideoPlaySurfaceSupport)
118 TRAPD(error, DoHandleRequestL(aMessage));
119 if (error != KErrNone)
121 aMessage.Complete(error);
126 aMessage.Complete(KErrNotSupported);
130 void CMMFVideoPlaySurfaceSupportCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
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())
137 case EMMFVideoPlaySurfaceSupportUseSurfaces:
138 complete = DoUseSurfacesL(aMessage);
140 case EMMFVideoPlaySurfaceSupportGetSurfaceParameters:
141 complete = DoGetSurfaceParametersL(aMessage);
143 case EMMFVideoPlaySurfaceSupportSurfaceRemoved:
144 complete = DoSurfaceRemovedL(aMessage);
148 User::Leave(KErrNotSupported);
153 aMessage.Complete(KErrNone);
157 TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoUseSurfacesL(TMMFMessage& /*aMessage*/)
159 iImplementor.MvpssUseSurfacesL();
163 TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoGetSurfaceParametersL(TMMFMessage& aMessage)
165 TPckgBuf<TMMFVideoSurfaceConfig> pckg;
166 iImplementor.MvpssGetSurfaceParametersL(pckg().iSurfaceId, pckg().iCropRectangle, pckg().iPixelAspectRatio );
167 aMessage.WriteDataToClientL(pckg);
171 TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoSurfaceRemovedL(TMMFMessage& aMessage)
173 TPckgBuf<TMMFVideoSurfaceConfig> pckg;
175 aMessage.ReadData1FromClientL(pckg);
176 iImplementor.MvpssSurfaceRemovedL(pckg().iSurfaceId);