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_G711Enc_Utils.h 30 * 31 * This is an header file for an G711 Encoder that is fully 32 * compliant with the OMX Audio specification 1.5. 33 * This the file that the application that uses OMX would include in its code. 34 * 35 * @path $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\g711_enc\inc 36 * 37 * @rev 1.0 38 */ 39/* --------------------------------------------------------------------------- */ 40/* ---------------------------------------------------------------------------- 41 *! 42 *! Revision History 43 *! =================================== 44 *! 12-Dec-2006: Initial Version 45 *! This is newest file 46 * =========================================================================== */ 47#ifndef OMX_G711ENC_UTILS__H 48#define OMX_G711ENC_UTILS__H 49#include <OMX_Component.h> 50#include <pthread.h> 51#include "LCML_DspCodec.h" 52#include <TIDspOmx.h> 53 54#ifdef DSP_RENDERING_ON 55#include <AudioManagerAPI.h> 56#endif 57 58#ifdef RESOURCE_MANAGER_ENABLED 59#include <ResourceManagerProxyAPI.h> 60#endif 61 62#ifdef UNDER_CE 63#define sleep Sleep 64#endif 65/* ======================================================================= */ 66/** 67 * @def G711ENC_DEBUG Turns debug messaging on and off 68 */ 69/* ======================================================================= */ 70#undef G711ENC_DEBUG 71/* ======================================================================= */ 72/** 73 * @def G711ENC_MEMCHECK Turns memory messaging on and off 74 */ 75/* ======================================================================= */ 76#undef G711ENC_MEMCHECK 77/* ======================================================================= */ 78/** 79 * @def G711ENC_PRINTS Turns normal prints messaging on and off 80 *implementation for substituing the normal printf 81 */ 82/* ======================================================================= */ 83#undef G711ENC_PRINT 84/*========================================================================*/ 85 86#ifndef UNDER_CE 87/* ======================================================================= */ 88/** 89 * @def G711ENC_DEBUG Debug print macro 90 */ 91/* ======================================================================= */ 92#ifdef G711ENC_DEBUG 93#define G711ENC_DPRINT(...) fprintf(stderr,__VA_ARGS__) 94#else 95#define G711ENC_DPRINT(...) 96#endif 97/* ======================================================================= */ 98/** 99 * @def G711ENC_PRINTS print macro 100 */ 101/* ======================================================================= */ 102#ifdef G711ENC_PRINT 103#define G711ENC_PRINT(...) fprintf(stderr,__VA_ARGS__) 104#else 105#define G711ENC_PRINT(...) 106#endif 107 108/* ======================================================================= */ 109/** 110 * @def G711ENC_MEMCHECK Memory print macro 111 */ 112/* ======================================================================= */ 113#ifdef G711ENC_MEMCHECK 114#define G711ENC_MEMPRINT(...) fprintf(stderr,__VA_ARGS__) 115#else 116#define G711ENC_MEMPRINT(...) 117#endif 118 119#else /*UNDER_CE*/ 120/* ======================================================================= */ 121/** 122 * @def G711ENC_DEBUG Debug print macro 123 */ 124/* ======================================================================= */ 125#ifdef G711ENC_DEBUG 126#define G711ENC_DPRINT(STR, ARG...) printf() 127#else 128 129#endif 130/* ======================================================================= */ 131/** 132 * @def G711ENC_MEMCHECK Memory print macro 133 */ 134/* ======================================================================= */ 135#ifdef G711ENC_MEMCHECK 136#define G711ENC_MEMPRINT(STR, ARG...) printf() 137#else 138 139#endif 140 141#ifdef UNDER_CE 142 143#ifdef DEBUG 144#define G711ENC_DPRINT printf 145#define G711ENC_MEMPRINT printf 146#else 147#define G711ENC_DPRINT 148#define G711ENC_MEMPRINT 149#endif 150 151#endif /*UNDER_CE*/ 152 153#endif 154 155/* ======================================================================= */ 156/** 157 * M A C R O S FOR MALLOC and MEMORY FREE and CLOSING PIPES 158 */ 159/* ======================================================================= */ 160 161#define OMX_G711ENC_INIT_STRUCT(_s_, _name_) \ 162 memset((_s_), 0x0, sizeof(_name_)); \ 163 (_s_)->nSize = sizeof(_name_); \ 164 (_s_)->nVersion.s.nVersionMajor = 0x1; \ 165 (_s_)->nVersion.s.nVersionMinor = 0x0; \ 166 (_s_)->nVersion.s.nRevision = 0x0; \ 167 (_s_)->nVersion.s.nStep = 0x0 168 169#define OMX_G711ENC_MEMFREE_STRUCT(_pStruct_) \ 170 if(_pStruct_ != NULL){ \ 171 G711ENC_MEMPRINT("%d :: [FREE] %p\n",__LINE__,_pStruct_); \ 172 free(_pStruct_); \ 173 _pStruct_ = NULL; \ 174 } 175 176#define OMX_G711ENC_CLOSE_PIPE(_pStruct_,err) \ 177 G711ENC_DPRINT("%d :: CLOSING PIPE \n",__LINE__); \ 178 err = close (_pStruct_); \ 179 if(0 != err && OMX_ErrorNone == eError){ \ 180 eError = OMX_ErrorHardware; \ 181 printf("%d :: Error while closing pipe\n",__LINE__); \ 182 goto EXIT; \ 183 } 184 185#define G711ENC_OMX_MALLOC_STRUCT(_pStruct_, _sName_) \ 186 _pStruct_ = (_sName_*)malloc(sizeof(_sName_)); \ 187 if(_pStruct_ == NULL){ \ 188 printf("***********************************\n"); \ 189 printf("%d :: Malloc Failed\n",__LINE__); \ 190 printf("***********************************\n"); \ 191 eError = OMX_ErrorInsufficientResources; \ 192 goto EXIT; \ 193 } \ 194 memset(_pStruct_,0,sizeof(_sName_)); \ 195 G711ENC_MEMPRINT("%d :: [ALLOC] %p\n",__LINE__,_pStruct_); 196 197#define G711ENC_OMX_MALLOC_SIZE(_ptr_, _size_,_name_) \ 198 _ptr_ = (_name_ *)malloc(_size_); \ 199 if(_ptr_ == NULL){ \ 200 printf("***********************************\n"); \ 201 printf("%d :: Malloc Failed\n",__LINE__); \ 202 printf("***********************************\n"); \ 203 eError = OMX_ErrorInsufficientResources; \ 204 goto EXIT; \ 205 } \ 206 memset(_ptr_,0,_size_); \ 207 G711ENC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_ptr_); 208 209/* ======================================================================= */ 210/** 211 * @def G711ENC_NUM_INPUT_BUFFERS Default number of input buffers 212 */ 213/* ======================================================================= */ 214#define G711ENC_NUM_INPUT_BUFFERS 1 215/* ======================================================================= */ 216/** 217 * @def G711ENC_NUM_INPUT_BUFFERS_DASF Default No.of input buffers DASF 218 */ 219/* ======================================================================= */ 220#define G711ENC_NUM_INPUT_BUFFERS_DASF 2 221/* ======================================================================= */ 222/** 223 * @def G711ENC_NUM_OUTPUT_BUFFERS Default number of output buffers 224 */ 225/* ======================================================================= */ 226#define G711ENC_NUM_OUTPUT_BUFFERS 1 227/* ======================================================================= */ 228/** 229 * @def G711ENC_INPUT_BUFFER_SIZE_DASF Default input buffer size DASF 230 */ 231/* ======================================================================= */ 232#define G711ENC_INPUT_BUFFER_SIZE_DASF 160 /*80*/ 233/* ======================================================================= */ 234/** 235 * @def G711ENC_OUTPUT_BUFFER_SIZE Default output buffer size 236 */ 237/* ======================================================================= */ 238#define G711ENC_OUTPUT_BUFFER_SIZE 80 239/* ======================================================================= */ 240/** 241 * @def G711ENC_INPUT_FRAME_SIZE Default input buffer size 242 */ 243/* ======================================================================= */ 244#define G711ENC_INPUT_FRAME_SIZE 160 245#define G711ENC_INPUT_FRAME_SIZE_20MS 320 246#define G711ENC_INPUT_FRAME_SIZE_30MS 480 247/* ======================================================================= */ 248/** 249 * @def G711ENC_OUTPUT_FRAME_SIZE Default output buffer size 250 */ 251/* ======================================================================= */ 252#define G711ENC_OUTPUT_FRAME_SIZE 80 253#define G711ENC_OUTPUT_FRAME_SIZE_20MS 160 254#define G711ENC_OUTPUT_FRAME_SIZE_30MS 240 255/* ======================================================================= */ 256/** 257 * @def G711ENC_APP_ID App ID Value setting 258 */ 259/* ======================================================================= */ 260#define G711ENC_APP_ID 100 261 262/* ======================================================================= */ 263/** 264 * @def G711ENC_SAMPLING_FREQUENCY Sampling frequency 265 */ 266/* ======================================================================= */ 267#define G711ENC_SAMPLING_FREQUENCY 8000 268/* ======================================================================= */ 269/** 270 * @def G711ENC_MAX_NUM_OF_BUFS Maximum number of buffers 271 */ 272/* ======================================================================= */ 273#define G711ENC_MAX_NUM_OF_BUFS 10 274/* ======================================================================= */ 275/** 276 * @def G711ENC_NUM_OF_PORTS Number of ports 277 */ 278/* ======================================================================= */ 279#define G711ENC_NUM_OF_PORTS 2 280/* ======================================================================= */ 281/** 282 * @def G711ENC_XXX_VER Component version 283 */ 284/* ======================================================================= */ 285#define G711ENC_MAJOR_VER 0xF1 286#define G711ENC_MINOR_VER 0xF2 287/* ======================================================================= */ 288/** 289 * @def G711ENC_NOT_USED Defines a value for "don't care" parameters 290 */ 291/* ======================================================================= */ 292#define G711ENC_NOT_USED 10 293/* ======================================================================= */ 294/** 295 * @def G711ENC_NORMAL_BUFFER Defines flag value with all flags off 296 */ 297/* ======================================================================= */ 298#define G711ENC_NORMAL_BUFFER 0 299/* ======================================================================= */ 300/** 301 * @def OMX_G711ENC_DEFAULT_SEGMENT Default segment ID for the LCML 302 */ 303/* ======================================================================= */ 304#define G711ENC_DEFAULT_SEGMENT (0) 305/* ======================================================================= */ 306/** 307 * @def OMX_G711ENC_SN_TIMEOUT Timeout value for the socket node 308 */ 309/* ======================================================================= */ 310#define G711ENC_SN_TIMEOUT (-1) 311/* ======================================================================= */ 312/** 313 * @def OMX_G711ENC_SN_PRIORITY Priority for the socket node 314 */ 315/* ======================================================================= */ 316#define G711ENC_SN_PRIORITY (10) 317/* ======================================================================= */ 318/** 319 * @def G711ENC_CPU TBD, 50MHz for the moment 320 */ 321/* ======================================================================= */ 322#define G711ENC_CPU (50) 323/* ======================================================================= */ 324/** 325 * @def OMX_G711ENC_NUM_DLLS number of DLL's 326 */ 327/* ======================================================================= */ 328#define G711ENC_NUM_DLLS (2) 329/* ======================================================================= */ 330/** 331 * @def OMX_G711ENC_NUM_DLLS number of DLL's 332 */ 333/* ======================================================================= */ 334#define G711ENC_EXIT_COMPONENT_THRD 10 335/* ======================================================================= */ 336/** 337 * @def DSP cache alignment number of bytes 338 */ 339/* ======================================================================= */ 340#define DSP_CACHE_ALIGNMENT 256 341/* ======================================================================= */ 342/** 343 * @def Extra buffer bytes used for DSP alignment 344 */ 345/* ======================================================================= */ 346#define EXTRA_BYTES 128 347/* ======================================================================= */ 348/** 349 * @def G711ENC_USN_DLL_NAME USN DLL name 350 */ 351/* ======================================================================= */ 352#ifdef UNDER_CE 353#define G711ENC_USN_DLL_NAME "\\windows\\usn.dll64P" 354#else 355#define G711ENC_USN_DLL_NAME "usn.dll64P" 356#endif 357 358/* ======================================================================= */ 359/** 360 * @def G711ENC_DLL_NAME G711 Encoder socket node dll name 361 */ 362/* ======================================================================= */ 363#ifdef UNDER_CE 364#define G711ENC_DLL_NAME "\\windows\\g711enc_sn.dll64P" 365#else 366#define G711ENC_DLL_NAME "g711enc_sn.dll64P" 367#endif 368 369/* ======================================================================= */ 370/** G711ENC_StreamType Stream types 371 * 372 * @param G711ENC_DMM DMM 373 * 374 * @param G711ENC_INSTRM Input stream 375 * 376 * @param G711ENC_OUTSTRM Output stream 377 */ 378/* ======================================================================= */ 379enum G711ENC_StreamType { 380 G711ENC_DMM = 0, 381 G711ENC_INSTRM, 382 G711ENC_OUTSTRM 383}; 384 385/* ======================================================================= */ 386/** 387 * @def G711ENC_TIMEOUTS Default timeout used to come out of blocking calls 388 *@G711ENC_TIMEOUTS refered to time out in seconds 389 *@G711ENC_TIMEOUTNS refered to time out in nano-seconds 390 */ 391/* ======================================================================= */ 392#define G711ENC_TIMEOUTS 1 393#define G711ENC_TIMEOUTNS 0 394/* ======================================================================= */ 395/* 396 * @def G711ENC_OMX_MAX_TIMEOUTS Max Time Outs 397 * @def G711ENC_DONT_CARE Dont Care Condition 398 * @def G711ENC_NUM_CHANNELS Number of Channels 399 * @def G711ENC_APP_ID App ID Value setting 400 */ 401/* ======================================================================= */ 402#define G711ENC_OMX_MAX_TIMEOUTS 20 403#define G711ENC_DONT_CARE 0 404#define G711ENC_NUM_CHANNELS 1 405/* ======================================================================= */ 406/** 407 * @def G711ENC_STREAM_COUNT Number of streams 408 * G711ENC_INPUT_STREAM_ID Stream ID for Input Buffer 409 */ 410/* ======================================================================= */ 411#define G711ENC_STREAM_COUNT 2 412#define G711ENC_INPUT_STREAM_ID 0 413 414#define G711ENC_EXIT_COMPONENT_THRD 10 415 416/* =================================================================================== */ 417/** 418 * 419 */ 420/* ================================================================================== */ 421typedef struct G711ENC_FTYPES{ 422 OMX_S16 FrameSizeType; 423 OMX_S16 VAUMode; 424 OMX_S16 VAUThresOffset; 425 OMX_S16 VAUNum; 426 OMX_S16 NMUNoise; 427 OMX_S16 LPOrder; 428}G711ENC_FTYPES; 429 430/* ======================================================================= */ 431/** G711ENC_COMP_PORT_TYPE Port types 432 * 433 * @param G711ENC_INPUT_PORT Input port 434 * 435 * @param G711ENC_OUTPUT_PORT Output port 436 */ 437/* ====================================================================== */ 438/*This enum must not be changed. */ 439typedef enum G711ENC_COMP_PORT_TYPE { 440 G711ENC_INPUT_PORT = 0, 441 G711ENC_OUTPUT_PORT 442}G711ENC_COMP_PORT_TYPE; 443 444/* ======================================================================= */ 445/** G711ENC_BUFFER_Dir Buffer Direction 446 * 447 * @param G711ENC_DIRECTION_INPUT Input direction 448 * 449 * @param G711ENC_DIRECTION_OUTPUT Output direction 450 * 451 */ 452/* ======================================================================= */ 453typedef enum { 454 G711ENC_DIRECTION_INPUT, 455 G711ENC_DIRECTION_OUTPUT 456}G711ENC_BUFFER_Dir; 457 458/* ======================================================================= */ 459/** G711ENC_BUFFS Buffer details 460 * 461 * @param BufHeader Buffer header 462 * 463 * @param Buffer Buffer 464 * 465 */ 466/* ======================================================================= */ 467typedef struct G711ENC_BUFFS { 468 char BufHeader; 469 char Buffer; 470}G711ENC_BUFFS; 471 472/* ======================================================================= */ 473/** G711ENC_BUFFERHEADERTYPE_INFO 474 * 475 * @param pBufHeader 476 * 477 * @param bBufOwner 478 * 479 */ 480/* ======================================================================= */ 481typedef struct G711ENC_BUFFERHEADERTYPE_INFO { 482 OMX_BUFFERHEADERTYPE* pBufHeader[G711ENC_MAX_NUM_OF_BUFS]; 483 G711ENC_BUFFS bBufOwner[G711ENC_MAX_NUM_OF_BUFS]; 484}G711ENC_BUFFERHEADERTYPE_INFO; 485 486 487typedef OMX_ERRORTYPE (*G711ENC_fpo)(OMX_HANDLETYPE); 488 489/* =================================================================================== */ 490/** 491 * Socket node Audio Codec Configuration parameters. 492 */ 493/* =================================================================================== */ 494typedef struct G711ENC_AudioCodecParams { 495 unsigned long iSamplingRate; 496 unsigned long iStrmId; 497 unsigned short iAudioFormat; 498}G711ENC_AudioCodecParams; 499 500/* =================================================================================== */ 501/** 502 * G711ENC_TALGCtrl Socket Node Alg Control parameters. 503 * G711ENC_UAlgInBufParamStruct Input Buffer Param Structure 504 * G711ENC_UAlgOutBufParamStruct Output Buffer Param Structure 505 */ 506/* =================================================================================== */ 507/* Algorithm specific command parameters */ 508typedef struct { 509 unsigned int iSize; 510 unsigned int iBitrate; 511 unsigned int iDTX; 512 unsigned int iMode; 513 unsigned int iFrameSize; 514 unsigned int iNoiseSuppressionMode; 515 unsigned int ittyTddMode; 516 unsigned int idtmfMode; 517 unsigned int idataTransmit; 518}G711ENC_TALGCtrl; 519 520/* =================================================================================== */ 521/** 522 * G711ENC_FrameStruct Input Frame Structure 523 * bLastBuffer To Send Last Buufer Flag 524 *frameType Tio save the frame type 525 */ 526/* =================================================================================== */ 527typedef struct G711ENC_FrameStruct{ 528 unsigned long usLastFrame; 529 unsigned long frameType; /* 0: voice frame (80 bytes), 1: SID frame (22 bytes), 2: No Data (0 bytes), 3: Frame lost */ 530} G711ENC_FrameStruct; 531/* =================================================================================== */ 532/** 533 * G711ENC_ParamStruct Input Buffer Param Structure 534 * usEndOfFile To Send Last Buufer Flag 535 */ 536/* =================================================================================== */ 537typedef struct G711ENC_ParamStruct 538{ 539 /*unsigned long usEndOfFile;*/ 540 unsigned long int usNbFrames; 541 G711ENC_FrameStruct *pParamElem; 542} G711ENC_ParamStruct; 543/* =================================================================================== */ 544/** 545 * G711ENC_UAlgOutBufParamStruct Output Buffer Param Structure 546 * ulFrameCount No.of Frames Encoded 547 */ 548/* =================================================================================== */ 549typedef struct { 550 unsigned long ulFrameCount; 551}G711ENC_UAlgOutBufParamStruct; 552 553/* =================================================================================== */ 554/** 555 * G711ENC_LCML_BUFHEADERTYPE Buffer Header Type 556 */ 557/* =================================================================================== */ 558typedef struct G711ENC_LCML_BUFHEADERTYPE { 559 G711ENC_BUFFER_Dir eDir; 560 G711ENC_ParamStruct *pIpParam; 561 G711ENC_UAlgOutBufParamStruct *pOpParam; 562 OMX_BUFFERHEADERTYPE* buffer; 563 G711ENC_FrameStruct *pFrameParam; 564 G711ENC_ParamStruct *pBufferParam; 565 DMM_BUFFER_OBJ* pDmmBuf; 566}G711ENC_LCML_BUFHEADERTYPE; 567 568typedef struct _G711ENC_BUFFERLIST G711ENC_BUFFERLIST; 569 570/* =================================================================================== */ 571/** 572 * _G711ENC_BUFFERLIST Structure for buffer list 573 */ 574/* ================================================================================== */ 575struct _G711ENC_BUFFERLIST{ 576 OMX_BUFFERHEADERTYPE sBufHdr; 577 OMX_BUFFERHEADERTYPE *pBufHdr[G711ENC_MAX_NUM_OF_BUFS]; 578 OMX_U32 bufferOwner[G711ENC_MAX_NUM_OF_BUFS]; 579 OMX_U32 bBufferPending[G711ENC_MAX_NUM_OF_BUFS]; 580 OMX_U32 numBuffers; 581 G711ENC_BUFFERLIST *pNextBuf; 582 G711ENC_BUFFERLIST *pPrevBuf; 583}; 584/* =================================================================================== */ 585/** 586 * G711ENC_BUFDATA 587 */ 588/* =================================================================================== */ 589typedef struct G711ENC_BUFDATA { 590 OMX_U8 nFrames; 591}G711ENC_BUFDATA; 592 593/* =================================================================================== */ 594/** 595 * G711ENC_PORT_TYPE Structure for PortFormat details 596 */ 597/* =================================================================================== */ 598typedef struct G711ENC_PORT_TYPE { 599 OMX_HANDLETYPE hTunnelComponent; 600 OMX_U32 nTunnelPort; 601 OMX_BUFFERSUPPLIERTYPE eSupplierSetting; 602 OMX_U8 nBufferCnt; 603 OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat; 604} G711ENC_PORT_TYPE; 605 606OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size, 607 void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf); 608OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr); 609/* =================================================================================== */ 610/** 611 * G711ENC_COMPONENT_PRIVATE Component private data Structure 612 */ 613/* =================================================================================== */ 614typedef struct G711ENC_COMPONENT_PRIVATE 615{ 616 /** Array of pointers to BUFFERHEADERTYPE structues 617 This pBufHeader[INPUT_PORT] will point to all the 618 BUFFERHEADERTYPE structures related to input port, 619 not just one structure. Same is the case for output 620 port also. */ 621 OMX_BUFFERHEADERTYPE* pBufHeader[G711ENC_NUM_OF_PORTS]; 622 OMX_CALLBACKTYPE cbInfo; 623 OMX_PORT_PARAM_TYPE* sPortParam; 624 OMX_PRIORITYMGMTTYPE* sPriorityMgmt; 625 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[G711ENC_NUM_OF_PORTS]; 626 OMX_PORT_PARAM_TYPE* pPortParamType; 627 OMX_AUDIO_PARAM_PCMMODETYPE* G711Params[G711ENC_NUM_OF_PORTS]; 628 G711ENC_BUFFERHEADERTYPE_INFO BufInfo[G711ENC_NUM_OF_PORTS]; 629 G711ENC_PORT_TYPE *pCompPort[G711ENC_NUM_OF_PORTS]; 630 G711ENC_LCML_BUFHEADERTYPE *pLcmlBufHeader[G711ENC_NUM_OF_PORTS]; 631 /** This is component handle */ 632 OMX_COMPONENTTYPE* pHandle; 633 /** Current state of this component */ 634 OMX_STATETYPE curState; 635 /** The component thread handle */ 636 pthread_t ComponentThread; 637 /** The pipes for sending buffers to the thread */ 638 int dataPipe[2]; 639 /** The pipes for sending command to the thread */ 640 int cmdPipe[2]; 641 /** The pipes for sending cmd data to the thread */ 642 int cmdDataPipe[2]; 643 644 OMX_U32 dasfMode; 645 646 OMX_U32 acdnMode; 647 648 OMX_U32 fdwrite; 649 650 OMX_U32 fdread; 651 652 OMX_U32 bLcmlHandleOpened; 653 654 /** Set to indicate component is stopping */ 655 OMX_U32 bIsEOFSent; 656 657 /** Count of number of buffers outstanding with bridge */ 658 OMX_U32 lcml_nIpBuf; 659 660 /** Count of number of buffers outstanding with bridge */ 661 OMX_U32 lcml_nOpBuf; 662 663 OMX_U32 app_nBuf; 664 665 OMX_U32 lcml_nCntIp; 666 667 OMX_U32 lcml_nCntOpReceived; 668 669 OMX_U32 lcml_nCntApp; 670 671 OMX_U32 lcml_compID; 672 673 OMX_U32 num_Reclaimed_Op_Buff; 674 675 OMX_U32 num_Sent_Ip_Buff; 676 677 OMX_U32 num_Op_Issued; 678 679 OMX_U32 streamID; 680 681 OMX_U32 bPortDefsAllocated; 682 683 OMX_U32 bCompThreadStarted; 684 685 OMX_U32 bBypassDSP; 686 687 OMX_U32 nVersion; 688 689 OMX_U32 nFillThisBufferCount; 690 691 OMX_U32 nFillBufferDoneCount; 692 693 OMX_U32 nEmptyThisBufferCount; 694 695 OMX_U32 nEmptyBufferDoneCount; 696 697 OMX_U32 bInitParamsInitialized; 698 699 OMX_U32 bIdleCommandPending; 700 701 OMX_U32 nNumInputBufPending; 702 703 OMX_U32 nNumOutputBufPending; 704 705 OMX_U32 nInvalidFrameCount; 706 707 OMX_U32 bDisableCommandPending; 708 709 OMX_U32 bDisableCommandParam; 710 711 OMX_U32 bEnableCommandParam; 712 713 /** Flag for frame size type mode */ 714 OMX_S16 fsizemode; 715 /** Flag for frame type */ 716 OMX_S16 frametype; 717 /** Flag for VAU mode */ 718 OMX_S16 vaumode; 719 /** Flag for VAU Threshold offset */ 720 OMX_S16 vauthreshold; 721 /** Flag for VAU number of ms */ 722 OMX_S16 vaunumber; 723 /** Flag for NMU TX Noise Mode */ 724 OMX_S16 nmunoise; 725 /** Flag for Linear Prediction order*/ 726 OMX_S16 lporder; 727 728 /**number of frames that has been sent*/ 729 OMX_U8 nNumOfFramesSent; 730 731 /** Buffers unhandled during fill this buffer call*/ 732 OMX_S8 nUnhandledFillThisBuffers; 733 OMX_S8 nUnhandledEmptyThisBuffers; 734 OMX_BOOL bFlushInputPortCommandPending; 735 OMX_BOOL bFlushOutputPortCommandPending; 736 737 /** Set to indicate component is stopping */ 738 OMX_U32 bIsStopping; 739 OMX_S8 ProcessingInputBuf; 740 OMX_S8 ProcessingOutputBuf; 741 742 /** Flag set when a disable command is pending */ 743 OMX_U32 bEnableCommandPending; 744 745 /** Parameter for pending disable command */ 746 OMX_U32 nEnableCommandParam; 747 748 OMX_HANDLETYPE pLcmlHandle; 749 750 OMX_PTR pMarkData; 751 752 OMX_MARKTYPE *pMarkBuf; 753 754 OMX_HANDLETYPE hMarkTargetComponent; 755 756 G711ENC_BUFFERLIST *pInputBufferList; 757 758 G711ENC_BUFFERLIST *pOutputBufferList; 759 760 LCML_STRMATTR *strmAttr; 761 762 G711ENC_TALGCtrl *pAlgParam; 763 764 G711ENC_AudioCodecParams *pParams; 765 766 OMX_STRING cComponentName; 767 768 OMX_VERSIONTYPE ComponentVersion; 769 770 OMX_BUFFERHEADERTYPE *pInputBufHdrPending[G711ENC_MAX_NUM_OF_BUFS]; 771 772 OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[G711ENC_MAX_NUM_OF_BUFS]; 773 774 TI_OMX_DSP_DEFINITION tiOmxDspDefinition; 775 776 /** Flag to set when socket node stop callback should not transition 777 component to OMX_StateIdle */ 778 OMX_U32 bNoIdleOnStop; 779 780 /** Flag set when socket node is stopped */ 781 OMX_U32 bDspStoppedWhileExecuting; 782 783 /** Number of outstanding FillBufferDone() calls */ 784 OMX_U32 nOutStandingFillDones; 785 786 OMX_BOOL bLoadedCommandPending; 787 788 OMX_PARAM_COMPONENTROLETYPE componentRole; 789 790 OMX_STRING* sDeviceString; 791 792 /* backup pointer for LCML */ 793 void* ptrLibLCML; 794 795 OMX_U32 bIsThreadstop; 796 797 /**Keep buffer tickcount*/ 798 OMX_U32 arrBufIndexTick[G711ENC_MAX_NUM_OF_BUFS]; 799 800 /** Keep buffer timestamps **/ 801 OMX_S64 arrBufIndex[G711ENC_MAX_NUM_OF_BUFS]; 802 803 /** Index to arrBufIndex[], used for input buffer timestamps */ 804 OMX_U8 IpBufindex; 805 806 /** Index to arrBufIndex[], used for output buffer timestamps */ 807 OMX_U8 OpBufindex; 808 809 /** Number of input buffers at runtime **/ 810 OMX_U32 nRuntimeInputBuffers; 811 812 /** Number of output buffers at runtime **/ 813 OMX_U32 nRuntimeOutputBuffers; 814 815 816 817#ifndef UNDER_CE 818 pthread_mutex_t AlloBuf_mutex; 819 pthread_cond_t AlloBuf_threshold; 820 OMX_U8 AlloBuf_waitingsignal; 821 822 pthread_mutex_t InIdle_mutex; 823 pthread_cond_t InIdle_threshold; 824 OMX_U8 InIdle_goingtoloaded; 825 826 pthread_mutex_t InLoaded_mutex; 827 pthread_cond_t InLoaded_threshold; 828 OMX_U8 InLoaded_readytoidle; 829#endif 830 831 OMX_BOOL bPreempted; 832 833 /** Pointer to RM callback **/ 834#ifdef RESOURCE_MANAGER_ENABLED 835 RMPROXY_CALLBACKTYPE rmproxyCallback; 836#endif 837 838} G711ENC_COMPONENT_PRIVATE; 839 840 841#ifndef UNDER_CE 842OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 843#else 844/* WinCE Implicit Export Syntax */ 845#define OMX_EXPORT __declspec(dllexport) 846/* =================================================================================== */ 847/** 848 * OMX_ComponentInit() Initializes component 849 * 850 * 851 * @param hComp OMX Handle 852 * 853 * @return OMX_ErrorNone = Successful 854 * Other error code = fail 855 * 856 */ 857/* =================================================================================== */ 858OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 859#endif 860/* =================================================================================== */ 861/** 862 * G711ENC_StartComponentThread() Starts component thread 863 * 864 * 865 * @param hComp OMX Handle 866 * 867 * @return OMX_ErrorNone = Successful 868 * Other error code = fail 869 * 870 */ 871/* =================================================================================== */ 872OMX_ERRORTYPE G711ENC_StartComponentThread(OMX_HANDLETYPE pHandle); 873/* =================================================================================== */ 874/** 875 * G711ENC_StopComponentThread() Stops component thread 876 * 877 * 878 * @param hComp OMX Handle 879 * 880 * @return OMX_ErrorNone = Successful 881 * Other error code = fail 882 * 883 */ 884/* =================================================================================== */ 885OMX_ERRORTYPE G711ENC_StopComponentThread(OMX_HANDLETYPE pHandle); 886/* =================================================================================== */ 887/** 888 * G711ENC_FreeCompResources() Frees allocated memory 889 * 890 * 891 * @param hComp OMX Handle 892 * 893 * @return OMX_ErrorNone = Successful 894 * Other error code = fail 895 * 896 */ 897/* =================================================================================== */ 898OMX_ERRORTYPE G711ENC_FreeCompResources(OMX_HANDLETYPE pComponent); 899/* =================================================================================== */ 900/** 901 * G711ENC_GetCorrespondingLCMLHeader() Returns LCML header 902 * that corresponds to the given buffer 903 * 904 * @param pComponentPrivate Component private data 905 * 906 * @return OMX_ErrorNone = Successful 907 * Other error code = fail 908 */ 909/* =================================================================================== */ 910OMX_ERRORTYPE G711ENC_GetCorrespondingLCMLHeader(G711ENC_COMPONENT_PRIVATE *pComponentPrivate, 911 OMX_U8 *pBuffer, 912 OMX_DIRTYPE eDir, 913 G711ENC_LCML_BUFHEADERTYPE **ppLcmlHdr); 914/* =================================================================================== */ 915/** 916 * G711ENC_LCMLCallback() Callback from LCML 917 * 918 * @param event Codec Event 919 * 920 * @param args Arguments from LCML 921 * 922 * @return OMX_ErrorNone = Successful 923 * Other error code = fail 924 */ 925/* =================================================================================== */ 926OMX_ERRORTYPE G711ENC_LCMLCallback(TUsnCodecEvent event, 927 void * args [10]); 928/* =================================================================================== */ 929/** 930 * G711ENC_FillLCMLInitParams() Fills the parameters needed 931 * to initialize the LCML 932 * 933 * @param pHandle OMX Handle 934 * 935 * @param plcml_Init LCML initialization parameters 936 * 937 * @return OMX_ErrorNone = Successful 938 * Other error code = fail 939 * 940 */ 941/* =================================================================================== */ 942OMX_ERRORTYPE G711ENC_FillLCMLInitParams(OMX_HANDLETYPE pHandle, 943 LCML_DSP *plcml_Init, 944 OMX_U16 arr[]); 945/* =================================================================================== */ 946/** 947 * G711ENC_GetBufferDirection() Returns direction of pBufHeader 948 * 949 * @param pBufHeader Buffer header 950 * 951 * @param eDir Buffer direction 952 * 953 * @param pComponentPrivate Component private data 954 * 955 * @return OMX_ErrorNone = Successful 956 * Other error code = fail 957 */ 958/* =================================================================================== */ 959OMX_ERRORTYPE G711ENC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, 960 OMX_DIRTYPE *eDir); 961/* =========================================================== */ 962/** 963 * G711ENC_HandleCommand() Handles commands sent via SendCommand() 964 * 965 * @param pComponentPrivate Component private data 966 * 967 * @return OMX_ErrorNone = Successful 968 * Other error code = fail 969 * @return OMX_ErrorNone = Successful 970 * Other error code = fail 971 */ 972/* =================================================================================== */ 973OMX_U32 G711ENC_HandleCommand(G711ENC_COMPONENT_PRIVATE *pComponentPrivate); 974/* =================================================================================== */ 975/** 976 * G711ENC_HandleDataBufFromApp() Handles data buffers received 977 * from the IL Client 978 * 979 * @param pComponentPrivate Component private data 980 * 981 * @return OMX_ErrorNone = Successful 982 * Other error code = fail 983 * @return OMX_ErrorNone = Successful 984 * Other error code = fail 985 */ 986/* =================================================================================== */ 987OMX_ERRORTYPE G711ENC_HandleDataBufFromApp(OMX_BUFFERHEADERTYPE *pBufHeader, 988 G711ENC_COMPONENT_PRIVATE *pComponentPrivate); 989/* =================================================================================== */ 990/** 991 * G711ENC_HandleDataBufFromLCML() Handles data buffers received 992 * from LCML 993 * 994 * @param pComponentPrivate Component private data 995 * 996 * @return OMX_ErrorNone = Successful 997 * Other error code = fail 998 * @return OMX_ErrorNone = Successful 999 * Other error code = fail 1000 */ 1001/* =================================================================================== */ 1002OMX_ERRORTYPE G711ENC_HandleDataBufFromLCML(G711ENC_COMPONENT_PRIVATE* pComponentPrivate, G711ENC_LCML_BUFHEADERTYPE* msgBuffer); 1003 1004/* =================================================================================== */ 1005/** 1006 * G711ENC_GetLCMLHandle() Get the handle to the LCML 1007 * 1008 * 1009 * @return OMX_ErrorNone = Successful 1010 * Other error code = fail 1011 */ 1012/* =================================================================================== */ 1013OMX_HANDLETYPE G711ENC_GetLCMLHandle(G711ENC_COMPONENT_PRIVATE *pComponentPrivate); 1014/* =================================================================================== */ 1015/** 1016 * G711ENC_FreeLCMLHandle() Frees the handle to the LCML 1017 * 1018 * 1019 * @return OMX_ErrorNone = Successful 1020 * Other error code = fail 1021 */ 1022/* =================================================================================== */ 1023OMX_ERRORTYPE G711ENC_FreeLCMLHandle(); 1024/* =================================================================================== */ 1025/** 1026 * G711ENC_CleanupInitParams() Starts component thread 1027 * 1028 * @param pComponent OMX Handle 1029 * 1030 * @return OMX_ErrorNone = Successful 1031 * Other error code = fail 1032 */ 1033/* =================================================================================== */ 1034OMX_ERRORTYPE G711ENC_CleanupInitParams(OMX_HANDLETYPE pHandle); 1035/* =================================================================================== */ 1036/** 1037 * G711ENC_SetPending() Called when the component queues a buffer 1038 * to the LCML 1039 * 1040 * @param pComponentPrivate Component private data 1041 * 1042 * @param pBufHdr Buffer header 1043 * 1044 * @param eDir Direction of the buffer 1045 * 1046 * @return None 1047 */ 1048/* =================================================================================== */ 1049void G711ENC_SetPending(G711ENC_COMPONENT_PRIVATE *pComponentPrivate, 1050 OMX_BUFFERHEADERTYPE *pBufHdr, 1051 OMX_DIRTYPE eDir, 1052 OMX_U32 lineNumber); 1053/* =================================================================================== */ 1054/** 1055 * G711ENC_ClearPending() Called when a buffer is returned 1056 * from the LCML 1057 * 1058 * @param pComponentPrivate Component private data 1059 * 1060 * @param pBufHdr Buffer header 1061 * 1062 * @param eDir Direction of the buffer 1063 * 1064 * @return None 1065 */ 1066/* =================================================================================== */ 1067void G711ENC_ClearPending(G711ENC_COMPONENT_PRIVATE *pComponentPrivate, 1068 OMX_BUFFERHEADERTYPE *pBufHdr, 1069 OMX_DIRTYPE eDir, 1070 OMX_U32 lineNumber); 1071/* =================================================================================== */ 1072/** 1073 * G711ENC_IsPending() 1074 * 1075 * 1076 * @param pComponentPrivate Component private data 1077 * 1078 * @return OMX_ErrorNone = Successful 1079 * Other error code = fail 1080 */ 1081/* =================================================================================== */ 1082OMX_U32 G711ENC_IsPending(G711ENC_COMPONENT_PRIVATE *pComponentPrivate, 1083 OMX_BUFFERHEADERTYPE *pBufHdr, 1084 OMX_DIRTYPE eDir); 1085/* =================================================================================== */ 1086/** 1087 * G711ENC_FillLCMLInitParamsEx() Fills the parameters needed 1088 * to initialize the LCML without recreating the socket node 1089 * 1090 * @param pComponent OMX Handle 1091 * 1092 * @return None 1093 */ 1094/* =================================================================================== */ 1095OMX_ERRORTYPE G711ENC_FillLCMLInitParamsEx(OMX_HANDLETYPE pComponent); 1096/* =================================================================================== */ 1097/** 1098 * G711ENC_IsValid() Returns whether a buffer is valid 1099 * 1100 * 1101 * @param pComponentPrivate Component private data 1102 * 1103 * @param pBuffer Data buffer 1104 * 1105 * @param eDir Buffer direction 1106 * 1107 * @return OMX_True = Valid 1108 * OMX_False= Invalid 1109 */ 1110/* =================================================================================== */ 1111OMX_U32 G711ENC_IsValid(G711ENC_COMPONENT_PRIVATE *pComponentPrivate, 1112 OMX_U8 *pBuffer, 1113 OMX_DIRTYPE eDir); 1114 1115 1116/* ======================================================================= */ 1117/** OMX_G711ENC_INDEXAUDIOTYPE Defines the custom configuration settings 1118 * for the component 1119 * 1120 * @param OMX_IndexCustomG711ENCModeConfig Sets the DASF mode 1121 * 1122 * 1123 */ 1124/* ==================================================================== */ 1125typedef enum OMX_G711ENC_INDEXAUDIOTYPE { 1126 OMX_IndexCustomG711ENCModeConfig = 0xFF000001, 1127 OMX_IndexCustomG711EncFrameParams, 1128 OMX_IndexCustomG711EncDataPath 1129}OMX_G711ENC_INDEXAUDIOTYPE; 1130 1131/* =========================================================== */ 1132/** 1133 * G711ENC_CompThread() Component Thread call 1134 * 1135 * 1136 * @param pComponentPrivate Component private data 1137 * 1138 * @return void 1139 */ 1140/*================================================================== */ 1141void* G711ENC_CompThread(void* pThreadData); 1142 1143#ifdef RESOURCE_MANAGER_ENABLED 1144/*********************************** 1145 * Callback to the RM * 1146 ***********************************/ 1147void G711ENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData); 1148#endif 1149 1150#endif /* OMX_G711ENC_UTILS__H */ 1151