examples/sfexamples/oggvorbiscodec/src/omx/encoder/OmxVorbisEncoder.h

Go to the documentation of this file.
00001 // OmxVorbisEncoder.h
00002 //
00003 // Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
00004 //
00005 
00011 #ifndef OMXVORBISENCODER_H
00012 #define OMXVORBISENCODER_H
00013 
00014 #include <e32msgqueue.h>
00015 #include <mdaaudiooutputstream.h>
00016 #include <OMX_Audio.h>
00017 #include "OmxImpl.h"
00018 
00019 class COmxVorbisEncoder;
00020 class CVorbisProcessor;
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(COmxVorbisEncoder& 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 SetInputSampleRate(TInt aInputSampleRate);
00055                 void SetInputChannels(TInt aInputChannels);
00056                 void SetInputDataType(OMX_NUMERICALDATATYPE aType);
00057                 void SetInputBitsPerSample(TInt aBitsPerSample);
00058                 void SetOutputBitRate(TInt aOutputBitRate);
00059                 TInt ConfigureInput();
00060                 TInt OutputBitRate();
00061 
00062                 virtual ~CCodecProcessor();             
00063             
00064         private:
00065                 void ConstructL();
00066                 CCodecProcessor(COmxVorbisEncoder& aParent);
00067 
00068                 void ProcessAvailableBuffers();
00069         
00070         private:
00071                 COmxVorbisEncoder* iParent;
00072                 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToEmpty;
00073                 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToFill;     
00074                 
00075                 TRequestStatus iQueueStatus;
00076                 RMsgQueue<TCodecMessage> iMessageQueue;
00077                 
00078                 OMX_BUFFERHEADERTYPE* iInputBuffer;
00079                 OMX_BUFFERHEADERTYPE* iOutputBuffer;
00080                 
00081                 // codec configuration settings
00082                 TInt iInputSampleRate;
00083                 TInt iInputChannels;
00084                 TInt iInputBitsPerSample; 
00085                 OMX_NUMERICALDATATYPE iInputDataType;
00086                 TInt iOutputBitRate; 
00087                 
00088                 CVorbisProcessor* iCodec;
00089                         
00090                 TBool iStarted;
00091                 };
00092 
00093 class COmxVorbisEncoder : public COmxComponentImpl
00094         {
00095 public:
00096         friend class CCodecProcessor;
00097         friend class CCodecCallbacks;
00098 
00099         static TInt CreateComponent(OMX_HANDLETYPE hComponent);
00100         ~COmxVorbisEncoder();
00101         
00102         OMX_ERRORTYPE GetComponentVersion(
00103                         OMX_STRING pComponentName,
00104                         OMX_VERSIONTYPE* pComponentVersion,
00105                         OMX_VERSIONTYPE* pSpecVersion,
00106                         OMX_UUIDTYPE* pComponentUUID);
00107     OMX_ERRORTYPE SendCommand(
00108                         OMX_COMMANDTYPE Cmd,
00109                         TUint32 nParam1,
00110                         TAny* pCmdData);
00111     OMX_ERRORTYPE GetParameter(
00112                         OMX_INDEXTYPE nParamIndex,  
00113                         TAny* ComponentParameterStructure);
00114     OMX_ERRORTYPE SetParameter(
00115                         OMX_INDEXTYPE nIndex,
00116                         TAny* ComponentParameterStructure);
00117     OMX_ERRORTYPE GetConfig(
00118                         OMX_INDEXTYPE nIndex, 
00119                         TAny* value);
00120     OMX_ERRORTYPE SetConfig(
00121                         OMX_INDEXTYPE nIndex, 
00122                         TAny* value);
00123     OMX_ERRORTYPE GetExtensionIndex(
00124                         OMX_STRING ParameterName,
00125                         OMX_INDEXTYPE* pIndexType);
00126     OMX_ERRORTYPE GetState(
00127                         OMX_STATETYPE* pState);
00128     OMX_ERRORTYPE ComponentTunnelRequest(
00129                         OMX_HANDLETYPE hInput,
00130                         TUint32 nInputPort,
00131                         OMX_HANDLETYPE hOutput,
00132                         TUint32 nOutputPort,
00133                         OMX_TUNNELSETUPTYPE* pTunnelSetup);
00134     virtual OMX_ERRORTYPE UseBuffer(
00135                         OMX_BUFFERHEADERTYPE** pBufferHdr,
00136                         TUint32 nPortIndex,
00137                         TAny* pAppPrivate,
00138                         TUint32 nSizeBytes,
00139                         TUint8* pBuffer);
00140     virtual OMX_ERRORTYPE AllocateBuffer(
00141            OMX_BUFFERHEADERTYPE** pBuffer,
00142            TUint32 nPortIndex,
00143            TAny* pAppData,
00144            TUint32 nSizeBytes);
00145     OMX_ERRORTYPE FreeBuffer(
00146                   TUint32 nPortIndex,   
00147               OMX_BUFFERHEADERTYPE* pBuffer);
00148     OMX_ERRORTYPE EmptyThisBuffer(
00149               OMX_BUFFERHEADERTYPE* pBuffer);
00150     OMX_ERRORTYPE FillThisBuffer(
00151               OMX_BUFFERHEADERTYPE* pBuffer);
00152     OMX_ERRORTYPE SetCallbacks(
00153               OMX_CALLBACKTYPE* pCallbacks, 
00154               TAny* pAppData);
00155               
00156     TInt StartExecution();
00157             
00158     void EventHandlerCallback(
00159                                  OMX_EVENTTYPE eEvent, 
00160                                  TUint32 nData1,
00161                                  TUint32 nData2,
00162                                  OMX_STRING cExtraInfo);
00163     void FillBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
00164     void EmptyBufferDoneCallback(OMX_BUFFERHEADERTYPE* pBuffer);
00165             
00166 private:
00167         COmxVorbisEncoder(OMX_HANDLETYPE hComponent);
00168         void ConstructL();
00169 
00170 private:
00171         OMX_CALLBACKTYPE* iCallback;
00172         TAny* iAppData;
00173         OMX_STATETYPE iState;
00174         
00175         TRequestStatus iThreadDeath;
00176         CCodecProcessor* iCodecProcessor;
00177         TBool iCreatedThread;
00178         RThread iProcessingThread;
00179         };
00180 
00181 #endif // OMXVORBISENCODER_H

Generated by  doxygen 1.6.2