1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/mdfunittest/codecapi/omx/pcmcodec/src/OmxImpl.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,275 @@
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 +#include <stdio.h>
1.20 +#include "OmxImpl.h"
1.21 +
1.22 +
1.23 +OMX_ERRORTYPE OMXComponentGetComponentVersion(
1.24 + OMX_IN OMX_HANDLETYPE hComponent,
1.25 + OMX_OUT OMX_STRING pComponentName,
1.26 + OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
1.27 + OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
1.28 + OMX_OUT OMX_UUIDTYPE* pComponentUUID);
1.29 +OMX_ERRORTYPE OMXComponentSendCommand(
1.30 + OMX_IN OMX_HANDLETYPE hComponent,
1.31 + OMX_IN OMX_COMMANDTYPE Cmd,
1.32 + OMX_IN OMX_U32 nParam1,
1.33 + OMX_IN OMX_PTR pCmdData);
1.34 +OMX_ERRORTYPE OMXComponentGetParameter(
1.35 + OMX_IN OMX_HANDLETYPE hComponent,
1.36 + OMX_IN OMX_INDEXTYPE nParamIndex,
1.37 + OMX_INOUT OMX_PTR ComponentParameterStructure);
1.38 +OMX_ERRORTYPE OMXComponentSetParameter(
1.39 + OMX_IN OMX_HANDLETYPE hComponent,
1.40 + OMX_IN OMX_INDEXTYPE nIndex,
1.41 + OMX_IN OMX_PTR ComponentParameterStructure);
1.42 +OMX_ERRORTYPE OMXComponentGetConfig(
1.43 + OMX_IN OMX_HANDLETYPE hComponent,
1.44 + OMX_IN OMX_INDEXTYPE nIndex,
1.45 + OMX_INOUT OMX_PTR value);
1.46 +OMX_ERRORTYPE OMXComponentSetConfig(
1.47 + OMX_IN OMX_HANDLETYPE hComponent,
1.48 + OMX_IN OMX_INDEXTYPE nIndex,
1.49 + OMX_IN OMX_PTR value);
1.50 +OMX_ERRORTYPE OMXComponentGetExtensionIndex(
1.51 + OMX_IN OMX_HANDLETYPE hComponent,
1.52 + OMX_IN OMX_STRING ParameterName,
1.53 + OMX_OUT OMX_INDEXTYPE* pIndexType);
1.54 +OMX_ERRORTYPE OMXComponentGetState(
1.55 + OMX_IN OMX_HANDLETYPE hComponent,
1.56 + OMX_OUT OMX_STATETYPE* pState);
1.57 +OMX_ERRORTYPE OMXComponentComponentTunnelRequest(
1.58 + OMX_IN OMX_HANDLETYPE hInput,
1.59 + OMX_IN OMX_U32 nPortInput,
1.60 + OMX_IN OMX_HANDLETYPE hOutput,
1.61 + OMX_IN OMX_U32 nPortOutput,
1.62 + OMX_IN OMX_TUNNELSETUPTYPE* pTunnelSetup);
1.63 +OMX_ERRORTYPE OMXComponentUseBuffer(
1.64 + OMX_IN OMX_HANDLETYPE hComponent,
1.65 + OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
1.66 + OMX_IN OMX_U32 nPortIndex,
1.67 + OMX_IN OMX_PTR pAppPrivate,
1.68 + OMX_IN OMX_U32 nSizeBytes,
1.69 + OMX_IN OMX_U8* pBuffer);
1.70 +OMX_ERRORTYPE OMXComponentAllocateBuffer(
1.71 + OMX_IN OMX_HANDLETYPE hComponent,
1.72 + OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
1.73 + OMX_IN OMX_U32 nPortIndex,
1.74 + OMX_IN OMX_PTR pAppData,
1.75 + OMX_IN OMX_U32 nSizeBytes);
1.76 +OMX_ERRORTYPE OMXComponentFreeBuffer(
1.77 + OMX_IN OMX_HANDLETYPE hComponent,
1.78 + OMX_IN OMX_U32 nPortIndex,
1.79 + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
1.80 +OMX_ERRORTYPE OMXComponentEmptyThisBuffer(
1.81 + OMX_IN OMX_HANDLETYPE hComponent,
1.82 + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
1.83 +OMX_ERRORTYPE OMXComponentFillThisBuffer(
1.84 + OMX_IN OMX_HANDLETYPE hComponent,
1.85 + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
1.86 +OMX_ERRORTYPE OMXComponentSetCallbacks(
1.87 + OMX_IN OMX_HANDLETYPE hComponent,
1.88 + OMX_IN OMX_CALLBACKTYPE* pCallbacks,
1.89 + OMX_IN OMX_PTR pAppData);
1.90 +OMX_ERRORTYPE OMXComponentDeInit(OMX_IN OMX_HANDLETYPE hComponent);
1.91 +
1.92 +
1.93 +void EventHandler(OMX_OUT OMX_HANDLETYPE hComponent,
1.94 + OMX_OUT OMX_PTR pAppData,
1.95 + OMX_OUT OMX_EVENTTYPE eEvent,
1.96 + OMX_OUT OMX_U32 Data,
1.97 + OMX_OUT OMX_STRING cExtraInfo);
1.98 +
1.99 +void InputBufferCallback(
1.100 + OMX_OUT OMX_HANDLETYPE hComponent,
1.101 + OMX_OUT OMX_PTR pAppData,
1.102 + OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
1.103 +
1.104 +void OutputBufferCallback(
1.105 + OMX_OUT OMX_HANDLETYPE hComponent,
1.106 + OMX_OUT OMX_PTR pAppData,
1.107 + OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
1.108 +
1.109 +COmxComponentImpl::COmxComponentImpl(OMX_HANDLETYPE hComponent)
1.110 + {
1.111 + iHandle = static_cast<OMX_COMPONENTTYPE*>(hComponent);
1.112 + OMX_VERSIONTYPE ver =
1.113 + {
1.114 + 1,0
1.115 + };
1.116 +
1.117 + // fill in handle structure
1.118 + iHandle->nVersion = ver;
1.119 + iHandle->pComponentPrivate = this;
1.120 + iHandle->GetComponentVersion = &::OMXComponentGetComponentVersion;
1.121 + iHandle->SendCommand = &::OMXComponentSendCommand;
1.122 + iHandle->GetParameter = &::OMXComponentGetParameter;
1.123 + iHandle->SetParameter = &::OMXComponentSetParameter;
1.124 + iHandle->GetConfig = &::OMXComponentGetConfig;
1.125 + iHandle->SetConfig = &::OMXComponentSetConfig;
1.126 + iHandle->GetExtensionIndex = &::OMXComponentGetExtensionIndex;
1.127 + iHandle->GetState = &::OMXComponentGetState;
1.128 + iHandle->ComponentTunnelRequest = &::OMXComponentComponentTunnelRequest;
1.129 + iHandle->UseBuffer = &::OMXComponentUseBuffer;
1.130 + iHandle->AllocateBuffer = &::OMXComponentAllocateBuffer;
1.131 + iHandle->FreeBuffer = &::OMXComponentFreeBuffer;
1.132 + iHandle->EmptyThisBuffer = &::OMXComponentEmptyThisBuffer;
1.133 + iHandle->FillThisBuffer = &::OMXComponentFillThisBuffer;
1.134 + iHandle->SetCallbacks = &::OMXComponentSetCallbacks;
1.135 + iHandle->ComponentDeInit = &::OMXComponentDeInit;
1.136 + }
1.137 +
1.138 +COmxComponentImpl::~COmxComponentImpl()
1.139 + {
1.140 + }
1.141 +
1.142 +COmxComponentImpl::operator OMX_HANDLETYPE()
1.143 + {
1.144 + return (OMX_HANDLETYPE)&iHandle;
1.145 + }
1.146 +
1.147 +OMX_ERRORTYPE OMXComponentGetComponentVersion(
1.148 + OMX_IN OMX_HANDLETYPE hComponent,
1.149 + OMX_OUT OMX_STRING pComponentName,
1.150 + OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
1.151 + OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
1.152 + OMX_OUT OMX_UUIDTYPE* pComponentUUID)
1.153 + {
1.154 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetComponentVersion(pComponentName,pComponentVersion,pSpecVersion, pComponentUUID);
1.155 + }
1.156 +
1.157 +OMX_ERRORTYPE OMXComponentSendCommand(
1.158 + OMX_IN OMX_HANDLETYPE hComponent,
1.159 + OMX_IN OMX_COMMANDTYPE Cmd,
1.160 + OMX_IN OMX_U32 nParam1,
1.161 + OMX_IN OMX_PTR pCmdData)
1.162 + {
1.163 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SendCommand(Cmd ,nParam1, pCmdData);
1.164 + }
1.165 +
1.166 +OMX_ERRORTYPE OMXComponentGetParameter(
1.167 + OMX_IN OMX_HANDLETYPE hComponent,
1.168 + OMX_IN OMX_INDEXTYPE nParamIndex,
1.169 + OMX_INOUT OMX_PTR ComponentParameterStructure)
1.170 + {
1.171 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetParameter(nParamIndex, ComponentParameterStructure);
1.172 + }
1.173 +
1.174 +OMX_ERRORTYPE OMXComponentSetParameter(
1.175 + OMX_IN OMX_HANDLETYPE hComponent,
1.176 + OMX_IN OMX_INDEXTYPE nIndex,
1.177 + OMX_IN OMX_PTR ComponentParameterStructure)
1.178 + {
1.179 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetParameter(nIndex, ComponentParameterStructure);
1.180 + }
1.181 +
1.182 +OMX_ERRORTYPE OMXComponentGetConfig(
1.183 + OMX_IN OMX_HANDLETYPE hComponent,
1.184 + OMX_IN OMX_INDEXTYPE nIndex,
1.185 + OMX_INOUT OMX_PTR value)
1.186 + {
1.187 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetConfig(nIndex, value);
1.188 + }
1.189 +
1.190 +OMX_ERRORTYPE OMXComponentSetConfig(
1.191 + OMX_IN OMX_HANDLETYPE hComponent,
1.192 + OMX_IN OMX_INDEXTYPE nIndex,
1.193 + OMX_IN OMX_PTR value)
1.194 + {
1.195 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetConfig(nIndex, value);
1.196 + }
1.197 +
1.198 +OMX_ERRORTYPE OMXComponentGetExtensionIndex(
1.199 + OMX_IN OMX_HANDLETYPE hComponent,
1.200 + OMX_IN OMX_STRING ParameterName,
1.201 + OMX_OUT OMX_INDEXTYPE* pIndexType)
1.202 + {
1.203 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetExtensionIndex(ParameterName, pIndexType);
1.204 + }
1.205 +
1.206 +OMX_ERRORTYPE OMXComponentGetState(
1.207 + OMX_IN OMX_HANDLETYPE hComponent,
1.208 + OMX_OUT OMX_STATETYPE* pState)
1.209 + {
1.210 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetState(pState);
1.211 + }
1.212 +
1.213 +OMX_ERRORTYPE OMXComponentComponentTunnelRequest(
1.214 + OMX_IN OMX_HANDLETYPE hInput,
1.215 + OMX_IN OMX_U32 nInputPort,
1.216 + OMX_IN OMX_HANDLETYPE hOutput,
1.217 + OMX_IN OMX_U32 nOutputPort,
1.218 + OMX_IN OMX_TUNNELSETUPTYPE* pTunnelSetup)
1.219 + {
1.220 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hInput)->pComponentPrivate)->ComponentTunnelRequest(hInput, nInputPort, hOutput, nOutputPort, pTunnelSetup);
1.221 + }
1.222 +
1.223 +OMX_ERRORTYPE OMXComponentUseBuffer(
1.224 + OMX_IN OMX_HANDLETYPE hComponent,
1.225 + OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
1.226 + OMX_IN OMX_U32 nPortIndex,
1.227 + OMX_IN OMX_PTR pAppPrivate,
1.228 + OMX_IN OMX_U32 nSizeBytes,
1.229 + OMX_IN OMX_U8* pBuffer)
1.230 + {
1.231 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->UseBuffer(ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
1.232 + }
1.233 +
1.234 +OMX_ERRORTYPE OMXComponentAllocateBuffer(
1.235 + OMX_IN OMX_HANDLETYPE hComponent,
1.236 + OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
1.237 + OMX_IN OMX_U32 nPortIndex,
1.238 + OMX_IN OMX_PTR pAppData,
1.239 + OMX_IN OMX_U32 nSizeBytes)
1.240 + {
1.241 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->AllocateBuffer(pBuffer, nPortIndex, pAppData, nSizeBytes);
1.242 + }
1.243 +
1.244 +OMX_ERRORTYPE OMXComponentFreeBuffer(
1.245 + OMX_IN OMX_HANDLETYPE hComponent,
1.246 + OMX_IN OMX_U32 nPortIndex,
1.247 + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
1.248 + {
1.249 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->FreeBuffer(nPortIndex, pBuffer);
1.250 + }
1.251 +
1.252 +OMX_ERRORTYPE OMXComponentEmptyThisBuffer(
1.253 + OMX_IN OMX_HANDLETYPE hComponent,
1.254 + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
1.255 + {
1.256 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->EmptyThisBuffer(pBuffer);
1.257 + }
1.258 +
1.259 +OMX_ERRORTYPE OMXComponentFillThisBuffer(
1.260 + OMX_IN OMX_HANDLETYPE hComponent,
1.261 + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
1.262 + {
1.263 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->FillThisBuffer(pBuffer);
1.264 + }
1.265 +
1.266 +OMX_ERRORTYPE OMXComponentSetCallbacks(
1.267 + OMX_IN OMX_HANDLETYPE hComponent,
1.268 + OMX_IN OMX_CALLBACKTYPE* pCallbacks,
1.269 + OMX_IN OMX_PTR pAppData)
1.270 + {
1.271 + return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetCallbacks(pCallbacks, pAppData);
1.272 + }
1.273 +
1.274 +OMX_ERRORTYPE OMXComponentDeInit(OMX_IN OMX_HANDLETYPE hComponent)
1.275 + {
1.276 + delete ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
1.277 + return OMX_ErrorNone;
1.278 + }