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.
14 // mdfvideoencoderhwdeviceadapter.h
18 #ifndef MDFVIDEOENCODEHWDEVICEADAPTER_H
19 #define MDFVIDEOENCODEHWDEVICEADAPTER_H
21 #include <mmf/devvideo/videorecordhwdevice.h>
22 #include <mdf/mdfinputport.h>
23 #include <mdf/mdfoutputport.h>
24 #include <mdf/mdfprocessingunit.h>
25 #include <mdf/mdfpuloader.h>
26 #include <mdf/codecapivideoresolverutils.h>
27 #include "mdfvideoencodehwdeviceadapter.hrh"
28 #include <mmf/devvideo/devvideobase.h>
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
30 #include <mmf/devvideo/devvideohwdeviceadaptersetup.h>
33 class CMMFDescriptorBuffer;
36 Video encoder hardware device.
37 This is the DevVideo encoder plugin component talking to a processing unit.
40 class CMdfVideoEncodeHwDeviceAdapter : public CMMFVideoEncodeHwDevice,
41 public MMdfInputPortObserver,
42 public MMdfOutputPortObserver,
43 public MMdfProcessingUnitObserver,
44 public MDevVideoHwDeviceAdapterSetup
47 static CMdfVideoEncodeHwDeviceAdapter* NewL();
48 ~CMdfVideoEncodeHwDeviceAdapter();
49 // from CMMFVideoHwDevice
50 TAny* CustomInterface(TUid aInterface);
52 // from CMMFVideoRecordHwDevice
53 CPreProcessorInfo* PreProcessorInfoLC();
54 void SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize);
55 void SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate);
56 void SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime);
57 void SetClockSource(MMMFClockSource* aClock);
58 void SetPreProcessTypesL(TUint32 aPreProcessTypes);
59 void SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat);
60 void SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat);
61 void SetRotateOptionsL(TRotationType aRotationType);
62 void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
63 void SetInputCropOptionsL(const TRect& aRect);
64 void SetOutputCropOptionsL(const TRect& aRect);
65 void SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos);
66 void SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions);
67 void SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation);
68 void SetCustomPreProcessOptionsL(const TDesC8& aOptions);
70 void WritePictureL(TVideoPicture* aPicture);
78 TTimeIntervalMicroSeconds RecordingPosition();
79 void GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters);
80 void GetFrameStabilisationOutput(TRect& aRect);
81 TUint NumComplexityLevels();
82 void SetComplexityLevel(TUint aLevel);
86 // from CMMFVideoEncodeHwDevice
87 CVideoEncoderInfo* VideoEncoderInfoLC();
88 void SetOutputFormatL(const CCompressedVideoFormat& aFormat,
89 TVideoDataUnitType aDataUnitType,
90 TVideoDataUnitEncapsulation aDataEncapsulation,
91 TBool aSegmentationAllowed=EFalse);
92 void SetOutputRectL(const TRect& aRect);
93 void SetInputDevice(CMMFVideoPreProcHwDevice* aDevice);
94 void SetErrorsExpected(TBool aBitErrors, TBool aPacketLosses);
95 void SetMinRandomAccessRate(TReal aRate);
96 void SetNumBitrateLayersL(TUint aNumLayers);
97 void SetScalabilityLayerTypeL(TUint aLayer, TScalabilityType aScalabilityType);
98 void SetGlobalReferenceOptions(TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay);
99 void SetLayerReferenceOptions(TUint aLayer, TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay);
100 void SetBufferOptionsL(const TEncoderBufferOptions& aOptions);
101 void SetCodingStandardSpecificOptionsL(const TDesC8& aOptions);
102 void SetImplementationSpecificEncoderOptionsL(const TDesC8& aOptions);
103 HBufC8* CodingStandardSpecificInitOutputLC();
104 HBufC8* ImplementationSpecificInitOutputLC();
105 void SetErrorProtectionLevelsL(TUint aNumLevels, TBool aSeparateBuffers);
106 void SetErrorProtectionLevelL(TUint aLevel, TUint aBitrate, TUint aStrength);
107 void SetChannelPacketLossRate(TUint aLevel,
109 TTimeIntervalMicroSeconds32 aLossBurstLength);
110 void SetChannelBitErrorRate(TUint aLevel, TReal aErrorRate, TReal aStdDeviation);
111 void SetSegmentTargetSize(TUint aLayer, TUint aSizeBytes, TUint aSizeMacroblocks);
112 void SetRateControlOptions(TUint aLayer, const TRateControlOptions& aOptions);
113 void SetInLayerScalabilityL(TUint aLayer,
115 TInLayerScalabilityType aScalabilityType,
116 const TArray<TUint>& aBitrateShare,
117 const TArray<TUint>& aPictureShare);
118 void SetLayerPromotionPointPeriod(TUint aLayer, TUint aPeriod);
119 HBufC8* CodingStandardSpecificSettingsOutputLC();
120 HBufC8* ImplementationSpecificSettingsOutputLC();
121 void SendSupplementalInfoL(const TDesC8& aData);
122 void SendSupplementalInfoL(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp);
123 void CancelSupplementalInfo();
124 void GetOutputBufferStatus(TUint& aNumFreeBuffers, TUint& aTotalFreeBytes);
125 void ReturnBuffer(TVideoOutputBuffer* aBuffer);
127 void PictureLoss(const TArray<TPictureId>& aPictures);
128 void SliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture);
129 void ReferencePictureSelection(const TDesC8& aSelectionData);
130 void SetProxy(MMMFDevVideoRecordProxy& aProxy);
132 // from MMdfInputPortObserver
133 void MipoWriteDataComplete(const MMdfInputPort* aInputPort,CMMFBuffer* aBuffer, TInt aErrorCode);
134 void MipoDisconnectTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
135 void MipoRestartTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
137 // from MMdfOutputPortObserver
138 void MopoReadDataComplete(const MMdfOutputPort* aOutputPort, CMMFBuffer* aBuffer, TInt aErrorCode);
139 void MopoDisconnectTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
140 void MopoRestartTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
142 // from MMdfProcessingUnitObserver
143 void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
144 void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
146 // from MDevVideoHwDeviceAdapterSetup
147 void LoadProcessingUnitL(const CImplementationInformation& aImplInfo);
149 CMdfVideoEncodeHwDeviceAdapter();
154 // call back class for the DevVideo
155 MMMFDevVideoRecordProxy* iProxy;
157 // the encoder itself
158 CMdfProcessingUnit* iEncoderPU;
160 // the processing unit loader
161 CMdfPuLoader* iPuLoader;
162 TUid iPuLoaderDtorKey;
164 // encoder port arrays
165 RPointerArray<MMdfInputPort> iEncoderPUInputPortsArray;
166 RPointerArray<MMdfOutputPort> iEncoderPUOutputPortsArray;
169 TUncompressedVideoFormat iFormat;
172 CMMFDevVideoRecord::TPictureCounters iPictureCounters;
174 // video format arrays (for VideoEncoderInfoLC())
175 RArray<CCompressedVideoFormat*> iOutputVideoFormats;
176 RArray<TUncompressedVideoFormat> iInputVideoFormats;
177 RArray<TPictureRateAndSize> iPictureRates;
179 // output data buffers
180 RArray<TVideoOutputBuffer> iDataBuffers;
182 TBool iInputStreamEnd;
184 // buffers used to communicate to the encoder PU
185 CMMFDescriptorBuffer* iInputBuffer;
186 CMMFDescriptorBuffer* iOutputBuffer;
188 TVideoPicture* iCurrentPicture;
193 CCodecApiVideoOpaqueData* iPuData;
194 HBufC* iManufacturer;
197 #endif // MDFVIDEOENCODEHWDEVICEADAPTER_H