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