os/mm/mmdevicefw/mdf/src/video/decoderadapter/mdfvideodecodehwdeviceadapter.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmdevicefw/mdf/src/video/decoderadapter/mdfvideodecodehwdeviceadapter.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,294 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef MDFVIDEODECODEHWDEVICEADAPTER_H
    1.20 +#define MDFVIDEODECODEHWDEVICEADAPTER_H
    1.21 +
    1.22 +#include <fbs.h>
    1.23 +#include <mmf/devvideo/videoplayhwdevice.h>
    1.24 +#include "mdfvideodecodehwdeviceadapter.hrh"
    1.25 +#include <mmf/server/mmfdatabuffer.h>
    1.26 +
    1.27 +#include <mdf/mdfinputport.h>
    1.28 +#include <mdf/mdfoutputport.h>
    1.29 +#include <mdf/mdfprocessingunit.h>
    1.30 +#include <mdf/mdfpuloader.h>
    1.31 +#include <mdf/codecapivideoresolverutils.h>
    1.32 +#include <mmf/devvideo/devvideopuconfig.h>
    1.33 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.34 +#include <mmf/devvideo/devvideohwdeviceadaptersetup.h>
    1.35 +#endif
    1.36 +
    1.37 +// From hwdevicevideoutils.dll
    1.38 +#include "mdfvideodecoderbuffermanager.h"
    1.39 +#include "mdfplayerengine.h"
    1.40 +
    1.41 +const TUid KUidDevVideoDecodeHwDevice = {KUidDevVideoDecoderHwDeviceDefine};
    1.42 +
    1.43 +// decoder info
    1.44 +_LIT(KVideoDecoderInfoManufacturer, "Symbian Ltd.");
    1.45 +_LIT8(KVideoDecoderInfoCSInfo, "Coded by Symbian");
    1.46 +_LIT8(KVideoDecoderInfoISInfo, "Implemented by Symbian");
    1.47 +const TInt KVideoDecoderInfoVersionMaj = 0;
    1.48 +const TInt KVideoDecoderInfoVersionMin = 1;
    1.49 +const TInt KVideoDecoderInfoVersionBuild = 1;
    1.50 +
    1.51 +/**
    1.52 +Video decoder hardware device. 
    1.53 +This is the DevVideo decoder plugin component
    1.54 +@internalComponent
    1.55 +*/
    1.56 +class CMdfVideoDecodeHwDeviceAdapter :	public CMMFVideoDecodeHwDevice,
    1.57 +				       					public MMdfVideoPlayerHwDeviceObserver,
    1.58 +				       					public MMdfInputPortObserver,
    1.59 +				       					public MMdfOutputPortObserver,
    1.60 +				       					public MMdfProcessingUnitObserver,
    1.61 +				       					public MDevVideoHwDeviceAdapterSetup		       					
    1.62 +
    1.63 +{
    1.64 +
    1.65 +public:
    1.66 +		
    1.67 +	/**
    1.68 +	The current state of the Hardware Device Adapter.
    1.69 +	*/
    1.70 +	enum THwDevAdapterState
    1.71 +		{
    1.72 +		/*
    1.73 +		The PULoader has been loaded.
    1.74 +		*/
    1.75 +		EProcessingUnitLoaderLoaded,
    1.76 +		/*
    1.77 +		The Processing Units have been loaded.
    1.78 +		*/
    1.79 +		EProcessingUnitLoaded,
    1.80 +		/*
    1.81 +		The Processing Units are currently being initialised.
    1.82 +		*/
    1.83 +		EProcessingUnitInitializing,
    1.84 +		/*
    1.85 +		The Processing Units are currently in the idle state.
    1.86 +		*/
    1.87 +		EProcessingUnitIdle,
    1.88 +		/*
    1.89 +		The Processing Units are currently in the executing state.
    1.90 +		*/
    1.91 +		EProcessingUnitExecuting,
    1.92 +		/*
    1.93 +		The Processing Units are currently in the paused state.
    1.94 +		*/
    1.95 +		EProcessingUnitPaused		
    1.96 +		};	
    1.97 +
    1.98 +
    1.99 +	static CMdfVideoDecodeHwDeviceAdapter* NewL();
   1.100 +	~CMdfVideoDecodeHwDeviceAdapter();		
   1.101 +	TBool FrameBufferAvailable() const;
   1.102 +
   1.103 +	// from CMMFVideoHwDevice
   1.104 +    TAny* CustomInterface(TUid aInterface);
   1.105 +
   1.106 +	// from CMMFVideoPlayHwDevice
   1.107 +	CPostProcessorInfo* PostProcessorInfoLC();
   1.108 +	void GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats);
   1.109 +	void SetOutputFormatL(const TUncompressedVideoFormat &aFormat);
   1.110 +	void SetPostProcessTypesL(TUint32 aPostProcCombination);
   1.111 +	void SetInputCropOptionsL(const TRect& aRect);
   1.112 +	void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat);
   1.113 +	void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions);
   1.114 +	void SetRotateOptionsL(TRotationType aRotationType);
   1.115 +	void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
   1.116 +	void SetOutputCropOptionsL(const TRect& aRect);
   1.117 +	void SetPostProcSpecificOptionsL(const TDesC8& aOptions);
   1.118 +	void SetClockSource(MMMFClockSource* aClock);
   1.119 +	void SetVideoDestScreenL(TBool aScreen);
   1.120 +	void Initialize();
   1.121 +	void StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion);
   1.122 +	void SetScreenClipRegion(const TRegion& aRegion);
   1.123 +	void SetPauseOnClipFail(TBool aPause);
   1.124 +	void AbortDirectScreenAccess();
   1.125 +	TBool IsPlaying();
   1.126 +	void Redraw();
   1.127 +	void Start();
   1.128 +	void Stop();
   1.129 +	void Pause();
   1.130 +	void Resume();
   1.131 +	void SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition);
   1.132 +	void FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp);
   1.133 +	void ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp);
   1.134 +	TTimeIntervalMicroSeconds PlaybackPosition();
   1.135 +	TUint PictureBufferBytes();
   1.136 +	void GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters);
   1.137 +	void SetComplexityLevel(TUint aLevel);
   1.138 +	TUint NumComplexityLevels();
   1.139 +	void GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo);
   1.140 +	void ReturnPicture(TVideoPicture* aPicture);
   1.141 +	TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat);
   1.142 +	void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp);
   1.143 +	void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId);
   1.144 +	void CancelTimedSnapshot();
   1.145 +	void GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats);
   1.146 +	void InputEnd();
   1.147 +	void CommitL();
   1.148 +	void Revert();
   1.149 +
   1.150 +	// from CMMFVideoDecodeHwDevice
   1.151 +    CVideoDecoderInfo* VideoDecoderInfoLC();
   1.152 +	TVideoPictureHeader* GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TVideoInputBuffer* aDataUnit);
   1.153 +    void ReturnHeader(TVideoPictureHeader* aHeader);
   1.154 +    void SetInputFormatL(const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder);
   1.155 +    void SynchronizeDecoding(TBool aSynchronize);
   1.156 +    void SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions);
   1.157 +    void GetBufferOptions(CMMFDevVideoPlay::TBufferOptions& aOptions);
   1.158 +    void SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams);
   1.159 +    void SetOutputDevice(CMMFVideoPostProcHwDevice* aDevice);
   1.160 +    TTimeIntervalMicroSeconds DecodingPosition();
   1.161 +    TUint PreDecoderBufferBytes();
   1.162 +    void GetBitstreamCounters(CMMFDevVideoPlay::TBitstreamCounters& aCounters);
   1.163 +    TUint NumFreeBuffers();
   1.164 +    TVideoInputBuffer* GetBufferL(TUint aBufferSize);
   1.165 +    void WriteCodedDataL(TVideoInputBuffer* aBuffer);
   1.166 +	void SetProxy(MMMFDevVideoPlayProxy& aProxy);
   1.167 +	void ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader);
   1.168 +	
   1.169 +	// from MMdfVideoPlayerHwDeviceObserver
   1.170 +	TUint Time() const;
   1.171 +	TBool FrameAvailable() const;
   1.172 +	void DisplayFrame();
   1.173 +	void DiscardFrame();
   1.174 +	
   1.175 +	// from MMdfInputPortObserver
   1.176 +	void MipoWriteDataComplete(const MMdfInputPort* aInputPort, CMMFBuffer* aBuffer,
   1.177 +		TInt aErrorCode);
   1.178 +	void MipoDisconnectTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
   1.179 +	void MipoRestartTunnelComplete(const MMdfInputPort* aInputPort,	TInt aErrorCode);
   1.180 +	
   1.181 +	// from MMdfOutputPortObserver
   1.182 +	void MopoReadDataComplete(const MMdfOutputPort* aOutputPort, CMMFBuffer* aBuffer,
   1.183 +		TInt aErrorCode);
   1.184 +	void MopoDisconnectTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
   1.185 +	void MopoRestartTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
   1.186 +		
   1.187 +	// from MMdfProcessingUnitObserver
   1.188 +	void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   1.189 +	void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   1.190 +	// from MDevVideoHwDeviceAdapterSetup
   1.191 +	void LoadProcessingUnitL(const CImplementationInformation& aImplInfo);
   1.192 +
   1.193 +private:
   1.194 +	CMdfVideoDecodeHwDeviceAdapter();
   1.195 +	void ConstructL();
   1.196 +	
   1.197 +	void InitializeL();
   1.198 +	void DoPostPictureNotify();
   1.199 +	void DisplayFrameDirect(TVideoPicture* aPicture); 
   1.200 +	void DisplayLastFrameDirect(); 
   1.201 +	
   1.202 +	void SendLastBuffer();
   1.203 +	
   1.204 +private:
   1.205 +	// minimum decoder buffer useful data size.
   1.206 +	// to work around a problem with the decoder when too 
   1.207 +	// small a buffer passed to it will cause a KERN-EXEC:3;
   1.208 +	// the alternative is putting bounds-checking into the C code
   1.209 +	// throughout reading an encoded header, which would be inefficient
   1.210 +	static const TInt KVideoDecoderMinUsefulDataSize = 256;
   1.211 +
   1.212 +	// minimum decoder data buffer size.
   1.213 +	// the decoder will always return a buffer of at least this size.
   1.214 +	static const TInt KVideoDecoderMinDataBufferSize = 0x2000; // 8k
   1.215 +
   1.216 +	// maximum decoder data buffer size.
   1.217 +	// this is the largest buffer the decoder is able to return.
   1.218 +	static const TInt KVideoDecoderMaxDataBufferSize = 0x40000; // 512k
   1.219 +	
   1.220 +	MMMFDevVideoPlayProxy* iProxy;
   1.221 +
   1.222 +	// the decoder itself
   1.223 +	CMdfProcessingUnit* iDecoderPU;
   1.224 +	
   1.225 +	// the buffer manager
   1.226 +	CMdfVideoDecoderBufferManager* iBufferManager;
   1.227 +	
   1.228 +	// the player engine
   1.229 +	CMdfVideoPlayerEngine* iPlayerEngine;
   1.230 +	
   1.231 +	// the Processing Unit Loader plugin
   1.232 +	CMdfPuLoader* iPuLoader;
   1.233 +	
   1.234 +	// video format arrays (for VideoDecoderInfoLC())
   1.235 +	RPointerArray<CCompressedVideoFormat> iInputVidFormats;
   1.236 +	RArray<TUncompressedVideoFormat> iOutputVidFormats;
   1.237 +	RArray<TPictureRateAndSize> iPictureRates;
   1.238 +	
   1.239 +	// Processing Unit Ports
   1.240 +	MMdfInputPort* iDecoderPUInputPort; 
   1.241 +	MMdfOutputPort* iDecoderPUOutputPort;
   1.242 +
   1.243 +	// decoder settings
   1.244 +	TUncompressedVideoFormat iFormat;
   1.245 +	TReal32 iFrameRate;
   1.246 +	CMMFDevVideoPlay::TPictureCounters iPictureCounters;
   1.247 +	CMMFDevVideoPlay::TBitstreamCounters iBitstreamCounters;
   1.248 +	CMMFDevVideoPlay::TComplexityLevelInfo iComplexityLevelInfo;
   1.249 +	CMMFDevVideoPlay::TBufferOptions iBufferOptions;
   1.250 +	
   1.251 +	// clock settings
   1.252 +	MMMFClockSource* iClockSource;
   1.253 +	TBool iSynchronize;
   1.254 +	TInt64 iSystemClock;	// system clock without HAL
   1.255 +	
   1.256 +	// header info
   1.257 +	TVideoPictureHeader* iPictureHeader;
   1.258 +			
   1.259 +	// input data buffer pointers 
   1.260 +	CVideoDataBuffer* iInputBuffer; // not owned
   1.261 +	CMMFBuffer* iPUInputBuffer; // not owned
   1.262 +	
   1.263 +	// parameters for decoding loop
   1.264 +	TInt iInDataSize;
   1.265 +	TInt iTotalBytesUsed;
   1.266 +	
   1.267 +	// player settings
   1.268 +	TBool iPrimed;
   1.269 +	TBool iInputBufferWaiting;
   1.270 +	TBool iInputEnd;
   1.271 +	TSize iFrameSize;
   1.272 +	
   1.273 +	TBool iDisplayPictureAvailable;
   1.274 +	
   1.275 +	// post-processor output device, if any
   1.276 +	CMMFVideoPostProcHwDevice* iPostProcOutputDevice;
   1.277 +	
   1.278 +	// direct screen access
   1.279 +	TBool iDSAEnabled;
   1.280 +	TBool iDSAStarted;
   1.281 +	CFbsScreenDevice* iScreenDevice; // not owned
   1.282 +	CFbsBitGc* iScreenDeviceGc;
   1.283 +	TRect iScreenDeviceRect;
   1.284 +	
   1.285 +	TUid iPuLoaderDtorKey;	
   1.286 +	THwDevAdapterState iState;	
   1.287 +	TBool iPUInitialized;
   1.288 +	
   1.289 +	CCodecApiVideoOpaqueData* iPuData;	
   1.290 +	HBufC* iManufacturer;
   1.291 +	TUid iPuUid;
   1.292 +	TBool iLastFrameBufferReceived;
   1.293 +	TSize iMaxPictureSize;
   1.294 +	TBool iWriteRequestOutstanding;
   1.295 +	};
   1.296 +
   1.297 +#endif // MDFVIDEODECODEHWDEVICEADAPTER_H