mmlibs/mmfw/src/Client/Video/VideoPlayerBody.h
changeset 0 40261b775718
child 12 b74061f7f3d2
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2002-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 #ifndef VIDEOPLAYERBODY_H
       
    17 #define VIDEOPLAYERBODY_H
       
    18 
       
    19 #include <fbs.h>
       
    20 #include <w32std.h>
       
    21 
       
    22 #ifdef SYMBIAN_BUILD_GCE
       
    23 #include <mmf/common/mmfvideosurfacecustomcommands.h>
       
    24 #endif
       
    25 
       
    26 #include <mmf/common/mmfbase.h>
       
    27 #include <mmf/common/mmfcontroller.h>
       
    28 #include <mmf/common/mmfaudio.h>
       
    29 #include <mmf/common/mmfstandardcustomcommands.h>
       
    30 #include <mmf/common/mmfdrmcustomcommands.h>
       
    31 #include <mda/common/base.h>
       
    32 #include <mmf/common/mmfutilities.h>
       
    33 #include <mmf/common/mmfcontrollerframeworkbase.h>
       
    34 #include "mmf/common/mmcaf.h"
       
    35 #include "mmfclientutility.h"
       
    36 
       
    37 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
       
    38 #include "mmfsubtitleutility.h"
       
    39 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
       
    40 
       
    41 #ifdef SYMBIAN_BUILD_GCE
       
    42 #include "mediaclientvideodisplaybody.h"
       
    43 #endif
       
    44 
       
    45 class CMMFVideoPlayerCallback;
       
    46 class MMMFDRMCustomCommand;
       
    47 class CVideoPlayerUtility;
       
    48 class MMMFSurfaceEventHandler;
       
    49 #ifdef SYMBIAN_BUILD_GCE
       
    50 	class TWindowData;
       
    51 	class CMediaClientVideoDisplayBody;
       
    52 #endif // SYMBIAN_BUILD_GCE
       
    53 NONSHARABLE_CLASS( CVideoPlayerUtility::CBody ): public CBase, 
       
    54 								   				 public MDirectScreenAccess, 
       
    55 								   				 public MMMFControllerEventMonitorObserver,
       
    56 								   				 public MMMFFindAndOpenControllerObserver
       
    57 
       
    58 	{
       
    59 
       
    60 public:
       
    61 	~CBody();
       
    62 
       
    63 	static CBody* NewL(CVideoPlayerUtility* aParent,
       
    64 					   MVideoPlayerUtilityObserver& aObserver,
       
    65 					   TInt aPriority,
       
    66 					   TInt aPref,
       
    67 					   RWsSession& aWs,
       
    68 					   CWsScreenDevice& aScreenDevice,
       
    69 					   RWindowBase& aWindow,
       
    70 					   const TRect& aScreenRect,
       
    71 					   const TRect& aClipRect);
       
    72 
       
    73 #ifdef SYMBIAN_BUILD_GCE
       
    74 	static CBody* NewL(CVideoPlayerUtility2* aParent,
       
    75 					   MVideoPlayerUtilityObserver& aObserver,
       
    76 					   TInt aPriority,
       
    77 					   TInt aPref);
       
    78 #endif
       
    79 	void OpenFileL(const TDesC& aFileName,TUid aControllerUid = KNullUid);
       
    80 	void OpenFileL(const RFile& aFile, TUid aControllerUid = KNullUid);
       
    81 
       
    82 
       
    83 	void OpenFileL(const TMMSource& aSource, TUid aControllerUid = KNullUid);
       
    84 
       
    85 	void OpenDesL(const TDesC8& aDescriptor,TUid aControllerUid = KNullUid);
       
    86 	void OpenUrlL(const TDesC& aUrl, TInt aIapId, const TDesC8& aMimeType=KNullDesC8, TUid aControllerUid = KNullUid);
       
    87 
       
    88 	void Prepare();
       
    89 
       
    90 	void Close();
       
    91 
       
    92 	void Play();
       
    93 	void Play(const TTimeIntervalMicroSeconds& aStartPoint, const TTimeIntervalMicroSeconds& aEndPoint);
       
    94 	TInt Stop();
       
    95 	void PauseL();
       
    96 
       
    97 	void SetPriorityL(TInt aPriority, TInt aPref);
       
    98 	void PriorityL(TInt& aPriority, TMdaPriorityPreference& aPref) const;
       
    99 
       
   100 	void SetDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow,
       
   101 						   const TRect& aScreenRect, const TRect& aClipRect);
       
   102 
       
   103 	void RegisterForVideoLoadingNotification(MVideoLoadingObserver& aObserver);
       
   104 
       
   105 	void GetFrameL(TDisplayMode aDisplayMode, TBool aUseIntentAPI = EFalse, ContentAccess::TIntent aIntent = ContentAccess::EPeek );
       
   106 	void RefreshFrameL();
       
   107 
       
   108 	TReal32 VideoFrameRateL() const;
       
   109 	void VideoFrameSizeL(TSize& aSize) const;
       
   110 	const TDesC8& VideoFormatMimeType() const;
       
   111 	TInt VideoBitRateL() const;
       
   112 
       
   113 	TInt AudioBitRateL() const;
       
   114 	TFourCC AudioTypeL() const;
       
   115 	TBool AudioEnabledL() const;
       
   116 
       
   117 	void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
       
   118 	TTimeIntervalMicroSeconds PositionL() const;
       
   119 	TTimeIntervalMicroSeconds DurationL() const;
       
   120 
       
   121 	void SetVolumeL(TInt aVolume);
       
   122 	TInt Volume() const;
       
   123 	TInt MaxVolume() const;
       
   124 	void SetBalanceL(TInt aBalance);
       
   125 	TInt Balance()const;
       
   126 
       
   127 	void SetRotationL(TVideoRotation aRotation);
       
   128 	TVideoRotation RotationL() const;
       
   129 	void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, TBool aAntiAliasFiltering);
       
   130 	void GetScaleFactorL(TReal32& aWidthPercentage, TReal32& aHeightPercentage, TBool& aAntiAliasFiltering) const;
       
   131 	void SetCropRegionL(const TRect& aCropRegion);
       
   132 	void GetCropRegionL(TRect& aCropRegion) const;
       
   133 
       
   134 	TInt NumberOfMetaDataEntriesL() const;
       
   135 	CMMFMetaDataEntry* MetaDataEntryL(TInt aIndex) const;
       
   136 	
       
   137 	void GetVideoLoadingProgressL(TInt& aPercentageProgress);
       
   138 	TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
       
   139 	TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
       
   140 	void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
       
   141 	void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
       
   142 	
       
   143 	void SetVideoFrameRateL(TReal32 aFramesPerSecond);
       
   144 	const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
       
   145 
       
   146 	MMMFDRMCustomCommand* GetDRMCustomCommand();
       
   147 
       
   148 	void StopDirectScreenAccessL();
       
   149 	void StartDirectScreenAccessL();
       
   150 	
       
   151 	TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback, TUid aNotificationEventUid, const TDesC8& aNotificationRegistrationData = KNullDesC8);
       
   152 	TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
       
   153 	TInt WillResumePlay();
       
   154 
       
   155 	TInt SetInitScreenNumber(TInt aScreenNumber);
       
   156 
       
   157     void SetPlayVelocityL(TInt aVelocity);
       
   158     TInt PlayVelocityL() const;
       
   159     void StepFrameL(TInt aStep);
       
   160     void GetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCapabilities) const;
       
   161     void SetVideoEnabledL(TBool aVideoEnabled);
       
   162     TBool VideoEnabledL() const;
       
   163     void SetAudioEnabledL(TBool aAudioEnabled);
       
   164     void SetAutoScaleL(TAutoScaleType aScaleType);
       
   165     void SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
       
   166 		
       
   167 #ifdef SYMBIAN_BUILD_GCE
       
   168 	void AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, 
       
   169 							RWindow& aWindow, const TRect& aVideoExtent, 
       
   170 							const TRect& aWindowClipRect);
       
   171 	void AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindow& aWindow);
       
   172  	void RemoveDisplayWindow(RWindowBase& aWindow);	
       
   173  	void SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent);	
       
   174 	void SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect);
       
   175     
       
   176    	void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType);
       
   177     void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
       
   178 
       
   179 	void SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation);
       
   180 	TVideoRotation RotationL(const RWindowBase& aWindow) const;
       
   181 	void SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage);
       
   182 	void GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage) const;
       
   183 	void AddDisplayL(TInt aDisplay, MMMFSurfaceEventHandler& aEventHandler);
       
   184 	void RemoveDisplay(TInt aDisplay);
       
   185 	void ConvertFromRelativeToDisplayToRelativeToWindow(
       
   186 	        const RWindowBase& aWindow,
       
   187 	        const TRect& aFromWindowRect,
       
   188 	        const TRect& aFromClipRect,
       
   189 	        TRect& aToWindowRect,
       
   190 	        TRect& aToClipRect);
       
   191 	void SetExternalDisplaySwitchingL(TInt aDisplay, TBool aControl);
       
   192 #endif
       
   193 
       
   194 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
       
   195 	TBool SubtitlesAvailable();
       
   196 	void EnableSubtitlesL();
       
   197 	void DisableSubtitles();
       
   198 	TArray<TLanguage> SupportedSubtitleLanguagesL();
       
   199 	TLanguage SubtitleLanguageL();
       
   200 	void SetSubtitleLanguageL(TLanguage aLanguage);
       
   201 	void RedrawSubtitle(RWindow& aWindow, const TRect &aRect);
       
   202 	static RWindow* FindWindowWithWsHandle(const RPointerArray<CMediaClientVideoDisplayBody>& aDisplays, TInt aWsHandle);
       
   203 	TInt EnableSubtitles(CMediaClientVideoDisplayBody& aDisplay);
       
   204 	TInt AddSubtitleConfig(CMediaClientVideoDisplayBody::TWindowData& aWindowData);
       
   205 	void GetSubtitleConfigFromWindowData(CMediaClientVideoDisplayBody::TWindowData& aWindowData, TMMFSubtitleWindowConfig& aConfig);
       
   206 	void UpdateSurfaceAndSubtitleConfigL(CMediaClientVideoDisplayBody& aDisplay,CMediaClientVideoDisplayBody::TWindowData& aWindowData, const TRect& aClipRect, TVideoRotation aRotation, const TRect& aCropRegion);
       
   207 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
       
   208 
       
   209 private:
       
   210 	void ConstructL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow,
       
   211 					const TRect& aWindowRect, const TRect& aClipRect);
       
   212 	CBody(CVideoPlayerUtility* aParent,
       
   213 		  MVideoPlayerUtilityObserver& aObserver,
       
   214 		  TInt aScreenNumber,
       
   215 		  TInt aPriority=EMdaPriorityNormal,
       
   216 		  TInt aPref=EMdaPriorityPreferenceTimeAndQuality);
       
   217 
       
   218 	void CommonConstructL();
       
   219 	void SetAndUpdateWindow();
       
   220 	void PrepareDSAL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow);
       
   221 
       
   222 #ifdef SYMBIAN_BUILD_GCE	
       
   223 	CBody(CVideoPlayerUtility2* aParent,
       
   224 		  MVideoPlayerUtilityObserver& aObserver,
       
   225 		  TInt aPriority=EMdaPriorityNormal,
       
   226 		  TInt aPref=EMdaPriorityPreferenceTimeAndQuality);
       
   227 
       
   228 	void ConstructL();
       
   229 	TInt CheckSurfaceSupported();
       
   230 	TBool RectContains(const TRect& aLeft, const TRect& aRight);
       
   231 	void DoAddDisplayWindowL(RWsSession& aWs, TInt aDisplay, RWindowBase& aWindow,
       
   232 								const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
       
   233 	TInt SurfaceCreated();
       
   234 	TInt SurfaceParametersChanged();
       
   235 	TInt SetBackgroundSurface(const CMediaClientVideoDisplayBody& aDisplay);
       
   236 	TInt RemoveSurface(TBool aControllerEvent);
       
   237 	TInt SetAllBackgroundSurfaces();
       
   238 
       
   239 #endif // SYMBIAN_BUILD_GCE
       
   240 	
       
   241 	// from MMMFControllerEventMonitorObserver
       
   242 	virtual void HandleEvent(const TMMFEvent& aEvent);
       
   243 
       
   244 	//from MDirectScreenAccess
       
   245 	virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
       
   246 	virtual void Restart(RDirectScreenAccess::TTerminationReasons aReason);
       
   247 
       
   248 	// from MMMFFindAndOpenControllerObserver 
       
   249 	virtual void MfaocComplete(
       
   250 		TInt& aError, 
       
   251 		RMMFController* aController, 
       
   252 		TUid aControllerUid, 
       
   253 		TMMFMessageDestination* aSourceHandle, 
       
   254 		TMMFMessageDestination* aSinkHandle);
       
   255 
       
   256 
       
   257 	void OpenComplete(TInt aError);
       
   258 	void FrameReady(TInt aError);
       
   259 	void PlayComplete(TInt aError);
       
   260 	void Reset();
       
   261 
       
   262 private:
       
   263 	//Source and sink handle info
       
   264 	TMMFMessageDestination iSourceHandle;
       
   265 	TMMFMessageDestination iSinkHandle;
       
   266 
       
   267 	RMMFController iController;
       
   268 	RMMFVideoControllerCustomCommands iVideoControllerCustomCommands;
       
   269 	RMMFVideoPlayControllerCustomCommands iVideoPlayControllerCustomCommands;
       
   270 	RMMFAudioPlayDeviceCustomCommands iAudioPlayDeviceCustomCommands;
       
   271 	RMMFAudioRecordDeviceCustomCommands iAudioRecordDeviceCustomCommands;
       
   272 	RMMFVideoDRMExtCustomCommands iVideoDRMExtCustomCommands;
       
   273 	RMMFDRMCustomCommands iDRMCustomCommands;
       
   274 	RMMFVideoPlayControllerExtCustomCommands iVideoPlayControllerExtCustomCommands;
       
   275 	RMMFResourceNotificationCustomCommands iNotificationRegistrationCommands;
       
   276 	MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
       
   277 #ifdef SYMBIAN_BUILD_GCE
       
   278 	RMMFVideoPlaySurfaceSupportCustomCommands iVideoPlaySurfaceSupportCustomCommands;
       
   279 #endif	
       
   280 	//for audio resource notification
       
   281 	TUid iArnEventHolder;
       
   282 	TBuf8<TMMFAudioConfig::KNotificationDataBufferSize> iNotificationDataHolder;
       
   283 	
       
   284 	RMMFVideoSetInitScreenCustomCommands iVideoSetInitScreenCustomCommands;
       
   285 	MVideoPlayerUtilityObserver& iObserver;
       
   286 	CMMFControllerEventMonitor* iControllerEventMonitor;
       
   287 	CVideoPlayerUtility::TMMFVideoPlayerState iState;
       
   288 	TTimeIntervalMicroSeconds iDuration;
       
   289 	TMMFPrioritySettings iPrioritySettings;
       
   290 	
       
   291 	MVideoLoadingObserver *iVideoLoadingObserver;
       
   292 	CDirectScreenAccess * iDirectScreenAccess;
       
   293 	HBufC8* iMimeType;
       
   294 	CMMFVideoPlayerCallback* iAsyncCallback;
       
   295 	CMMFVideoPlayerCallback* iFrameCallback;
       
   296 	CMMFControllerImplementationInformation* iControllerImplementationInformation;
       
   297 	TUid iControllerUid;
       
   298 
       
   299 	CVideoPlayerUtility* iParent;
       
   300 	CFbsBitmap* iFrameBitmap;
       
   301 	RFbsSession iFbsSession;
       
   302 
       
   303 	TRect iWindowRect;
       
   304 	TRect iClipRect;
       
   305 	TBool iControllerOpen;
       
   306 	TBool iFbsSessionConnected;
       
   307 
       
   308 	// utility class to find and open a suitable controller asynchronously
       
   309 	CMMFFindAndOpenController* iFindAndOpenController;
       
   310 
       
   311 	// received a KMMFEventCategoryVideoOpenComplete event
       
   312 	TBool iEventOpenReceived;
       
   313 	
       
   314 	// received a MfaocComplete() callback
       
   315 	TBool iCallbackOpenReceived;
       
   316 	
       
   317 	TInt iOpenError;
       
   318 	TInt iScreenNumber;
       
   319 
       
   320 	// flag indicating DSA abort in StopDirectScreenAccess() - to be used in SetDisplayWindowL
       
   321 	TBool iDirectScreenAccessAbort;	
       
   322 		
       
   323 #ifdef SYMBIAN_BUILD_GCE
       
   324 
       
   325 	TSurfaceId iSurfaceId;
       
   326 	
       
   327 	//video graphics surface supported
       
   328 	TBool iGraphicsSurfaceSupported;
       
   329 	TBool iUsingVPU2;
       
   330 			
       
   331 	// store scale factor
       
   332 	TReal32 iGlobalScaleWidth;
       
   333 	TReal32 iGlobalScaleHeight;
       
   334 	TBool iAntiAliasFiltering;
       
   335 	TRect iCropRegion;
       
   336 	TVideoRotation iGlobalRotation;
       
   337 	TRect iSurfaceCropRect;
       
   338 	TVideoAspectRatio iAspectRatio;
       
   339 	// for storing window added during NewL,
       
   340 	// i.e. DSA
       
   341 	RWsSession* iWs;
       
   342 	TInt iDisplayId;
       
   343 	RWindowBase* iWindow;
       
   344 			
       
   345 	RPointerArray<CMediaClientVideoDisplayBody> iActiveDisplays;
       
   346 
       
   347 	// Autoscale info
       
   348 	TAutoScaleType iGlobalAutoScaleType;
       
   349 	TInt iGlobalHorizPos;
       
   350 	TInt iGlobalVertPos;
       
   351 #endif // SYMBIAN_BUILD_GCE
       
   352 
       
   353 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
       
   354 	CMMFSubtitleUtility* iSubtitleUtility;
       
   355 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
       
   356 
       
   357 	friend class CMMFVideoPlayerCallback;
       
   358 	friend class CTestStepUnitMMFVidClient;
       
   359 	friend class CTestView;
       
   360 	friend class CVideoPlayerUtility;
       
   361 	
       
   362 #ifdef SYMBIAN_BUILD_GCE
       
   363 	friend class CVideoPlayerUtility2;
       
   364 #endif
       
   365 	};
       
   366 
       
   367 
       
   368 #endif // VIDEOPLAYERBODY_H