examples/SFExamples/oggvorbiscodec/src/omx/OmxImpl.cpp

00001 // OmxImpl.cpp
00002 //
00003 // Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
00004 //
00005 
00006 #include <stdio.h>
00007 #include "OmxImpl.h"
00008         
00009 OMX_ERRORTYPE OMXComponentGetComponentVersion(
00010                 OMX_IN  OMX_HANDLETYPE hComponent,
00011         OMX_OUT OMX_STRING pComponentName,
00012         OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
00013         OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
00014         OMX_OUT OMX_UUIDTYPE* pComponentUUID);
00015 OMX_ERRORTYPE OMXComponentSendCommand(
00016         OMX_IN  OMX_HANDLETYPE hComponent,
00017         OMX_IN  OMX_COMMANDTYPE Cmd,
00018         OMX_IN  OMX_U32 nParam1,
00019         OMX_IN  OMX_PTR pCmdData);
00020 OMX_ERRORTYPE OMXComponentGetParameter(
00021         OMX_IN  OMX_HANDLETYPE hComponent, 
00022         OMX_IN  OMX_INDEXTYPE nParamIndex,  
00023         OMX_INOUT OMX_PTR ComponentParameterStructure);
00024 OMX_ERRORTYPE OMXComponentSetParameter(
00025         OMX_IN  OMX_HANDLETYPE hComponent, 
00026         OMX_IN  OMX_INDEXTYPE nIndex,
00027         OMX_IN  OMX_PTR ComponentParameterStructure);
00028 OMX_ERRORTYPE OMXComponentGetConfig(
00029         OMX_IN  OMX_HANDLETYPE hComponent,
00030         OMX_IN  OMX_INDEXTYPE nIndex, 
00031         OMX_INOUT OMX_PTR value);
00032 OMX_ERRORTYPE OMXComponentSetConfig(
00033         OMX_IN  OMX_HANDLETYPE hComponent,
00034         OMX_IN  OMX_INDEXTYPE nIndex, 
00035         OMX_IN  OMX_PTR value);
00036 OMX_ERRORTYPE OMXComponentGetExtensionIndex(
00037         OMX_IN  OMX_HANDLETYPE hComponent,
00038         OMX_IN  OMX_STRING ParameterName,
00039         OMX_OUT OMX_INDEXTYPE* pIndexType);
00040 OMX_ERRORTYPE OMXComponentGetState(
00041         OMX_IN  OMX_HANDLETYPE hComponent,
00042         OMX_OUT OMX_STATETYPE* pState);
00043 OMX_ERRORTYPE OMXComponentComponentTunnelRequest(
00044         OMX_IN  OMX_HANDLETYPE hInput,
00045         OMX_IN  OMX_U32 nPortInput,
00046         OMX_IN  OMX_HANDLETYPE hOutput,
00047         OMX_IN  OMX_U32 nPortOutput,
00048         OMX_IN  OMX_TUNNELSETUPTYPE* pTunnelSetup);
00049 OMX_ERRORTYPE OMXComponentUseBuffer(
00050         OMX_IN  OMX_HANDLETYPE hComponent,
00051         OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
00052         OMX_IN  OMX_U32 nPortIndex,
00053         OMX_IN  OMX_PTR pAppPrivate,
00054         OMX_IN  OMX_U32 nSizeBytes,
00055         OMX_IN  OMX_U8* pBuffer);
00056 OMX_ERRORTYPE OMXComponentAllocateBuffer(
00057         OMX_IN  OMX_HANDLETYPE hComponent,
00058         OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
00059         OMX_IN  OMX_U32 nPortIndex,
00060         OMX_IN  OMX_PTR pAppData,
00061         OMX_IN  OMX_U32 nSizeBytes);
00062 OMX_ERRORTYPE OMXComponentFreeBuffer(
00063         OMX_IN  OMX_HANDLETYPE hComponent,
00064         OMX_IN  OMX_U32 nPortIndex,
00065         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
00066 OMX_ERRORTYPE OMXComponentEmptyThisBuffer(
00067         OMX_IN  OMX_HANDLETYPE hComponent,
00068         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
00069 OMX_ERRORTYPE OMXComponentFillThisBuffer(
00070         OMX_IN  OMX_HANDLETYPE hComponent,
00071         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
00072 OMX_ERRORTYPE OMXComponentSetCallbacks(
00073         OMX_IN  OMX_HANDLETYPE hComponent,
00074         OMX_IN  OMX_CALLBACKTYPE* pCallbacks, 
00075         OMX_IN  OMX_PTR pAppData);   
00076 OMX_ERRORTYPE OMXComponentDeInit(OMX_IN  OMX_HANDLETYPE hComponent);
00077 
00078 
00079 void EventHandler(OMX_OUT OMX_HANDLETYPE hComponent, 
00080                                         OMX_OUT OMX_PTR pAppData,
00081                                 OMX_OUT OMX_EVENTTYPE eEvent, 
00082                                 OMX_OUT OMX_U32 Data,
00083                                 OMX_OUT OMX_STRING cExtraInfo);
00084                                 
00085 void InputBufferCallback(
00086         OMX_OUT OMX_HANDLETYPE hComponent,
00087         OMX_OUT OMX_PTR pAppData,
00088         OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
00089         
00090 void OutputBufferCallback(
00091         OMX_OUT OMX_HANDLETYPE hComponent,
00092         OMX_OUT OMX_PTR pAppData,
00093         OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
00094         
00095         
00096         
00097 //COmxComponentImpl* COmxComponentImpl::NewL(OMX_HANDLETYPE hComponent)
00098 //      {
00099 //      COmxComponentImpl* self = new (ELeave) COmxComponentImpl(hComponent);
00100 //      return self;
00101 //      }
00102 
00103 
00104         
00105  COmxComponentImpl::COmxComponentImpl(OMX_HANDLETYPE hComponent)
00106         {
00107         iHandle = static_cast<OMX_COMPONENTTYPE*>(hComponent);
00108         OMX_VERSIONTYPE ver = 
00109                 {
00110                 1,0
00111                 };
00112 
00113         // fill in handle structure             
00114         
00115         iHandle->nVersion = ver;
00116         iHandle->pComponentPrivate = this; 
00117         iHandle->GetComponentVersion = &::OMXComponentGetComponentVersion;
00118         iHandle->SendCommand = &::OMXComponentSendCommand;
00119         iHandle->GetParameter = &::OMXComponentGetParameter;
00120         iHandle->SetParameter = &::OMXComponentSetParameter;
00121         iHandle->GetConfig = &::OMXComponentGetConfig;
00122         iHandle->SetConfig = &::OMXComponentSetConfig;
00123         iHandle->GetExtensionIndex = &::OMXComponentGetExtensionIndex;
00124         iHandle->GetState =     &::OMXComponentGetState;
00125         iHandle->ComponentTunnelRequest = &::OMXComponentComponentTunnelRequest;
00126         iHandle->UseBuffer = &::OMXComponentUseBuffer;
00127         iHandle->AllocateBuffer = &::OMXComponentAllocateBuffer;
00128         iHandle->FreeBuffer = &::OMXComponentFreeBuffer;
00129         iHandle->EmptyThisBuffer = &::OMXComponentEmptyThisBuffer;
00130         iHandle->FillThisBuffer = &::OMXComponentFillThisBuffer;
00131         iHandle->SetCallbacks = &::OMXComponentSetCallbacks;
00132         iHandle->ComponentDeInit = &::OMXComponentDeInit;
00133         }
00134         
00135  COmxComponentImpl::~COmxComponentImpl()
00136         {
00137         
00138         }
00139  COmxComponentImpl::operator OMX_HANDLETYPE()
00140                 {
00141                 return (OMX_HANDLETYPE)&iHandle;
00142                 }
00143 
00144         
00145 OMX_ERRORTYPE OMXComponentGetComponentVersion(
00146                 OMX_IN  OMX_HANDLETYPE hComponent,
00147         OMX_OUT OMX_STRING pComponentName,
00148         OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
00149         OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
00150         OMX_OUT OMX_UUIDTYPE* pComponentUUID)
00151         {
00152         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetComponentVersion(pComponentName,pComponentVersion,pSpecVersion, pComponentUUID);
00153         }
00154         
00155 
00156 OMX_ERRORTYPE OMXComponentSendCommand(
00157         OMX_IN  OMX_HANDLETYPE hComponent,
00158         OMX_IN  OMX_COMMANDTYPE Cmd,
00159         OMX_IN  OMX_U32 nParam1,
00160         OMX_IN  OMX_PTR pCmdData)
00161         {
00162         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SendCommand(Cmd ,nParam1, pCmdData);
00163         
00164         }
00165 OMX_ERRORTYPE OMXComponentGetParameter(
00166         OMX_IN  OMX_HANDLETYPE hComponent, 
00167         OMX_IN  OMX_INDEXTYPE nParamIndex,  
00168         OMX_INOUT OMX_PTR ComponentParameterStructure)
00169         {
00170         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetParameter(nParamIndex, ComponentParameterStructure);
00171         }
00172 OMX_ERRORTYPE OMXComponentSetParameter(
00173         OMX_IN  OMX_HANDLETYPE hComponent, 
00174         OMX_IN  OMX_INDEXTYPE nIndex,
00175         OMX_IN  OMX_PTR ComponentParameterStructure)
00176         {
00177         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetParameter(nIndex, ComponentParameterStructure);
00178         }
00179 OMX_ERRORTYPE OMXComponentGetConfig(
00180         OMX_IN  OMX_HANDLETYPE hComponent,
00181         OMX_IN  OMX_INDEXTYPE nIndex, 
00182         OMX_INOUT OMX_PTR value)
00183         {
00184         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetConfig(nIndex, value);
00185         }
00186 OMX_ERRORTYPE OMXComponentSetConfig(
00187         OMX_IN  OMX_HANDLETYPE hComponent,
00188         OMX_IN  OMX_INDEXTYPE nIndex, 
00189         OMX_IN  OMX_PTR value)
00190         {
00191         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetConfig(nIndex, value);
00192         }
00193 OMX_ERRORTYPE OMXComponentGetExtensionIndex(
00194         OMX_IN  OMX_HANDLETYPE hComponent,
00195         OMX_IN  OMX_STRING ParameterName,
00196         OMX_OUT OMX_INDEXTYPE* pIndexType)
00197         {
00198         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetExtensionIndex(ParameterName, pIndexType);
00199         }
00200 OMX_ERRORTYPE OMXComponentGetState(
00201         OMX_IN  OMX_HANDLETYPE hComponent,
00202         OMX_OUT OMX_STATETYPE* pState)
00203         {
00204         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetState(pState);
00205         }
00206 OMX_ERRORTYPE OMXComponentComponentTunnelRequest(
00207         OMX_IN  OMX_HANDLETYPE hInput,
00208         OMX_IN  OMX_U32 nInputPort,
00209         OMX_IN  OMX_HANDLETYPE hOutput,
00210         OMX_IN  OMX_U32 nOutputPort,
00211         OMX_IN  OMX_TUNNELSETUPTYPE* pTunnelSetup)
00212         {
00213         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hInput)->pComponentPrivate)->ComponentTunnelRequest(hInput, nInputPort, hOutput, nOutputPort, pTunnelSetup);
00214         }
00215 OMX_ERRORTYPE OMXComponentUseBuffer(
00216         OMX_IN  OMX_HANDLETYPE hComponent,
00217         OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
00218         OMX_IN  OMX_U32 nPortIndex,
00219         OMX_IN  OMX_PTR pAppPrivate,
00220         OMX_IN  OMX_U32 nSizeBytes,
00221         OMX_IN  OMX_U8* pBuffer)
00222         {
00223         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->UseBuffer(ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
00224         }
00225         
00226 OMX_ERRORTYPE OMXComponentAllocateBuffer(
00227         OMX_IN  OMX_HANDLETYPE hComponent,
00228         OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
00229         OMX_IN  OMX_U32 nPortIndex,
00230         OMX_IN  OMX_PTR pAppData,
00231         OMX_IN  OMX_U32 nSizeBytes)
00232         {
00233         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->AllocateBuffer(pBuffer, nPortIndex, pAppData, nSizeBytes);
00234         }
00235 
00236 OMX_ERRORTYPE OMXComponentFreeBuffer(
00237         OMX_IN  OMX_HANDLETYPE hComponent,
00238         OMX_IN  OMX_U32 nPortIndex,
00239         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
00240         {
00241         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->FreeBuffer(nPortIndex, pBuffer);
00242         }
00243 OMX_ERRORTYPE OMXComponentEmptyThisBuffer(
00244         OMX_IN  OMX_HANDLETYPE hComponent,
00245         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
00246         {
00247         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->EmptyThisBuffer(pBuffer);
00248         }
00249 OMX_ERRORTYPE OMXComponentFillThisBuffer(
00250         OMX_IN  OMX_HANDLETYPE hComponent,
00251         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
00252         {
00253         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->FillThisBuffer(pBuffer);
00254         }
00255 OMX_ERRORTYPE OMXComponentSetCallbacks(
00256         OMX_IN  OMX_HANDLETYPE hComponent,
00257         OMX_IN  OMX_CALLBACKTYPE* pCallbacks, 
00258         OMX_IN  OMX_PTR pAppData)
00259         {
00260         return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetCallbacks(pCallbacks, pAppData);
00261         }
00262         
00263 OMX_ERRORTYPE OMXComponentDeInit(OMX_IN  OMX_HANDLETYPE hComponent)
00264         {
00265         delete ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
00266         return OMX_ErrorNone;
00267         }

Generated by  doxygen 1.6.2