os/mm/mmdevicefw/mdfunittest/codecapi/omx/pcmcodec/src/OmxImpl.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <stdio.h>
    17 #include "OmxImpl.h"
    18 
    19 	
    20 OMX_ERRORTYPE OMXComponentGetComponentVersion(
    21 		OMX_IN  OMX_HANDLETYPE hComponent,
    22         OMX_OUT OMX_STRING pComponentName,
    23         OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
    24         OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
    25         OMX_OUT OMX_UUIDTYPE* pComponentUUID);
    26 OMX_ERRORTYPE OMXComponentSendCommand(
    27         OMX_IN  OMX_HANDLETYPE hComponent,
    28         OMX_IN  OMX_COMMANDTYPE Cmd,
    29         OMX_IN  OMX_U32 nParam1,
    30         OMX_IN  OMX_PTR pCmdData);
    31 OMX_ERRORTYPE OMXComponentGetParameter(
    32         OMX_IN  OMX_HANDLETYPE hComponent, 
    33         OMX_IN  OMX_INDEXTYPE nParamIndex,  
    34         OMX_INOUT OMX_PTR ComponentParameterStructure);
    35 OMX_ERRORTYPE OMXComponentSetParameter(
    36         OMX_IN  OMX_HANDLETYPE hComponent, 
    37         OMX_IN  OMX_INDEXTYPE nIndex,
    38         OMX_IN  OMX_PTR ComponentParameterStructure);
    39 OMX_ERRORTYPE OMXComponentGetConfig(
    40         OMX_IN  OMX_HANDLETYPE hComponent,
    41         OMX_IN  OMX_INDEXTYPE nIndex, 
    42         OMX_INOUT OMX_PTR value);
    43 OMX_ERRORTYPE OMXComponentSetConfig(
    44         OMX_IN  OMX_HANDLETYPE hComponent,
    45         OMX_IN  OMX_INDEXTYPE nIndex, 
    46         OMX_IN  OMX_PTR value);
    47 OMX_ERRORTYPE OMXComponentGetExtensionIndex(
    48         OMX_IN  OMX_HANDLETYPE hComponent,
    49         OMX_IN  OMX_STRING ParameterName,
    50         OMX_OUT OMX_INDEXTYPE* pIndexType);
    51 OMX_ERRORTYPE OMXComponentGetState(
    52         OMX_IN  OMX_HANDLETYPE hComponent,
    53         OMX_OUT OMX_STATETYPE* pState);
    54 OMX_ERRORTYPE OMXComponentComponentTunnelRequest(
    55         OMX_IN  OMX_HANDLETYPE hInput,
    56         OMX_IN  OMX_U32 nPortInput,
    57         OMX_IN  OMX_HANDLETYPE hOutput,
    58         OMX_IN  OMX_U32 nPortOutput,
    59         OMX_IN  OMX_TUNNELSETUPTYPE* pTunnelSetup);
    60 OMX_ERRORTYPE OMXComponentUseBuffer(
    61         OMX_IN  OMX_HANDLETYPE hComponent,
    62         OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
    63         OMX_IN  OMX_U32 nPortIndex,
    64         OMX_IN	OMX_PTR pAppPrivate,
    65         OMX_IN	OMX_U32 nSizeBytes,
    66         OMX_IN	OMX_U8* pBuffer);
    67 OMX_ERRORTYPE OMXComponentAllocateBuffer(
    68         OMX_IN  OMX_HANDLETYPE hComponent,
    69         OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
    70         OMX_IN  OMX_U32 nPortIndex,
    71         OMX_IN	OMX_PTR pAppData,
    72         OMX_IN	OMX_U32 nSizeBytes);
    73 OMX_ERRORTYPE OMXComponentFreeBuffer(
    74         OMX_IN  OMX_HANDLETYPE hComponent,
    75         OMX_IN  OMX_U32 nPortIndex,
    76         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
    77 OMX_ERRORTYPE OMXComponentEmptyThisBuffer(
    78         OMX_IN  OMX_HANDLETYPE hComponent,
    79         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
    80 OMX_ERRORTYPE OMXComponentFillThisBuffer(
    81         OMX_IN  OMX_HANDLETYPE hComponent,
    82         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
    83 OMX_ERRORTYPE OMXComponentSetCallbacks(
    84         OMX_IN  OMX_HANDLETYPE hComponent,
    85         OMX_IN  OMX_CALLBACKTYPE* pCallbacks, 
    86         OMX_IN  OMX_PTR pAppData);   
    87 OMX_ERRORTYPE OMXComponentDeInit(OMX_IN  OMX_HANDLETYPE hComponent);
    88 
    89 
    90 void EventHandler(OMX_OUT OMX_HANDLETYPE hComponent, 
    91 					OMX_OUT OMX_PTR pAppData,
    92         			OMX_OUT OMX_EVENTTYPE eEvent, 
    93         			OMX_OUT OMX_U32 Data,
    94         			OMX_OUT OMX_STRING cExtraInfo);
    95         			
    96 void InputBufferCallback(
    97         OMX_OUT OMX_HANDLETYPE hComponent,
    98         OMX_OUT OMX_PTR pAppData,
    99         OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
   100         
   101 void OutputBufferCallback(
   102         OMX_OUT OMX_HANDLETYPE hComponent,
   103         OMX_OUT OMX_PTR pAppData,
   104         OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);
   105         
   106 COmxComponentImpl::COmxComponentImpl(OMX_HANDLETYPE hComponent)
   107 	{
   108 	iHandle = static_cast<OMX_COMPONENTTYPE*>(hComponent);
   109 	OMX_VERSIONTYPE ver = 
   110 		{
   111 		1,0
   112 		};
   113 
   114 	// fill in handle structure
   115 	iHandle->nVersion = ver;
   116 	iHandle->pComponentPrivate = this; 
   117 	iHandle->GetComponentVersion = &::OMXComponentGetComponentVersion;
   118 	iHandle->SendCommand = &::OMXComponentSendCommand;
   119 	iHandle->GetParameter = &::OMXComponentGetParameter;
   120 	iHandle->SetParameter = &::OMXComponentSetParameter;
   121 	iHandle->GetConfig = &::OMXComponentGetConfig;
   122 	iHandle->SetConfig = &::OMXComponentSetConfig;
   123 	iHandle->GetExtensionIndex = &::OMXComponentGetExtensionIndex;
   124 	iHandle->GetState =	&::OMXComponentGetState;
   125 	iHandle->ComponentTunnelRequest = &::OMXComponentComponentTunnelRequest;
   126 	iHandle->UseBuffer = &::OMXComponentUseBuffer;
   127 	iHandle->AllocateBuffer = &::OMXComponentAllocateBuffer;
   128 	iHandle->FreeBuffer = &::OMXComponentFreeBuffer;
   129 	iHandle->EmptyThisBuffer = &::OMXComponentEmptyThisBuffer;
   130 	iHandle->FillThisBuffer = &::OMXComponentFillThisBuffer;
   131 	iHandle->SetCallbacks = &::OMXComponentSetCallbacks;
   132 	iHandle->ComponentDeInit = &::OMXComponentDeInit;
   133 	}
   134 	
   135 COmxComponentImpl::~COmxComponentImpl()
   136 	{
   137 	}
   138 	
   139 COmxComponentImpl::operator OMX_HANDLETYPE()
   140 	{
   141 	return (OMX_HANDLETYPE)&iHandle;
   142 	}
   143 	
   144 OMX_ERRORTYPE OMXComponentGetComponentVersion(
   145 		OMX_IN  OMX_HANDLETYPE hComponent,
   146         OMX_OUT OMX_STRING pComponentName,
   147         OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
   148         OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
   149         OMX_OUT OMX_UUIDTYPE* pComponentUUID)
   150 	{
   151 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetComponentVersion(pComponentName,pComponentVersion,pSpecVersion, pComponentUUID);
   152 	}
   153 
   154 OMX_ERRORTYPE OMXComponentSendCommand(
   155         OMX_IN  OMX_HANDLETYPE hComponent,
   156         OMX_IN  OMX_COMMANDTYPE Cmd,
   157         OMX_IN  OMX_U32 nParam1,
   158         OMX_IN  OMX_PTR pCmdData)
   159 	{
   160 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SendCommand(Cmd ,nParam1, pCmdData);	
   161 	}
   162 	
   163 OMX_ERRORTYPE OMXComponentGetParameter(
   164         OMX_IN  OMX_HANDLETYPE hComponent, 
   165         OMX_IN  OMX_INDEXTYPE nParamIndex,  
   166         OMX_INOUT OMX_PTR ComponentParameterStructure)
   167 	{
   168 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetParameter(nParamIndex, ComponentParameterStructure);
   169 	}
   170 	
   171 OMX_ERRORTYPE OMXComponentSetParameter(
   172         OMX_IN  OMX_HANDLETYPE hComponent, 
   173         OMX_IN  OMX_INDEXTYPE nIndex,
   174         OMX_IN  OMX_PTR ComponentParameterStructure)
   175 	{
   176 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetParameter(nIndex, ComponentParameterStructure);
   177 	}
   178 	
   179 OMX_ERRORTYPE OMXComponentGetConfig(
   180         OMX_IN  OMX_HANDLETYPE hComponent,
   181         OMX_IN  OMX_INDEXTYPE nIndex, 
   182         OMX_INOUT OMX_PTR value)
   183 	{
   184 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetConfig(nIndex, value);
   185 	}
   186 	
   187 OMX_ERRORTYPE OMXComponentSetConfig(
   188         OMX_IN  OMX_HANDLETYPE hComponent,
   189         OMX_IN  OMX_INDEXTYPE nIndex, 
   190         OMX_IN  OMX_PTR value)
   191 	{
   192 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetConfig(nIndex, value);
   193 	}
   194 	
   195 OMX_ERRORTYPE OMXComponentGetExtensionIndex(
   196         OMX_IN  OMX_HANDLETYPE hComponent,
   197         OMX_IN  OMX_STRING ParameterName,
   198         OMX_OUT OMX_INDEXTYPE* pIndexType)
   199 	{
   200 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetExtensionIndex(ParameterName, pIndexType);
   201 	}
   202 	
   203 OMX_ERRORTYPE OMXComponentGetState(
   204         OMX_IN  OMX_HANDLETYPE hComponent,
   205         OMX_OUT OMX_STATETYPE* pState)
   206 	{
   207 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->GetState(pState);
   208 	}
   209 	
   210 OMX_ERRORTYPE OMXComponentComponentTunnelRequest(
   211     	OMX_IN	OMX_HANDLETYPE hInput,
   212         OMX_IN  OMX_U32 nInputPort,
   213         OMX_IN  OMX_HANDLETYPE hOutput,
   214         OMX_IN  OMX_U32 nOutputPort,
   215         OMX_IN  OMX_TUNNELSETUPTYPE* pTunnelSetup)
   216 	{
   217 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hInput)->pComponentPrivate)->ComponentTunnelRequest(hInput, nInputPort, hOutput, nOutputPort, pTunnelSetup);
   218 	}
   219 	
   220 OMX_ERRORTYPE OMXComponentUseBuffer(
   221         OMX_IN  OMX_HANDLETYPE hComponent,
   222         OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
   223         OMX_IN  OMX_U32 nPortIndex,
   224         OMX_IN	OMX_PTR pAppPrivate,
   225         OMX_IN  OMX_U32 nSizeBytes,
   226         OMX_IN  OMX_U8* pBuffer)
   227 	{
   228 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->UseBuffer(ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
   229 	}
   230 	
   231 OMX_ERRORTYPE OMXComponentAllocateBuffer(
   232         OMX_IN  OMX_HANDLETYPE hComponent,
   233         OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
   234         OMX_IN  OMX_U32 nPortIndex,
   235         OMX_IN  OMX_PTR pAppData,
   236         OMX_IN	OMX_U32 nSizeBytes)
   237 	{
   238 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->AllocateBuffer(pBuffer, nPortIndex, pAppData, nSizeBytes);
   239 	}
   240 
   241 OMX_ERRORTYPE OMXComponentFreeBuffer(
   242         OMX_IN  OMX_HANDLETYPE hComponent,
   243         OMX_IN  OMX_U32 nPortIndex,
   244         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
   245 	{
   246 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->FreeBuffer(nPortIndex, pBuffer);
   247 	}
   248 	
   249 OMX_ERRORTYPE OMXComponentEmptyThisBuffer(
   250         OMX_IN  OMX_HANDLETYPE hComponent,
   251         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
   252 	{
   253 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->EmptyThisBuffer(pBuffer);
   254 	}
   255 	
   256 OMX_ERRORTYPE OMXComponentFillThisBuffer(
   257         OMX_IN  OMX_HANDLETYPE hComponent,
   258         OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
   259 	{
   260 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->FillThisBuffer(pBuffer);
   261 	}
   262 	
   263 OMX_ERRORTYPE OMXComponentSetCallbacks(
   264         OMX_IN  OMX_HANDLETYPE hComponent,
   265         OMX_IN  OMX_CALLBACKTYPE* pCallbacks, 
   266         OMX_IN  OMX_PTR pAppData)
   267 	{
   268 	return ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate)->SetCallbacks(pCallbacks, pAppData);
   269 	}
   270 	
   271 OMX_ERRORTYPE OMXComponentDeInit(OMX_IN  OMX_HANDLETYPE hComponent)
   272 	{
   273 	delete ((COmxComponentImpl*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
   274 	return OMX_ErrorNone;
   275 	}