sl@0: // Copyright (c) 2002-2010 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: #ifndef MEDIACLIENTVIDEODISPLAYBODY_H sl@0: #define MEDIACLIENTVIDEODISPLAYBODY_H sl@0: sl@0: #include "mediaclientextdisplayhandler.h" sl@0: #include "mediaclientwseventobserver.h" sl@0: #include <graphics/surface.h> sl@0: #include <graphics/surfaceconfiguration.h> sl@0: #include <mmf/common/mmfvideosurfacecustomcommands.h> sl@0: #include <videoplayer.h> sl@0: #include <mmf/plugin/mmfmediaclientextdisplayinterface.h> sl@0: sl@0: class MMMFSurfaceEventHandler; sl@0: class CMediaClientPolicyServerClient; sl@0: sl@0: /** sl@0: @internalTechnology sl@0: @released sl@0: sl@0: */ sl@0: NONSHARABLE_CLASS(CMediaClientVideoDisplayBody) : public CBase, public MExtDisplayConnectionProviderCallback, sl@0: public MMediaClientWsEventObserverCallback sl@0: { sl@0: private: sl@0: NONSHARABLE_CLASS(TWindowData) sl@0: { sl@0: public: sl@0: TWindowData() : sl@0: iWindow(NULL) sl@0: { sl@0: } sl@0: sl@0: TWindowData(const RWindowBase* aWindow) : sl@0: iWindow(const_cast<RWindowBase*>(aWindow)) sl@0: { sl@0: } sl@0: sl@0: TWindowData(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aVideoExtent, sl@0: TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, TAutoScaleType aAutoScaleType, sl@0: TInt aHorizPos, TInt aVertPos,RWindow* aWindow2) : sl@0: iWindow(const_cast<RWindowBase*>(aWindow)), sl@0: iClipRect(aClipRect), sl@0: iVideoExtent(aVideoExtent), sl@0: iScaleWidth(aScaleWidth), sl@0: iScaleHeight(aScaleHeight), sl@0: iRotation(aRotation), sl@0: iAutoScaleType(aAutoScaleType), sl@0: iHorizPos(aHorizPos), sl@0: iVertPos(aVertPos), sl@0: iWindow2(aWindow2) sl@0: { sl@0: } sl@0: sl@0: RWindowBase* iWindow; sl@0: TSurfaceConfiguration iSurfaceConfig; sl@0: TRect iClipRect; sl@0: TRect iVideoExtent; sl@0: sl@0: TReal32 iScaleWidth; sl@0: TReal32 iScaleHeight; sl@0: TVideoRotation iRotation; sl@0: sl@0: TAutoScaleType iAutoScaleType; sl@0: TInt iHorizPos; sl@0: TInt iVertPos; sl@0: sl@0: // iWindow2 is set when using CVideoPlayerUtility2. This is used to avoid sl@0: // casting iWindow from RWindowBase* to RWindow*. sl@0: RWindow* iWindow2; sl@0: sl@0: sl@0: static TBool CompareByWsHandle(const TInt* aWsHandle, const TWindowData& aWindowData) sl@0: { sl@0: TBool ret = EFalse; sl@0: if (aWsHandle) sl@0: { sl@0: ret = (*aWsHandle == aWindowData.iWindow->WsHandle()); sl@0: } sl@0: return ret; sl@0: } sl@0: }; sl@0: public: sl@0: sl@0: static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, TBool aExtDisplaySwitchingControl); sl@0: static CMediaClientVideoDisplayBody* NewL(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, TBool aExtDisplaySwitchingControl); sl@0: sl@0: ~CMediaClientVideoDisplayBody(); sl@0: sl@0: void AddDisplayL(MMMFSurfaceEventHandler& aEventHandler); sl@0: void AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, sl@0: TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, sl@0: TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2); sl@0: void UpdateDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, sl@0: TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, sl@0: TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2); sl@0: void RemoveDisplay(); sl@0: TInt RemoveDisplayWindow(const RWindowBase& aWindow); sl@0: sl@0: TInt SurfaceCreated(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio, const TRect& aCropRegion); sl@0: TInt SurfaceParametersChanged(const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio); sl@0: void RemoveSurface(TBool aControllerEvent); sl@0: void RemoveBackgroundSurface(TBool aTriggerRedraw); sl@0: TInt RedrawWindows(const TRect& aCropRegion); sl@0: sl@0: void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion); sl@0: void SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion); sl@0: TVideoRotation RotationL(const RWindowBase& aWindow); sl@0: void SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion); sl@0: void GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage); sl@0: sl@0: void SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos, const TRect& aCropRegion); sl@0: void SetRotationL(TVideoRotation aRotation, const TRect& aCropRegion); sl@0: void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, const TRect& aCropRegion); sl@0: void SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect, const TRect& aCropRegion); sl@0: void SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion); sl@0: sl@0: void SetExternalDisplaySwitchingL(TBool aControl); sl@0: sl@0: private: sl@0: sl@0: CMediaClientVideoDisplayBody(TInt aDisplayId); sl@0: CMediaClientVideoDisplayBody(TInt aDisplayId, const TSurfaceId& aSurfaceId, const TRect& aCropRect, TVideoAspectRatio aAspectRatio); sl@0: sl@0: void ConstructL(TBool aExtDisplaySwitchingControl); sl@0: sl@0: CFbsBitGc::TGraphicsOrientation ConvertRotation(TVideoRotation aRotation); sl@0: sl@0: RArray<CMediaClientVideoDisplayBody::TWindowData>& Windows(); sl@0: TInt DisplayId() const; sl@0: TBool IsUsed() const; sl@0: static TInt CompareByDisplay(const TInt* aDisplayId, const CMediaClientVideoDisplayBody& aDisplay); sl@0: static TInt Compare(const CMediaClientVideoDisplayBody& aLeft, const CMediaClientVideoDisplayBody& aRight); sl@0: static CMediaClientVideoDisplayBody* FindDisplayWithWindowL(const RPointerArray<CMediaClientVideoDisplayBody>& aDisplays, const RWindowBase& aWindow); sl@0: TBool IsSurfaceCreated() const; sl@0: TInt SetBackgroundSurface(TWindowData& aWindowData, const TRect& aCropRegion); sl@0: TBool HasWindows() const; sl@0: sl@0: void UpdateCropRegionL(const TRect& aCropRegion, TInt aPos, TBool aRedrawIndividualWindow); sl@0: void CreateExtDisplayPluginL(); sl@0: void RemoveExtDisplayPlugin(); sl@0: void CreateExtDisplayHandlerL(); sl@0: void RemoveExtDisplayHandler(); sl@0: void SetWindowArrayPtr2Client(); sl@0: void SetWindowArrayPtr2Ext(); sl@0: void SwitchSurface(); sl@0: void UpdateFocus(); sl@0: TBool IsRotationValid(TVideoRotation aVideoRotation); sl@0: TBool IsAutoScaleTypeValid(TAutoScaleType aAutoScaleType); sl@0: TBool SurfaceCropRectChangeRequiresRedraw(TRect aOldSurfaceCropRect, TRect aNewSurfaceCropRect, TRect aClientCropRegion); sl@0: TBool ClientCropRegionChangeRequiresRedraw(TRect aOldClientCropRegion, TRect aNewClientCropRegion, TRect aSurfaceCropRect); sl@0: TBool IntersectionAreaChanged(TRect aOldRect, TRect aNewRect, TRect aOtherRect); sl@0: void UpdateDeltaForExtDisplay(TReal32 aViewportAspect, const TRect& aVideoExtent, TInt& aDeltaHeight, TInt& aDeltaWidth); sl@0: TBool IsWideScreenL(); sl@0: TAutoScaleType ExtDisplayAutoScaleTypeL(); sl@0: sl@0: // MExtDisplayConnectionProviderCallback sl@0: void MedcpcExtDisplayNotifyConnected(TExtDisplayConnectionProviderConnType aExtDisplayConnType); sl@0: sl@0: // MMediaClientWsEventObserverCallback sl@0: void MmcweoFocusWindowGroupChanged(); sl@0: TBool MmcweoIgnoreProcess(TSecureId aId); sl@0: sl@0: #ifdef MEDIA_CLIENT_SURFACE_NOT_REMOVED_FROM_CLIENT_WINDOW sl@0: void HideAllClientWindows(); sl@0: TInt HideWindow(RWindowBase* aWindow); sl@0: void SetHiddenBackgroundSurfaceOnAllClientWindows(); sl@0: TInt SetHiddenBackgroundSurfaceOnClientWindow(TWindowData& aWindowData); sl@0: #endif sl@0: sl@0: private: sl@0: sl@0: MMMFSurfaceEventHandler* iEventHandler; sl@0: const TInt iDisplayId; sl@0: TSurfaceId iSurfaceId; sl@0: TRect iCropRect; sl@0: TVideoAspectRatio iAspectRatio; sl@0: sl@0: RArray<TWindowData> iClientWindows; sl@0: RArray<TWindowData> iExtDisplayWindows; sl@0: RArray<TWindowData>* iWindowsArrayPtr; sl@0: TBool iSwitchedToExternalDisplay; sl@0: sl@0: TRect iCropRegion; sl@0: TBool iClientRequestedExtDisplaySwitching; sl@0: CExtDisplayConnectionProviderInterface* iExtDisplayConnectionProvider; sl@0: CMediaClientExtDisplayHandler* iExtDisplayHandler; sl@0: CMediaClientWsEventObserver* iWsEventObserver; sl@0: TBool iClientWindowIsInFocus; sl@0: TBool iExtDisplayConnected; sl@0: TBool iExtDisplaySwitchingSupported; sl@0: TExtDisplayConnectionProviderConnType iExtDisplayConnType; sl@0: sl@0: CMediaClientPolicyServerClient* iServerClient; sl@0: sl@0: friend class CVideoPlayerUtility::CBody; sl@0: friend class CTestStepUnitMMFVidClient; sl@0: }; sl@0: sl@0: #endif // MEDIACLIENTVIDEODISPLAYBODY_H sl@0: