sl@0: // Copyright (c) 2005-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: // sl@0: sl@0: #ifndef OMXPCMCODEC_H sl@0: #define OMXPCMCODEC_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "OmxImpl.h" sl@0: sl@0: #include "MMFAudioU8ToS16PcmCodec.h" sl@0: #include "MMFAudioPcm8ToPcm16Codec.h" sl@0: #include "MMFAudioPcmS16ToPcmS8Codec.h" sl@0: #include "MMFAudioS16ToU8PcmCodec.h" sl@0: sl@0: class COmxPCMCodec; sl@0: sl@0: sl@0: class CCodecProcessor : public CBase sl@0: { sl@0: sl@0: enum TCodecMessageType sl@0: { sl@0: EStopProcessing, sl@0: EPauseProcessing, sl@0: EInputBuffer, sl@0: EOutputBuffer, sl@0: EExit sl@0: }; sl@0: sl@0: class TCodecMessage sl@0: { sl@0: public: sl@0: TCodecMessageType iType; sl@0: OMX_BUFFERHEADERTYPE* iBuffer; sl@0: }; sl@0: sl@0: public: sl@0: static CCodecProcessor* NewL(COmxPCMCodec& aParent); sl@0: sl@0: void RunThreadL(); sl@0: void Stop(); sl@0: void Exit(); sl@0: sl@0: OMX_ERRORTYPE EmptyThisBuffer( sl@0: OMX_BUFFERHEADERTYPE* pBuffer); sl@0: OMX_ERRORTYPE FillThisBuffer( sl@0: OMX_BUFFERHEADERTYPE* pBuffer); sl@0: sl@0: void SetInputDataType(OMX_NUMERICALDATATYPE aType); sl@0: void SetInputBitsPerSample(TInt aBitsPerSample); sl@0: void SetOutputDataType(OMX_NUMERICALDATATYPE aType); sl@0: void SetOutputBitsPerSample(TInt aBitsPerSample); sl@0: sl@0: virtual ~CCodecProcessor(); sl@0: sl@0: private: sl@0: void ConstructL(); sl@0: CCodecProcessor(COmxPCMCodec& aParent); sl@0: sl@0: void ProcessAvailableBuffers(); sl@0: void ChooseCodec(); sl@0: sl@0: private: sl@0: COmxPCMCodec* iParent; sl@0: RPointerArray iBuffersToEmpty; sl@0: RPointerArray iBuffersToFill; sl@0: sl@0: TRequestStatus iQueueStatus; sl@0: RMsgQueue iMessageQueue; sl@0: sl@0: OMX_BUFFERHEADERTYPE* iInputBuffer; sl@0: OMX_BUFFERHEADERTYPE* iOutputBuffer; sl@0: sl@0: TMMFAudioCodecBase* iCodec; sl@0: sl@0: // codec configuration settings sl@0: TInt iInputBitsPerSample; sl@0: TInt iOutputBitsPerSample; sl@0: OMX_NUMERICALDATATYPE iInputDataType; sl@0: OMX_NUMERICALDATATYPE iOutputDataType; sl@0: sl@0: TInt iInputBufferPos; sl@0: sl@0: TMMFAudioCodecBase* iCurrentCodec; sl@0: sl@0: TMMFAudioU8ToS16PcmCodec iAudioU8ToS16PcmCodec; sl@0: TMMFAudioPcm8ToPcm16Codec iAudioS8ToS16PcmCodec; sl@0: sl@0: TMMFAudioPcmS16ToPcmS8Codec iAudioS16ToS8PcmCodec; sl@0: TMMFAudioS16ToU8PcmCodec iAudioS16ToU8PcmCodec; sl@0: sl@0: TBool iStarted; sl@0: TReal iOutputSamplesPerInputSample; sl@0: }; sl@0: sl@0: sl@0: sl@0: class COmxPCMCodec : public COmxComponentImpl sl@0: { sl@0: public: sl@0: friend class CCodecProcessor; sl@0: friend class CCodecCallbacks; sl@0: sl@0: static TInt CreateComponent(OMX_HANDLETYPE hComponent); sl@0: ~COmxPCMCodec(); sl@0: sl@0: OMX_ERRORTYPE GetComponentVersion( sl@0: OMX_STRING pComponentName, sl@0: OMX_VERSIONTYPE* pComponentVersion, sl@0: OMX_VERSIONTYPE* pSpecVersion, sl@0: OMX_UUIDTYPE* pComponentUUID); sl@0: OMX_ERRORTYPE SendCommand( sl@0: OMX_COMMANDTYPE Cmd, sl@0: TUint32 nParam1, sl@0: TAny* pCmdData); sl@0: OMX_ERRORTYPE GetParameter( sl@0: OMX_INDEXTYPE nParamIndex, sl@0: TAny* ComponentParameterStructure); sl@0: OMX_ERRORTYPE SetParameter( sl@0: OMX_INDEXTYPE nIndex, sl@0: TAny* ComponentParameterStructure); sl@0: OMX_ERRORTYPE GetConfig( sl@0: OMX_INDEXTYPE nIndex, sl@0: TAny* value); sl@0: OMX_ERRORTYPE SetConfig( sl@0: OMX_INDEXTYPE nIndex, sl@0: TAny* value); sl@0: OMX_ERRORTYPE GetExtensionIndex( sl@0: OMX_STRING ParameterName, sl@0: OMX_INDEXTYPE* pIndexType); sl@0: OMX_ERRORTYPE GetState( sl@0: OMX_STATETYPE* pState); sl@0: OMX_ERRORTYPE ComponentTunnelRequest( sl@0: OMX_HANDLETYPE hInput, sl@0: TUint32 nInputPort, sl@0: OMX_HANDLETYPE hOutput, sl@0: TUint32 nOutputPort, sl@0: OMX_TUNNELSETUPTYPE* pTunnelSetup); sl@0: virtual OMX_ERRORTYPE UseBuffer( sl@0: OMX_BUFFERHEADERTYPE** pBufferHdr, sl@0: TUint32 nPortIndex, sl@0: TAny* pAppPrivate, sl@0: TUint32 nSizeBytes, sl@0: TUint8* pBuffer); sl@0: virtual OMX_ERRORTYPE AllocateBuffer( sl@0: OMX_BUFFERHEADERTYPE** pBuffer, sl@0: TUint32 nPortIndex, sl@0: TAny* pAppData, sl@0: TUint32 nSizeBytes); sl@0: OMX_ERRORTYPE FreeBuffer( sl@0: TUint32 nPortIndex, sl@0: OMX_BUFFERHEADERTYPE* pBuffer); sl@0: OMX_ERRORTYPE EmptyThisBuffer( sl@0: OMX_BUFFERHEADERTYPE* pBuffer); sl@0: OMX_ERRORTYPE FillThisBuffer( sl@0: OMX_BUFFERHEADERTYPE* pBuffer); sl@0: OMX_ERRORTYPE SetCallbacks( sl@0: OMX_CALLBACKTYPE* pCallbacks, sl@0: TAny* pAppData); sl@0: sl@0: TInt StartExecution(); sl@0: sl@0: void EventHandlerCallback( sl@0: OMX_EVENTTYPE eEvent, sl@0: TUint32 nData1, sl@0: TUint32 nData2, sl@0: OMX_STRING cExtraInfo); sl@0: void FillBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer); sl@0: void EmptyBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer); sl@0: sl@0: sl@0: private: sl@0: COmxPCMCodec(OMX_HANDLETYPE hComponent); sl@0: void ConstructL(); sl@0: sl@0: private: sl@0: OMX_CALLBACKTYPE* iCallback; sl@0: TAny* iAppData; sl@0: OMX_STATETYPE iState; sl@0: sl@0: TRequestStatus iThreadDeath; sl@0: CCodecProcessor* iCodecProcessor; sl@0: TBool iCreatedThread; sl@0: RThread iProcessingThread; sl@0: }; sl@0: sl@0: #endif // OMXPCMCODEC_H