sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "mmfvideosurfacecustomcommands.h" sl@0: sl@0: /** sl@0: @internalTechnology sl@0: @prototype sl@0: sl@0: Class used when sending custom commands from the client API sl@0: to the video surface controller to get or set the video configuration. sl@0: */ sl@0: class TMMFVideoSurfaceConfig sl@0: { sl@0: public: sl@0: /** sl@0: The surface ID for the display. sl@0: */ sl@0: TSurfaceId iSurfaceId; sl@0: /** sl@0: The crop region currently applied to the image. sl@0: */ sl@0: TRect iCropRectangle; sl@0: /** sl@0: The video picture pixel aspect ratio. sl@0: */ sl@0: TVideoAspectRatio iPixelAspectRatio; sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: enum TMMFVideoPlaySurfaceSupportMessages sl@0: { sl@0: EMMFVideoPlaySurfaceSupportUseSurfaces, sl@0: EMMFVideoPlaySurfaceSupportGetSurfaceParameters, sl@0: EMMFVideoPlaySurfaceSupportSurfaceRemoved sl@0: }; sl@0: sl@0: EXPORT_C RMMFVideoPlaySurfaceSupportCustomCommands::RMMFVideoPlaySurfaceSupportCustomCommands(RMMFController& aController) : sl@0: RMMFCustomCommandsBase(aController, KUidInterfaceMMFVideoPlaySurfaceSupport) sl@0: { sl@0: } sl@0: sl@0: EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::UseSurfaces() const sl@0: { sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFVideoPlaySurfaceSupportUseSurfaces, sl@0: KNullDesC8, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::GetSurfaceParameters(TSurfaceId& aSurfaceId, sl@0: TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: sl@0: TInt err = iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFVideoPlaySurfaceSupportGetSurfaceParameters, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: configPackage); sl@0: sl@0: if (!err) sl@0: { sl@0: aSurfaceId = configPackage().iSurfaceId; sl@0: aCropRect = configPackage().iCropRectangle; sl@0: aPixelAspectRatio = configPackage().iPixelAspectRatio; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: EXPORT_C TInt RMMFVideoPlaySurfaceSupportCustomCommands::SurfaceRemoved(TSurfaceId& aSurfaceId) const sl@0: { sl@0: TPckgBuf configPackage; sl@0: sl@0: configPackage().iSurfaceId = aSurfaceId; sl@0: sl@0: return iController.CustomCommandSync(iDestinationPckg, sl@0: EMMFVideoPlaySurfaceSupportSurfaceRemoved, sl@0: configPackage, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser* CMMFVideoPlaySurfaceSupportCustomCommandParser::NewL( sl@0: MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor) sl@0: { sl@0: return new(ELeave) CMMFVideoPlaySurfaceSupportCustomCommandParser(aImplementor); sl@0: } sl@0: sl@0: EXPORT_C CMMFVideoPlaySurfaceSupportCustomCommandParser::~CMMFVideoPlaySurfaceSupportCustomCommandParser() sl@0: { sl@0: } sl@0: sl@0: CMMFVideoPlaySurfaceSupportCustomCommandParser::CMMFVideoPlaySurfaceSupportCustomCommandParser( sl@0: MMMFVideoPlaySurfaceSupportCustomCommandImplementor& aImplementor) : sl@0: CMMFCustomCommandParserBase(KUidInterfaceMMFVideoPlaySurfaceSupport), sl@0: iImplementor(aImplementor) sl@0: { sl@0: } sl@0: sl@0: void CMMFVideoPlaySurfaceSupportCustomCommandParser::HandleRequest(TMMFMessage& aMessage) sl@0: { sl@0: if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFVideoPlaySurfaceSupport) sl@0: { sl@0: TRAPD(error, DoHandleRequestL(aMessage)); sl@0: if (error != KErrNone) sl@0: { sl@0: aMessage.Complete(error); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: aMessage.Complete(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: void CMMFVideoPlaySurfaceSupportCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: // Keep the same style of the implemetation for future maintainance and flexibility in sl@0: // case of the asynchronous event. sl@0: TBool complete = ETrue; sl@0: switch (aMessage.Function()) sl@0: { sl@0: case EMMFVideoPlaySurfaceSupportUseSurfaces: sl@0: complete = DoUseSurfacesL(aMessage); sl@0: break; sl@0: case EMMFVideoPlaySurfaceSupportGetSurfaceParameters: sl@0: complete = DoGetSurfaceParametersL(aMessage); sl@0: break; sl@0: case EMMFVideoPlaySurfaceSupportSurfaceRemoved: sl@0: complete = DoSurfaceRemovedL(aMessage); sl@0: break; sl@0: sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: break; sl@0: } sl@0: if (complete) sl@0: { sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: } sl@0: sl@0: TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoUseSurfacesL(TMMFMessage& /*aMessage*/) sl@0: { sl@0: iImplementor.MvpssUseSurfacesL(); sl@0: return ETrue; sl@0: } sl@0: sl@0: TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoGetSurfaceParametersL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckg; sl@0: iImplementor.MvpssGetSurfaceParametersL(pckg().iSurfaceId, pckg().iCropRectangle, pckg().iPixelAspectRatio ); sl@0: aMessage.WriteDataToClientL(pckg); sl@0: return ETrue; sl@0: } sl@0: sl@0: TBool CMMFVideoPlaySurfaceSupportCustomCommandParser::DoSurfaceRemovedL(TMMFMessage& aMessage) sl@0: { sl@0: TPckgBuf pckg; sl@0: sl@0: aMessage.ReadData1FromClientL(pckg); sl@0: iImplementor.MvpssSurfaceRemovedL(pckg().iSurfaceId); sl@0: return ETrue; sl@0: } sl@0: sl@0: