os/mm/mmdevicefw/mdfunittest/codecapi/omxvorbis/hwdeviceadapter/audiocodectestadapter.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 /**
    20 @file
    21 @internalComponent
    22 */
    23 
    24 #ifndef AUDIOCODECTESTADAPTER_H
    25 #define AUDIOCODECTESTADAPTER_H
    26 
    27 #include <mmf/server/mmfhwdevice.h>
    28 #include <mdf/mdfinputport.h>
    29 #include <mdf/mdfoutputport.h>
    30 #include <mdf/mdfprocessingunit.h>
    31 #include <mdf/mdfpuloader.h>
    32 #include <mmf/server/mmfdatabuffer.h>
    33 #include <mmf/server/mmfhwdevicesetup.h>
    34 #include <mmf/common/mmfutilities.h>
    35 
    36 class CMMFBuffer;
    37 
    38 class CMdfHwDeviceCodecTestAdapter :	public CMMFHwDevice,
    39 									 	public MMdfInputPortObserver,
    40 										public MMdfOutputPortObserver,
    41 										public MMdfProcessingUnitObserver,
    42 										public MMdfHwDeviceSetup
    43 	{
    44 public:
    45 	/*
    46 	Hardware Device Adapter panics raised as a result of a programming error.
    47 	*/	
    48 	enum THwDeviceAdapterPanics
    49 		{
    50 		/*
    51 		Raised when the Codec Processing Unit has not been initialised.
    52 		@see CMdfHwDeviceAdapter::CustomInterface
    53 		@see CMdfHwDeviceAdapter::SetDataTypesL
    54 		*/
    55 		EPanicCodecNotSet
    56 		};
    57 	/**
    58 	The current state of the Hardware Device Adapter.
    59 	*/
    60 	enum THwDevAdapterState
    61 		{
    62 		/*
    63 		The PULoader has been loaded.
    64 		*/
    65 		EProcessingUnitLoaderLoaded,
    66 		/*
    67 		The Processing Units have been loaded.
    68 		*/
    69 		EProcessingUnitLoaded,
    70 		/*
    71 		The Processing Units are currently being initialised.
    72 		*/
    73 		EProcessingUnitInitializing,
    74 		/*
    75 		The Processing Units are currently in the idle state.
    76 		*/
    77 		EProcessingUnitIdle,
    78 		/*
    79 		The Processing Units are currently in the executing state.
    80 		*/
    81 		EProcessingUnitExecuting,
    82 		/*
    83 		The Processing Units are currently in the paused state.
    84 		*/
    85 		EProcessingUnitPaused		
    86 		};		
    87 	
    88 public:
    89 	static CMdfHwDeviceCodecTestAdapter* NewL();
    90 	
    91 	// from CMMFHwDevice
    92 	TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd);
    93 	TInt Stop();
    94 	TInt Pause();
    95 	TInt Init(THwDeviceInitParams& aDevInfo);
    96 	TAny* CustomInterface(TUid aInterfaceId);
    97 	TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr);
    98 	TInt ThisHwBufferEmptied(CMMFBuffer& aEmptyBufferPtr);
    99 	TInt SetConfig(TTaskConfig& aConfig);
   100 	TInt StopAndDeleteCodec();
   101 	TInt DeleteCodec();
   102 	~CMdfHwDeviceCodecTestAdapter();
   103 	
   104 	// from MMdfInputPortObserver
   105 	void MipoWriteDataComplete(const MMdfInputPort* aPu,
   106 		CMMFBuffer* aBuffer, TInt aErrorCode);
   107 	void MipoDisconnectTunnelComplete(const MMdfInputPort* aPu,  TInt aErrorCode);
   108 	void MipoRestartTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode);
   109 	
   110 	// from MMdfOutputPortObserver
   111 	void MopoReadDataComplete(const MMdfOutputPort* aPu, 
   112 		CMMFBuffer* aBuffer, TInt aErrorCode);
   113 	void MopoDisconnectTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode);
   114 	void MopoRestartTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode);
   115 	
   116 	// from MMdfProcessingUnitObserver
   117 	void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   118 	void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   119 	
   120 	// from MMdfHwDeviceSetup	
   121 	void SetDataTypesL(TFourCC aSrcType, TFourCC aDestType);
   122 	
   123 	void GetState(THwDevAdapterState& aState) const;
   124 	
   125 private:
   126 	CMdfHwDeviceCodecTestAdapter();
   127 	void ConstructL();
   128 	TInt CreateBuffers();
   129 	TInt StartEncode();
   130 	TInt StartDecode();
   131 	TInt InitializeEncodeDecode();
   132 	TInt StartExecuting();
   133 	
   134 	void StopHwDevice(TInt error);
   135 
   136 private:
   137 	CMdfPuLoader* iPuLoader;
   138 	TUid iPuLoaderDtorKey;
   139 	MMdfInputPort* iInputPort;
   140 	MMdfOutputPort* iOutputPort;
   141 	
   142 	CMdfProcessingUnit* iCodecPU;
   143 		
   144 	THwDevAdapterState iState;
   145 	TBool iStopping;
   146 	
   147 	TBool iPCMPUCallbackComplete;
   148 	
   149 	TBool iPCMPuMopoStopCompleted;
   150 	TBool iPCMPuMipoStopCompleted;
   151 	
   152 	TInt iExecuteError;
   153 	
   154 	enum TPUType
   155 		{
   156 		EPcmPu
   157 		};
   158 
   159 	CMMFBuffer* iInputBuffer;
   160 	CMMFBuffer* iOutputBuffer;
   161 	
   162 	TUint32 iInputPortBufferSize;
   163 	TUint32 iOutputPortBufferSize;
   164 	TInt iInputPortBufferData;	
   165 	TInt iOutputPortBufferData;
   166 	
   167 	CActiveSchedulerWait* iActiveWait;
   168 
   169 	TDeviceFunc iFuncCmd;
   170 
   171 	TFourCC iFirstFourCC;
   172 	TFourCC iSecondFourCC;
   173 	};
   174 	
   175 #endif // AUDIOCODECTESTADAPTER_H