os/mm/mmplugins/mmfwplugins/src/Plugin/Controller/Video/AviPlayController/aviplaycontroller.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 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 AVIPLAYCONTROLLER_H
sl@0
    17
#define AVIPLAYCONTROLLER_H
sl@0
    18
sl@0
    19
//standard epoc32 includes
sl@0
    20
#include <ecom/implementationproxy.h>
sl@0
    21
#include <ecom/ecom.h>
sl@0
    22
#include <e32std.h>
sl@0
    23
#include <e32base.h>
sl@0
    24
#include <fbs.h>
sl@0
    25
#include <bitstd.h>
sl@0
    26
#include <bitdev.h>
sl@0
    27
sl@0
    28
#include <mmf/common/mmfcontroller.h>
sl@0
    29
#include <mmf/server/mmfdatasource.h>
sl@0
    30
#include <mmf/server/mmfdatasink.h>
sl@0
    31
#include <mmf/server/mmffile.h>
sl@0
    32
#include <mmf/common/mmfdrmcustomcommands.h>
sl@0
    33
#include <mmf/common/mmfstandardcustomcommands.h>
sl@0
    34
#include <mmf/devvideo/devvideoplay.h>
sl@0
    35
#include <mmf/devvideo/videoplayhwdevice.h>
sl@0
    36
#include <mmf/server/sounddevice.h>
sl@0
    37
#include <mmf/server/mmfaudiooutput.h>
sl@0
    38
#include <mmf/server/mmfcodec.h>
sl@0
    39
sl@0
    40
#ifdef SYMBIAN_BUILD_GCE
sl@0
    41
#include <mmf/common/mmfvideosurfacecustomcommands.h>
sl@0
    42
#include <mmf/devvideo/devvideovideosurfacecustominterface.h>
sl@0
    43
#endif // SYMBIAN_BUILD_GCE
sl@0
    44
sl@0
    45
#include "avireader.h"
sl@0
    46
#include "aviplaycontrolleruids.hrh"
sl@0
    47
sl@0
    48
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
    49
#include <mmf/common/mmfvideosubtitlecustomcommands.h>
sl@0
    50
sl@0
    51
class CSrtReader;
sl@0
    52
class CMMFDevSubtitle;
sl@0
    53
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
    54
	
sl@0
    55
class CAviReader;
sl@0
    56
class MAviReaderObserver;
sl@0
    57
sl@0
    58
const TInt KNumSampleRates = 9;
sl@0
    59
sl@0
    60
struct TSampleRateTable
sl@0
    61
  	{
sl@0
    62
	TInt iRate;
sl@0
    63
	TMMFSampleRate iRateEnum;
sl@0
    64
	};
sl@0
    65
sl@0
    66
//TAviPlayControllerPanics is an enumeration with the following entries:
sl@0
    67
//EBadState indicates a state violation.
sl@0
    68
//EBadCall indicates a bad call
sl@0
    69
enum TAviPlayControllerPanics
sl@0
    70
	{
sl@0
    71
	EBadCall,
sl@0
    72
	EBadState
sl@0
    73
	};
sl@0
    74
sl@0
    75
sl@0
    76
//The public API of CAviPlayController.It mainly implements the public APIs in CMMFController. It also implements PlayCustomInterfaces 
sl@0
    77
//to support extended functionality during playing.This class is reponsible for controlling the audio and video data transfer from file to
sl@0
    78
//devvideoplay and devsound.
sl@0
    79
class CAviPlayController: public CMMFController, 
sl@0
    80
                          public MMMFVideoPlayControllerCustomCommandImplementor,
sl@0
    81
						  public MMMFVideoControllerCustomCommandImplementor,
sl@0
    82
						  public MMMFAudioPlayDeviceCustomCommandImplementor,
sl@0
    83
						  public MMMFDevVideoPlayObserver,
sl@0
    84
						  public MDevSoundObserver,
sl@0
    85
						  public MAviReaderObserver,
sl@0
    86
						  public MMMFResourceNotificationCustomCommandImplementor,
sl@0
    87
 					  	  public MMMFVideoSetInitScreenCustomCommandImplementor,
sl@0
    88
 					  	  public MMMFVideoPlayControllerExtCustomCommandImplementor
sl@0
    89
#ifdef SYMBIAN_BUILD_GCE 					  	  
sl@0
    90
 					  	  ,public MMMFVideoPlaySurfaceSupportCustomCommandImplementor,
sl@0
    91
 					  	  public MMMFVideoSurfaceObserver
sl@0
    92
#endif // SYMBIAN_BUILD_GCE  
sl@0
    93
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
    94
						  ,public MMMFVideoPlaySubtitleSupportCustomCommandImplementor
sl@0
    95
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
    96
	{
sl@0
    97
public:
sl@0
    98
sl@0
    99
	static CAviPlayController* NewL();
sl@0
   100
	~CAviPlayController();
sl@0
   101
	// from CMMFController Implementation
sl@0
   102
    virtual void AddDataSourceL(MDataSource& aDataSource);
sl@0
   103
	virtual void AddDataSinkL(MDataSink& aDataSink);
sl@0
   104
	virtual void RemoveDataSourceL(MDataSource& aDataSource);
sl@0
   105
	virtual void RemoveDataSinkL(MDataSink& aDataSink);
sl@0
   106
	virtual void ResetL();
sl@0
   107
	virtual void PrimeL();
sl@0
   108
    virtual void PrimeL(TMMFMessage& aMessage);
sl@0
   109
	virtual void PlayL();
sl@0
   110
	virtual void PauseL();
sl@0
   111
	virtual void StopL();
sl@0
   112
	virtual TTimeIntervalMicroSeconds PositionL() const;
sl@0
   113
	virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
sl@0
   114
	virtual TTimeIntervalMicroSeconds DurationL() const;
sl@0
   115
	virtual void CustomCommand(TMMFMessage& aMessage);
sl@0
   116
	virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
sl@0
   117
	virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries);
sl@0
   118
	virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex);
sl@0
   119
	//MMMFVideoPlayControllerCustomCommandImplementor
sl@0
   120
    void MvpcPrepare();
sl@0
   121
	void MvpcGetFrameL(MMMFVideoFrameMessage& aMessage);
sl@0
   122
	void MvpcGetAudioEnabledL(TBool& aEnabled);
sl@0
   123
	void MvpcSetDisplayWindowL(const TRect& aWindowRect, const TRect& aClipRect);
sl@0
   124
	void MvpcUpdateDisplayRegionL(const TRegion& aRegion);
sl@0
   125
	void MvpcDirectScreenAccessEventL(const TMMFDSAEvent aDSAEvent);
sl@0
   126
	void MvpcRefreshFrameL();
sl@0
   127
	void MvpcPlayL(const TTimeIntervalMicroSeconds& aBegin, const TTimeIntervalMicroSeconds& aEnd);
sl@0
   128
	void MvpcGetLoadingProgressL(TInt& aPercentage);
sl@0
   129
	void MvpcSetRotationL(TVideoRotation aRotation);
sl@0
   130
	void MvpcGetRotationL(TVideoRotation& aRotation);
sl@0
   131
	void MvpcSetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, TBool aAntiAliasFiltering);
sl@0
   132
	void MvpcGetScaleFactorL(TReal32& aWidthPercentage, TReal32& aHeightPercentage, TBool& aAntiAliasFiltering);
sl@0
   133
	void MvpcSetCropRegionL(const TRect& aCropRegion);
sl@0
   134
	void MvpcGetCropRegionL(TRect& aCropRegion);
sl@0
   135
	// MMMFVideoControllerCustomCommandImplementor 
sl@0
   136
	void MvcGetAudioCodecL(TFourCC& aCodec);
sl@0
   137
	void MvcGetVideoBitRateL(TInt& aBitRate);
sl@0
   138
	void MvcGetAudioBitRateL(TInt& aBitRate);
sl@0
   139
	void MvcSetFrameRateL(TReal32 aFramesPerSecond);
sl@0
   140
	void MvcGetFrameRateL(TReal32& aFramesPerSecond);
sl@0
   141
	void MvcGetVideoFrameSizeL(class TSize &aVideoFrameSize);
sl@0
   142
	void MvcGetVideoMimeTypeL(TDes8& aMimeType);
sl@0
   143
	// from MMMFAudioPlayDeviceCustomCommandImplemetor 
sl@0
   144
	void MapdSetVolumeL(TInt aVolume);
sl@0
   145
	void MapdGetMaxVolumeL(TInt& aMaxVolume);
sl@0
   146
	void MapdGetVolumeL(TInt& aVolume);
sl@0
   147
	void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
sl@0
   148
	void MapdSetBalanceL(TInt aBalance);
sl@0
   149
	void MapdGetBalanceL(TInt& aBalance);
sl@0
   150
sl@0
   151
	//from MMMFDevVideoPlayObserver
sl@0
   152
    void MdvpoNewBuffers();
sl@0
   153
    void MdvpoReturnPicture(TVideoPicture *aPicture);
sl@0
   154
    void MdvpoSupplementalInformation(const TDesC8 &aData, const TTimeIntervalMicroSeconds &aTimestamp, const TPictureId &aPictureId);
sl@0
   155
    void MdvpoPictureLoss();
sl@0
   156
    void MdvpoPictureLoss(const TArray< TPictureId > &aPictures);
sl@0
   157
    void MdvpoSliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId &aPicture);
sl@0
   158
    void MdvpoReferencePictureSelection(const TDesC8 &aSelectionData);
sl@0
   159
    void MdvpoTimedSnapshotComplete(TInt aError, TPictureData *aPictureData, const TTimeIntervalMicroSeconds &aPresentationTimestamp, const TPictureId &aPictureId);
sl@0
   160
    void MdvpoFatalError(TInt aError);
sl@0
   161
    void MdvpoNewPictures();
sl@0
   162
    void MdvpoInitComplete(TInt aError);
sl@0
   163
    void MdvpoStreamEnd();
sl@0
   164
    // from MDevSoundObserver
sl@0
   165
    void InitializeComplete(TInt aError);
sl@0
   166
	void ToneFinished(TInt aError);
sl@0
   167
	void BufferToBeFilled(CMMFBuffer* aBuffer);
sl@0
   168
	void PlayError(TInt aError);
sl@0
   169
	void BufferToBeEmptied(CMMFBuffer* aBuffer); 
sl@0
   170
	void RecordError(TInt aError);
sl@0
   171
	void ConvertError(TInt aError);
sl@0
   172
	void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
sl@0
   173
	void SendEventToClient(const TMMFEvent& aEvent);
sl@0
   174
	//from  MMMFResourceNotificationCustomCommandImplementor,for audio resource notification 
sl@0
   175
	virtual void MarnRegisterAsClientL(TUid aEventType, const TDesC8& aNotificationRegistrationData);
sl@0
   176
	virtual void MarnCancelRegisterAsClientL(TUid aEventType);
sl@0
   177
	virtual void MarnGetResourceNotificationDataL(TUid aEventType, TDes8& aNotificationData);
sl@0
   178
	virtual void MarnWillResumePlayL();		
sl@0
   179
	// MMMFVideoSetInitScreenCustomCommandImplementor
sl@0
   180
	void MvsdSetInitScreenNumber(TInt aScreenNumber);
sl@0
   181
sl@0
   182
	// from MMMFVideoPlayControllerExtCustomCommandImplementor
sl@0
   183
	virtual void MvpecSetPlayVelocityL(TInt aVelocity);
sl@0
   184
	virtual TInt MvpecPlayVelocityL();
sl@0
   185
	virtual void MvpecStepFrameL(TInt aStep);
sl@0
   186
	virtual void MvpecGetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCapabilities);
sl@0
   187
	virtual void MvpecSetVideoEnabledL(TBool aVideoEnabled);
sl@0
   188
	virtual TBool MvpecVideoEnabledL();
sl@0
   189
	virtual void MvpecSetAudioEnabledL(TBool aAudioEnabled);
sl@0
   190
	virtual void MvpecSetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
sl@0
   191
sl@0
   192
#ifdef SYMBIAN_BUILD_GCE
sl@0
   193
	// MMMFVideoPlaySurfaceSupportCustomCommandImplementor
sl@0
   194
	void MvpssUseSurfacesL();
sl@0
   195
	void MvpssGetSurfaceParametersL(TSurfaceId& aSurfaceId,	TRect& aCropRect,
sl@0
   196
											TVideoAspectRatio& aPixelAspectRatio);
sl@0
   197
	void MvpssSurfaceRemovedL(const TSurfaceId& aSurfaceId);
sl@0
   198
	
sl@0
   199
	// MMMFVideoSurfaceObserver
sl@0
   200
	void MmvsoSurfaceCreated();
sl@0
   201
    void MmvsoSurfaceParametersChanged();
sl@0
   202
    void MmvsoRemoveSurface();
sl@0
   203
#endif // SYMBIAN_BUILD_GCE
sl@0
   204
sl@0
   205
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   206
	// MMMFVideoPlaySubtitleSupportCustomCommandImplementor
sl@0
   207
	void MvpsusGetCrpParametersL(TInt aWindowId, TWsGraphicId& aId, TRect& aCrpRect);
sl@0
   208
	void MvpsusAddSubtitleConfigL(const TMMFSubtitleWindowConfig& aConfig);
sl@0
   209
	void MvpsusRemoveSubtitleConfigL(TInt aWindowId);
sl@0
   210
	void MvpsusUpdateSubtitleConfigL(const TMMFSubtitleWindowConfig& aConfig);
sl@0
   211
	void MvpsusGetSubtitlesAvailableL(TBool& aAvailable);
sl@0
   212
	void MvpsusDisableSubtitlesL();
sl@0
   213
	void MvpsusEnableSubtitlesL();
sl@0
   214
	void MvpsusGetSubtitleLanguageL(TLanguage& aLanguage);
sl@0
   215
	void MvpsusGetSupportedSubtitleLanguagesL(RArray<TLanguage>& aLanguages);
sl@0
   216
	void MvpsusSetSubtitleLanguageL(TLanguage aLanguage);
sl@0
   217
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   218
	
sl@0
   219
public:
sl@0
   220
   //TControllerState is an enumeration within the namespace  CAviVideoPlayController
sl@0
   221
   //The enumeration provides a set of control states:
sl@0
   222
   //EStopped is the initial state the controller resides in after it has been loaded
sl@0
   223
   //EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data
sl@0
   224
   //EPlaying is the state the controller is in when it is streaming data
sl@0
   225
   enum TControllerState
sl@0
   226
		{
sl@0
   227
		EStopped,
sl@0
   228
		EPrimed,
sl@0
   229
		EAudioReadyToPlay,
sl@0
   230
		EPlaying
sl@0
   231
		};
sl@0
   232
protected:
sl@0
   233
    CAviPlayController();
sl@0
   234
   	void StartPrimeL();
sl@0
   235
	TBool SelectFirstSuitableDecoderL(
sl@0
   236
		const RArray<TUid>& aDecodersArray,
sl@0
   237
		const TUncompressedVideoFormat& aRequiredOutputFormat,
sl@0
   238
		TBool aUseSurfaces);
sl@0
   239
	void ConstructL();
sl@0
   240
	void SendErrorToClient(TInt aError);
sl@0
   241
	void CopyFrameL(CFbsBitmap& aBitmap);
sl@0
   242
	void CheckDevSoundPresentL();
sl@0
   243
	void CheckDevVideoPresentL()const;
sl@0
   244
	void CheckAviReaderPresentL()const;
sl@0
   245
	void CheckForInitComplete();
sl@0
   246
	void Panic(TInt aPanicCode);
sl@0
   247
	void StopVideoL();
sl@0
   248
	void StopAudioL();
sl@0
   249
	void StopAviReaderL();
sl@0
   250
	void RecreateDevVideoAfterFatalErrorL();
sl@0
   251
	TBool LocateDecoderL(TBool aUseSurfaces);
sl@0
   252
	void UpdateClipRegion();
sl@0
   253
sl@0
   254
	//from MAviReaderObserver
sl@0
   255
	void AudioBufferFilled();
sl@0
   256
	void VideoBufferFilled(TVideoInputBuffer* aBuffer);
sl@0
   257
	
sl@0
   258
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   259
	CSrtReader* CreateSubtitleSourceL();
sl@0
   260
	void StopSubtitles();
sl@0
   261
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   262
sl@0
   263
sl@0
   264
private:
sl@0
   265
	class CMMFMessageHolder : public CBase
sl@0
   266
		{
sl@0
   267
		public:
sl@0
   268
			static CMMFMessageHolder* NewL(TMMFMessage& aMessage);
sl@0
   269
			void Complete(TInt aError);
sl@0
   270
		private:
sl@0
   271
			CMMFMessageHolder(TMMFMessage& aMessage);
sl@0
   272
			TMMFMessage iMessage;
sl@0
   273
		};
sl@0
   274
	
sl@0
   275
	class CSourceSinkEventHandler : public MAsyncEventHandler
sl@0
   276
		{
sl@0
   277
		public:
sl@0
   278
			CSourceSinkEventHandler(CAviPlayController& aParent);
sl@0
   279
			virtual ~CSourceSinkEventHandler();
sl@0
   280
		public:
sl@0
   281
			virtual TInt SendEventToClient(const TMMFEvent& aEvent);
sl@0
   282
		private:
sl@0
   283
			CAviPlayController& iParent;
sl@0
   284
		};
sl@0
   285
	
sl@0
   286
private:
sl@0
   287
	CMMFDevVideoPlay *iDevVideoPlay;
sl@0
   288
	CMMFDevSound* iDevSound;
sl@0
   289
	TControllerState iState;
sl@0
   290
	CAviReader* iAviReader;
sl@0
   291
	CMMFFile* iClip;
sl@0
   292
	CSourceSinkEventHandler *iEventHandler;
sl@0
   293
	TMMFPrioritySettings iPrioritySettings;
sl@0
   294
	THwDeviceId iDecoderDeviceId;
sl@0
   295
	CMMFMessageHolder* iMessage;
sl@0
   296
    CFbsScreenDevice* iScreenDev;
sl@0
   297
	CFbsBitGc* iScreenGc;
sl@0
   298
	CFbsBitmap* iBitmap;
sl@0
   299
	TRect iScreenRect;
sl@0
   300
	TRect iClipRect;
sl@0
   301
	RRegion iDisplayRegion;
sl@0
   302
	RRegion iDerivedClipRegion;
sl@0
   303
	TRect iCropRect;
sl@0
   304
	TVideoRotation iRotation;
sl@0
   305
	TReal32 iWidthPercentage;
sl@0
   306
	TReal32 iHeightPercentage;
sl@0
   307
	TBool iAntiAliasFiltering;
sl@0
   308
	TBool iDevVideoInitialized;
sl@0
   309
	TBool iDevSoundInitialized;
sl@0
   310
	TSize iFrameSize;
sl@0
   311
	TBool iAudioEnabled;
sl@0
   312
	TUid iDecoder;
sl@0
   313
	TBool iVideoDecoderInitialized;
sl@0
   314
	TInt iScreenNumber;
sl@0
   315
	TBool iVideoFatalError;
sl@0
   316
#ifdef SYMBIAN_BUILD_GCE
sl@0
   317
	MMMFVideoSurfaceSupport* iVideoSurfaceSupport;
sl@0
   318
#else
sl@0
   319
	const TAny* const iVideoSurfaceSupport;	
sl@0
   320
#endif // SYMBIAN_BUILD_GCE
sl@0
   321
sl@0
   322
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   323
	CMMFDevSubtitle* iDevSubtitle;
sl@0
   324
	CSrtReader* iSrtReader;
sl@0
   325
	TBool iDevSubtitleStarted;
sl@0
   326
	TInt iSubtitleConfigCount;
sl@0
   327
#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
sl@0
   328
 	};
sl@0
   329
sl@0
   330
#endif