os/mm/mmdevicefw/mdf/src/video/encoderadapter/mdfvideoencodehwdeviceadapter.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/encoderadapter/mdfvideoencodehwdeviceadapter.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,197 @@
     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 +// mdfvideoencoderhwdeviceadapter.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef MDFVIDEOENCODEHWDEVICEADAPTER_H
    1.22 +#define MDFVIDEOENCODEHWDEVICEADAPTER_H
    1.23 +
    1.24 +#include <mmf/devvideo/videorecordhwdevice.h>
    1.25 +#include <mdf/mdfinputport.h>
    1.26 +#include <mdf/mdfoutputport.h>
    1.27 +#include <mdf/mdfprocessingunit.h>
    1.28 +#include <mdf/mdfpuloader.h>
    1.29 +#include <mdf/codecapivideoresolverutils.h>
    1.30 +#include "mdfvideoencodehwdeviceadapter.hrh"
    1.31 +#include <mmf/devvideo/devvideobase.h>
    1.32 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.33 +#include <mmf/devvideo/devvideohwdeviceadaptersetup.h>
    1.34 +#endif
    1.35 +
    1.36 +class CMMFDescriptorBuffer;
    1.37 +
    1.38 +/**
    1.39 +Video encoder hardware device. 
    1.40 +This is the DevVideo encoder plugin component talking to a processing unit.
    1.41 +@internalComponent
    1.42 +*/
    1.43 +class CMdfVideoEncodeHwDeviceAdapter :  public CMMFVideoEncodeHwDevice,
    1.44 +										public MMdfInputPortObserver,
    1.45 +										public MMdfOutputPortObserver,
    1.46 +										public MMdfProcessingUnitObserver,
    1.47 +										public MDevVideoHwDeviceAdapterSetup
    1.48 +	{
    1.49 +public:
    1.50 +	static CMdfVideoEncodeHwDeviceAdapter* NewL();
    1.51 +	~CMdfVideoEncodeHwDeviceAdapter();
    1.52 +	// from CMMFVideoHwDevice
    1.53 +    TAny* CustomInterface(TUid aInterface);
    1.54 +
    1.55 +	// from CMMFVideoRecordHwDevice
    1.56 +	CPreProcessorInfo* PreProcessorInfoLC();
    1.57 +	void SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize);
    1.58 +	void SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate);
    1.59 +	void SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime);
    1.60 +	void SetClockSource(MMMFClockSource* aClock);
    1.61 +	void SetPreProcessTypesL(TUint32 aPreProcessTypes);
    1.62 +	void SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat);
    1.63 +	void SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat);
    1.64 +	void SetRotateOptionsL(TRotationType aRotationType);
    1.65 +	void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
    1.66 +	void SetInputCropOptionsL(const TRect& aRect);
    1.67 +	void SetOutputCropOptionsL(const TRect& aRect);
    1.68 +	void SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos);
    1.69 +	void SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions);
    1.70 +	void SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation);
    1.71 +	void SetCustomPreProcessOptionsL(const TDesC8& aOptions);
    1.72 +	void Initialize();
    1.73 +	void WritePictureL(TVideoPicture* aPicture);
    1.74 +	void InputEnd();
    1.75 +	void Start();
    1.76 +	void Stop();
    1.77 +	void Pause();
    1.78 +	void Resume();
    1.79 +	void Freeze();
    1.80 +	void ReleaseFreeze();
    1.81 +	TTimeIntervalMicroSeconds RecordingPosition();
    1.82 +	void GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters);
    1.83 +	void GetFrameStabilisationOutput(TRect& aRect);
    1.84 +	TUint NumComplexityLevels();
    1.85 +	void SetComplexityLevel(TUint aLevel);
    1.86 +	void CommitL();
    1.87 +	void Revert();
    1.88 +
    1.89 +	// from CMMFVideoEncodeHwDevice
    1.90 +	CVideoEncoderInfo* VideoEncoderInfoLC();
    1.91 +	void SetOutputFormatL(const CCompressedVideoFormat& aFormat, 
    1.92 +								  TVideoDataUnitType aDataUnitType, 
    1.93 +								  TVideoDataUnitEncapsulation aDataEncapsulation,
    1.94 +								  TBool aSegmentationAllowed=EFalse);
    1.95 +	void SetOutputRectL(const TRect& aRect);
    1.96 +	void SetInputDevice(CMMFVideoPreProcHwDevice* aDevice);
    1.97 +	void SetErrorsExpected(TBool aBitErrors, TBool aPacketLosses);
    1.98 +	void SetMinRandomAccessRate(TReal aRate);
    1.99 +	void SetNumBitrateLayersL(TUint aNumLayers);
   1.100 +	void SetScalabilityLayerTypeL(TUint aLayer, TScalabilityType aScalabilityType);
   1.101 +	void SetGlobalReferenceOptions(TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay);
   1.102 +	void SetLayerReferenceOptions(TUint aLayer, TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay);
   1.103 +	void SetBufferOptionsL(const TEncoderBufferOptions& aOptions);
   1.104 +	void SetCodingStandardSpecificOptionsL(const TDesC8& aOptions);
   1.105 +	void SetImplementationSpecificEncoderOptionsL(const TDesC8& aOptions);
   1.106 +	HBufC8* CodingStandardSpecificInitOutputLC();
   1.107 +	HBufC8* ImplementationSpecificInitOutputLC();
   1.108 +	void SetErrorProtectionLevelsL(TUint aNumLevels, TBool aSeparateBuffers);
   1.109 +	void SetErrorProtectionLevelL(TUint aLevel, TUint aBitrate, TUint aStrength);
   1.110 +	void SetChannelPacketLossRate(TUint aLevel, 
   1.111 +									  TReal aLossRate, 
   1.112 +									  TTimeIntervalMicroSeconds32 aLossBurstLength);
   1.113 +	void SetChannelBitErrorRate(TUint aLevel, TReal aErrorRate, TReal aStdDeviation);
   1.114 +	void SetSegmentTargetSize(TUint aLayer, TUint aSizeBytes, TUint aSizeMacroblocks);
   1.115 +	void SetRateControlOptions(TUint aLayer, const TRateControlOptions& aOptions);
   1.116 +	void SetInLayerScalabilityL(TUint aLayer, 
   1.117 +									TUint aNumSteps,
   1.118 +									TInLayerScalabilityType aScalabilityType,
   1.119 +									const TArray<TUint>& aBitrateShare,
   1.120 +									const TArray<TUint>& aPictureShare);
   1.121 +	void SetLayerPromotionPointPeriod(TUint aLayer, TUint aPeriod);
   1.122 +	HBufC8* CodingStandardSpecificSettingsOutputLC();
   1.123 +	HBufC8* ImplementationSpecificSettingsOutputLC();
   1.124 +	void SendSupplementalInfoL(const TDesC8& aData);
   1.125 +	void SendSupplementalInfoL(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp);
   1.126 +	void CancelSupplementalInfo();
   1.127 +	void GetOutputBufferStatus(TUint& aNumFreeBuffers, TUint& aTotalFreeBytes);
   1.128 +	void ReturnBuffer(TVideoOutputBuffer* aBuffer);
   1.129 +	void PictureLoss();
   1.130 +	void PictureLoss(const TArray<TPictureId>& aPictures);
   1.131 +	void SliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture);
   1.132 +	void ReferencePictureSelection(const TDesC8& aSelectionData);
   1.133 +	void SetProxy(MMMFDevVideoRecordProxy& aProxy);
   1.134 +
   1.135 +	// from MMdfInputPortObserver
   1.136 +	void MipoWriteDataComplete(const MMdfInputPort* aInputPort,CMMFBuffer* aBuffer, TInt aErrorCode);
   1.137 +	void MipoDisconnectTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
   1.138 +	void MipoRestartTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
   1.139 +
   1.140 +	// from MMdfOutputPortObserver
   1.141 +	void MopoReadDataComplete(const MMdfOutputPort* aOutputPort, CMMFBuffer* aBuffer, TInt aErrorCode);
   1.142 +	void MopoDisconnectTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
   1.143 +	void MopoRestartTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);	
   1.144 +
   1.145 +	// from MMdfProcessingUnitObserver
   1.146 +	void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   1.147 +	void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   1.148 +	
   1.149 +	// from MDevVideoHwDeviceAdapterSetup
   1.150 +	void LoadProcessingUnitL(const CImplementationInformation& aImplInfo);
   1.151 +private:
   1.152 +	CMdfVideoEncodeHwDeviceAdapter();
   1.153 +	void InitializeL();
   1.154 +	void ConstructL();
   1.155 +
   1.156 +private:
   1.157 +	// call back class for the DevVideo
   1.158 +	MMMFDevVideoRecordProxy* iProxy;
   1.159 +	
   1.160 +	// the encoder itself
   1.161 +	CMdfProcessingUnit* iEncoderPU;
   1.162 +
   1.163 +	// the processing unit loader	
   1.164 +	CMdfPuLoader* iPuLoader;
   1.165 +	TUid iPuLoaderDtorKey;
   1.166 +
   1.167 +	// encoder port arrays
   1.168 +	RPointerArray<MMdfInputPort>  iEncoderPUInputPortsArray;
   1.169 +	RPointerArray<MMdfOutputPort> iEncoderPUOutputPortsArray;
   1.170 +
   1.171 +	// encoder settings
   1.172 +	TUncompressedVideoFormat iFormat;
   1.173 +	TSize iPictureSize;
   1.174 +	TReal32 iFrameRate;
   1.175 +	CMMFDevVideoRecord::TPictureCounters iPictureCounters;
   1.176 +
   1.177 +	// video format arrays (for VideoEncoderInfoLC())
   1.178 +	RArray<CCompressedVideoFormat*> iOutputVideoFormats;
   1.179 +	RArray<TUncompressedVideoFormat> iInputVideoFormats;
   1.180 +	RArray<TPictureRateAndSize> iPictureRates;
   1.181 +
   1.182 +	// output data buffers
   1.183 +	RArray<TVideoOutputBuffer> iDataBuffers;
   1.184 +	
   1.185 +	TBool iInputStreamEnd;
   1.186 +	
   1.187 +	// buffers used to communicate to the encoder PU
   1.188 +	CMMFDescriptorBuffer* iInputBuffer;
   1.189 +	CMMFDescriptorBuffer* iOutputBuffer;
   1.190 +	
   1.191 +	TVideoPicture* iCurrentPicture;	
   1.192 +		
   1.193 +	// Uid of PU to load
   1.194 +	TUid iPuUid;
   1.195 +
   1.196 +	CCodecApiVideoOpaqueData* iPuData;	
   1.197 +	HBufC* iManufacturer;
   1.198 +	};
   1.199 +
   1.200 +#endif // MDFVIDEOENCODEHWDEVICEADAPTER_H