os/mm/mmdevicefw/mdf/src/video/encoderadapter/mdfvideoencodehwdeviceadapter.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// mdfvideoencoderhwdeviceadapter.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef MDFVIDEOENCODEHWDEVICEADAPTER_H
sl@0
    19
#define MDFVIDEOENCODEHWDEVICEADAPTER_H
sl@0
    20
sl@0
    21
#include <mmf/devvideo/videorecordhwdevice.h>
sl@0
    22
#include <mdf/mdfinputport.h>
sl@0
    23
#include <mdf/mdfoutputport.h>
sl@0
    24
#include <mdf/mdfprocessingunit.h>
sl@0
    25
#include <mdf/mdfpuloader.h>
sl@0
    26
#include <mdf/codecapivideoresolverutils.h>
sl@0
    27
#include "mdfvideoencodehwdeviceadapter.hrh"
sl@0
    28
#include <mmf/devvideo/devvideobase.h>
sl@0
    29
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    30
#include <mmf/devvideo/devvideohwdeviceadaptersetup.h>
sl@0
    31
#endif
sl@0
    32
sl@0
    33
class CMMFDescriptorBuffer;
sl@0
    34
sl@0
    35
/**
sl@0
    36
Video encoder hardware device. 
sl@0
    37
This is the DevVideo encoder plugin component talking to a processing unit.
sl@0
    38
@internalComponent
sl@0
    39
*/
sl@0
    40
class CMdfVideoEncodeHwDeviceAdapter :  public CMMFVideoEncodeHwDevice,
sl@0
    41
										public MMdfInputPortObserver,
sl@0
    42
										public MMdfOutputPortObserver,
sl@0
    43
										public MMdfProcessingUnitObserver,
sl@0
    44
										public MDevVideoHwDeviceAdapterSetup
sl@0
    45
	{
sl@0
    46
public:
sl@0
    47
	static CMdfVideoEncodeHwDeviceAdapter* NewL();
sl@0
    48
	~CMdfVideoEncodeHwDeviceAdapter();
sl@0
    49
	// from CMMFVideoHwDevice
sl@0
    50
    TAny* CustomInterface(TUid aInterface);
sl@0
    51
sl@0
    52
	// from CMMFVideoRecordHwDevice
sl@0
    53
	CPreProcessorInfo* PreProcessorInfoLC();
sl@0
    54
	void SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize);
sl@0
    55
	void SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate);
sl@0
    56
	void SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime);
sl@0
    57
	void SetClockSource(MMMFClockSource* aClock);
sl@0
    58
	void SetPreProcessTypesL(TUint32 aPreProcessTypes);
sl@0
    59
	void SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat);
sl@0
    60
	void SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat);
sl@0
    61
	void SetRotateOptionsL(TRotationType aRotationType);
sl@0
    62
	void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
sl@0
    63
	void SetInputCropOptionsL(const TRect& aRect);
sl@0
    64
	void SetOutputCropOptionsL(const TRect& aRect);
sl@0
    65
	void SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos);
sl@0
    66
	void SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions);
sl@0
    67
	void SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation);
sl@0
    68
	void SetCustomPreProcessOptionsL(const TDesC8& aOptions);
sl@0
    69
	void Initialize();
sl@0
    70
	void WritePictureL(TVideoPicture* aPicture);
sl@0
    71
	void InputEnd();
sl@0
    72
	void Start();
sl@0
    73
	void Stop();
sl@0
    74
	void Pause();
sl@0
    75
	void Resume();
sl@0
    76
	void Freeze();
sl@0
    77
	void ReleaseFreeze();
sl@0
    78
	TTimeIntervalMicroSeconds RecordingPosition();
sl@0
    79
	void GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters);
sl@0
    80
	void GetFrameStabilisationOutput(TRect& aRect);
sl@0
    81
	TUint NumComplexityLevels();
sl@0
    82
	void SetComplexityLevel(TUint aLevel);
sl@0
    83
	void CommitL();
sl@0
    84
	void Revert();
sl@0
    85
sl@0
    86
	// from CMMFVideoEncodeHwDevice
sl@0
    87
	CVideoEncoderInfo* VideoEncoderInfoLC();
sl@0
    88
	void SetOutputFormatL(const CCompressedVideoFormat& aFormat, 
sl@0
    89
								  TVideoDataUnitType aDataUnitType, 
sl@0
    90
								  TVideoDataUnitEncapsulation aDataEncapsulation,
sl@0
    91
								  TBool aSegmentationAllowed=EFalse);
sl@0
    92
	void SetOutputRectL(const TRect& aRect);
sl@0
    93
	void SetInputDevice(CMMFVideoPreProcHwDevice* aDevice);
sl@0
    94
	void SetErrorsExpected(TBool aBitErrors, TBool aPacketLosses);
sl@0
    95
	void SetMinRandomAccessRate(TReal aRate);
sl@0
    96
	void SetNumBitrateLayersL(TUint aNumLayers);
sl@0
    97
	void SetScalabilityLayerTypeL(TUint aLayer, TScalabilityType aScalabilityType);
sl@0
    98
	void SetGlobalReferenceOptions(TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay);
sl@0
    99
	void SetLayerReferenceOptions(TUint aLayer, TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay);
sl@0
   100
	void SetBufferOptionsL(const TEncoderBufferOptions& aOptions);
sl@0
   101
	void SetCodingStandardSpecificOptionsL(const TDesC8& aOptions);
sl@0
   102
	void SetImplementationSpecificEncoderOptionsL(const TDesC8& aOptions);
sl@0
   103
	HBufC8* CodingStandardSpecificInitOutputLC();
sl@0
   104
	HBufC8* ImplementationSpecificInitOutputLC();
sl@0
   105
	void SetErrorProtectionLevelsL(TUint aNumLevels, TBool aSeparateBuffers);
sl@0
   106
	void SetErrorProtectionLevelL(TUint aLevel, TUint aBitrate, TUint aStrength);
sl@0
   107
	void SetChannelPacketLossRate(TUint aLevel, 
sl@0
   108
									  TReal aLossRate, 
sl@0
   109
									  TTimeIntervalMicroSeconds32 aLossBurstLength);
sl@0
   110
	void SetChannelBitErrorRate(TUint aLevel, TReal aErrorRate, TReal aStdDeviation);
sl@0
   111
	void SetSegmentTargetSize(TUint aLayer, TUint aSizeBytes, TUint aSizeMacroblocks);
sl@0
   112
	void SetRateControlOptions(TUint aLayer, const TRateControlOptions& aOptions);
sl@0
   113
	void SetInLayerScalabilityL(TUint aLayer, 
sl@0
   114
									TUint aNumSteps,
sl@0
   115
									TInLayerScalabilityType aScalabilityType,
sl@0
   116
									const TArray<TUint>& aBitrateShare,
sl@0
   117
									const TArray<TUint>& aPictureShare);
sl@0
   118
	void SetLayerPromotionPointPeriod(TUint aLayer, TUint aPeriod);
sl@0
   119
	HBufC8* CodingStandardSpecificSettingsOutputLC();
sl@0
   120
	HBufC8* ImplementationSpecificSettingsOutputLC();
sl@0
   121
	void SendSupplementalInfoL(const TDesC8& aData);
sl@0
   122
	void SendSupplementalInfoL(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp);
sl@0
   123
	void CancelSupplementalInfo();
sl@0
   124
	void GetOutputBufferStatus(TUint& aNumFreeBuffers, TUint& aTotalFreeBytes);
sl@0
   125
	void ReturnBuffer(TVideoOutputBuffer* aBuffer);
sl@0
   126
	void PictureLoss();
sl@0
   127
	void PictureLoss(const TArray<TPictureId>& aPictures);
sl@0
   128
	void SliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture);
sl@0
   129
	void ReferencePictureSelection(const TDesC8& aSelectionData);
sl@0
   130
	void SetProxy(MMMFDevVideoRecordProxy& aProxy);
sl@0
   131
sl@0
   132
	// from MMdfInputPortObserver
sl@0
   133
	void MipoWriteDataComplete(const MMdfInputPort* aInputPort,CMMFBuffer* aBuffer, TInt aErrorCode);
sl@0
   134
	void MipoDisconnectTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
sl@0
   135
	void MipoRestartTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode);
sl@0
   136
sl@0
   137
	// from MMdfOutputPortObserver
sl@0
   138
	void MopoReadDataComplete(const MMdfOutputPort* aOutputPort, CMMFBuffer* aBuffer, TInt aErrorCode);
sl@0
   139
	void MopoDisconnectTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);
sl@0
   140
	void MopoRestartTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode);	
sl@0
   141
sl@0
   142
	// from MMdfProcessingUnitObserver
sl@0
   143
	void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
sl@0
   144
	void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
sl@0
   145
	
sl@0
   146
	// from MDevVideoHwDeviceAdapterSetup
sl@0
   147
	void LoadProcessingUnitL(const CImplementationInformation& aImplInfo);
sl@0
   148
private:
sl@0
   149
	CMdfVideoEncodeHwDeviceAdapter();
sl@0
   150
	void InitializeL();
sl@0
   151
	void ConstructL();
sl@0
   152
sl@0
   153
private:
sl@0
   154
	// call back class for the DevVideo
sl@0
   155
	MMMFDevVideoRecordProxy* iProxy;
sl@0
   156
	
sl@0
   157
	// the encoder itself
sl@0
   158
	CMdfProcessingUnit* iEncoderPU;
sl@0
   159
sl@0
   160
	// the processing unit loader	
sl@0
   161
	CMdfPuLoader* iPuLoader;
sl@0
   162
	TUid iPuLoaderDtorKey;
sl@0
   163
sl@0
   164
	// encoder port arrays
sl@0
   165
	RPointerArray<MMdfInputPort>  iEncoderPUInputPortsArray;
sl@0
   166
	RPointerArray<MMdfOutputPort> iEncoderPUOutputPortsArray;
sl@0
   167
sl@0
   168
	// encoder settings
sl@0
   169
	TUncompressedVideoFormat iFormat;
sl@0
   170
	TSize iPictureSize;
sl@0
   171
	TReal32 iFrameRate;
sl@0
   172
	CMMFDevVideoRecord::TPictureCounters iPictureCounters;
sl@0
   173
sl@0
   174
	// video format arrays (for VideoEncoderInfoLC())
sl@0
   175
	RArray<CCompressedVideoFormat*> iOutputVideoFormats;
sl@0
   176
	RArray<TUncompressedVideoFormat> iInputVideoFormats;
sl@0
   177
	RArray<TPictureRateAndSize> iPictureRates;
sl@0
   178
sl@0
   179
	// output data buffers
sl@0
   180
	RArray<TVideoOutputBuffer> iDataBuffers;
sl@0
   181
	
sl@0
   182
	TBool iInputStreamEnd;
sl@0
   183
	
sl@0
   184
	// buffers used to communicate to the encoder PU
sl@0
   185
	CMMFDescriptorBuffer* iInputBuffer;
sl@0
   186
	CMMFDescriptorBuffer* iOutputBuffer;
sl@0
   187
	
sl@0
   188
	TVideoPicture* iCurrentPicture;	
sl@0
   189
		
sl@0
   190
	// Uid of PU to load
sl@0
   191
	TUid iPuUid;
sl@0
   192
sl@0
   193
	CCodecApiVideoOpaqueData* iPuData;	
sl@0
   194
	HBufC* iManufacturer;
sl@0
   195
	};
sl@0
   196
sl@0
   197
#endif // MDFVIDEOENCODEHWDEVICEADAPTER_H