00001
00002
00003
00004
00005
00011 #ifndef OMXVORBISDECODER_H
00012 #define OMXVORBISDECODER_H
00013
00014 #include <e32msgqueue.h>
00015 #include <mdaaudiooutputstream.h>
00016 #include <OMX_Audio.h>
00017 #include "OmxImpl.h"
00018
00019 class COmxVorbisDecoder;
00020 class CVorbisDecoderProcessor;
00021
00022 class CCodecProcessor
00023 : public CBase
00024 {
00025
00026 enum TCodecMessageType
00027 {
00028 EStopProcessing,
00029 EPauseProcessing,
00030 EInputBuffer,
00031 EOutputBuffer,
00032 EExit
00033 };
00034
00035 class TCodecMessage
00036 {
00037 public:
00038 TCodecMessageType iType;
00039 OMX_BUFFERHEADERTYPE* iBuffer;
00040 };
00041
00042 public:
00043 static CCodecProcessor* NewL(COmxVorbisDecoder& aParent);
00044
00045 void RunThreadL();
00046 void Stop();
00047 void Exit();
00048
00049 OMX_ERRORTYPE EmptyThisBuffer(
00050 OMX_BUFFERHEADERTYPE* pBuffer);
00051 OMX_ERRORTYPE FillThisBuffer(
00052 OMX_BUFFERHEADERTYPE* pBuffer);
00053
00054 void SetOutputDataType(OMX_NUMERICALDATATYPE aType);
00055 void SetOutputBitsPerSample(TInt aBitsPerSample);
00056
00057 virtual ~CCodecProcessor();
00058
00059 private:
00060 void ConstructL();
00061 CCodecProcessor(COmxVorbisDecoder& aParent);
00062
00063 void ProcessAvailableBuffers();
00064
00065 private:
00066 COmxVorbisDecoder* iParent;
00067 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToEmpty;
00068 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToFill;
00069
00070 TRequestStatus iQueueStatus;
00071 RMsgQueue<TCodecMessage> iMessageQueue;
00072
00073 OMX_BUFFERHEADERTYPE* iInputBuffer;
00074 OMX_BUFFERHEADERTYPE* iOutputBuffer;
00075
00076
00077 TInt iOutputBitsPerSample;
00078 OMX_NUMERICALDATATYPE iOutputDataType;
00079
00080 CVorbisDecoderProcessor* iCodec;
00081
00082 CMMFDataBuffer* iDummyBuffer;
00083
00084 TBool iStarted;
00085 TBool iLastInputBuffer;
00086 };
00087
00088 class COmxVorbisDecoder : public COmxComponentImpl
00089 {
00090 public:
00091 friend class CCodecProcessor;
00092 friend class CCodecCallbacks;
00093
00094 static TInt CreateComponent(OMX_HANDLETYPE hComponent);
00095 ~COmxVorbisDecoder();
00096
00097 OMX_ERRORTYPE GetComponentVersion(
00098 OMX_STRING pComponentName,
00099 OMX_VERSIONTYPE* pComponentVersion,
00100 OMX_VERSIONTYPE* pSpecVersion,
00101 OMX_UUIDTYPE* pComponentUUID);
00102 OMX_ERRORTYPE SendCommand(
00103 OMX_COMMANDTYPE Cmd,
00104 TUint32 nParam1,
00105 TAny* pCmdData);
00106 OMX_ERRORTYPE GetParameter(
00107 OMX_INDEXTYPE nParamIndex,
00108 TAny* ComponentParameterStructure);
00109 OMX_ERRORTYPE SetParameter(
00110 OMX_INDEXTYPE nIndex,
00111 TAny* ComponentParameterStructure);
00112 OMX_ERRORTYPE GetConfig(
00113 OMX_INDEXTYPE nIndex,
00114 TAny* value);
00115 OMX_ERRORTYPE SetConfig(
00116 OMX_INDEXTYPE nIndex,
00117 TAny* value);
00118 OMX_ERRORTYPE GetExtensionIndex(
00119 OMX_STRING ParameterName,
00120 OMX_INDEXTYPE* pIndexType);
00121 OMX_ERRORTYPE GetState(
00122 OMX_STATETYPE* pState);
00123 OMX_ERRORTYPE ComponentTunnelRequest(
00124 OMX_HANDLETYPE hInput,
00125 TUint32 nInputPort,
00126 OMX_HANDLETYPE hOutput,
00127 TUint32 nOutputPort,
00128 OMX_TUNNELSETUPTYPE* pTunnelSetup);
00129 virtual OMX_ERRORTYPE UseBuffer(
00130 OMX_BUFFERHEADERTYPE** pBufferHdr,
00131 TUint32 nPortIndex,
00132 TAny* pAppPrivate,
00133 TUint32 nSizeBytes,
00134 TUint8* pBuffer);
00135 virtual OMX_ERRORTYPE AllocateBuffer(
00136 OMX_BUFFERHEADERTYPE** pBuffer,
00137 TUint32 nPortIndex,
00138 TAny* pAppData,
00139 TUint32 nSizeBytes);
00140 OMX_ERRORTYPE FreeBuffer(
00141 TUint32 nPortIndex,
00142 OMX_BUFFERHEADERTYPE* pBuffer);
00143 OMX_ERRORTYPE EmptyThisBuffer(
00144 OMX_BUFFERHEADERTYPE* pBuffer);
00145 OMX_ERRORTYPE FillThisBuffer(
00146 OMX_BUFFERHEADERTYPE* pBuffer);
00147 OMX_ERRORTYPE SetCallbacks(
00148 OMX_CALLBACKTYPE* pCallbacks,
00149 TAny* pAppData);
00150
00151 TInt StartExecution();
00152
00153 void EventHandlerCallback(
00154 OMX_EVENTTYPE eEvent,
00155 TUint32 nData1,
00156 TUint32 nData2,
00157 OMX_STRING cExtraInfo);
00158 void FillBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
00159 void EmptyBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
00160
00161 private:
00162 COmxVorbisDecoder(OMX_HANDLETYPE hComponent);
00163 void ConstructL();
00164
00165 private:
00166 OMX_CALLBACKTYPE* iCallback;
00167 TAny* iAppData;
00168 OMX_STATETYPE iState;
00169
00170 TRequestStatus iThreadDeath;
00171 CCodecProcessor* iCodecProcessor;
00172 TBool iCreatedThread;
00173 RThread iProcessingThread;
00174 };
00175
00176 #endif // OMXVORBISDECODER_H