1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/mdfunittest/codecapi/omx/pcmcodec/src/OmxPCMCodec.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,201 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef OMXPCMCODEC_H
1.20 +#define OMXPCMCODEC_H
1.21 +
1.22 +#include <e32msgqueue.h>
1.23 +#include <mdaaudiooutputstream.h>
1.24 +#include <openmax/il/khronos/v1_x/OMX_Audio.h>
1.25 +#include "OmxImpl.h"
1.26 +
1.27 +#include "MMFAudioU8ToS16PcmCodec.h"
1.28 +#include "MMFAudioPcm8ToPcm16Codec.h"
1.29 +#include "MMFAudioPcmS16ToPcmS8Codec.h"
1.30 +#include "MMFAudioS16ToU8PcmCodec.h"
1.31 +
1.32 +class COmxPCMCodec;
1.33 +
1.34 +
1.35 +class CCodecProcessor : public CBase
1.36 + {
1.37 +
1.38 + enum TCodecMessageType
1.39 + {
1.40 + EStopProcessing,
1.41 + EPauseProcessing,
1.42 + EInputBuffer,
1.43 + EOutputBuffer,
1.44 + EExit
1.45 + };
1.46 +
1.47 + class TCodecMessage
1.48 + {
1.49 + public:
1.50 + TCodecMessageType iType;
1.51 + OMX_BUFFERHEADERTYPE* iBuffer;
1.52 + };
1.53 +
1.54 + public:
1.55 + static CCodecProcessor* NewL(COmxPCMCodec& aParent);
1.56 +
1.57 + void RunThreadL();
1.58 + void Stop();
1.59 + void Exit();
1.60 +
1.61 + OMX_ERRORTYPE EmptyThisBuffer(
1.62 + OMX_BUFFERHEADERTYPE* pBuffer);
1.63 + OMX_ERRORTYPE FillThisBuffer(
1.64 + OMX_BUFFERHEADERTYPE* pBuffer);
1.65 +
1.66 + void SetInputDataType(OMX_NUMERICALDATATYPE aType);
1.67 + void SetInputBitsPerSample(TInt aBitsPerSample);
1.68 + void SetOutputDataType(OMX_NUMERICALDATATYPE aType);
1.69 + void SetOutputBitsPerSample(TInt aBitsPerSample);
1.70 +
1.71 + virtual ~CCodecProcessor();
1.72 +
1.73 + private:
1.74 + void ConstructL();
1.75 + CCodecProcessor(COmxPCMCodec& aParent);
1.76 +
1.77 + void ProcessAvailableBuffers();
1.78 + void ChooseCodec();
1.79 +
1.80 + private:
1.81 + COmxPCMCodec* iParent;
1.82 + RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToEmpty;
1.83 + RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToFill;
1.84 +
1.85 + TRequestStatus iQueueStatus;
1.86 + RMsgQueue<TCodecMessage> iMessageQueue;
1.87 +
1.88 + OMX_BUFFERHEADERTYPE* iInputBuffer;
1.89 + OMX_BUFFERHEADERTYPE* iOutputBuffer;
1.90 +
1.91 + TMMFAudioCodecBase* iCodec;
1.92 +
1.93 + // codec configuration settings
1.94 + TInt iInputBitsPerSample;
1.95 + TInt iOutputBitsPerSample;
1.96 + OMX_NUMERICALDATATYPE iInputDataType;
1.97 + OMX_NUMERICALDATATYPE iOutputDataType;
1.98 +
1.99 + TInt iInputBufferPos;
1.100 +
1.101 + TMMFAudioCodecBase* iCurrentCodec;
1.102 +
1.103 + TMMFAudioU8ToS16PcmCodec iAudioU8ToS16PcmCodec;
1.104 + TMMFAudioPcm8ToPcm16Codec iAudioS8ToS16PcmCodec;
1.105 +
1.106 + TMMFAudioPcmS16ToPcmS8Codec iAudioS16ToS8PcmCodec;
1.107 + TMMFAudioS16ToU8PcmCodec iAudioS16ToU8PcmCodec;
1.108 +
1.109 + TBool iStarted;
1.110 + TReal iOutputSamplesPerInputSample;
1.111 + };
1.112 +
1.113 +
1.114 +
1.115 +class COmxPCMCodec : public COmxComponentImpl
1.116 + {
1.117 +public:
1.118 + friend class CCodecProcessor;
1.119 + friend class CCodecCallbacks;
1.120 +
1.121 + static TInt CreateComponent(OMX_HANDLETYPE hComponent);
1.122 + ~COmxPCMCodec();
1.123 +
1.124 + OMX_ERRORTYPE GetComponentVersion(
1.125 + OMX_STRING pComponentName,
1.126 + OMX_VERSIONTYPE* pComponentVersion,
1.127 + OMX_VERSIONTYPE* pSpecVersion,
1.128 + OMX_UUIDTYPE* pComponentUUID);
1.129 + OMX_ERRORTYPE SendCommand(
1.130 + OMX_COMMANDTYPE Cmd,
1.131 + TUint32 nParam1,
1.132 + TAny* pCmdData);
1.133 + OMX_ERRORTYPE GetParameter(
1.134 + OMX_INDEXTYPE nParamIndex,
1.135 + TAny* ComponentParameterStructure);
1.136 + OMX_ERRORTYPE SetParameter(
1.137 + OMX_INDEXTYPE nIndex,
1.138 + TAny* ComponentParameterStructure);
1.139 + OMX_ERRORTYPE GetConfig(
1.140 + OMX_INDEXTYPE nIndex,
1.141 + TAny* value);
1.142 + OMX_ERRORTYPE SetConfig(
1.143 + OMX_INDEXTYPE nIndex,
1.144 + TAny* value);
1.145 + OMX_ERRORTYPE GetExtensionIndex(
1.146 + OMX_STRING ParameterName,
1.147 + OMX_INDEXTYPE* pIndexType);
1.148 + OMX_ERRORTYPE GetState(
1.149 + OMX_STATETYPE* pState);
1.150 + OMX_ERRORTYPE ComponentTunnelRequest(
1.151 + OMX_HANDLETYPE hInput,
1.152 + TUint32 nInputPort,
1.153 + OMX_HANDLETYPE hOutput,
1.154 + TUint32 nOutputPort,
1.155 + OMX_TUNNELSETUPTYPE* pTunnelSetup);
1.156 + virtual OMX_ERRORTYPE UseBuffer(
1.157 + OMX_BUFFERHEADERTYPE** pBufferHdr,
1.158 + TUint32 nPortIndex,
1.159 + TAny* pAppPrivate,
1.160 + TUint32 nSizeBytes,
1.161 + TUint8* pBuffer);
1.162 + virtual OMX_ERRORTYPE AllocateBuffer(
1.163 + OMX_BUFFERHEADERTYPE** pBuffer,
1.164 + TUint32 nPortIndex,
1.165 + TAny* pAppData,
1.166 + TUint32 nSizeBytes);
1.167 + OMX_ERRORTYPE FreeBuffer(
1.168 + TUint32 nPortIndex,
1.169 + OMX_BUFFERHEADERTYPE* pBuffer);
1.170 + OMX_ERRORTYPE EmptyThisBuffer(
1.171 + OMX_BUFFERHEADERTYPE* pBuffer);
1.172 + OMX_ERRORTYPE FillThisBuffer(
1.173 + OMX_BUFFERHEADERTYPE* pBuffer);
1.174 + OMX_ERRORTYPE SetCallbacks(
1.175 + OMX_CALLBACKTYPE* pCallbacks,
1.176 + TAny* pAppData);
1.177 +
1.178 + TInt StartExecution();
1.179 +
1.180 + void EventHandlerCallback(
1.181 + OMX_EVENTTYPE eEvent,
1.182 + TUint32 nData1,
1.183 + TUint32 nData2,
1.184 + OMX_STRING cExtraInfo);
1.185 + void FillBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
1.186 + void EmptyBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
1.187 +
1.188 +
1.189 +private:
1.190 + COmxPCMCodec(OMX_HANDLETYPE hComponent);
1.191 + void ConstructL();
1.192 +
1.193 +private:
1.194 + OMX_CALLBACKTYPE* iCallback;
1.195 + TAny* iAppData;
1.196 + OMX_STATETYPE iState;
1.197 +
1.198 + TRequestStatus iThreadDeath;
1.199 + CCodecProcessor* iCodecProcessor;
1.200 + TBool iCreatedThread;
1.201 + RThread iProcessingThread;
1.202 + };
1.203 +
1.204 +#endif // OMXPCMCODEC_H