sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // mdfvideoencoderhwdeviceadapter.h sl@0: // sl@0: // sl@0: sl@0: #ifndef MDFVIDEOENCODEHWDEVICEADAPTER_H sl@0: #define MDFVIDEOENCODEHWDEVICEADAPTER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "mdfvideoencodehwdeviceadapter.hrh" sl@0: #include sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: class CMMFDescriptorBuffer; sl@0: sl@0: /** sl@0: Video encoder hardware device. sl@0: This is the DevVideo encoder plugin component talking to a processing unit. sl@0: @internalComponent sl@0: */ sl@0: class CMdfVideoEncodeHwDeviceAdapter : public CMMFVideoEncodeHwDevice, sl@0: public MMdfInputPortObserver, sl@0: public MMdfOutputPortObserver, sl@0: public MMdfProcessingUnitObserver, sl@0: public MDevVideoHwDeviceAdapterSetup sl@0: { sl@0: public: sl@0: static CMdfVideoEncodeHwDeviceAdapter* NewL(); sl@0: ~CMdfVideoEncodeHwDeviceAdapter(); sl@0: // from CMMFVideoHwDevice sl@0: TAny* CustomInterface(TUid aInterface); sl@0: sl@0: // from CMMFVideoRecordHwDevice sl@0: CPreProcessorInfo* PreProcessorInfoLC(); sl@0: void SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize); sl@0: void SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate); sl@0: void SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime); sl@0: void SetClockSource(MMMFClockSource* aClock); sl@0: void SetPreProcessTypesL(TUint32 aPreProcessTypes); sl@0: void SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat); sl@0: void SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat); sl@0: void SetRotateOptionsL(TRotationType aRotationType); sl@0: void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering); sl@0: void SetInputCropOptionsL(const TRect& aRect); sl@0: void SetOutputCropOptionsL(const TRect& aRect); sl@0: void SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos); sl@0: void SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions); sl@0: void SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation); sl@0: void SetCustomPreProcessOptionsL(const TDesC8& aOptions); sl@0: void Initialize(); sl@0: void WritePictureL(TVideoPicture* aPicture); sl@0: void InputEnd(); sl@0: void Start(); sl@0: void Stop(); sl@0: void Pause(); sl@0: void Resume(); sl@0: void Freeze(); sl@0: void ReleaseFreeze(); sl@0: TTimeIntervalMicroSeconds RecordingPosition(); sl@0: void GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters); sl@0: void GetFrameStabilisationOutput(TRect& aRect); sl@0: TUint NumComplexityLevels(); sl@0: void SetComplexityLevel(TUint aLevel); sl@0: void CommitL(); sl@0: void Revert(); sl@0: sl@0: // from CMMFVideoEncodeHwDevice sl@0: CVideoEncoderInfo* VideoEncoderInfoLC(); sl@0: void SetOutputFormatL(const CCompressedVideoFormat& aFormat, sl@0: TVideoDataUnitType aDataUnitType, sl@0: TVideoDataUnitEncapsulation aDataEncapsulation, sl@0: TBool aSegmentationAllowed=EFalse); sl@0: void SetOutputRectL(const TRect& aRect); sl@0: void SetInputDevice(CMMFVideoPreProcHwDevice* aDevice); sl@0: void SetErrorsExpected(TBool aBitErrors, TBool aPacketLosses); sl@0: void SetMinRandomAccessRate(TReal aRate); sl@0: void SetNumBitrateLayersL(TUint aNumLayers); sl@0: void SetScalabilityLayerTypeL(TUint aLayer, TScalabilityType aScalabilityType); sl@0: void SetGlobalReferenceOptions(TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay); sl@0: void SetLayerReferenceOptions(TUint aLayer, TUint aMaxReferencePictures, TUint aMaxPictureOrderDelay); sl@0: void SetBufferOptionsL(const TEncoderBufferOptions& aOptions); sl@0: void SetCodingStandardSpecificOptionsL(const TDesC8& aOptions); sl@0: void SetImplementationSpecificEncoderOptionsL(const TDesC8& aOptions); sl@0: HBufC8* CodingStandardSpecificInitOutputLC(); sl@0: HBufC8* ImplementationSpecificInitOutputLC(); sl@0: void SetErrorProtectionLevelsL(TUint aNumLevels, TBool aSeparateBuffers); sl@0: void SetErrorProtectionLevelL(TUint aLevel, TUint aBitrate, TUint aStrength); sl@0: void SetChannelPacketLossRate(TUint aLevel, sl@0: TReal aLossRate, sl@0: TTimeIntervalMicroSeconds32 aLossBurstLength); sl@0: void SetChannelBitErrorRate(TUint aLevel, TReal aErrorRate, TReal aStdDeviation); sl@0: void SetSegmentTargetSize(TUint aLayer, TUint aSizeBytes, TUint aSizeMacroblocks); sl@0: void SetRateControlOptions(TUint aLayer, const TRateControlOptions& aOptions); sl@0: void SetInLayerScalabilityL(TUint aLayer, sl@0: TUint aNumSteps, sl@0: TInLayerScalabilityType aScalabilityType, sl@0: const TArray& aBitrateShare, sl@0: const TArray& aPictureShare); sl@0: void SetLayerPromotionPointPeriod(TUint aLayer, TUint aPeriod); sl@0: HBufC8* CodingStandardSpecificSettingsOutputLC(); sl@0: HBufC8* ImplementationSpecificSettingsOutputLC(); sl@0: void SendSupplementalInfoL(const TDesC8& aData); sl@0: void SendSupplementalInfoL(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp); sl@0: void CancelSupplementalInfo(); sl@0: void GetOutputBufferStatus(TUint& aNumFreeBuffers, TUint& aTotalFreeBytes); sl@0: void ReturnBuffer(TVideoOutputBuffer* aBuffer); sl@0: void PictureLoss(); sl@0: void PictureLoss(const TArray& aPictures); sl@0: void SliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture); sl@0: void ReferencePictureSelection(const TDesC8& aSelectionData); sl@0: void SetProxy(MMMFDevVideoRecordProxy& aProxy); sl@0: sl@0: // from MMdfInputPortObserver sl@0: void MipoWriteDataComplete(const MMdfInputPort* aInputPort,CMMFBuffer* aBuffer, TInt aErrorCode); sl@0: void MipoDisconnectTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode); sl@0: void MipoRestartTunnelComplete(const MMdfInputPort* aInputPort, TInt aErrorCode); sl@0: sl@0: // from MMdfOutputPortObserver sl@0: void MopoReadDataComplete(const MMdfOutputPort* aOutputPort, CMMFBuffer* aBuffer, TInt aErrorCode); sl@0: void MopoDisconnectTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode); sl@0: void MopoRestartTunnelComplete(const MMdfOutputPort* aOutputPort, TInt aErrorCode); sl@0: sl@0: // from MMdfProcessingUnitObserver sl@0: void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode); sl@0: void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode); sl@0: sl@0: // from MDevVideoHwDeviceAdapterSetup sl@0: void LoadProcessingUnitL(const CImplementationInformation& aImplInfo); sl@0: private: sl@0: CMdfVideoEncodeHwDeviceAdapter(); sl@0: void InitializeL(); sl@0: void ConstructL(); sl@0: sl@0: private: sl@0: // call back class for the DevVideo sl@0: MMMFDevVideoRecordProxy* iProxy; sl@0: sl@0: // the encoder itself sl@0: CMdfProcessingUnit* iEncoderPU; sl@0: sl@0: // the processing unit loader sl@0: CMdfPuLoader* iPuLoader; sl@0: TUid iPuLoaderDtorKey; sl@0: sl@0: // encoder port arrays sl@0: RPointerArray iEncoderPUInputPortsArray; sl@0: RPointerArray iEncoderPUOutputPortsArray; sl@0: sl@0: // encoder settings sl@0: TUncompressedVideoFormat iFormat; sl@0: TSize iPictureSize; sl@0: TReal32 iFrameRate; sl@0: CMMFDevVideoRecord::TPictureCounters iPictureCounters; sl@0: sl@0: // video format arrays (for VideoEncoderInfoLC()) sl@0: RArray iOutputVideoFormats; sl@0: RArray iInputVideoFormats; sl@0: RArray iPictureRates; sl@0: sl@0: // output data buffers sl@0: RArray iDataBuffers; sl@0: sl@0: TBool iInputStreamEnd; sl@0: sl@0: // buffers used to communicate to the encoder PU sl@0: CMMFDescriptorBuffer* iInputBuffer; sl@0: CMMFDescriptorBuffer* iOutputBuffer; sl@0: sl@0: TVideoPicture* iCurrentPicture; sl@0: sl@0: // Uid of PU to load sl@0: TUid iPuUid; sl@0: sl@0: CCodecApiVideoOpaqueData* iPuData; sl@0: HBufC* iManufacturer; sl@0: }; sl@0: sl@0: #endif // MDFVIDEOENCODEHWDEVICEADAPTER_H