Update contrib.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef MDFVIDEODECODEHWDEVICEADAPTER_H
17 #define MDFVIDEODECODEHWDEVICEADAPTER_H
20 #include <mmf/devvideo/videoplayhwdevice.h>
21 #include "mdfvideodecodehwdeviceadapter.hrh"
22 #include <mmf/server/mmfdatabuffer.h>
24 #include <mdf/mdfinputport.h>
25 #include <mdf/mdfoutputport.h>
26 #include <mdf/mdfprocessingunit.h>
27 #include <mdf/mdfpuloader.h>
28 #include <mdf/codecapivideoresolverutils.h>
29 #include <mmf/devvideo/devvideopuconfig.h>
30 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
31 #include <mmf/devvideo/devvideohwdeviceadaptersetup.h>
34 // From hwdevicevideoutils.dll
35 #include "mdfvideodecoderbuffermanager.h"
36 #include "mdfplayerengine.h"
38 const TUid KUidDevVideoDecodeHwDevice = {KUidDevVideoDecoderHwDeviceDefine};
41 _LIT(KVideoDecoderInfoManufacturer, "Symbian Ltd.");
42 _LIT8(KVideoDecoderInfoCSInfo, "Coded by Symbian");
43 _LIT8(KVideoDecoderInfoISInfo, "Implemented by Symbian");
44 const TInt KVideoDecoderInfoVersionMaj = 0;
45 const TInt KVideoDecoderInfoVersionMin = 1;
46 const TInt KVideoDecoderInfoVersionBuild = 1;
49 Video decoder hardware device.
50 This is the DevVideo decoder plugin component
53 class CMdfVideoDecodeHwDeviceAdapter : public CMMFVideoDecodeHwDevice,
54 public MMdfVideoPlayerHwDeviceObserver,
55 public MMdfInputPortObserver,
56 public MMdfOutputPortObserver,
57 public MMdfProcessingUnitObserver,
58 public MDevVideoHwDeviceAdapterSetup
65 The current state of the Hardware Device Adapter.
67 enum THwDevAdapterState
70 The PULoader has been loaded.
72 EProcessingUnitLoaderLoaded,
74 The Processing Units have been loaded.
76 EProcessingUnitLoaded,
78 The Processing Units are currently being initialised.
80 EProcessingUnitInitializing,
82 The Processing Units are currently in the idle state.
86 The Processing Units are currently in the executing state.
88 EProcessingUnitExecuting,
90 The Processing Units are currently in the paused state.
96 static CMdfVideoDecodeHwDeviceAdapter* NewL();
97 ~CMdfVideoDecodeHwDeviceAdapter();
98 TBool FrameBufferAvailable() const;
100 // from CMMFVideoHwDevice
101 TAny* CustomInterface(TUid aInterface);
103 // from CMMFVideoPlayHwDevice
104 CPostProcessorInfo* PostProcessorInfoLC();
105 void GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats);
106 void SetOutputFormatL(const TUncompressedVideoFormat &aFormat);
107 void SetPostProcessTypesL(TUint32 aPostProcCombination);
108 void SetInputCropOptionsL(const TRect& aRect);
109 void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat);
110 void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions);
111 void SetRotateOptionsL(TRotationType aRotationType);
112 void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
113 void SetOutputCropOptionsL(const TRect& aRect);
114 void SetPostProcSpecificOptionsL(const TDesC8& aOptions);
115 void SetClockSource(MMMFClockSource* aClock);
116 void SetVideoDestScreenL(TBool aScreen);
118 void StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion);
119 void SetScreenClipRegion(const TRegion& aRegion);
120 void SetPauseOnClipFail(TBool aPause);
121 void AbortDirectScreenAccess();
128 void SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition);
129 void FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp);
130 void ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp);
131 TTimeIntervalMicroSeconds PlaybackPosition();
132 TUint PictureBufferBytes();
133 void GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters);
134 void SetComplexityLevel(TUint aLevel);
135 TUint NumComplexityLevels();
136 void GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo);
137 void ReturnPicture(TVideoPicture* aPicture);
138 TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat);
139 void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp);
140 void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId);
141 void CancelTimedSnapshot();
142 void GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats);
147 // from CMMFVideoDecodeHwDevice
148 CVideoDecoderInfo* VideoDecoderInfoLC();
149 TVideoPictureHeader* GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TVideoInputBuffer* aDataUnit);
150 void ReturnHeader(TVideoPictureHeader* aHeader);
151 void SetInputFormatL(const CCompressedVideoFormat& aFormat, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation, TBool aDataInOrder);
152 void SynchronizeDecoding(TBool aSynchronize);
153 void SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions);
154 void GetBufferOptions(CMMFDevVideoPlay::TBufferOptions& aOptions);
155 void SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams);
156 void SetOutputDevice(CMMFVideoPostProcHwDevice* aDevice);
157 TTimeIntervalMicroSeconds DecodingPosition();
158 TUint PreDecoderBufferBytes();
159 void GetBitstreamCounters(CMMFDevVideoPlay::TBitstreamCounters& aCounters);
160 TUint NumFreeBuffers();
161 TVideoInputBuffer* GetBufferL(TUint aBufferSize);
162 void WriteCodedDataL(TVideoInputBuffer* aBuffer);
163 void SetProxy(MMMFDevVideoPlayProxy& aProxy);
164 void ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader);
166 // from MMdfVideoPlayerHwDeviceObserver
168 TBool FrameAvailable() const;
172 // from MMdfInputPortObserver
173 void MipoWriteDataComplete(const MMdfInputPort* aInputPort, CMMFBuffer* aBuffer,
175 void MipoDisconnectTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
176 void MipoRestartTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
178 // from MMdfOutputPortObserver
179 void MopoReadDataComplete(const MMdfOutputPort* aOutputPort, CMMFBuffer* aBuffer,
181 void MopoDisconnectTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
182 void MopoRestartTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
184 // from MMdfProcessingUnitObserver
185 void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
186 void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
187 // from MDevVideoHwDeviceAdapterSetup
188 void LoadProcessingUnitL(const CImplementationInformation& aImplInfo);
191 CMdfVideoDecodeHwDeviceAdapter();
195 void DoPostPictureNotify();
196 void DisplayFrameDirect(TVideoPicture* aPicture);
197 void DisplayLastFrameDirect();
199 void SendLastBuffer();
202 // minimum decoder buffer useful data size.
203 // to work around a problem with the decoder when too
204 // small a buffer passed to it will cause a KERN-EXEC:3;
205 // the alternative is putting bounds-checking into the C code
206 // throughout reading an encoded header, which would be inefficient
207 static const TInt KVideoDecoderMinUsefulDataSize = 256;
209 // minimum decoder data buffer size.
210 // the decoder will always return a buffer of at least this size.
211 static const TInt KVideoDecoderMinDataBufferSize = 0x2000; // 8k
213 // maximum decoder data buffer size.
214 // this is the largest buffer the decoder is able to return.
215 static const TInt KVideoDecoderMaxDataBufferSize = 0x40000; // 512k
217 MMMFDevVideoPlayProxy* iProxy;
219 // the decoder itself
220 CMdfProcessingUnit* iDecoderPU;
222 // the buffer manager
223 CMdfVideoDecoderBufferManager* iBufferManager;
226 CMdfVideoPlayerEngine* iPlayerEngine;
228 // the Processing Unit Loader plugin
229 CMdfPuLoader* iPuLoader;
231 // video format arrays (for VideoDecoderInfoLC())
232 RPointerArray<CCompressedVideoFormat> iInputVidFormats;
233 RArray<TUncompressedVideoFormat> iOutputVidFormats;
234 RArray<TPictureRateAndSize> iPictureRates;
236 // Processing Unit Ports
237 MMdfInputPort* iDecoderPUInputPort;
238 MMdfOutputPort* iDecoderPUOutputPort;
241 TUncompressedVideoFormat iFormat;
243 CMMFDevVideoPlay::TPictureCounters iPictureCounters;
244 CMMFDevVideoPlay::TBitstreamCounters iBitstreamCounters;
245 CMMFDevVideoPlay::TComplexityLevelInfo iComplexityLevelInfo;
246 CMMFDevVideoPlay::TBufferOptions iBufferOptions;
249 MMMFClockSource* iClockSource;
251 TInt64 iSystemClock; // system clock without HAL
254 TVideoPictureHeader* iPictureHeader;
256 // input data buffer pointers
257 CVideoDataBuffer* iInputBuffer; // not owned
258 CMMFBuffer* iPUInputBuffer; // not owned
260 // parameters for decoding loop
262 TInt iTotalBytesUsed;
266 TBool iInputBufferWaiting;
270 TBool iDisplayPictureAvailable;
272 // post-processor output device, if any
273 CMMFVideoPostProcHwDevice* iPostProcOutputDevice;
275 // direct screen access
278 CFbsScreenDevice* iScreenDevice; // not owned
279 CFbsBitGc* iScreenDeviceGc;
280 TRect iScreenDeviceRect;
282 TUid iPuLoaderDtorKey;
283 THwDevAdapterState iState;
284 TBool iPUInitialized;
286 CCodecApiVideoOpaqueData* iPuData;
287 HBufC* iManufacturer;
289 TBool iLastFrameBufferReceived;
290 TSize iMaxPictureSize;
291 TBool iWriteRequestOutstanding;
294 #endif // MDFVIDEODECODEHWDEVICEADAPTER_H