1 2/* 3 * Copyright (C) Texas Instruments - http://www.ti.com/ 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21/* ============================================================================= 22 * Texas Instruments OMAP (TM) Platform Software 23 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. 24 * 25 * Use of this software is controlled by the terms and conditions found 26 * in the license agreement under which this software has been supplied. 27 * =========================================================================== */ 28/** 29 * @file OMX_G711Encoder.c 30 * 31 * This file implements OpenMAX (TM) 1.0 Specific APIs and its functionality 32 * that is fully compliant with the Khronos OpenMAX (TM) 1.0 Specification 33 * 34 * @path $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\g711_enc\src 35 * 36 * @rev 1.0 37 */ 38/* ---------------------------------------------------------------------------- 39 *! 40 *! Revision History 41 *! =================================== 42 *! 12-Dec-2006: Initial Version 43 *! This is newest file 44 * =========================================================================== */ 45/* ------compilation control switches -------------------------*/ 46/**************************************************************** 47 * INCLUDE FILES 48 ****************************************************************/ 49/* ----- system and platform files ----------------------------*/ 50#ifdef UNDER_CE 51#include <windows.h> 52#include <oaf_osal.h> 53#include <omx_core.h> 54#else 55#include <unistd.h> 56#include <sys/time.h> 57#include <sys/types.h> 58#include <sys/ioctl.h> 59#include <sys/select.h> 60#include <errno.h> 61#include <pthread.h> 62#endif 63 64#include <string.h> 65#include <fcntl.h> 66#include <stdlib.h> 67#include <stdio.h> 68#include <dbapi.h> 69 70 71/*-------program files ----------------------------------------*/ 72#include <OMX_Component.h> 73//#include <encode_common_ti.h> 74 75#include "OMX_G711Enc_Utils.h" 76 77/**************************************************************** 78 * EXTERNAL REFERENCES NOTE : only use if not found in header file 79 ****************************************************************/ 80/*--------data declarations -----------------------------------*/ 81 82/*--------function prototypes ---------------------------------*/ 83 84/**************************************************************** 85 * PUBLIC DECLARATIONS Defined here, used elsewhere 86 ****************************************************************/ 87/*--------data declarations -----------------------------------*/ 88 89/*--------function prototypes ---------------------------------*/ 90 91/**************************************************************** 92 * PRIVATE DECLARATIONS Defined here, used only here 93 ****************************************************************/ 94/*--------data declarations -----------------------------------*/ 95 96/*--------function prototypes ---------------------------------*/ 97 98static OMX_ERRORTYPE SetCallbacks (OMX_HANDLETYPE hComp, 99 OMX_CALLBACKTYPE* pCallBacks, OMX_PTR pAppData); 100static OMX_ERRORTYPE GetComponentVersion (OMX_HANDLETYPE hComp, 101 OMX_STRING pComponentName, 102 OMX_VERSIONTYPE* pComponentVersion, 103 OMX_VERSIONTYPE* pSpecVersion, 104 OMX_UUIDTYPE* pComponentUUID); 105static OMX_ERRORTYPE SendCommand (OMX_HANDLETYPE hComp, OMX_COMMANDTYPE nCommand, 106 OMX_U32 nParam,OMX_PTR pCmdData); 107static OMX_ERRORTYPE GetParameter(OMX_HANDLETYPE hComp, OMX_INDEXTYPE nParamIndex, 108 OMX_PTR ComponentParamStruct); 109static OMX_ERRORTYPE SetParameter (OMX_HANDLETYPE hComp, 110 OMX_INDEXTYPE nParamIndex, 111 OMX_PTR ComponentParamStruct); 112static OMX_ERRORTYPE GetConfig (OMX_HANDLETYPE hComp, 113 OMX_INDEXTYPE nConfigIndex, 114 OMX_PTR pComponentConfigStructure); 115static OMX_ERRORTYPE SetConfig (OMX_HANDLETYPE hComp, 116 OMX_INDEXTYPE nConfigIndex, 117 OMX_PTR pComponentConfigStructure); 118 119static OMX_ERRORTYPE EmptyThisBuffer (OMX_HANDLETYPE hComp, OMX_BUFFERHEADERTYPE* pBuffer); 120 121static OMX_ERRORTYPE FillThisBuffer (OMX_HANDLETYPE hComp, OMX_BUFFERHEADERTYPE* pBuffer); 122static OMX_ERRORTYPE GetState (OMX_HANDLETYPE hComp, OMX_STATETYPE* pState); 123static OMX_ERRORTYPE ComponentTunnelRequest (OMX_HANDLETYPE hComp, 124 OMX_U32 nPort, OMX_HANDLETYPE hTunneledComp, 125 OMX_U32 nTunneledPort, 126 OMX_TUNNELSETUPTYPE* pTunnelSetup); 127static OMX_ERRORTYPE ComponentDeInit(OMX_HANDLETYPE pHandle); 128static OMX_ERRORTYPE AllocateBuffer (OMX_IN OMX_HANDLETYPE hComponent, 129 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer, 130 OMX_IN OMX_U32 nPortIndex, 131 OMX_IN OMX_PTR pAppPrivate, 132 OMX_IN OMX_U32 nSizeBytes); 133 134static OMX_ERRORTYPE FreeBuffer( 135 OMX_IN OMX_HANDLETYPE hComponent, 136 OMX_IN OMX_U32 nPortIndex, 137 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); 138 139static OMX_ERRORTYPE UseBuffer ( 140 OMX_IN OMX_HANDLETYPE hComponent, 141 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 142 OMX_IN OMX_U32 nPortIndex, 143 OMX_IN OMX_PTR pAppPrivate, 144 OMX_IN OMX_U32 nSizeBytes, 145 OMX_IN OMX_U8* pBuffer); 146 147static OMX_ERRORTYPE GetExtensionIndex( 148 OMX_IN OMX_HANDLETYPE hComponent, 149 OMX_IN OMX_STRING cParameterName, 150 OMX_OUT OMX_INDEXTYPE* pIndexType); 151 152 153static OMX_ERRORTYPE ComponentRoleEnum( 154 OMX_IN OMX_HANDLETYPE hComponent, 155 OMX_OUT OMX_U8 *cRole, 156 OMX_IN OMX_U32 nIndex); 157 158 159/* interface with audio manager*/ 160#define FIFO1 "/dev/fifo.1" 161#define FIFO2 "/dev/fifo.2" 162#define PERMS 0666 163 164#define G711_ENC_ROLE "audio_encoder.g711" 165 166/*-------------------------------------------------------------------*/ 167/** 168 * OMX_ComponentInit() Set the all the function pointers of component 169 * 170 * This method will update the component function pointer to the handle 171 * 172 * @param hComp handle for this instance of the component 173 * 174 * @retval OMX_NoError Success, ready to roll 175 * OMX_ErrorInsufficientResources If the malloc fails 176 **/ 177/*-------------------------------------------------------------------*/ 178OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp) 179{ 180 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef_ip=NULL, *pPortDef_op=NULL; 181 G711ENC_COMPONENT_PRIVATE *pComponentPrivate=NULL; 182 OMX_AUDIO_PARAM_PCMMODETYPE *G711_op=NULL; 183 OMX_AUDIO_PARAM_PCMMODETYPE *G711_ip=NULL; 184 OMX_ERRORTYPE eError = OMX_ErrorNone; 185 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*) hComp; 186 G711ENC_PORT_TYPE *pCompPort = NULL; 187 OMX_AUDIO_PARAM_PORTFORMATTYPE *pInPortFormat = NULL; 188 OMX_AUDIO_PARAM_PORTFORMATTYPE *pOutPortFormat = NULL; 189 int i = 0; 190 191 G711ENC_DPRINT("%d :: Entering OMX_ComponentInit\n", __LINE__); 192 /*Set the all component function pointer to the handle */ 193 pHandle->SetCallbacks = SetCallbacks; 194 pHandle->GetComponentVersion = GetComponentVersion; 195 pHandle->SendCommand = SendCommand; 196 pHandle->GetParameter = GetParameter; 197 pHandle->SetParameter = SetParameter; 198 pHandle->GetConfig = GetConfig; 199 pHandle->SetConfig = SetConfig; 200 pHandle->GetState = GetState; 201 pHandle->EmptyThisBuffer = EmptyThisBuffer; 202 pHandle->FillThisBuffer = FillThisBuffer; 203 pHandle->ComponentTunnelRequest = ComponentTunnelRequest; 204 pHandle->ComponentDeInit = ComponentDeInit; 205 pHandle->AllocateBuffer = AllocateBuffer; 206 pHandle->FreeBuffer = FreeBuffer; 207 pHandle->UseBuffer = UseBuffer; 208 pHandle->GetExtensionIndex = GetExtensionIndex; 209 pHandle->ComponentRoleEnum = ComponentRoleEnum; 210 211 /*Allocate the memory for Component private data area */ 212 G711ENC_OMX_MALLOC_STRUCT(pHandle->pComponentPrivate, G711ENC_COMPONENT_PRIVATE); 213 214 ((G711ENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pHandle = pHandle; 215 pComponentPrivate = pHandle->pComponentPrivate; 216 217 G711ENC_OMX_MALLOC_STRUCT(pCompPort, G711ENC_PORT_TYPE); 218 pComponentPrivate->pCompPort[G711ENC_INPUT_PORT] = pCompPort; 219 220 G711ENC_OMX_MALLOC_STRUCT(pCompPort, G711ENC_PORT_TYPE); 221 pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT] = pCompPort; 222 223 G711ENC_OMX_MALLOC_STRUCT(pComponentPrivate->sPortParam, OMX_PORT_PARAM_TYPE); 224 OMX_G711ENC_INIT_STRUCT(pComponentPrivate->sPortParam, OMX_PORT_PARAM_TYPE); 225 226 /* Initialize sPortParam data structures to default values */ 227 pComponentPrivate->sPortParam->nPorts = 0x2; 228 pComponentPrivate->sPortParam->nStartPortNumber = 0x0; 229 230 /* Malloc and Set pPriorityMgmt defaults */ 231 G711ENC_OMX_MALLOC_STRUCT(pComponentPrivate->sPriorityMgmt, OMX_PRIORITYMGMTTYPE); 232 OMX_G711ENC_INIT_STRUCT(pComponentPrivate->sPriorityMgmt, OMX_PRIORITYMGMTTYPE); 233 234 /* Initialize sPriorityMgmt data structures to default values */ 235 pComponentPrivate->sPriorityMgmt->nGroupPriority = -1; 236 pComponentPrivate->sPriorityMgmt->nGroupID = -1; 237 238 G711ENC_OMX_MALLOC_STRUCT(G711_op, OMX_AUDIO_PARAM_PCMMODETYPE); 239 OMX_G711ENC_INIT_STRUCT(G711_op, OMX_AUDIO_PARAM_PCMMODETYPE); 240 pComponentPrivate->G711Params[G711ENC_OUTPUT_PORT] = G711_op; 241 /*Input PCM format defaults */ 242 G711_op->nPortIndex = G711ENC_OUTPUT_PORT; 243 G711_op->nChannels = 1; 244 G711_op->eNumData = OMX_NumericalDataUnsigned; 245 G711_op->eEndian = OMX_EndianLittle; 246 G711_op->bInterleaved = OMX_FALSE; 247 G711_op->nSamplingRate = 0; 248 G711_op->nBitPerSample = 8; 249 G711_op->ePCMMode = OMX_AUDIO_PCMModeLinear; 250 251 G711ENC_OMX_MALLOC_STRUCT(G711_ip, OMX_AUDIO_PARAM_PCMMODETYPE); 252 OMX_G711ENC_INIT_STRUCT(G711_ip, OMX_AUDIO_PARAM_PCMMODETYPE); 253 pComponentPrivate->G711Params[G711ENC_INPUT_PORT] = G711_ip; 254 /* Output PCM format defaults */ 255 G711_ip->nPortIndex = G711ENC_INPUT_PORT; 256 G711_ip->nChannels = 1; 257 G711_ip->eNumData = OMX_NumericalDataUnsigned; 258 G711_ip->eEndian = OMX_EndianLittle; 259 G711_ip->bInterleaved = OMX_FALSE; 260 G711_ip->nSamplingRate = 8000; 261 G711_ip->nBitPerSample = 16; 262 G711_ip->ePCMMode = OMX_AUDIO_PCMModeLinear; 263 264 /* Initialize number of input buffers */ 265 G711ENC_OMX_MALLOC_STRUCT(pComponentPrivate->pInputBufferList, G711ENC_BUFFERLIST); 266 pComponentPrivate->pInputBufferList->numBuffers = 0; 267 268 /* Initialize number of output buffers */ 269 G711ENC_OMX_MALLOC_STRUCT(pComponentPrivate->pOutputBufferList, G711ENC_BUFFERLIST); 270 pComponentPrivate->pOutputBufferList->numBuffers = 0; 271 272 for (i=0; i < G711ENC_MAX_NUM_OF_BUFS; i++) { 273 pComponentPrivate->pOutputBufferList->pBufHdr[i] = NULL; 274 pComponentPrivate->pInputBufferList->pBufHdr[i] = NULL; 275 } 276 277 /* Set input port defaults */ 278 G711ENC_OMX_MALLOC_STRUCT(pPortDef_ip, OMX_PARAM_PORTDEFINITIONTYPE); 279 OMX_G711ENC_INIT_STRUCT(pPortDef_ip, OMX_PARAM_PORTDEFINITIONTYPE); 280 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT] = pPortDef_ip; 281 282 pPortDef_ip->nPortIndex = G711ENC_INPUT_PORT; 283 pPortDef_ip->eDir = OMX_DirInput; 284 pPortDef_ip->nBufferCountActual = G711ENC_NUM_INPUT_BUFFERS; 285 pPortDef_ip->nBufferCountMin = G711ENC_NUM_INPUT_BUFFERS; 286 pPortDef_ip->nBufferSize = G711ENC_INPUT_BUFFER_SIZE_DASF; 287 pPortDef_ip->bEnabled = OMX_TRUE; 288 pPortDef_ip->bPopulated = OMX_FALSE; 289 pPortDef_ip->eDomain = OMX_PortDomainAudio; 290 pPortDef_ip->format.audio.eEncoding = OMX_AUDIO_CodingPCM; 291 pPortDef_ip->format.audio.pNativeRender = NULL; 292 pPortDef_ip->format.audio.bFlagErrorConcealment = OMX_FALSE; 293 294 /* Set output port defaults */ 295 G711ENC_OMX_MALLOC_STRUCT(pPortDef_op, OMX_PARAM_PORTDEFINITIONTYPE); 296 OMX_G711ENC_INIT_STRUCT(pPortDef_op, OMX_PARAM_PORTDEFINITIONTYPE); 297 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT] = pPortDef_op; 298 299 pPortDef_op->nPortIndex = G711ENC_OUTPUT_PORT; 300 pPortDef_op->eDir = OMX_DirOutput; 301 pPortDef_op->nBufferCountMin = G711ENC_NUM_OUTPUT_BUFFERS; 302 pPortDef_op->nBufferCountActual = G711ENC_NUM_OUTPUT_BUFFERS; 303 pPortDef_op->nBufferSize = G711ENC_OUTPUT_BUFFER_SIZE; 304 pPortDef_op->bEnabled = OMX_TRUE; 305 pPortDef_op->bPopulated = OMX_FALSE; 306 pPortDef_op->eDomain = OMX_PortDomainAudio; 307 pPortDef_op->format.audio.eEncoding = OMX_AUDIO_CodingG711; 308 pPortDef_op->format.audio.pNativeRender = NULL; 309 pPortDef_op->format.audio.bFlagErrorConcealment = OMX_FALSE; 310 311 /* Set input port format defaults */ 312 G711ENC_OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE); 313 OMX_G711ENC_INIT_STRUCT(pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE); 314 315 pInPortFormat = pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat; 316 OMX_G711ENC_INIT_STRUCT(pInPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE); 317 318 pInPortFormat->nPortIndex = G711ENC_INPUT_PORT; 319 pInPortFormat->nIndex = OMX_IndexParamAudioPcm; 320 pInPortFormat->eEncoding = OMX_AUDIO_CodingPCM; 321 322 /* Set output port format defaults */ 323 G711ENC_OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE); 324 OMX_G711ENC_INIT_STRUCT(pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE); 325 326 pOutPortFormat = pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat; 327 OMX_G711ENC_INIT_STRUCT(pOutPortFormat, OMX_AUDIO_PARAM_PORTFORMATTYPE); 328 329 pOutPortFormat->nPortIndex = G711ENC_OUTPUT_PORT; 330 pOutPortFormat->nIndex = OMX_IndexParamAudioPcm; 331 pOutPortFormat->eEncoding = OMX_AUDIO_CodingG711; 332 333 G711ENC_DPRINT("%d :: Setting dasf & acdn and MultiFrame modes to 0\n",__LINE__); 334 pComponentPrivate->dasfMode = 0; 335 pComponentPrivate->acdnMode = 0; 336 pComponentPrivate->bPortDefsAllocated = 0; 337 pComponentPrivate->bCompThreadStarted = 0; 338 pComponentPrivate->pParams = NULL; 339 pComponentPrivate->pAlgParam = NULL; 340 pComponentPrivate->bInitParamsInitialized = 0; 341 pComponentPrivate->pMarkBuf = NULL; 342 pComponentPrivate->pMarkData = NULL; 343 pComponentPrivate->nEmptyBufferDoneCount = 0; 344 pComponentPrivate->nEmptyThisBufferCount = 0; 345 pComponentPrivate->nFillBufferDoneCount = 0; 346 pComponentPrivate->nFillThisBufferCount = 0; 347 pComponentPrivate->strmAttr = NULL; 348 pComponentPrivate->bIdleCommandPending = 0; 349 pComponentPrivate->bDisableCommandParam = 0; 350 pComponentPrivate->bIsEOFSent = 0; 351 pComponentPrivate->bBypassDSP = 0; 352 pComponentPrivate->bEnableCommandParam = 0; 353 pComponentPrivate->nRuntimeInputBuffers = 0; 354 pComponentPrivate->nRuntimeOutputBuffers = 0; 355 pComponentPrivate->nUnhandledEmptyThisBuffers = 0; 356 pComponentPrivate->nUnhandledFillThisBuffers = 0; 357 358 for (i=0; i < G711ENC_MAX_NUM_OF_BUFS; i++) { 359 pComponentPrivate->pInputBufHdrPending[i] = NULL; 360 pComponentPrivate->pOutputBufHdrPending[i] = NULL; 361 } 362 pComponentPrivate->nInvalidFrameCount = 0; 363 pComponentPrivate->nNumInputBufPending = 0; 364 pComponentPrivate->nNumOutputBufPending = 0; 365 pComponentPrivate->bDisableCommandPending = 0; 366 pComponentPrivate->bEnableCommandPending = 0; 367 pComponentPrivate->bNoIdleOnStop= OMX_FALSE; 368 pComponentPrivate->bIdleCommandPending = OMX_FALSE; 369 pComponentPrivate->nOutStandingFillDones = 0; 370 pComponentPrivate->bDspStoppedWhileExecuting = OMX_FALSE; 371 pComponentPrivate->bPreempted = OMX_FALSE; 372 373 /* Default create phase parameters */ 374 /*pComponentPrivate->frametype = 0; 375 pComponentPrivate->vaumode = 2; 376 pComponentPrivate->vauthreshold = 0; 377 pComponentPrivate->vaunumber = 0; 378 pComponentPrivate->nmunoise = 2; 379 pComponentPrivate->lporder = 5;*/ 380 381 /* initialize role name */ 382 strcpy((char*)pComponentPrivate->componentRole.cRole,G711_ENC_ROLE); 383 384 G711ENC_OMX_MALLOC_SIZE(pComponentPrivate->sDeviceString, 385 100*sizeof(OMX_STRING), 386 OMX_STRING); 387 /* Initialize device string to the default value */ 388 strcpy((char*)pComponentPrivate->sDeviceString,"/eteedn:i0:o0/codec\0"); 389 390 /* Initialize LMCL back up pointer*/ 391 pComponentPrivate->ptrLibLCML = NULL; 392 393#ifndef UNDER_CE 394 pthread_mutex_init(&pComponentPrivate->AlloBuf_mutex, NULL); 395 pthread_cond_init (&pComponentPrivate->AlloBuf_threshold, NULL); 396 pComponentPrivate->AlloBuf_waitingsignal = 0; 397 398 pthread_mutex_init(&pComponentPrivate->InIdle_mutex, NULL); 399 pthread_cond_init (&pComponentPrivate->InIdle_threshold, NULL); 400 pComponentPrivate->InIdle_goingtoloaded = 0; 401 402 pthread_mutex_init(&pComponentPrivate->InLoaded_mutex, NULL); 403 pthread_cond_init (&pComponentPrivate->InLoaded_threshold, NULL); 404 pComponentPrivate->InLoaded_readytoidle = 0; 405#endif 406 407 408#ifdef RESOURCE_MANAGER_ENABLED 409 eError = RMProxy_NewInitalize(); 410 G711ENC_DPRINT("%d :: OMX_ComponentInit\n", __LINE__); 411 if (eError != OMX_ErrorNone) { 412 G711ENC_DPRINT("%d :: Error returned from loading ResourceManagerProxy thread\n",__LINE__); 413 goto EXIT; 414 } 415#endif 416 417 eError = G711ENC_StartComponentThread(pHandle); 418 G711ENC_DPRINT("%d :: OMX_ComponentInit\n", __LINE__); 419 if (eError != OMX_ErrorNone) { 420 G711ENC_PRINT("%d :: Error returned from the Component\n",__LINE__); 421 goto EXIT; 422 } 423 424#ifdef DSP_RENDERING_ON 425 G711ENC_DPRINT("%d :: OMX_ComponentInit\n", __LINE__); 426 if((pComponentPrivate->fdwrite=open(FIFO1,O_WRONLY))<0) { 427 G711ENC_DPRINT("%d :: [G711E Component] - failure to open WRITE pipe\n",__LINE__); 428 } 429 G711ENC_DPRINT("%d :: OMX_ComponentInit\n", __LINE__); 430 if((pComponentPrivate->fdread=open(FIFO2,O_RDONLY))<0) { 431 G711ENC_DPRINT("%d :: [G711E Component] - failure to open READ pipe\n",__LINE__); 432 } 433 G711ENC_DPRINT("%d :: OMX_ComponentInit\n", __LINE__); 434#endif 435 436 EXIT: 437 G711ENC_DPRINT("%d :: Exiting OMX_ComponentInit\n", __LINE__); 438 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 439 return eError; 440} 441 442/*-------------------------------------------------------------------*/ 443/** 444 * SetCallbacks() Sets application callbacks to the component 445 * 446 * This method will update application callbacks 447 * to the component. So that component can make use of those call back 448 * while sending buffers to the application. And also it will copy the 449 * application private data to component memory 450 * 451 * @param pComponent handle for this instance of the component 452 * @param pCallBacks application callbacks 453 * @param pAppData Application private data 454 * 455 * @retval OMX_NoError Success, ready to roll 456 * OMX_Error_BadParameter The input parameter pointer is null 457 **/ 458/*-------------------------------------------------------------------*/ 459 460static OMX_ERRORTYPE SetCallbacks (OMX_HANDLETYPE pComponent, 461 OMX_CALLBACKTYPE* pCallBacks, 462 OMX_PTR pAppData) 463{ 464 OMX_ERRORTYPE eError = OMX_ErrorNone; 465 466 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*)pComponent; 467 468 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = 469 (G711ENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 470 G711ENC_DPRINT("%d :: Entering SetCallbacks\n", __LINE__); 471 if (pCallBacks == NULL) { 472 eError = OMX_ErrorBadParameter; 473 G711ENC_DPRINT("%d :: Received the empty callbacks from the application\n",__LINE__); 474 goto EXIT; 475 } 476 477 /*Copy the callbacks of the application to the component private*/ 478 memcpy (&(pComponentPrivate->cbInfo), pCallBacks, sizeof(OMX_CALLBACKTYPE)); 479 480 /*copy the application private data to component memory */ 481 pHandle->pApplicationPrivate = pAppData; 482 483 pComponentPrivate->curState = OMX_StateLoaded; 484 485 EXIT: 486 G711ENC_DPRINT("%d :: Exiting SetCallbacks\n", __LINE__); 487 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 488 return eError; 489} 490 491/*-------------------------------------------------------------------*/ 492/** 493 * GetComponentVersion() This will return the component version 494 * 495 * This method will retrun the component version 496 * 497 * @param hComp handle for this instance of the component 498 * @param pCompnentName Name of the component 499 * @param pCompnentVersion handle for this instance of the component 500 * @param pSpecVersion application callbacks 501 * @param pCompnentUUID 502 * 503 * @retval OMX_NoError Success, ready to roll 504 * OMX_Error_BadParameter The input parameter pointer is null 505 **/ 506/*-------------------------------------------------------------------*/ 507 508static OMX_ERRORTYPE GetComponentVersion (OMX_HANDLETYPE hComp, 509 OMX_STRING pComponentName, 510 OMX_VERSIONTYPE* pComponentVersion, 511 OMX_VERSIONTYPE* pSpecVersion, 512 OMX_UUIDTYPE* pComponentUUID) 513{ 514 OMX_ERRORTYPE eError = OMX_ErrorNone; 515 516 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*) hComp; 517 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; 518 G711ENC_DPRINT("%d :: Entering GetComponentVersion\n", __LINE__); 519 /* Copy component version structure */ 520 if(pComponentVersion != NULL && pComponentName != NULL) { 521 strcpy(pComponentName, pComponentPrivate->cComponentName); 522 memcpy(pComponentVersion, &(pComponentPrivate->ComponentVersion.s), sizeof(pComponentPrivate->ComponentVersion.s)); 523 } 524 else { 525 G711ENC_DPRINT("%d :: OMX_ErrorBadParameter from GetComponentVersion",__LINE__); 526 eError = OMX_ErrorBadParameter; 527 } 528 529 G711ENC_DPRINT("%d :: Exiting GetComponentVersion\n", __LINE__); 530 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 531 return eError; 532} 533/*-------------------------------------------------------------------*/ 534/** 535 * SendCommand() used to send the commands to the component 536 * 537 * This method will be used by the application. 538 * 539 * @param phandle handle for this instance of the component 540 * @param Cmd Command to be sent to the component 541 * @param nParam indicates commmad is sent using this method 542 * 543 * @retval OMX_NoError Success, ready to roll 544 * OMX_Error_BadParameter The input parameter pointer is null 545 **/ 546/*-------------------------------------------------------------------*/ 547 548static OMX_ERRORTYPE SendCommand (OMX_HANDLETYPE phandle, 549 OMX_COMMANDTYPE Cmd, 550 OMX_U32 nParam, 551 OMX_PTR pCmdData) 552{ 553 OMX_ERRORTYPE eError = OMX_ErrorNone; 554 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)phandle; 555 G711ENC_COMPONENT_PRIVATE *pCompPrivate = 556 (G711ENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 557 int nRet = 0; 558 G711ENC_DPRINT("%d :: Entering SendCommand()\n", __LINE__); 559 if(pCompPrivate->curState == OMX_StateInvalid) { 560 eError = OMX_ErrorInvalidState; 561 G711ENC_DPRINT("%d :: Error OMX_ErrorInvalidState Sent to App\n",__LINE__); 562 goto EXIT; 563 } 564 565 switch(Cmd) { 566 case OMX_CommandStateSet: 567 G711ENC_DPRINT("%d :: OMX_CommandStateSet SendCommand\n",__LINE__); 568 G711ENC_DPRINT("%d :: OMX_CommandStateSet nparam: %d \n",__LINE__,(int)nParam); 569 570 if (nParam == OMX_StateLoaded) { 571 pCompPrivate->bLoadedCommandPending = OMX_TRUE; 572 } 573 if(pCompPrivate->curState == OMX_StateLoaded) { 574 if((nParam == OMX_StateExecuting) || (nParam == OMX_StatePause)) { 575 pCompPrivate->cbInfo.EventHandler ( pHandle, 576 pHandle->pApplicationPrivate, 577 OMX_EventError, 578 OMX_ErrorIncorrectStateTransition, 579 0, 580 NULL); 581 goto EXIT; 582 } 583 584 if(nParam == OMX_StateInvalid) { 585 G711ENC_DPRINT("%d :: OMX_CommandStateSet SendCommand\n",__LINE__); 586 pCompPrivate->curState = OMX_StateInvalid; 587 pCompPrivate->cbInfo.EventHandler ( pHandle, 588 pHandle->pApplicationPrivate, 589 OMX_EventError, 590 OMX_ErrorInvalidState, 591 0, 592 NULL); 593 goto EXIT; 594 } 595 } 596 break; 597 case OMX_CommandFlush: 598 G711ENC_DPRINT("%d :: OMX_CommandFlush SendCommand\n",__LINE__); 599 if(nParam > 1 && nParam != -1) { 600 eError = OMX_ErrorBadPortIndex; 601 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from SendCommand",__LINE__); 602 goto EXIT; 603 } 604 break; 605 case OMX_CommandPortDisable: 606 G711ENC_DPRINT("%d :: OMX_CommandPortDisable SendCommand\n",__LINE__); 607 break; 608 case OMX_CommandPortEnable: 609 G711ENC_DPRINT("%d :: OMX_CommandPortEnable SendCommand\n",__LINE__); 610 break; 611 case OMX_CommandMarkBuffer: 612 G711ENC_DPRINT("%d :: OMX_CommandMarkBuffer SendCommand\n",__LINE__); 613 if (nParam > 0) { 614 eError = OMX_ErrorBadPortIndex; 615 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from SendCommand",__LINE__); 616 goto EXIT; 617 } 618 break; 619 default: 620 G711ENC_DPRINT("%d :: Command Received Default eError\n",__LINE__); 621 pCompPrivate->cbInfo.EventHandler ( pHandle, 622 pHandle->pApplicationPrivate, 623 OMX_EventError, 624 OMX_ErrorUndefined, 625 0, 626 "Invalid Command"); 627 break; 628 629 } 630 631 nRet = write (pCompPrivate->cmdPipe[1], &Cmd, sizeof(Cmd)); 632 if (nRet == -1) { 633 eError = OMX_ErrorInsufficientResources; 634 G711ENC_PRINT("%d :: OMX_ErrorInsufficientResources from SendCommand",__LINE__); 635 goto EXIT; 636 } 637 638 if (Cmd == OMX_CommandMarkBuffer) { 639 nRet = write(pCompPrivate->cmdDataPipe[1], &pCmdData,sizeof(OMX_PTR)); 640 } else { 641 nRet = write(pCompPrivate->cmdDataPipe[1], &nParam,sizeof(OMX_U32)); 642 } 643 if (nRet == -1) { 644 G711ENC_DPRINT("%d :: OMX_ErrorInsufficientResources from SendCommand",__LINE__); 645 eError = OMX_ErrorInsufficientResources; 646 goto EXIT; 647 } 648 649 EXIT: 650 G711ENC_DPRINT("%d :: Exiting SendCommand()\n", __LINE__); 651 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 652 return eError; 653} 654/*-------------------------------------------------------------------*/ 655/** 656 * GetParameter() Gets the current configurations of the component 657 * 658 * @param hComp handle for this instance of the component 659 * @param nParamIndex 660 * @param ComponentParameterStructure 661 * 662 * @retval OMX_NoError Success, ready to roll 663 * OMX_Error_BadParameter The input parameter pointer is null 664 **/ 665/*-------------------------------------------------------------------*/ 666 667static OMX_ERRORTYPE GetParameter (OMX_HANDLETYPE hComp, 668 OMX_INDEXTYPE nParamIndex, 669 OMX_PTR ComponentParameterStructure) 670{ 671 OMX_ERRORTYPE eError = OMX_ErrorNone; 672 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = NULL; 673 OMX_PARAM_PORTDEFINITIONTYPE *pParameterStructure = NULL; 674 675 pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *)(((OMX_COMPONENTTYPE*)hComp)->pComponentPrivate); 676 pParameterStructure = (OMX_PARAM_PORTDEFINITIONTYPE*)ComponentParameterStructure; 677 678 G711ENC_DPRINT("%d :: Entering the GetParameter\n",__LINE__); 679 if (pParameterStructure == NULL) { 680 eError = OMX_ErrorBadParameter; 681 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from GetParameter",__LINE__); 682 goto EXIT; 683 } 684 685 if(pComponentPrivate->curState == OMX_StateInvalid) { 686 eError = OMX_ErrorIncorrectStateOperation; 687 G711ENC_DPRINT("%d :: OMX_ErrorIncorrectStateOperation from GetParameter",__LINE__); 688 goto EXIT; 689 } 690 691 switch(nParamIndex){ 692 case OMX_IndexParamAudioInit: 693 if (pComponentPrivate->sPortParam == NULL) { 694 eError = OMX_ErrorBadParameter; 695 break; 696 } 697 G711ENC_DPRINT("%d :: GetParameter OMX_IndexParamAudioInit \n",__LINE__); 698 memcpy(ComponentParameterStructure, pComponentPrivate->sPortParam, sizeof(OMX_PORT_PARAM_TYPE)); 699 break; 700 701 case OMX_IndexParamPortDefinition: 702 G711ENC_DPRINT("%d :: GetParameter OMX_IndexParamPortDefinition \n",__LINE__); 703 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex == 704 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nPortIndex) { 705 memcpy(ComponentParameterStructure, pComponentPrivate->pPortDef[G711ENC_INPUT_PORT], sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 706 } 707 else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex == 708 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->nPortIndex) { 709 memcpy(ComponentParameterStructure, pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT], sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 710 } 711 else { 712 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from GetParameter \n",__LINE__); 713 eError = OMX_ErrorBadPortIndex; 714 } 715 break; 716 717 case OMX_IndexParamAudioPortFormat: 718 G711ENC_DPRINT("%d :: GetParameter OMX_IndexParamAudioPortFormat \n",__LINE__); 719 if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex == 720 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nPortIndex) { 721 if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nIndex > 722 pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat->nPortIndex) { 723 eError = OMX_ErrorNoMore; 724 } 725 else { 726 memcpy(ComponentParameterStructure, pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 727 } 728 } 729 else if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex == 730 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->nPortIndex){ 731 if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nIndex > 732 pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat->nPortIndex) { 733 eError = OMX_ErrorNoMore; 734 } 735 else { 736 memcpy(ComponentParameterStructure, pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 737 } 738 } 739 else { 740 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from GetParameter \n",__LINE__); 741 eError = OMX_ErrorBadPortIndex; 742 } 743 break; 744 745 case OMX_IndexParamAudioPcm: 746 G711ENC_DPRINT("%d :: GetParameter OMX_IndexParamAudioG711 \n",__LINE__); 747 if(((OMX_AUDIO_PARAM_PCMMODETYPE *)(ComponentParameterStructure))->nPortIndex == 748 pComponentPrivate->G711Params[G711ENC_OUTPUT_PORT]->nPortIndex) { 749 memcpy(ComponentParameterStructure, pComponentPrivate->G711Params[G711ENC_OUTPUT_PORT], sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 750 } 751 else if(((OMX_AUDIO_PARAM_PCMMODETYPE *)(ComponentParameterStructure))->nPortIndex == 752 pComponentPrivate->G711Params[G711ENC_INPUT_PORT]->nPortIndex) { 753 memcpy(ComponentParameterStructure, pComponentPrivate->G711Params[G711ENC_INPUT_PORT], sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 754 } 755 else { 756 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from GetParameter \n",__LINE__); 757 eError = OMX_ErrorBadPortIndex; 758 } 759 break; 760 761 case OMX_IndexParamCompBufferSupplier: 762 if(((OMX_PARAM_BUFFERSUPPLIERTYPE *)(ComponentParameterStructure))->nPortIndex == OMX_DirInput) { 763 G711ENC_DPRINT(":: GetParameter OMX_IndexParamCompBufferSupplier \n"); 764 /* memcpy(ComponentParameterStructure, pBufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); */ 765 } 766 else 767 if(((OMX_PARAM_BUFFERSUPPLIERTYPE *)(ComponentParameterStructure))->nPortIndex == OMX_DirOutput) { 768 G711ENC_DPRINT(":: GetParameter OMX_IndexParamCompBufferSupplier \n"); 769 /*memcpy(ComponentParameterStructure, pBufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); */ 770 } 771 else { 772 G711ENC_DPRINT(":: OMX_ErrorBadPortIndex from GetParameter"); 773 eError = OMX_ErrorBadPortIndex; 774 } 775 break; 776 777 case OMX_IndexParamPriorityMgmt: 778 G711ENC_DPRINT("%d :: GetParameter OMX_IndexParamPriorityMgmt \n",__LINE__); 779 if (pComponentPrivate->sPriorityMgmt == NULL) { 780 eError = OMX_ErrorBadParameter; 781 break; 782 } 783 memcpy(ComponentParameterStructure, pComponentPrivate->sPriorityMgmt, sizeof(OMX_PRIORITYMGMTTYPE)); 784 break; 785 786 case OMX_IndexParamVideoInit: 787 break; 788 789 case OMX_IndexParamImageInit: 790 break; 791 792 case OMX_IndexParamOtherInit: 793 break; 794 795 default: 796 G711ENC_DPRINT("%d :: OMX_ErrorUnsupportedIndex GetParameter \n",__LINE__); 797 eError = OMX_ErrorUnsupportedIndex; 798 break; 799 } 800 EXIT: 801 G711ENC_DPRINT("%d :: Exiting GetParameter\n",__LINE__); 802 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 803 return eError; 804} 805/*-------------------------------------------------------------------*/ 806/** 807 * SetParameter() Sets configuration paramets to the component 808 * 809 * @param hComp handle for this instance of the component 810 * @param nParamIndex 811 * @param pCompParam 812 * 813 * @retval OMX_NoError Success, ready to roll 814 * OMX_Error_BadParameter The input parameter pointer is null 815 **/ 816/*-------------------------------------------------------------------*/ 817 818static OMX_ERRORTYPE SetParameter (OMX_HANDLETYPE hComp, 819 OMX_INDEXTYPE nParamIndex, 820 OMX_PTR pCompParam) 821{ 822 OMX_ERRORTYPE eError = OMX_ErrorNone; 823 OMX_COMPONENTTYPE* pHandle= (OMX_COMPONENTTYPE*)hComp; 824 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = NULL; 825 OMX_AUDIO_PARAM_PORTFORMATTYPE* pComponentParam = NULL; 826 OMX_PARAM_PORTDEFINITIONTYPE *pComponentParamPort = NULL; 827 OMX_AUDIO_PARAM_PCMMODETYPE *pCompG711Param = NULL; 828 OMX_PARAM_COMPONENTROLETYPE *pRole = NULL; 829 OMX_PARAM_BUFFERSUPPLIERTYPE sBufferSupplier; 830 831 pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *)(((OMX_COMPONENTTYPE*)hComp)->pComponentPrivate); 832 833 834 G711ENC_DPRINT("%d :: Entering the SetParameter\n",__LINE__); 835 if (pCompParam == NULL) { 836 eError = OMX_ErrorBadParameter; 837 G711ENC_DPRINT("%d :: OMX_ErrorBadParameter from SetParameter",__LINE__); 838 goto EXIT; 839 } 840 if (pComponentPrivate->curState != OMX_StateLoaded) { 841 eError = OMX_ErrorIncorrectStateOperation; 842 G711ENC_DPRINT("%d :: OMX_ErrorIncorrectStateOperation from SetParameter",__LINE__); 843 goto EXIT; 844 } 845 846 switch(nParamIndex) { 847 case OMX_IndexParamAudioPortFormat: 848 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamAudioPortFormat \n",__LINE__); 849 pComponentParam = (OMX_AUDIO_PARAM_PORTFORMATTYPE *)pCompParam; 850 if ( pComponentParam->nPortIndex == pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat->nPortIndex ) { 851 memcpy(pComponentPrivate->pCompPort[G711ENC_INPUT_PORT]->pPortFormat, pComponentParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 852 } else if ( pComponentParam->nPortIndex == pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat->nPortIndex ) { 853 memcpy(pComponentPrivate->pCompPort[G711ENC_OUTPUT_PORT]->pPortFormat, pComponentParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 854 } else { 855 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from SetParameter",__LINE__); 856 eError = OMX_ErrorBadPortIndex; 857 } 858 break; 859 case OMX_IndexParamAudioPcm: 860 861 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamAudioG711 \n",__LINE__); 862 pCompG711Param = (OMX_AUDIO_PARAM_PCMMODETYPE *)pCompParam; 863 if (pCompG711Param->nPortIndex == OMX_DirOutput) { 864 if (((G711ENC_COMPONENT_PRIVATE *) 865 pHandle->pComponentPrivate)->G711Params[G711ENC_OUTPUT_PORT] == NULL) { 866 eError = OMX_ErrorBadParameter; 867 break; 868 } 869 memcpy(((G711ENC_COMPONENT_PRIVATE *) 870 pHandle->pComponentPrivate)->G711Params[G711ENC_OUTPUT_PORT], pCompG711Param, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 871 } 872 else if (pCompG711Param->nPortIndex == OMX_DirInput) { 873 if (((G711ENC_COMPONENT_PRIVATE *) 874 pHandle->pComponentPrivate)->G711Params[G711ENC_INPUT_PORT] == NULL) { 875 eError = OMX_ErrorBadParameter; 876 break; 877 } 878 memcpy(((G711ENC_COMPONENT_PRIVATE *) 879 pHandle->pComponentPrivate)->G711Params[G711ENC_INPUT_PORT], pCompG711Param, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 880 } 881 else { 882 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from SetParameter",__LINE__); 883 eError = OMX_ErrorBadPortIndex; 884 } 885 break; 886 case OMX_IndexParamPortDefinition: 887 pComponentParamPort = (OMX_PARAM_PORTDEFINITIONTYPE *)pCompParam; 888 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamPortDefinition \n",__LINE__); 889 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex == 890 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nPortIndex) { 891 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamPortDefinition \n",__LINE__); 892 memcpy(pComponentPrivate->pPortDef[G711ENC_INPUT_PORT], pCompParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 893 G711ENC_DPRINT("Input Count actual %d \n",(int)pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nBufferCountActual); 894 } 895 else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex == 896 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->nPortIndex) { 897 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamPortDefinition \n",__LINE__); 898 memcpy(pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT], pCompParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 899 G711ENC_DPRINT("Output Count actual %d \n",(int)pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nBufferCountActual); 900 } 901 else { 902 G711ENC_DPRINT("%d :: OMX_ErrorBadPortIndex from SetParameter",__LINE__); 903 eError = OMX_ErrorBadPortIndex; 904 } 905 break; 906 case OMX_IndexParamPriorityMgmt: 907 if (pComponentPrivate->sPriorityMgmt == NULL) { 908 eError = OMX_ErrorBadParameter; 909 break; 910 } 911 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamPriorityMgmt \n",__LINE__); 912 memcpy(pComponentPrivate->sPriorityMgmt, (OMX_PRIORITYMGMTTYPE*)pCompParam, sizeof(OMX_PRIORITYMGMTTYPE)); 913 break; 914 915 case OMX_IndexParamAudioInit: 916 if (pComponentPrivate->sPortParam == NULL) { 917 eError = OMX_ErrorBadParameter; 918 break; 919 } 920 G711ENC_DPRINT("%d :: SetParameter OMX_IndexParamAudioInit \n",__LINE__); 921 memcpy(pComponentPrivate->sPortParam, (OMX_PORT_PARAM_TYPE*)pCompParam, sizeof(OMX_PORT_PARAM_TYPE)); 922 break; 923 924 case OMX_IndexParamStandardComponentRole: 925 if (pCompParam) { 926 pRole = (OMX_PARAM_COMPONENTROLETYPE *)pCompParam; 927 memcpy(&(pComponentPrivate->componentRole), (void *)pRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); 928 } else { 929 eError = OMX_ErrorBadParameter; 930 } 931 break; 932 933 case OMX_IndexParamCompBufferSupplier: 934 /* eError = OMX_ErrorBadPortIndex; *//*remove for StdAudioDecoderTest, leave for other tests*/ 935 if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex == 936 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nPortIndex) { 937 G711ENC_DPRINT(":: SetParameter OMX_IndexParamCompBufferSupplier \n"); 938 sBufferSupplier.eBufferSupplier = OMX_BufferSupplyInput; 939 memcpy(&sBufferSupplier, pCompParam, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 940 941 } 942 else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(pCompParam))->nPortIndex == 943 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->nPortIndex) { 944 G711ENC_DPRINT(":: SetParameter OMX_IndexParamCompBufferSupplier \n"); 945 sBufferSupplier.eBufferSupplier = OMX_BufferSupplyOutput; 946 memcpy(&sBufferSupplier, pCompParam, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 947 } 948 else { 949 G711ENC_DPRINT(":: OMX_ErrorBadPortIndex from SetParameter"); 950 eError = OMX_ErrorBadPortIndex; 951 } 952 break; 953 954 default: 955 G711ENC_DPRINT("%d :: SetParameter OMX_ErrorUnsupportedIndex \n",__LINE__); 956 eError = OMX_ErrorUnsupportedIndex; 957 break; 958 959 } 960 EXIT: 961 G711ENC_DPRINT("%d :: Exiting SetParameter\n",__LINE__); 962 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 963 return eError; 964} 965 966/*-------------------------------------------------------------------*/ 967/** 968 * GetConfig() Gets the current configuration of to the component 969 * 970 * @param hComp handle for this instance of the component 971 * @param nConfigIndex 972 * @param ComponentConfigStructure 973 * 974 * @retval OMX_NoError Success, ready to roll 975 * OMX_Error_BadParameter The input parameter pointer is null 976 **/ 977/*-------------------------------------------------------------------*/ 978 979static OMX_ERRORTYPE GetConfig (OMX_HANDLETYPE hComp, 980 OMX_INDEXTYPE nConfigIndex, 981 OMX_PTR ComponentConfigStructure) 982{ 983 OMX_ERRORTYPE eError = OMX_ErrorNone; 984 G711ENC_DPRINT("%d :: Entering GetConfig\n", __LINE__); 985 G711ENC_DPRINT("%d :: Exiting GetConfig\n", __LINE__); 986 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 987 return eError; 988} 989/*-------------------------------------------------------------------*/ 990/** 991 * SetConfig() Sets the configraiton to the component 992 * 993 * @param hComp handle for this instance of the component 994 * @param nConfigIndex 995 * @param ComponentConfigStructure 996 * 997 * @retval OMX_NoError Success, ready to roll 998 * OMX_Error_BadParameter The input parameter pointer is null 999 **/ 1000/*-------------------------------------------------------------------*/ 1001 1002static OMX_ERRORTYPE SetConfig (OMX_HANDLETYPE hComp, 1003 OMX_INDEXTYPE nConfigIndex, 1004 OMX_PTR ComponentConfigStructure) 1005{ 1006 OMX_ERRORTYPE eError = OMX_ErrorNone; 1007 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = NULL; 1008 OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*)hComp; 1009 TI_OMX_DSP_DEFINITION *pTiDspDefinition = NULL; 1010 G711ENC_FTYPES *confFrameParams = NULL; 1011 TI_OMX_DATAPATH dataPath; 1012 OMX_S16 *customFlag = NULL; 1013 1014 G711ENC_DPRINT("%d :: Entering SetConfig\n", __LINE__); 1015 if (pHandle == NULL) { 1016 G711ENC_DPRINT ("%d :: Invalid HANDLE OMX_ErrorBadParameter \n",__LINE__); 1017 eError = OMX_ErrorBadParameter; 1018 goto EXIT; 1019 } 1020 1021 pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 1022 G711ENC_DPRINT("Index: %x \n",nConfigIndex); 1023 switch (nConfigIndex) { 1024 1025 case OMX_IndexCustomG711ENCModeConfig: 1026 pTiDspDefinition = (TI_OMX_DSP_DEFINITION*)ComponentConfigStructure; 1027 memcpy(&(pComponentPrivate->tiOmxDspDefinition),pTiDspDefinition,sizeof(TI_OMX_DSP_DEFINITION)); 1028 pComponentPrivate->dasfMode = pComponentPrivate->tiOmxDspDefinition.dasfMode; 1029 pComponentPrivate->acdnMode = pComponentPrivate->tiOmxDspDefinition.acousticMode; 1030 pComponentPrivate->streamID= pTiDspDefinition->streamId; 1031 1032 G711ENC_DPRINT("%d :: dasfMode : %d \n",__LINE__,(int)pComponentPrivate->dasfMode); 1033 G711ENC_DPRINT("%d :: acdnMode : %d \n",__LINE__,(int)pComponentPrivate->acdnMode); 1034 G711ENC_DPRINT("%d :: streamID : %d \n",__LINE__,(int)pComponentPrivate->streamID); 1035 1036 break; 1037 case OMX_IndexCustomG711EncFrameParams: 1038 1039 confFrameParams = (G711ENC_FTYPES*)ComponentConfigStructure; 1040 pComponentPrivate->frametype = confFrameParams->FrameSizeType; 1041 pComponentPrivate->vaumode = confFrameParams->VAUMode; 1042 pComponentPrivate->vauthreshold = confFrameParams->VAUThresOffset; 1043 pComponentPrivate->vaunumber = confFrameParams->VAUNum; 1044 pComponentPrivate->nmunoise = confFrameParams->NMUNoise; 1045 pComponentPrivate->lporder = confFrameParams->LPOrder; 1046 1047 break; 1048 1049 1050 case OMX_IndexCustomG711EncDataPath: 1051 customFlag = (OMX_S16*)ComponentConfigStructure; 1052 if (customFlag == NULL) { 1053 G711ENC_DPRINT("%d :: OMX_ErrorBadParameter from SetConfig() \n",__LINE__); 1054 eError = OMX_ErrorBadParameter; 1055 goto EXIT; 1056 } 1057 dataPath = *customFlag; 1058 switch(dataPath) { 1059 case DATAPATH_APPLICATION: 1060 OMX_MMMIXER_DATAPATH(pComponentPrivate->sDeviceString, RENDERTYPE_ENCODER, pComponentPrivate->streamID); 1061 break; 1062 1063 case DATAPATH_APPLICATION_RTMIXER: 1064 strcpy((char*)pComponentPrivate->sDeviceString,(char*)RTM_STRING_ENCODER); 1065 break; 1066 1067 case DATAPATH_ACDN: 1068 break; 1069 case DATAPATH_APPLICATION_TEE: 1070 break; 1071 } 1072 break; 1073 1074 default: 1075 eError = OMX_ErrorUnsupportedIndex; 1076 G711ENC_DPRINT("%d :: OMX_ErrorUnsupportedIndex.\n",__LINE__); 1077 break; 1078 } 1079 EXIT: 1080 G711ENC_DPRINT("%d :: Exiting SetConfig\n", __LINE__); 1081 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1082 return eError; 1083} 1084 1085/*-------------------------------------------------------------------*/ 1086/** 1087 * GetState() Gets the current state of the component 1088 * 1089 * @param pCompomponent handle for this instance of the component 1090 * @param pState 1091 * 1092 * @retval OMX_NoError Success, ready to roll 1093 * OMX_Error_BadParameter The input parameter pointer is null 1094 **/ 1095/*-------------------------------------------------------------------*/ 1096 1097static OMX_ERRORTYPE GetState (OMX_HANDLETYPE pComponent, OMX_STATETYPE* pState) 1098{ 1099 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 1100 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 1101 G711ENC_DPRINT("%d :: Entering GetState\n", __LINE__); 1102 if (!pState) { 1103 eError = OMX_ErrorBadParameter; 1104 G711ENC_DPRINT("%d :: OMX_ErrorBadParameter from GetState\n",__LINE__); 1105 goto EXIT; 1106 } 1107 1108 if (pHandle && pHandle->pComponentPrivate) { 1109 *pState = ((G711ENC_COMPONENT_PRIVATE*) 1110 pHandle->pComponentPrivate)->curState; 1111 } else { 1112 *pState = OMX_StateLoaded; 1113 } 1114 eError = OMX_ErrorNone; 1115 G711ENC_DPRINT("State = %d \n", (*pState)); 1116 1117 EXIT: 1118 G711ENC_DPRINT("%d :: Exiting GetState\n", __LINE__); 1119 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1120 return eError; 1121} 1122 1123/*-------------------------------------------------------------------*/ 1124/** 1125 * EmptyThisBuffer() This callback is used to send the input buffer to 1126 * component 1127 * 1128 * @param pComponent handle for this instance of the component 1129 * @param nPortIndex input port index 1130 * @param pBuffer buffer to be sent to codec 1131 * 1132 * @retval OMX_NoError Success, ready to roll 1133 * OMX_Error_BadParameter The input parameter pointer is null 1134 **/ 1135/*-------------------------------------------------------------------*/ 1136 1137static OMX_ERRORTYPE EmptyThisBuffer (OMX_HANDLETYPE pComponent, 1138 OMX_BUFFERHEADERTYPE* pBuffer) 1139{ 1140 OMX_ERRORTYPE eError = OMX_ErrorNone; 1141 int ret = 0; 1142 1143 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; 1144 1145 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 1146 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = 1147 (G711ENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 1148 pPortDef = ((G711ENC_COMPONENT_PRIVATE*)pComponentPrivate)->pPortDef[G711ENC_INPUT_PORT]; 1149 1150 G711ENC_DPRINT("%d :: Entering EmptyThisBuffer\n", __LINE__); 1151 1152 if (pBuffer == NULL) { 1153 eError = OMX_ErrorBadParameter; 1154 G711ENC_PRINT("%d :: About to return OMX_ErrorBadParameter\n",__LINE__); 1155 goto EXIT; 1156 } 1157 1158 if (pBuffer->nSize != sizeof(OMX_BUFFERHEADERTYPE)) { 1159 eError = OMX_ErrorBadParameter; 1160 G711ENC_PRINT("%d :: About to return OMX_ErrorBadParameter\n",__LINE__); 1161 goto EXIT; 1162 } 1163 1164 if (!pPortDef->bEnabled) { 1165 eError = OMX_ErrorIncorrectStateOperation; 1166 G711ENC_PRINT("%d :: About to return OMX_ErrorIncorrectStateOperation\n",__LINE__); 1167 goto EXIT; 1168 } 1169 1170 if (pBuffer->nVersion.nVersion != pComponentPrivate->nVersion) { 1171 eError = OMX_ErrorVersionMismatch; 1172 G711ENC_PRINT("%d :: About to return OMX_ErrorVersionMismatch\n",__LINE__); 1173 goto EXIT; 1174 } 1175 1176 if (pBuffer->nInputPortIndex != G711ENC_INPUT_PORT) { 1177 eError = OMX_ErrorBadPortIndex; 1178 G711ENC_PRINT("%d :: About to return OMX_ErrorBadPortIndex\n",__LINE__); 1179 goto EXIT; 1180 } 1181 1182 if (pComponentPrivate->curState != OMX_StateExecuting && 1183 pComponentPrivate->curState != OMX_StatePause) { 1184 eError= OMX_ErrorIncorrectStateOperation; 1185 G711ENC_PRINT("%d :: current state: %d \n ",__LINE__,pComponentPrivate->curState); 1186 G711ENC_PRINT("%d :: About to return OMX_ErrorIncorrectStateOperation\n",__LINE__); 1187 goto EXIT; 1188 } 1189 1190 1191 G711ENC_DPRINT("----------------------------------------------------------------\n"); 1192 G711ENC_DPRINT("%d :: Comp Sending Filled ip buff = %p to CompThread\n",__LINE__,pBuffer); 1193 G711ENC_DPRINT("----------------------------------------------------------------\n"); 1194 1195 pComponentPrivate->app_nBuf--; 1196 pComponentPrivate->pMarkData = pBuffer->pMarkData; 1197 pComponentPrivate->hMarkTargetComponent = pBuffer->hMarkTargetComponent; 1198 1199 pComponentPrivate->nUnhandledEmptyThisBuffers++; 1200 1201 ret = write (pComponentPrivate->dataPipe[1], &pBuffer, sizeof(OMX_BUFFERHEADERTYPE*)); 1202 if (ret == -1) { 1203 G711ENC_PRINT("%d :: Error in Writing to the Data pipe\n", __LINE__); 1204 eError = OMX_ErrorHardware; 1205 goto EXIT; 1206 } 1207 pComponentPrivate->nEmptyThisBufferCount++; 1208 EXIT: 1209 G711ENC_DPRINT("%d :: Exiting EmptyThisBuffer\n", __LINE__); 1210 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1211 return eError; 1212} 1213/*-------------------------------------------------------------------*/ 1214/** 1215 * FillThisBuffer() This callback is used to send the output buffer to 1216 * the component 1217 * 1218 * @param pComponent handle for this instance of the component 1219 * @param nPortIndex output port number 1220 * @param pBuffer buffer to be sent to codec 1221 * 1222 * @retval OMX_NoError Success, ready to roll 1223 * OMX_Error_BadParameter The input parameter pointer is null 1224 **/ 1225/*-------------------------------------------------------------------*/ 1226 1227static OMX_ERRORTYPE FillThisBuffer (OMX_HANDLETYPE pComponent, 1228 OMX_BUFFERHEADERTYPE* pBuffer) 1229{ 1230 OMX_ERRORTYPE eError = OMX_ErrorNone; 1231 int ret = 0; 1232 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; 1233 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent; 1234 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = 1235 (G711ENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate; 1236 pPortDef = ((G711ENC_COMPONENT_PRIVATE*)pComponentPrivate)->pPortDef[G711ENC_OUTPUT_PORT]; 1237 G711ENC_DPRINT("%d :: Entering FillThisBuffer\n", __LINE__); 1238 G711ENC_DPRINT("------------------------------------------------------------------\n"); 1239 G711ENC_DPRINT("%d :: Comp Sending Emptied op buff = %p to CompThread\n",__LINE__,pBuffer); 1240 G711ENC_DPRINT("------------------------------------------------------------------\n"); 1241 if (pBuffer == NULL) { 1242 eError = OMX_ErrorBadParameter; 1243 G711ENC_DPRINT(" %d :: About to return OMX_ErrorBadParameter\n",__LINE__); 1244 goto EXIT; 1245 } 1246 1247 if (pBuffer->nSize != sizeof(OMX_BUFFERHEADERTYPE)) { 1248 eError = OMX_ErrorBadParameter; 1249 G711ENC_DPRINT(" %d :: About to return OMX_ErrorBadParameter\n",__LINE__); 1250 goto EXIT; 1251 } 1252 1253 if (!pPortDef->bEnabled) { 1254 eError = OMX_ErrorIncorrectStateOperation; 1255 G711ENC_DPRINT("%d :: About to return OMX_ErrorIncorrectStateOperation\n",__LINE__); 1256 goto EXIT; 1257 } 1258 1259 if (pBuffer->nVersion.nVersion != pComponentPrivate->nVersion) { 1260 eError = OMX_ErrorVersionMismatch; 1261 G711ENC_DPRINT(" %d :: About to return OMX_ErrorVersionMismatch\n",__LINE__); 1262 goto EXIT; 1263 } 1264 1265 if (pBuffer->nOutputPortIndex != G711ENC_OUTPUT_PORT) { 1266 eError = OMX_ErrorBadPortIndex; 1267 G711ENC_DPRINT(" %d :: About to return OMX_ErrorBadPortIndex\n",__LINE__); 1268 goto EXIT; 1269 } 1270 1271 if(pComponentPrivate->curState != OMX_StateExecuting && 1272 pComponentPrivate->curState != OMX_StatePause) { 1273 eError = OMX_ErrorIncorrectStateOperation; 1274 G711ENC_DPRINT("%d :: About to return OMX_ErrorIncorrectStateOperation\n",__LINE__); 1275 goto EXIT; 1276 } 1277 1278 /*pBuffer->nFilledLen = 0; 1279 memset(pBuffer->pBuffer, 0, pBuffer->nAllocLen);*/ 1280 1281 pComponentPrivate->app_nBuf--; 1282 if(pComponentPrivate->pMarkBuf != NULL){ 1283 pBuffer->hMarkTargetComponent = pComponentPrivate->pMarkBuf->hMarkTargetComponent; 1284 pBuffer->pMarkData = pComponentPrivate->pMarkBuf->pMarkData; 1285 pComponentPrivate->pMarkBuf = NULL; 1286 } 1287 1288 if (pComponentPrivate->pMarkData != NULL) { 1289 pBuffer->hMarkTargetComponent = pComponentPrivate->hMarkTargetComponent; 1290 pBuffer->pMarkData = pComponentPrivate->pMarkData; 1291 pComponentPrivate->pMarkData = NULL; 1292 } 1293 1294 pComponentPrivate->nUnhandledFillThisBuffers++; 1295 1296 ret = write (pComponentPrivate->dataPipe[1], &pBuffer, sizeof (OMX_BUFFERHEADERTYPE*)); 1297 if (ret == -1) { 1298 G711ENC_DPRINT("%d :: Error in Writing to the Data pipe\n", __LINE__); 1299 eError = OMX_ErrorHardware; 1300 goto EXIT; 1301 } 1302 pComponentPrivate->nFillThisBufferCount++; 1303 EXIT: 1304 G711ENC_DPRINT("%d :: Exiting FillThisBuffer\n", __LINE__); 1305 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1306 return eError; 1307} 1308/*-------------------------------------------------------------------*/ 1309/** 1310 * OMX_ComponentDeinit() this methold will de init the component 1311 * 1312 * @param pComp handle for this instance of the component 1313 * 1314 * @retval OMX_NoError Success, ready to roll 1315 * OMX_Error_BadParameter The input parameter pointer is null 1316 **/ 1317/*-------------------------------------------------------------------*/ 1318 1319static OMX_ERRORTYPE ComponentDeInit(OMX_HANDLETYPE pHandle) 1320{ 1321 OMX_ERRORTYPE eError = OMX_ErrorNone; 1322 OMX_COMPONENTTYPE *pComponent = (OMX_COMPONENTTYPE *)pHandle; 1323 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = 1324 (G711ENC_COMPONENT_PRIVATE *)pComponent->pComponentPrivate; 1325 G711ENC_DPRINT("%d :: Entering ComponentDeInit\n", __LINE__); 1326 1327#ifdef DSP_RENDERING_ON 1328 close(pComponentPrivate->fdwrite); 1329 close(pComponentPrivate->fdread); 1330#endif 1331 1332#ifdef RESOURCE_MANAGER_ENABLED 1333 eError = RMProxy_NewSendCommand(pHandle, RMProxy_FreeResource, 1334 OMX_G711_Encoder_COMPONENT, 1335 0, 1234, NULL); 1336 if (eError != OMX_ErrorNone) { 1337 G711ENC_DPRINT ("%d ::Error returned from destroy ResourceManagerProxy thread\n", 1338 __LINE__); 1339 } 1340 eError = RMProxy_Deinitalize(); 1341 if (eError != OMX_ErrorNone) { 1342 G711ENC_DPRINT("%d :: Error from RMProxy_Deinitalize\n",__LINE__); 1343 goto EXIT; 1344 } 1345#endif 1346 1347 pComponentPrivate->bIsThreadstop = 1; 1348 1349 eError = G711ENC_StopComponentThread(pHandle); 1350 if (eError != OMX_ErrorNone) { 1351 G711ENC_DPRINT("%d :: Error from G711ENC_StopComponentThread\n",__LINE__); 1352 goto EXIT; 1353 } 1354 /* Wait for thread to exit so we can get the status into "eError" */ 1355 /* close the pipe handles */ 1356 eError = G711ENC_FreeCompResources(pHandle); 1357 if (eError != OMX_ErrorNone) { 1358 G711ENC_DPRINT("%d :: Error from G711ENC_FreeCompResources\n",__LINE__); 1359 goto EXIT; 1360 } 1361 1362 OMX_G711ENC_MEMFREE_STRUCT(pComponentPrivate->sDeviceString); 1363 OMX_G711ENC_MEMFREE_STRUCT(pComponentPrivate); 1364 1365 EXIT: 1366 G711ENC_DPRINT("%d :: Exiting ComponentDeInit\n", __LINE__); 1367 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1368 return eError; 1369} 1370 1371/*-------------------------------------------------------------------*/ 1372/** 1373 * ComponentTunnelRequest() this method is not implemented in 1.5 1374 * 1375 * This method will update application callbacks 1376 * the application. 1377 * 1378 * @param pComp handle for this instance of the component 1379 * @param pCallBacks application callbacks 1380 * @param ptr 1381 * 1382 * @retval OMX_NoError Success, ready to roll 1383 * OMX_Error_BadParameter The input parameter pointer is null 1384 **/ 1385/*-------------------------------------------------------------------*/ 1386 1387static OMX_ERRORTYPE ComponentTunnelRequest (OMX_HANDLETYPE hComp, 1388 OMX_U32 nPort, OMX_HANDLETYPE hTunneledComp, 1389 OMX_U32 nTunneledPort, 1390 OMX_TUNNELSETUPTYPE* pTunnelSetup) 1391{ 1392 OMX_ERRORTYPE eError = OMX_ErrorNone; 1393 eError = OMX_ErrorNotImplemented; 1394 G711ENC_DPRINT("%d :: Entering ComponentTunnelRequest\n", __LINE__); 1395 G711ENC_DPRINT("%d :: Exiting ComponentTunnelRequest\n", __LINE__); 1396 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1397 return eError; 1398} 1399 1400/*-------------------------------------------------------------------*/ 1401/** 1402 * AllocateBuffer() 1403 1404 * @param pComp handle for this instance of the component 1405 * @param pCallBacks application callbacks 1406 * @param ptr 1407 * 1408 * @retval OMX_NoError Success, ready to roll 1409 * OMX_Error_BadParameter The input parameter pointer is null 1410 **/ 1411/*-------------------------------------------------------------------*/ 1412 1413static OMX_ERRORTYPE AllocateBuffer (OMX_IN OMX_HANDLETYPE hComponent, 1414 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer, 1415 OMX_IN OMX_U32 nPortIndex, 1416 OMX_IN OMX_PTR pAppPrivate, 1417 OMX_IN OMX_U32 nSizeBytes) 1418 1419{ 1420 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; 1421 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = NULL; 1422 OMX_ERRORTYPE eError = OMX_ErrorNone; 1423 OMX_BUFFERHEADERTYPE *pBufferHeader = NULL; 1424 1425 pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *) 1426 (((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate); 1427 1428 pPortDef = ((G711ENC_COMPONENT_PRIVATE*)pComponentPrivate)->pPortDef[nPortIndex]; 1429 G711ENC_DPRINT("%d :: Entering AllocateBuffer\n", __LINE__); 1430 G711ENC_DPRINT("%d :: pPortDef = %p\n", __LINE__,pPortDef); 1431 1432 if(!pPortDef->bEnabled){ 1433 pComponentPrivate->AlloBuf_waitingsignal = 1; 1434 1435#ifndef UNDER_CE 1436 pthread_mutex_lock(&pComponentPrivate->AlloBuf_mutex); 1437 pthread_cond_wait(&pComponentPrivate->AlloBuf_threshold, 1438 &pComponentPrivate->AlloBuf_mutex); 1439 pthread_mutex_unlock(&pComponentPrivate->AlloBuf_mutex); 1440#else 1441 OMX_WaitForEvent(&(pComponentPrivate->AlloBuf_event)); 1442#endif 1443 } 1444 1445 G711ENC_DPRINT("%d :: pPortDef->bEnabled = %d\n", __LINE__,pPortDef->bEnabled); 1446 1447 G711ENC_OMX_MALLOC_STRUCT(pBufferHeader, OMX_BUFFERHEADERTYPE); 1448 1449 G711ENC_OMX_MALLOC_SIZE(pBufferHeader->pBuffer, 1450 (nSizeBytes + DSP_CACHE_ALIGNMENT), 1451 OMX_U8); 1452 1453 pBufferHeader->pBuffer += EXTRA_BYTES; 1454 1455 if (nPortIndex == G711ENC_INPUT_PORT) { 1456 pBufferHeader->nInputPortIndex = nPortIndex; 1457 pBufferHeader->nOutputPortIndex = -1; 1458 pComponentPrivate->pInputBufferList->pBufHdr[pComponentPrivate->pInputBufferList->numBuffers] = pBufferHeader; 1459 pComponentPrivate->pInputBufferList->bBufferPending[pComponentPrivate->pInputBufferList->numBuffers] = 0; 1460 pComponentPrivate->pInputBufferList->bufferOwner[pComponentPrivate->pInputBufferList->numBuffers++] = 1; 1461 G711ENC_DPRINT("%d ::Comparing INPUT numBuffers : pPortDef->nBufferCountActual = %d : %d \n",__LINE__, 1462 (int)pComponentPrivate->pInputBufferList->numBuffers,(int)pPortDef->nBufferCountActual); 1463 if (pComponentPrivate->pInputBufferList->numBuffers == pPortDef->nBufferCountActual) { 1464 pPortDef->bPopulated = OMX_TRUE; 1465 G711ENC_DPRINT("%d :: pPortDef->bPopulated = %d\n", __LINE__, pPortDef->bPopulated); 1466 } 1467 } 1468 else if (nPortIndex == G711ENC_OUTPUT_PORT) { 1469 pBufferHeader->nInputPortIndex = -1; 1470 pBufferHeader->nOutputPortIndex = nPortIndex; 1471 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->pOutputBufferList->numBuffers] = pBufferHeader; 1472 pComponentPrivate->pOutputBufferList->bBufferPending[pComponentPrivate->pOutputBufferList->numBuffers] = 0; 1473 pComponentPrivate->pOutputBufferList->bufferOwner[pComponentPrivate->pOutputBufferList->numBuffers++] = 1; 1474 G711ENC_DPRINT("%d :: Comparing OUTPUT numBuffers : pPortDef->nBufferCountActual = %d : %d \n",__LINE__, 1475 (int)pComponentPrivate->pOutputBufferList->numBuffers,(int)pPortDef->nBufferCountActual); 1476 if (pComponentPrivate->pOutputBufferList->numBuffers == pPortDef->nBufferCountActual) { 1477 pPortDef->bPopulated = OMX_TRUE; 1478 G711ENC_DPRINT("%d :: pPortDef->bPopulated = %d\n", __LINE__, pPortDef->bPopulated); 1479 } 1480 } 1481 else { 1482 eError = OMX_ErrorBadPortIndex; 1483 G711ENC_DPRINT(" %d :: About to return OMX_ErrorBadPortIndex\n",__LINE__); 1484 goto EXIT; 1485 } 1486 1487 if((pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bPopulated == 1488 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bEnabled) && 1489 (pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bPopulated == 1490 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bEnabled) && 1491 (pComponentPrivate->InLoaded_readytoidle)){ 1492 pComponentPrivate->InLoaded_readytoidle = 0; 1493#ifndef UNDER_CE 1494 pthread_mutex_lock(&pComponentPrivate->InLoaded_mutex); 1495 pthread_cond_signal(&pComponentPrivate->InLoaded_threshold); 1496 pthread_mutex_unlock(&pComponentPrivate->InLoaded_mutex); 1497#else 1498 OMX_SignalEvent(&(pComponentPrivate->InLoaded_event)); 1499#endif 1500 } 1501 1502 1503 1504 pBufferHeader->pAppPrivate = pAppPrivate; 1505 pBufferHeader->pPlatformPrivate = pComponentPrivate; 1506 pBufferHeader->nAllocLen = nSizeBytes; 1507 pBufferHeader->nVersion.s.nVersionMajor = G711ENC_MAJOR_VER; 1508 pBufferHeader->nVersion.s.nVersionMinor = G711ENC_MINOR_VER; 1509 pComponentPrivate->nVersion = pBufferHeader->nVersion.nVersion; 1510 pBufferHeader->nSize = sizeof(OMX_BUFFERHEADERTYPE); 1511 *pBuffer = pBufferHeader; 1512 1513 if (pComponentPrivate->bEnableCommandPending && pPortDef->bPopulated) { 1514 SendCommand (pComponentPrivate->pHandle, 1515 OMX_CommandPortEnable, 1516 pComponentPrivate->nEnableCommandParam, 1517 NULL); 1518 } 1519 1520 1521 EXIT: 1522 G711ENC_DPRINT("%d :: Exiting AllocateBuffer\n",__LINE__); 1523 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1524 return eError; 1525} 1526 1527/*-------------------------------------------------------------------*/ 1528/** 1529 * FreeBuffer() 1530 1531 * @param hComponent handle for this instance of the component 1532 * @param pCallBacks application callbacks 1533 * @param ptr 1534 * 1535 * @retval OMX_NoError Success, ready to roll 1536 * OMX_Error_BadParameter The input parameter pointer is null 1537 **/ 1538/*-------------------------------------------------------------------*/ 1539 1540static OMX_ERRORTYPE FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, 1541 OMX_IN OMX_U32 nPortIndex, 1542 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 1543{ 1544 OMX_ERRORTYPE eError = OMX_ErrorNone; 1545 G711ENC_COMPONENT_PRIVATE * pComponentPrivate = NULL; 1546 OMX_BUFFERHEADERTYPE* buff = NULL; 1547 OMX_U8* tempBuff = NULL; 1548 int i = 0; 1549 int inputIndex = -1; 1550 int outputIndex = -1; 1551 OMX_COMPONENTTYPE *pHandle = NULL; 1552 1553 pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *) 1554 (((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate); 1555 1556 pHandle = (OMX_COMPONENTTYPE *) pComponentPrivate->pHandle; 1557 1558 G711ENC_DPRINT("%d :: Entering FreeBuffer\n", __LINE__); 1559 for (i=0; i < G711ENC_MAX_NUM_OF_BUFS; i++) { 1560 buff = pComponentPrivate->pInputBufferList->pBufHdr[i]; 1561 if (buff == pBuffer) { 1562 G711ENC_DPRINT("%d :: Found matching input buffer\n",__LINE__); 1563 G711ENC_DPRINT("%d :: buff = %p\n",__LINE__,buff); 1564 G711ENC_DPRINT("%d :: pBuffer = %p\n",__LINE__,pBuffer); 1565 inputIndex = i; 1566 break; 1567 } 1568 else { 1569 G711ENC_DPRINT("%d :: This is not a match\n",__LINE__); 1570 G711ENC_DPRINT("%d :: buff = %p\n",__LINE__,buff); 1571 G711ENC_DPRINT("%d :: pBuffer = %p\n",__LINE__,pBuffer); 1572 } 1573 } 1574 1575 for (i=0; i < G711ENC_MAX_NUM_OF_BUFS; i++) { 1576 buff = pComponentPrivate->pOutputBufferList->pBufHdr[i]; 1577 if (buff == pBuffer) { 1578 G711ENC_DPRINT("%d :: Found matching output buffer\n",__LINE__); 1579 G711ENC_DPRINT("%d :: buff = %p\n",__LINE__,buff); 1580 G711ENC_DPRINT("%d :: pBuffer = %p\n",__LINE__,pBuffer); 1581 outputIndex = i; 1582 break; 1583 } 1584 else { 1585 G711ENC_DPRINT("%d :: This is not a match\n",__LINE__); 1586 G711ENC_DPRINT("%d :: buff = %p\n",__LINE__,buff); 1587 G711ENC_DPRINT("%d :: pBuffer = %p\n",__LINE__,pBuffer); 1588 } 1589 } 1590 1591 if (inputIndex != -1) { 1592 if (pComponentPrivate->pInputBufferList->bufferOwner[inputIndex] == 1) { 1593 tempBuff = pComponentPrivate->pInputBufferList->pBufHdr[inputIndex]->pBuffer; 1594 if (tempBuff != 0){ 1595 tempBuff -= EXTRA_BYTES; 1596 } 1597 OMX_G711ENC_MEMFREE_STRUCT(tempBuff); 1598 } 1599 1600 OMX_G711ENC_MEMFREE_STRUCT(pComponentPrivate->pInputBufferList->pBufHdr[inputIndex]); 1601 1602 pComponentPrivate->pInputBufferList->numBuffers--; 1603 1604 G711ENC_DPRINT("%d :: pComponentPrivate->pInputBufferList->numBuffers = %ld \n",__LINE__,pComponentPrivate->pInputBufferList->numBuffers); 1605 G711ENC_DPRINT("%d :: pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nBufferCountMin = %ld \n",__LINE__,pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nBufferCountMin); 1606 if (pComponentPrivate->pInputBufferList->numBuffers < 1607 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->nBufferCountMin) { 1608 1609 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bPopulated = OMX_FALSE; 1610 } 1611 if(pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bEnabled && 1612 pComponentPrivate->bLoadedCommandPending == OMX_FALSE && 1613 (pComponentPrivate->curState == OMX_StateIdle || 1614 pComponentPrivate->curState == OMX_StateExecuting || 1615 pComponentPrivate->curState == OMX_StatePause)) { 1616 G711ENC_DPRINT("%d :: pPortDef[G711ENC_INPUT_PORT]->bPopulated = %d \n", 1617 __LINE__, 1618 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bPopulated); 1619 G711ENC_DPRINT("%d :: pComponentPrivate->curState = %d \n", 1620 __LINE__, 1621 pComponentPrivate->curState); 1622 pComponentPrivate->cbInfo.EventHandler( pHandle, 1623 pHandle->pApplicationPrivate, 1624 OMX_EventError, 1625 OMX_ErrorPortUnpopulated, 1626 nPortIndex, 1627 NULL); 1628 } 1629 } 1630 else if (outputIndex != -1) { 1631 if (pComponentPrivate->pOutputBufferList->bufferOwner[outputIndex] == 1) { 1632 tempBuff = pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]->pBuffer; 1633 if (tempBuff != 0){ 1634 tempBuff -= EXTRA_BYTES; 1635 } 1636 OMX_G711ENC_MEMFREE_STRUCT(tempBuff); 1637 } 1638 OMX_G711ENC_MEMFREE_STRUCT(pComponentPrivate->pOutputBufferList->pBufHdr[outputIndex]); 1639 1640 pComponentPrivate->pOutputBufferList->numBuffers--; 1641 G711ENC_DPRINT("\n%d :: pComponentPrivate->pOutputBufferList->numBuffers = %ld \n", 1642 __LINE__, 1643 pComponentPrivate->pOutputBufferList->numBuffers); 1644 G711ENC_DPRINT("\n%d :: pComponentPrivate->pPortDef[OUTPUT_PORT]->nBufferCountMin = %ld \n", 1645 __LINE__, 1646 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->nBufferCountMin); 1647 1648 if (pComponentPrivate->pOutputBufferList->numBuffers < 1649 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->nBufferCountMin) { 1650 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bPopulated = OMX_FALSE; 1651 } 1652 if(pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bEnabled && 1653 pComponentPrivate->bLoadedCommandPending == OMX_FALSE && 1654 (pComponentPrivate->curState == OMX_StateIdle || 1655 pComponentPrivate->curState == OMX_StateExecuting || 1656 pComponentPrivate->curState == OMX_StatePause)) { 1657 G711ENC_DPRINT("\n%d :: pPortDef[G711ENC_OUTPUT_PORT]->bPopulated = %d \n", 1658 __LINE__, 1659 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bPopulated); 1660 G711ENC_DPRINT("\n%d :: pComponentPrivate->curState = %d \n", 1661 __LINE__, 1662 pComponentPrivate->curState); 1663 pComponentPrivate->cbInfo.EventHandler( pHandle, 1664 pHandle->pApplicationPrivate, 1665 OMX_EventError, 1666 OMX_ErrorPortUnpopulated, 1667 nPortIndex, 1668 NULL); 1669 } 1670 } 1671 else { 1672 G711ENC_DPRINT("%d :: Returning OMX_ErrorBadParameter\n",__LINE__); 1673 eError = OMX_ErrorBadParameter; 1674 } 1675 if ((!pComponentPrivate->pInputBufferList->numBuffers && 1676 !pComponentPrivate->pOutputBufferList->numBuffers) && 1677 pComponentPrivate->InIdle_goingtoloaded){ 1678 pComponentPrivate->InIdle_goingtoloaded = 0; 1679#ifndef UNDER_CE 1680 pthread_mutex_lock(&pComponentPrivate->InIdle_mutex); 1681 pthread_cond_signal(&pComponentPrivate->InIdle_threshold); 1682 pthread_mutex_unlock(&pComponentPrivate->InIdle_mutex); 1683#else 1684 OMX_SignalEvent(&(pComponentPrivate->InIdle_event)); 1685#endif 1686 } 1687 1688 if (pComponentPrivate->bDisableCommandPending && 1689 (pComponentPrivate->pInputBufferList->numBuffers + 1690 pComponentPrivate->pOutputBufferList->numBuffers == 0)) { 1691 1692 SendCommand (pComponentPrivate->pHandle, 1693 OMX_CommandPortDisable, 1694 pComponentPrivate->bDisableCommandParam, 1695 NULL); 1696 } 1697 G711ENC_DPRINT("%d :: Exiting FreeBuffer\n", __LINE__); 1698 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1699 return eError; 1700} 1701 1702/*-------------------------------------------------------------------*/ 1703/** 1704 * UseBuffer() 1705 1706 * @param pComp handle for this instance of the component 1707 * @param pCallBacks application callbacks 1708 * @param ptr 1709 * 1710 * @retval OMX_NoError Success, ready to roll 1711 * OMX_Error_BadParameter The input parameter pointer is null 1712 **/ 1713/*-------------------------------------------------------------------*/ 1714static OMX_ERRORTYPE UseBuffer (OMX_IN OMX_HANDLETYPE hComponent, 1715 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 1716 OMX_IN OMX_U32 nPortIndex, 1717 OMX_IN OMX_PTR pAppPrivate, 1718 OMX_IN OMX_U32 nSizeBytes, 1719 OMX_IN OMX_U8* pBuffer) 1720{ 1721 OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; 1722 G711ENC_COMPONENT_PRIVATE *pComponentPrivate = NULL; 1723 OMX_ERRORTYPE eError = OMX_ErrorNone; 1724 OMX_BUFFERHEADERTYPE *pBufferHeader = NULL; 1725 1726 pComponentPrivate = (G711ENC_COMPONENT_PRIVATE *) 1727 (((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate); 1728 1729 pPortDef = ((G711ENC_COMPONENT_PRIVATE*)pComponentPrivate)->pPortDef[nPortIndex]; 1730 G711ENC_DPRINT("%d :: Entering UseBuffer\n", __LINE__); 1731 G711ENC_DPRINT("%d :: pPortDef->bPopulated = %d \n",__LINE__,pPortDef->bPopulated); 1732 1733 if(!pPortDef->bEnabled) { 1734 G711ENC_DPRINT("%d :: About to return OMX_ErrorIncorrectStateOperation\n",__LINE__); 1735 eError = OMX_ErrorIncorrectStateOperation; 1736 goto EXIT; 1737 } 1738 1739 if(nSizeBytes != pPortDef->nBufferSize || pPortDef->bPopulated) { 1740 G711ENC_DPRINT("%d :: About to return OMX_ErrorBadParameter\n",__LINE__); 1741 eError = OMX_ErrorBadParameter; 1742 goto EXIT; 1743 } 1744 1745 G711ENC_OMX_MALLOC_STRUCT(pBufferHeader, OMX_BUFFERHEADERTYPE); 1746 1747 if (nPortIndex == G711ENC_OUTPUT_PORT) { 1748 pBufferHeader->nInputPortIndex = -1; 1749 pBufferHeader->nOutputPortIndex = nPortIndex; 1750 pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->pOutputBufferList->numBuffers] = pBufferHeader; 1751 pComponentPrivate->pOutputBufferList->bBufferPending[pComponentPrivate->pOutputBufferList->numBuffers] = 0; 1752 pComponentPrivate->pOutputBufferList->bufferOwner[pComponentPrivate->pOutputBufferList->numBuffers++] = 0; 1753 1754 if (pComponentPrivate->pOutputBufferList->numBuffers == pPortDef->nBufferCountActual) { 1755 pPortDef->bPopulated = OMX_TRUE; 1756 } 1757 G711ENC_DPRINT("%d :: pPortDef->bPopulated = %d\n", __LINE__, pPortDef->bPopulated); 1758 } 1759 else { 1760 pBufferHeader->nInputPortIndex = nPortIndex; 1761 pBufferHeader->nOutputPortIndex = -1; 1762 pComponentPrivate->pInputBufferList->pBufHdr[pComponentPrivate->pInputBufferList->numBuffers] = pBufferHeader; 1763 pComponentPrivate->pInputBufferList->bBufferPending[pComponentPrivate->pInputBufferList->numBuffers] = 0; 1764 pComponentPrivate->pInputBufferList->bufferOwner[pComponentPrivate->pInputBufferList->numBuffers++] = 0; 1765 1766 if (pComponentPrivate->pInputBufferList->numBuffers == pPortDef->nBufferCountActual) { 1767 pPortDef->bPopulated = OMX_TRUE; 1768 } 1769 G711ENC_DPRINT("%d :: pPortDef->bPopulated = %d\n", __LINE__, pPortDef->bPopulated); 1770 } 1771 1772 if((pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bPopulated == 1773 pComponentPrivate->pPortDef[G711ENC_OUTPUT_PORT]->bEnabled)&& 1774 (pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bPopulated == 1775 pComponentPrivate->pPortDef[G711ENC_INPUT_PORT]->bEnabled) && 1776 (pComponentPrivate->InLoaded_readytoidle)){ 1777 pComponentPrivate->InLoaded_readytoidle = 0; 1778#ifndef UNDER_CE 1779 pthread_mutex_lock(&pComponentPrivate->InLoaded_mutex); 1780 pthread_cond_signal(&pComponentPrivate->InLoaded_threshold); 1781 pthread_mutex_unlock(&pComponentPrivate->InLoaded_mutex); 1782#else 1783 OMX_SignalEvent(&(pComponentPrivate->InLoaded_event)); 1784#endif 1785 } 1786 1787 pBufferHeader->pAppPrivate = pAppPrivate; 1788 pBufferHeader->pPlatformPrivate = pComponentPrivate; 1789 pBufferHeader->nAllocLen = nSizeBytes; 1790 pBufferHeader->nVersion.s.nVersionMajor = G711ENC_MAJOR_VER; 1791 pBufferHeader->nVersion.s.nVersionMinor = G711ENC_MINOR_VER; 1792 pComponentPrivate->nVersion = pBufferHeader->nVersion.nVersion; 1793 pBufferHeader->pBuffer = pBuffer; 1794 pBufferHeader->nSize = sizeof(OMX_BUFFERHEADERTYPE); 1795 *ppBufferHdr = pBufferHeader; 1796 EXIT: 1797 G711ENC_DPRINT("%d :: Exiting UseBuffer\n", __LINE__); 1798 G711ENC_DPRINT("%d :: Returning = 0x%x\n",__LINE__,eError); 1799 return eError; 1800} 1801 1802/* ================================================================================= */ 1803/** 1804 * @fn GetExtensionIndex() description for GetExtensionIndex 1805 GetExtensionIndex(). 1806 Returns index for vendor specific settings. 1807 * 1808 * @see OMX_Core.h 1809 */ 1810/* ================================================================================ */ 1811static OMX_ERRORTYPE GetExtensionIndex( OMX_IN OMX_HANDLETYPE hComponent, 1812 OMX_IN OMX_STRING cParameterName, 1813 OMX_OUT OMX_INDEXTYPE* pIndexType) 1814{ 1815 OMX_ERRORTYPE eError = OMX_ErrorNone; 1816 1817 G711ENC_DPRINT("GetExtensionIndex\n"); 1818 if (!(strcmp(cParameterName,"OMX.TI.index.config.tispecific"))) { 1819 *pIndexType = OMX_IndexCustomG711ENCModeConfig; 1820 G711ENC_DPRINT("OMX_IndexCustomG711ENCModeConfig\n"); 1821 } 1822 else if(!(strcmp(cParameterName,"OMX.TI.index.config.g711.datapath"))) { 1823 *pIndexType = OMX_IndexCustomG711EncDataPath; 1824 G711ENC_DPRINT("OMX_IndexCustomG711EncDataPath\n"); 1825 } 1826 1827 else if(!strcmp(cParameterName,"OMX.TI.index.config.g711.frameparamters")){ 1828 *pIndexType = OMX_IndexCustomG711EncFrameParams; 1829 } 1830 1831 else { 1832 eError = OMX_ErrorBadParameter; 1833 } 1834 1835 G711ENC_DPRINT("pIndexType %x \n",*pIndexType); 1836 G711ENC_DPRINT("Exiting GetExtensionIndex\n"); 1837 return eError; 1838} 1839 1840/* ================================================================================= */ 1841/** 1842 * @fn ComponentRoleEnum() description for ComponentRoleEnum() 1843 1844 Returns the role at the given index 1845 * 1846 * @see OMX_Core.h 1847 */ 1848/* ================================================================================ */ 1849static OMX_ERRORTYPE ComponentRoleEnum( OMX_IN OMX_HANDLETYPE hComponent, 1850 OMX_OUT OMX_U8 *cRole, 1851 OMX_IN OMX_U32 nIndex) 1852{ 1853 OMX_ERRORTYPE eError = OMX_ErrorNone; 1854 eError = OMX_ErrorNotImplemented; 1855 1856 return eError; 1857} 1858