os/mm/mmdevicefw/mdf/src/video/encoderadapter/mdfvideoencodehwdeviceadapter.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // mdfvideoencoderhwdeviceadapter.h
    15 // 
    16 //
    17 
    18 #ifndef MDFVIDEOENCODEHWDEVICEADAPTER_H
    19 #define MDFVIDEOENCODEHWDEVICEADAPTER_H
    20 
    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>
    31 #endif
    32 
    33 class CMMFDescriptorBuffer;
    34 
    35 /**
    36 Video encoder hardware device. 
    37 This is the DevVideo encoder plugin component talking to a processing unit.
    38 @internalComponent
    39 */
    40 class CMdfVideoEncodeHwDeviceAdapter :  public CMMFVideoEncodeHwDevice,
    41 										public MMdfInputPortObserver,
    42 										public MMdfOutputPortObserver,
    43 										public MMdfProcessingUnitObserver,
    44 										public MDevVideoHwDeviceAdapterSetup
    45 	{
    46 public:
    47 	static CMdfVideoEncodeHwDeviceAdapter* NewL();
    48 	~CMdfVideoEncodeHwDeviceAdapter();
    49 	// from CMMFVideoHwDevice
    50     TAny* CustomInterface(TUid aInterface);
    51 
    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);
    69 	void Initialize();
    70 	void WritePictureL(TVideoPicture* aPicture);
    71 	void InputEnd();
    72 	void Start();
    73 	void Stop();
    74 	void Pause();
    75 	void Resume();
    76 	void Freeze();
    77 	void ReleaseFreeze();
    78 	TTimeIntervalMicroSeconds RecordingPosition();
    79 	void GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters);
    80 	void GetFrameStabilisationOutput(TRect& aRect);
    81 	TUint NumComplexityLevels();
    82 	void SetComplexityLevel(TUint aLevel);
    83 	void CommitL();
    84 	void Revert();
    85 
    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, 
   108 									  TReal aLossRate, 
   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, 
   114 									TUint aNumSteps,
   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);
   126 	void PictureLoss();
   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);
   131 
   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);
   136 
   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);	
   141 
   142 	// from MMdfProcessingUnitObserver
   143 	void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   144 	void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   145 	
   146 	// from MDevVideoHwDeviceAdapterSetup
   147 	void LoadProcessingUnitL(const CImplementationInformation& aImplInfo);
   148 private:
   149 	CMdfVideoEncodeHwDeviceAdapter();
   150 	void InitializeL();
   151 	void ConstructL();
   152 
   153 private:
   154 	// call back class for the DevVideo
   155 	MMMFDevVideoRecordProxy* iProxy;
   156 	
   157 	// the encoder itself
   158 	CMdfProcessingUnit* iEncoderPU;
   159 
   160 	// the processing unit loader	
   161 	CMdfPuLoader* iPuLoader;
   162 	TUid iPuLoaderDtorKey;
   163 
   164 	// encoder port arrays
   165 	RPointerArray<MMdfInputPort>  iEncoderPUInputPortsArray;
   166 	RPointerArray<MMdfOutputPort> iEncoderPUOutputPortsArray;
   167 
   168 	// encoder settings
   169 	TUncompressedVideoFormat iFormat;
   170 	TSize iPictureSize;
   171 	TReal32 iFrameRate;
   172 	CMMFDevVideoRecord::TPictureCounters iPictureCounters;
   173 
   174 	// video format arrays (for VideoEncoderInfoLC())
   175 	RArray<CCompressedVideoFormat*> iOutputVideoFormats;
   176 	RArray<TUncompressedVideoFormat> iInputVideoFormats;
   177 	RArray<TPictureRateAndSize> iPictureRates;
   178 
   179 	// output data buffers
   180 	RArray<TVideoOutputBuffer> iDataBuffers;
   181 	
   182 	TBool iInputStreamEnd;
   183 	
   184 	// buffers used to communicate to the encoder PU
   185 	CMMFDescriptorBuffer* iInputBuffer;
   186 	CMMFDescriptorBuffer* iOutputBuffer;
   187 	
   188 	TVideoPicture* iCurrentPicture;	
   189 		
   190 	// Uid of PU to load
   191 	TUid iPuUid;
   192 
   193 	CCodecApiVideoOpaqueData* iPuData;	
   194 	HBufC* iManufacturer;
   195 	};
   196 
   197 #endif // MDFVIDEOENCODEHWDEVICEADAPTER_H