Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <e32msgqueue.h>
20 #include <mdaaudiooutputstream.h>
21 #include <openmax/il/khronos/v1_x/OMX_Audio.h>
24 #include "MMFAudioU8ToS16PcmCodec.h"
25 #include "MMFAudioPcm8ToPcm16Codec.h"
26 #include "MMFAudioPcmS16ToPcmS8Codec.h"
27 #include "MMFAudioS16ToU8PcmCodec.h"
32 class CCodecProcessor : public CBase
35 enum TCodecMessageType
47 TCodecMessageType iType;
48 OMX_BUFFERHEADERTYPE* iBuffer;
52 static CCodecProcessor* NewL(COmxPCMCodec& aParent);
58 OMX_ERRORTYPE EmptyThisBuffer(
59 OMX_BUFFERHEADERTYPE* pBuffer);
60 OMX_ERRORTYPE FillThisBuffer(
61 OMX_BUFFERHEADERTYPE* pBuffer);
63 void SetInputDataType(OMX_NUMERICALDATATYPE aType);
64 void SetInputBitsPerSample(TInt aBitsPerSample);
65 void SetOutputDataType(OMX_NUMERICALDATATYPE aType);
66 void SetOutputBitsPerSample(TInt aBitsPerSample);
68 virtual ~CCodecProcessor();
72 CCodecProcessor(COmxPCMCodec& aParent);
74 void ProcessAvailableBuffers();
78 COmxPCMCodec* iParent;
79 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToEmpty;
80 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToFill;
82 TRequestStatus iQueueStatus;
83 RMsgQueue<TCodecMessage> iMessageQueue;
85 OMX_BUFFERHEADERTYPE* iInputBuffer;
86 OMX_BUFFERHEADERTYPE* iOutputBuffer;
88 TMMFAudioCodecBase* iCodec;
90 // codec configuration settings
91 TInt iInputBitsPerSample;
92 TInt iOutputBitsPerSample;
93 OMX_NUMERICALDATATYPE iInputDataType;
94 OMX_NUMERICALDATATYPE iOutputDataType;
98 TMMFAudioCodecBase* iCurrentCodec;
100 TMMFAudioU8ToS16PcmCodec iAudioU8ToS16PcmCodec;
101 TMMFAudioPcm8ToPcm16Codec iAudioS8ToS16PcmCodec;
103 TMMFAudioPcmS16ToPcmS8Codec iAudioS16ToS8PcmCodec;
104 TMMFAudioS16ToU8PcmCodec iAudioS16ToU8PcmCodec;
107 TReal iOutputSamplesPerInputSample;
112 class COmxPCMCodec : public COmxComponentImpl
115 friend class CCodecProcessor;
116 friend class CCodecCallbacks;
118 static TInt CreateComponent(OMX_HANDLETYPE hComponent);
121 OMX_ERRORTYPE GetComponentVersion(
122 OMX_STRING pComponentName,
123 OMX_VERSIONTYPE* pComponentVersion,
124 OMX_VERSIONTYPE* pSpecVersion,
125 OMX_UUIDTYPE* pComponentUUID);
126 OMX_ERRORTYPE SendCommand(
130 OMX_ERRORTYPE GetParameter(
131 OMX_INDEXTYPE nParamIndex,
132 TAny* ComponentParameterStructure);
133 OMX_ERRORTYPE SetParameter(
134 OMX_INDEXTYPE nIndex,
135 TAny* ComponentParameterStructure);
136 OMX_ERRORTYPE GetConfig(
137 OMX_INDEXTYPE nIndex,
139 OMX_ERRORTYPE SetConfig(
140 OMX_INDEXTYPE nIndex,
142 OMX_ERRORTYPE GetExtensionIndex(
143 OMX_STRING ParameterName,
144 OMX_INDEXTYPE* pIndexType);
145 OMX_ERRORTYPE GetState(
146 OMX_STATETYPE* pState);
147 OMX_ERRORTYPE ComponentTunnelRequest(
148 OMX_HANDLETYPE hInput,
150 OMX_HANDLETYPE hOutput,
152 OMX_TUNNELSETUPTYPE* pTunnelSetup);
153 virtual OMX_ERRORTYPE UseBuffer(
154 OMX_BUFFERHEADERTYPE** pBufferHdr,
159 virtual OMX_ERRORTYPE AllocateBuffer(
160 OMX_BUFFERHEADERTYPE** pBuffer,
164 OMX_ERRORTYPE FreeBuffer(
166 OMX_BUFFERHEADERTYPE* pBuffer);
167 OMX_ERRORTYPE EmptyThisBuffer(
168 OMX_BUFFERHEADERTYPE* pBuffer);
169 OMX_ERRORTYPE FillThisBuffer(
170 OMX_BUFFERHEADERTYPE* pBuffer);
171 OMX_ERRORTYPE SetCallbacks(
172 OMX_CALLBACKTYPE* pCallbacks,
175 TInt StartExecution();
177 void EventHandlerCallback(
178 OMX_EVENTTYPE eEvent,
181 OMX_STRING cExtraInfo);
182 void FillBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
183 void EmptyBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
187 COmxPCMCodec(OMX_HANDLETYPE hComponent);
191 OMX_CALLBACKTYPE* iCallback;
193 OMX_STATETYPE iState;
195 TRequestStatus iThreadDeath;
196 CCodecProcessor* iCodecProcessor;
197 TBool iCreatedThread;
198 RThread iProcessingThread;
201 #endif // OMXPCMCODEC_H