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_AmrEnc_Utils.h 30* 31* This is an header file for an NBAMR 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\nbamr_enc\inc 36* 37* @rev 1.0 38*/ 39/* --------------------------------------------------------------------------- */ 40/* ---------------------------------------------------------------------------- 41*! 42*! Revision History 43*! =================================== 44*! 21-sept-2006 bk: updated review findings for alpha release 45*! 24-Aug-2006 bk: Khronos OpenMAX (TM) 1.0 Conformance tests some more 46*! 18-July-2006 bk: Khronos OpenMAX (TM) 1.0 Conformance tests validated for few cases 47*! 21-Jun-2006 bk: Khronos OpenMAX (TM) 1.0 migration done 48*! 22-May-2006 bk: DASF recording quality improved 49*! 19-Apr-2006 bk: DASF recording speed issue resloved 50*! 23-Feb-2006 bk: DASF functionality added 51*! 18-Jan-2006 bk: Repated recording issue fixed and LCML changes taken care 52*! 14-Dec-2005 bk: Initial Version 53*! 16-Nov-2005 bk: Initial Version 54*! 23-Sept-2005 bk: Initial Version 55*! 10-Sept-2005 bk: Initial Version 56*! 10-Sept-2005 bk: 57*! This is newest file 58* =========================================================================== */ 59#ifndef OMX_AMRENC_UTILS__H 60#define OMX_AMRENC_UTILS__H 61 62#include <pthread.h> 63#include "LCML_DspCodec.h" 64#include <OMX_Component.h> 65#include "OMX_TI_Common.h" 66#include "OMX_TI_Debug.h" 67#include <TIDspOmx.h> 68 69#ifdef RESOURCE_MANAGER_ENABLED 70#include <ResourceManagerProxyAPI.h> 71#endif 72 73#ifdef __PERF_INSTRUMENTATION__ 74 #include "perf.h" 75#endif 76 77#ifdef DSP_RENDERING_ON 78 #include <AudioManagerAPI.h> 79#endif 80 81#ifdef UNDER_CE 82 #define sleep Sleep 83#endif 84 85#ifndef ANDROID 86 #define ANDROID 87#endif 88 89#ifdef ANDROID 90 #undef LOG_TAG 91 #define LOG_TAG "OMX_NBAMRENC" 92// #define LOG_TAG "nbamr_enc" 93 /* PV opencore capability custom parameter index */ 94 #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347 95#endif 96 97/* ======================================================================= */ 98/** 99 * @def AMRENC_DEBUG Turns debug messaging on and off 100 */ 101/* ======================================================================= */ 102#define AMRENC_DEBUG 103/* ======================================================================= */ 104/** 105 * @def AMRENC_MEMCHECK Turns memory messaging on and off 106 */ 107/* ======================================================================= */ 108#undef AMRENC_MEMCHECK 109 110/* ======================================================================= */ 111/** 112 * @def NBAMRENC_DEBUGMEM Turns memory leaks messaging on and off. 113 * APP_DEBUGMEM must be defined in Test App in order to get 114 * this functionality On. 115 */ 116/* ======================================================================= */ 117#undef NBAMRENC_DEBUGMEM 118 119/* ======================================================================= */ 120/** 121 * @def AMRENC_EPRINT Error print macro 122 */ 123/* ======================================================================= */ 124#ifndef UNDER_CE 125 #ifdef ANDROID 126 #define AMRENC_EPRINT ALOGE 127 #else 128 #define AMRENC_EPRINT(...) fprintf(stderr,__VA_ARGS__) 129 #endif 130#else 131 #define AMRENC_EPRINT 132#endif 133 134 135 136/* ======================================================================= */ 137/** 138 * @def AMRENC_DEBUG Debug print macro 139 */ 140/* ======================================================================= */ 141#ifndef UNDER_CE 142 143#ifdef AMRENC_DEBUG 144 #define AMRENC_DPRINT(...) fprintf(stderr,__VA_ARGS__) 145 146 #ifdef ANDROID 147 #undef AMRENC_DPRINT 148 #define AMRENC_DPRINT ALOGW 149 #endif 150 151#else 152 #define AMRENC_DPRINT(...) 153#endif 154 155 156/* ======================================================================= */ 157/** 158 * @def AMRENC_MEMCHECK Memory print macro 159 */ 160/* ======================================================================= */ 161#ifdef AMRENC_MEMCHECK 162 #define AMRENC_MEMPRINT(...) fprintf(stderr,__VA_ARGS__) 163 164 #ifdef ANDROID 165 #undef AMRENC_MEMPRINT 166 #define AMRENC_MEMPRINT ALOGW 167 #endif 168 169#else 170 #define AMRENC_MEMPRINT(...) printf 171#endif 172 173#else /*UNDER_CE*/ 174/* ======================================================================= */ 175/** 176 * @def AMRENC_DEBUG Debug print macro 177 */ 178/* ======================================================================= */ 179#ifdef AMRENC_DEBUG 180 #define AMRENC_DPRINT(STR, ARG...) printf() 181#else 182 183#endif 184/* ======================================================================= */ 185/** 186 * @def AMRENC_MEMCHECK Memory print macro 187 */ 188/* ======================================================================= */ 189#ifdef AMRENC_MEMCHECK 190 #define AMRENC_MEMPRINT(STR, ARG...) printf() 191#else 192 193#endif 194 195#ifdef UNDER_CE 196 197#ifdef DEBUG 198 #ifdef ANDROID 199 #define AMRENC_DPRINT ALOGW 200 #define AMRENC_MEMPRINT ALOGW 201 #else 202 #define AMRENC_DPRINT printf 203 #define AMRENC_MEMPRINT printf 204 #endif 205#else 206 #define AMRENC_DPRINT 207 #define AMRENC_MEMPRINT 208#endif 209 210#endif /*UNDER_CE*/ 211 212#endif 213 214/* ======================================================================= */ 215/** 216 * M A C R O S FOR MALLOC and MEMORY FREE and CLOSING PIPES 217 */ 218/* ======================================================================= */ 219 220#define OMX_NBCONF_INIT_STRUCT(_s_, _name_) \ 221 memset((_s_), 0x0, sizeof(_name_)); \ 222 (_s_)->nSize = sizeof(_name_); \ 223 (_s_)->nVersion.s.nVersionMajor = 0x1; \ 224 (_s_)->nVersion.s.nVersionMinor = 0x0; \ 225 (_s_)->nVersion.s.nRevision = 0x0; \ 226 (_s_)->nVersion.s.nStep = 0x0 227 228#define OMX_NBCLOSE_PIPE(_pStruct_,err)\ 229 OMXDBG_PRINT(stderr, COMM, 2, OMX_DBG_BASEMASK, "%d :: CLOSING PIPE \n",__LINE__); \ 230 err = close (_pStruct_);\ 231 if(0 != err && OMX_ErrorNone == eError){\ 232 eError = OMX_ErrorHardware;\ 233 OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d :: Error while closing pipe\n",__LINE__);\ 234 goto EXIT;\ 235 } 236 237#define NBAMRENC_OMX_ERROR_EXIT(_e_, _c_, _s_)\ 238 _e_ = _c_;\ 239 OMXDBG_PRINT(stderr, ERROR, 4, 0, "\n**************** OMX ERROR ************************\n");\ 240 OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d : Error Name: %s : Error Num = %x",__LINE__, _s_, _e_);\ 241 OMXDBG_PRINT(stderr, ERROR, 4, 0, "\n**************** OMX ERROR ************************\n");\ 242 goto EXIT; 243 244/* ======================================================================= */ 245/** 246 * @def NBAMRENC_NUM_INPUT_BUFFERS Default number of input buffers 247 */ 248/* ======================================================================= */ 249#define NBAMRENC_NUM_INPUT_BUFFERS 1 250/* ======================================================================= */ 251/** 252 * @def NBAMRENC_NUM_INPUT_BUFFERS_DASF Default No.of input buffers DASF 253 */ 254/* ======================================================================= */ 255#define NBAMRENC_NUM_INPUT_BUFFERS_DASF 2 256/* ======================================================================= */ 257/** 258 * @def NBAMRENC_NUM_OUTPUT_BUFFERS Default number of output buffers 259 */ 260/* ======================================================================= */ 261#define NBAMRENC_NUM_OUTPUT_BUFFERS 1 262/* ======================================================================= */ 263/** 264 * @def NBAMRENC_INPUT_BUFFER_SIZE Default input buffer size 265 * NBAMRENC_INPUT_BUFFER_SIZE_DASF Default input buffer size DASF 266 * NBAMRENC_INPUT_FRAME_SIZE Default input Frame Size 267 */ 268/* ======================================================================= */ 269#define NBAMRENC_INPUT_BUFFER_SIZE 320 270#define NBAMRENC_INPUT_BUFFER_SIZE_DASF 320 271#define NBAMRENC_INPUT_FRAME_SIZE 320 272/* ======================================================================= */ 273/** 274 * @def NBAMRENC_OUTPUT_BUFFER_SIZE Default output buffer size 275 * NBAMRENC_OUTPUT_FRAME_SIZE Default output frame size 276 */ 277/* ======================================================================= */ 278#define NBAMRENC_OUTPUT_BUFFER_SIZE 118 279#define NBAMRENC_OUTPUT_FRAME_SIZE 118 280/* ======================================================================= */ 281/** 282 * @def NBAMRENC_OUTPUT_BUFFER_SIZE_MIME Default input buffer size MIME 283 */ 284/* ======================================================================= */ 285#define NBAMRENC_OUTPUT_BUFFER_SIZE_MIME 34 286 287/* ======================================================================= */ 288/** 289 * @def NBAMRENC_OUTPUT_BUFFER_SIZE_MIME Default input buffer size IF2 290 */ 291/* ======================================================================= */ 292#define NBAMRENC_OUTPUT_BUFFER_SIZE_IF2 32 293 294/* ======================================================================= */ 295/** 296 * @def NBAMRENC_OUTPUT_BUFFER_SIZE_EFR Default input buffer size EFR 297 */ 298/* ======================================================================= */ 299#define NBAMRENC_OUTPUT_BUFFER_SIZE_EFR 120 300 301/* ======================================================================= */ 302/* 303 * @def NBAMRENC_APP_ID App ID Value setting 304 */ 305/* ======================================================================= */ 306#define NBAMRENC_APP_ID 100 307 308/* ======================================================================= */ 309/** 310 * @def NBAMRENC_SAMPLING_FREQUENCY Sampling frequency 311 */ 312/* ======================================================================= */ 313#define NBAMRENC_SAMPLING_FREQUENCY 8000 314/* ======================================================================= */ 315/** 316 * @def NBAMRENC_CPU_LOAD CPU Load in MHz 317 */ 318/* ======================================================================= */ 319#define NBAMRENC_CPU_LOAD 12 320/* ======================================================================= */ 321/** 322 * @def NBAMRENC_MAX_NUM_OF_BUFS Maximum number of buffers 323 */ 324/* ======================================================================= */ 325#define NBAMRENC_MAX_NUM_OF_BUFS 15 326/* ======================================================================= */ 327/** 328 * @def NBAMRENC_NUM_OF_PORTS Number of ports 329 */ 330/* ======================================================================= */ 331#define NBAMRENC_NUM_OF_PORTS 2 332/* ======================================================================= */ 333/** 334 * @def NBAMRENC_XXX_VER Component version 335 */ 336/* ======================================================================= */ 337#define NBAMRENC_MAJOR_VER 0x1 338#define NBAMRENC_MINOR_VER 0x1 339/* ======================================================================= */ 340/** 341 * @def NBAMRENC_NOT_USED Defines a value for "don't care" parameters 342 */ 343/* ======================================================================= */ 344#define NBAMRENC_NOT_USED 10 345/* ======================================================================= */ 346/** 347 * @def NBAMRENC_NORMAL_BUFFER Defines flag value with all flags off 348 */ 349/* ======================================================================= */ 350#define NBAMRENC_NORMAL_BUFFER 0 351/* ======================================================================= */ 352/** 353 * @def OMX_NBAMRENC_DEFAULT_SEGMENT Default segment ID for the LCML 354 */ 355/* ======================================================================= */ 356#define NBAMRENC_DEFAULT_SEGMENT (0) 357/* ======================================================================= */ 358/** 359 * @def OMX_NBAMRENC_SN_TIMEOUT Timeout value for the socket node 360 */ 361/* ======================================================================= */ 362#define NBAMRENC_SN_TIMEOUT (-1) 363/* ======================================================================= */ 364/** 365 * @def OMX_NBAMRENC_SN_PRIORITY Priority for the socket node 366 */ 367/* ======================================================================= */ 368#define NBAMRENC_SN_PRIORITY (10) 369/* ======================================================================= */ 370/** 371 * @def OMX_NBAMRENC_NUM_DLLS number of DLL's 372 */ 373/* ======================================================================= */ 374#define NBAMRENC_NUM_DLLS (2) 375/* ======================================================================= */ 376/** 377 * @def NBAMRENC_USN_DLL_NAME USN DLL name 378 */ 379/* ======================================================================= */ 380#ifdef UNDER_CE 381 #define NBAMRENC_USN_DLL_NAME "\\windows\\usn.dll64P" 382#else 383 #define NBAMRENC_USN_DLL_NAME "usn.dll64P" 384#endif 385 386/* ======================================================================= */ 387/** 388 * @def NBAMRENC_DLL_NAME NBAMR Encoder socket node dll name 389 */ 390/* ======================================================================= */ 391#ifdef UNDER_CE 392 #define NBAMRENC_DLL_NAME "\\windows\\nbamrenc_sn.dll64P" 393#else 394 #define NBAMRENC_DLL_NAME "nbamrenc_sn.dll64P" 395#endif 396 397/* ======================================================================= */ 398/** NBAMRENC_StreamType Stream types 399* 400* @param NBAMRENC_DMM DMM 401* 402* @param NBAMRENC_INSTRM Input stream 403* 404* @param NBAMRENC_OUTSTRM Output stream 405*/ 406/* ======================================================================= */ 407enum NBAMRENC_StreamType { 408 NBAMRENC_DMM = 0, 409 NBAMRENC_INSTRM, 410 NBAMRENC_OUTSTRM 411}; 412/* ======================================================================= */ 413/** NBAMRENC_EncodeType coding types 414* 415* @param NBAMRENC_NBAMR NBAMR mode 416* 417* @param NBAMRENC_EFR EFR mode 418* 419*/ 420/* ======================================================================= */ 421enum NBAMRENC_EncodeType { 422 NBAMRENC_NBAMR = 0, 423 NBAMRENC_EFR 424}; 425/* ======================================================================= */ 426/** NBAMRENC_MimeMode format types 427* 428* @param NBAMRENC_MIMEMODE MIME 429* 430* @param NBAMRENC_FORMATCONFORMANCE NBAMR mode 431* 432* @param NBAMRENC_IF2 IF2 433* 434*/ 435/* ======================================================================= */ 436enum NBAMRENC_MimeMode { 437 NBAMRENC_FORMATCONFORMANCE = 0, 438 NBAMRENC_MIMEMODE, 439 NBAMRENC_IF2 440}; 441 442/* ======================================================================= */ 443/* 444 * Different Frame sizes for different index in MIME Mode 445 */ 446/* ======================================================================= */ 447#define NBAMRENC_FRAME_SIZE_0 0 448#define NBAMRENC_FRAME_SIZE_1 1 449#define NBAMRENC_FRAME_SIZE_6 6 450#define NBAMRENC_FRAME_SIZE_13 13 451#define NBAMRENC_FRAME_SIZE_14 14 452#define NBAMRENC_FRAME_SIZE_16 16 453#define NBAMRENC_FRAME_SIZE_18 18 454#define NBAMRENC_FRAME_SIZE_19 19 455#define NBAMRENC_FRAME_SIZE_20 20 456#define NBAMRENC_FRAME_SIZE_21 21 457#define NBAMRENC_FRAME_SIZE_26 26 458#define NBAMRENC_FRAME_SIZE_27 27 459#define NBAMRENC_FRAME_SIZE_31 31 460#define NBAMRENC_FRAME_SIZE_32 32 461 462 463 464/* ======================================================================= */ 465/** 466 * @def NBAMRENC_TIMEOUT Default timeout used to come out of blocking calls 467 */ 468/* ======================================================================= */ 469#define NBAMRENC_TIMEOUT 1000 470/* ======================================================================= */ 471/* 472 * @def NBAMRENC_OMX_MAX_TIMEOUTS Max Time Outs 473 * @def NBAMRENC_DONT_CARE Dont Care Condition 474 * @def NBAMRENC_NUM_CHANNELS Number of Channels 475 * @def NBAMRENC_APP_ID App ID Value setting 476 */ 477/* ======================================================================= */ 478#define NBAMRENC_OMX_MAX_TIMEOUTS 20 479#define NBAMRENC_DONT_CARE 0 480#define NBAMRENC_NUM_CHANNELS 1 481/* ======================================================================= */ 482/** 483 * @def NBAMRENC_STREAM_COUNT Number of streams 484 * NBAMRENC_INPUT_STREAM_ID Stream ID for Input Buffer 485 */ 486/* ======================================================================= */ 487#define NBAMRENC_STREAM_COUNT 2 488#define NBAMRENC_INPUT_STREAM_ID 0 489 490/* ======================================================================= */ 491/** 492 * @def _ERROR_PROPAGATION__ Allow Logic to Detec&Report Arm Errors 493 */ 494/* ======================================================================= */ 495#define _ERROR_PROPAGATION__ 496 497 498typedef struct PV_OMXComponentCapabilityFlagsType 499{ 500 ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability) 501 OMX_BOOL iIsOMXComponentMultiThreaded; 502 OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc; 503 OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc; 504 OMX_BOOL iOMXComponentSupportsMovableInputBuffers; 505 OMX_BOOL iOMXComponentSupportsPartialFrames; 506 OMX_BOOL iOMXComponentNeedsNALStartCode; 507 OMX_BOOL iOMXComponentCanHandleIncompleteFrames; 508} PV_OMXComponentCapabilityFlagsType; 509/* ======================================================================= */ 510/** NBAMRENC_COMP_PORT_TYPE Port types 511 * 512 * @param NBAMRENC_INPUT_PORT Input port 513 * 514 * @param NBAMRENC_OUTPUT_PORT Output port 515 */ 516/* ====================================================================== */ 517/*This enum must not be changed. */ 518typedef enum NBAMRENC_COMP_PORT_TYPE { 519 NBAMRENC_INPUT_PORT = 0, 520 NBAMRENC_OUTPUT_PORT 521}NBAMRENC_COMP_PORT_TYPE; 522 523/* ======================================================================= */ 524/** NBAMRENC_BUFFER_Dir Buffer Direction 525* 526* @param NBAMRENC_DIRECTION_INPUT Input direction 527* 528* @param NBAMRENC_DIRECTION_OUTPUT Output direction 529* 530*/ 531/* ======================================================================= */ 532typedef enum { 533 NBAMRENC_DIRECTION_INPUT, 534 NBAMRENC_DIRECTION_OUTPUT 535}NBAMRENC_BUFFER_Dir; 536 537/* ======================================================================= */ 538/** AUDIO_SN_AMRBANDMODETYPE BitRate Enum on the format used by 539* the SN 540* @param SN_AUDIO_BR_X 541*/ 542/* ======================================================================= */ 543typedef enum AUDIO_SN_AMRBANDMODETYPE { 544 SN_AUDIO_BR122 = 0, 545 SN_AUDIO_BR102, 546 SN_AUDIO_BR795, 547 SN_AUDIO_BR74, 548 SN_AUDIO_BR67, 549 SN_AUDIO_BR59, 550 SN_AUDIO_BR515, 551 SN_AUDIO_475, 552 SN_AUDIO_AMRBandModeMax = 0x7FFFFFFF 553}AUDIO_SN_AMRBANDMODETYPE; 554 555/* ======================================================================= */ 556/** NBAMRENC_BUFFS Buffer details 557* 558* @param BufHeader Buffer header 559* 560* @param Buffer Buffer 561* 562*/ 563/* ======================================================================= */ 564typedef struct NBAMRENC_BUFFS { 565 char BufHeader; 566 char Buffer; 567}NBAMRENC_BUFFS; 568 569/* ======================================================================= */ 570/** NBAMRENC_BUFFERHEADERTYPE_INFO 571* 572* @param pBufHeader 573* 574* @param bBufOwner 575* 576*/ 577/* ======================================================================= */ 578typedef struct NBAMRENC_BUFFERHEADERTYPE_INFO { 579 OMX_BUFFERHEADERTYPE* pBufHeader[NBAMRENC_MAX_NUM_OF_BUFS]; 580 NBAMRENC_BUFFS bBufOwner[NBAMRENC_MAX_NUM_OF_BUFS]; 581}NBAMRENC_BUFFERHEADERTYPE_INFO; 582 583 584typedef OMX_ERRORTYPE (*NBAMRENC_fpo)(OMX_HANDLETYPE); 585 586/* =================================================================================== */ 587/** 588* Socket node Audio Codec Configuration parameters. 589*/ 590/* =================================================================================== */ 591typedef struct NBAMRENC_AudioCodecParams { 592 unsigned long iSamplingRate; 593 unsigned long iStrmId; 594 unsigned short iAudioFormat; 595}NBAMRENC_AudioCodecParams; 596 597/* =================================================================================== */ 598/** 599* NBAMRENC_TALGCtrl Socket Node Alg Control parameters. 600* NBAMRENC_TALGCtrlDTX Socket Node Alg Control parameters (DTX). 601* NBAMRENC_UAlgInBufParamStruct Input Buffer Param Structure 602* NBAMRENC_UAlgOutBufParamStruct Output Buffer Param Structure 603*/ 604/* =================================================================================== */ 605/* Algorithm specific command parameters */ 606typedef struct { 607 int iSize; 608 unsigned int iBitrate; 609 610}NBAMRENC_TALGCtrl; 611 612typedef struct { 613 int iSize; 614 unsigned int iVADFlag; 615 616}NBAMRENC_TALGCtrlDTX; 617/* =================================================================================== */ 618/** 619* NBAMRENC_UAlgInBufParamStruct Input Buffer Param Structure 620* usLastFrame To Send Last Buufer Flag 621*/ 622/* =================================================================================== */ 623typedef struct { 624 unsigned long int usLastFrame; 625}NBAMRENC_FrameStruct; 626 627typedef struct{ 628 unsigned long int usNbFrames; 629 NBAMRENC_FrameStruct *pParamElem; 630}NBAMRENC_ParamStruct; 631 632/* =================================================================================== */ 633/** 634* NBAMRENC_LCML_BUFHEADERTYPE Buffer Header Type 635*/ 636/* =================================================================================== */ 637typedef struct NBAMRENC_LCML_BUFHEADERTYPE { 638 NBAMRENC_BUFFER_Dir eDir; 639 NBAMRENC_FrameStruct *pFrameParam; 640 NBAMRENC_ParamStruct *pBufferParam; 641 DMM_BUFFER_OBJ* pDmmBuf; 642 OMX_BUFFERHEADERTYPE* buffer; 643}NBAMRENC_LCML_BUFHEADERTYPE; 644 645typedef struct _NBAMRENC_BUFFERLIST NBAMRENC_BUFFERLIST; 646 647/* =================================================================================== */ 648/** 649* _NBAMRENC_BUFFERLIST Structure for buffer list 650*/ 651/* ================================================================================== */ 652struct _NBAMRENC_BUFFERLIST{ 653 OMX_BUFFERHEADERTYPE sBufHdr; 654 OMX_BUFFERHEADERTYPE *pBufHdr[NBAMRENC_MAX_NUM_OF_BUFS]; 655 OMX_U32 bufferOwner[NBAMRENC_MAX_NUM_OF_BUFS]; 656 OMX_U32 bBufferPending[NBAMRENC_MAX_NUM_OF_BUFS]; 657 OMX_U16 numBuffers; 658 NBAMRENC_BUFFERLIST *pNextBuf; 659 NBAMRENC_BUFFERLIST *pPrevBuf; 660}; 661 662/* =================================================================================== */ 663/** 664* NBAMRENC_PORT_TYPE Structure for PortFormat details 665*/ 666/* =================================================================================== */ 667typedef struct NBAMRENC_PORT_TYPE { 668 OMX_HANDLETYPE hTunnelComponent; 669 OMX_U32 nTunnelPort; 670 OMX_BUFFERSUPPLIERTYPE eSupplierSetting; 671 OMX_U8 nBufferCnt; 672 OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat; 673} NBAMRENC_PORT_TYPE; 674 675#ifdef UNDER_CE 676 #ifndef _OMX_EVENT_ 677 #define _OMX_EVENT_ 678 typedef struct OMX_Event { 679 HANDLE event; 680 } OMX_Event; 681 #endif 682 int OMX_CreateEvent(OMX_Event *event); 683 int OMX_SignalEvent(OMX_Event *event); 684 int OMX_WaitForEvent(OMX_Event *event); 685 int OMX_DestroyEvent(OMX_Event *event); 686#endif 687 688/* =================================================================================== */ 689/** 690* NBAMRENC_BUFDATA 691*/ 692/* =================================================================================== */ 693typedef struct NBAMRENC_BUFDATA { 694 OMX_U8 nFrames; 695}NBAMRENC_BUFDATA; 696 697/* =================================================================================== */ 698/** 699* AMRENC_COMPONENT_PRIVATE Component private data Structure 700*/ 701/* =================================================================================== */ 702typedef struct AMRENC_COMPONENT_PRIVATE 703{ 704 /** Array of pointers to BUFFERHEADERTYPE structues 705 This pBufHeader[INPUT_PORT] will point to all the 706 BUFFERHEADERTYPE structures related to input port, 707 not just one structure. Same is the case for output 708 port also. */ 709 OMX_BUFFERHEADERTYPE* pBufHeader[NBAMRENC_NUM_OF_PORTS]; 710 OMX_U32 nRuntimeInputBuffers; 711 712 OMX_U32 nRuntimeOutputBuffers; 713 OMX_CALLBACKTYPE cbInfo; 714 OMX_PORT_PARAM_TYPE* sPortParam; 715 OMX_PRIORITYMGMTTYPE* sPriorityMgmt; 716 717#ifdef RESOURCE_MANAGER_ENABLED 718 RMPROXY_CALLBACKTYPE rmproxyCallback; 719#endif 720 721 OMX_BOOL bPreempted; 722 723 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NBAMRENC_NUM_OF_PORTS]; 724 OMX_PORT_PARAM_TYPE* pPortParamType; 725 OMX_AUDIO_PARAM_AMRTYPE* amrParams; 726 OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams; 727 NBAMRENC_BUFFERHEADERTYPE_INFO BufInfo[NBAMRENC_NUM_OF_PORTS]; 728 NBAMRENC_PORT_TYPE *pCompPort[NBAMRENC_NUM_OF_PORTS]; 729 NBAMRENC_LCML_BUFHEADERTYPE *pLcmlBufHeader[NBAMRENC_NUM_OF_PORTS]; 730 /** This is component handle */ 731 OMX_COMPONENTTYPE* pHandle; 732 /** Current state of this component */ 733 OMX_STATETYPE curState; 734 /** The component thread handle */ 735 pthread_t ComponentThread; 736 /** The pipes for sending buffers to the thread */ 737 int dataPipe[2]; 738 /** The pipes for sending command to the thread */ 739 int cmdPipe[2]; 740 /** The pipes for sending cmd data to the thread */ 741 int cmdDataPipe[2]; 742 743 OMX_U32 efrMode; 744 745 OMX_U32 amrMode; 746 747 OMX_U32 dasfMode; 748 749 OMX_U32 frameMode; 750 751 OMX_U32 acdnMode; 752 753 OMX_U32 nMultiFrameMode; 754 755 OMX_S32 fdwrite; 756 757 OMX_S32 fdread; 758 759 /** Set to indicate component is stopping */ 760 OMX_U32 bIsStopping; 761 762 OMX_U32 bIsThreadstop; 763 764 /** Count of number of buffers outstanding with bridge */ 765 OMX_U32 lcml_nIpBuf; 766 767 /** Count of number of buffers outstanding with bridge */ 768 OMX_U32 lcml_nOpBuf; 769 770 OMX_U32 app_nBuf; 771 772 OMX_U32 num_Op_Issued; 773 774 OMX_U32 streamID; 775 776 OMX_U32 bCompThreadStarted; 777 778 OMX_U32 nVersion; 779 780 OMX_U32 amrMimeBytes[16]; 781 782 OMX_U32 amrIf2Bytes[16]; 783 784 OMX_U32 iHoldLen; 785 786 OMX_U32 nHoldLength; 787 788 OMX_U32 nFillThisBufferCount; 789 790 OMX_U32 nFillBufferDoneCount; 791 792 OMX_U32 nEmptyThisBufferCount; 793 794 OMX_U32 nEmptyBufferDoneCount; 795 796 OMX_U32 bInitParamsInitialized; 797 798 OMX_U32 nNumInputBufPending; 799 800 OMX_U32 nNumOutputBufPending; 801 802 OMX_U32 bDisableCommandPending; 803 804 OMX_U32 bEnableCommandPending; 805 806 OMX_U32 bDisableCommandParam; 807 808 OMX_U32 bEnableCommandParam; 809 810 OMX_HANDLETYPE pLcmlHandle; 811 812 OMX_PTR pMarkData; 813 814 OMX_MARKTYPE *pMarkBuf; 815 816 OMX_HANDLETYPE hMarkTargetComponent; 817 818 NBAMRENC_BUFFERLIST *pInputBufferList; 819 820 NBAMRENC_BUFFERLIST *pOutputBufferList; 821 822 LCML_STRMATTR *strmAttr; 823 824 NBAMRENC_TALGCtrl *pAlgParam; 825 826 NBAMRENC_TALGCtrlDTX *pAlgParamDTX; 827 828 NBAMRENC_AudioCodecParams *pParams; 829 830 OMX_STRING cComponentName; 831 832 OMX_VERSIONTYPE ComponentVersion; 833 834 OMX_BUFFERHEADERTYPE *pInputBufHdrPending[NBAMRENC_MAX_NUM_OF_BUFS]; 835 836 OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[NBAMRENC_MAX_NUM_OF_BUFS]; 837 838 OMX_BUFFERHEADERTYPE *iMMFDataLastBuffer; 839 840 OMX_U8 *pHoldBuffer,*pHoldBuffer2; 841 842 OMX_U8* iHoldBuffer; 843 844 845 /** Flag to set when socket node stop callback should not transition 846 component to OMX_StateIdle */ 847 OMX_U32 bNoIdleOnStop; 848 849 /** Flag set when socket node is stopped */ 850 OMX_U32 bDspStoppedWhileExecuting; 851 852 /** Number of outstanding FillBufferDone() calls */ 853 OMX_S32 nOutStandingFillDones; 854 OMX_S32 nOutStandingEmptyDones; 855 856#ifndef UNDER_CE 857 pthread_mutex_t AlloBuf_mutex; 858 pthread_cond_t AlloBuf_threshold; 859 OMX_U8 AlloBuf_waitingsignal; 860 861 pthread_mutex_t codecStop_mutex; 862 pthread_cond_t codecStop_threshold; 863 OMX_U8 codecStop_waitingsignal; 864 865 pthread_mutex_t InLoaded_mutex; 866 pthread_cond_t InLoaded_threshold; 867 OMX_U8 InLoaded_readytoidle; 868 869 pthread_mutex_t InIdle_mutex; 870 pthread_cond_t InIdle_threshold; 871 OMX_U8 InIdle_goingtoloaded; 872 873 OMX_U8 nUnhandledFillThisBuffers; 874 OMX_U8 nUnhandledEmptyThisBuffers; 875 OMX_BOOL bFlushOutputPortCommandPending; 876 OMX_BOOL bFlushInputPortCommandPending; 877 878 pthread_mutex_t ToLoaded_mutex; 879#else 880 OMX_Event AlloBuf_event; 881 OMX_U8 AlloBuf_waitingsignal; 882 883 OMX_Event InLoaded_event; 884 OMX_U8 InLoaded_readytoidle; 885 886 OMX_Event InIdle_event; 887 OMX_U8 InIdle_goingtoloaded; 888#endif 889 890 OMX_U8 nNumOfFramesSent; 891 892 OMX_U8 InBuf_Eos_alreadysent; 893 894 OMX_U8 PendingPausedBufs; 895 OMX_BUFFERHEADERTYPE *pOutputBufHdrPausedPending[NBAMRENC_MAX_NUM_OF_BUFS]; 896 897#ifdef __PERF_INSTRUMENTATION__ 898 PERF_OBJHANDLE pPERF, pPERFcomp; 899 OMX_U32 nLcml_nCntIp; 900 OMX_U32 nLcml_nCntOpReceived; 901#endif 902 OMX_BUFFERHEADERTYPE *LastOutbuf; 903 OMX_BOOL bIsInvalidState; 904 905 OMX_STRING* sDeviceString; 906 907 void* ptrLibLCML; 908 909 /** Circular array to keep buffer timestamps */ 910 OMX_S64 arrBufIndex[NBAMRENC_MAX_NUM_OF_BUFS]; 911 /** Circular array to keep buffer nTickCounts */ 912 OMX_S64 arrTickCount[NBAMRENC_MAX_NUM_OF_BUFS]; 913 /** Index to arrBufIndex[], used for input buffer timestamps */ 914 OMX_U8 IpBufindex; 915 /** Index to arrBufIndex[], used for output buffer timestamps */ 916 OMX_U8 OpBufindex; 917 OMX_TICKS TimeStamp; 918 OMX_BOOL bFirstInputBufReceived; 919 920 OMX_S8 ProcessingInputBuf; 921 OMX_S8 ProcessingOutputBuf; 922 923 OMX_BOOL bLoadedCommandPending; 924 OMX_BOOL bLoadedWaitingFreeBuffers; 925 926 OMX_PARAM_COMPONENTROLETYPE componentRole; 927 OMX_U32 teeMode; 928 PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags; 929 930 struct OMX_TI_Debug dbg; 931 932 /* Reference count for pending state change requests */ 933 OMX_U32 nPendingStateChangeRequests; 934 pthread_mutex_t mutexStateChangeRequest; 935 pthread_cond_t StateChangeCondition; 936} AMRENC_COMPONENT_PRIVATE; 937 938 939#ifndef UNDER_CE 940 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 941#else 942/* WinCE Implicit Export Syntax */ 943#define OMX_EXPORT __declspec(dllexport) 944/* =================================================================================== */ 945/** 946* OMX_ComponentInit() Initializes component 947* 948* 949* @param hComp OMX Handle 950* 951* @return OMX_ErrorNone = Successful 952* Other error code = fail 953* 954*/ 955/* =================================================================================== */ 956OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 957#endif 958/* =================================================================================== */ 959/** 960* NBAMRENC_StartComponentThread() Starts component thread 961* 962* 963* @param hComp OMX Handle 964* 965* @return OMX_ErrorNone = Successful 966* Other error code = fail 967* 968*/ 969/* =================================================================================== */ 970OMX_ERRORTYPE NBAMRENC_StartComponentThread(OMX_HANDLETYPE pHandle); 971/* =================================================================================== */ 972/** 973* NBAMRENC_StopComponentThread() Stops component thread 974* 975* 976* @param hComp OMX Handle 977* 978* @return OMX_ErrorNone = Successful 979* Other error code = fail 980* 981*/ 982/* =================================================================================== */ 983OMX_ERRORTYPE NBAMRENC_StopComponentThread(OMX_HANDLETYPE pHandle); 984/* =================================================================================== */ 985/** 986* NBAMRENC_FreeCompResources() Frees allocated memory 987* 988* 989* @param hComp OMX Handle 990* 991* @return OMX_ErrorNone = Successful 992* Other error code = fail 993* 994*/ 995/* =================================================================================== */ 996OMX_ERRORTYPE NBAMRENC_FreeCompResources(OMX_HANDLETYPE pComponent); 997/* =================================================================================== */ 998/** 999* NBAMRENC_GetCorrespondingLCMLHeader() Returns LCML header 1000* that corresponds to the given buffer 1001* 1002* @param pComponentPrivate Component private data 1003* 1004* @return OMX_ErrorNone = Successful 1005* Other error code = fail 1006*/ 1007/* =================================================================================== */ 1008OMX_ERRORTYPE NBAMRENC_GetCorrespondingLCMLHeader(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1009 OMX_U8 *pBuffer, 1010 OMX_DIRTYPE eDir, 1011 NBAMRENC_LCML_BUFHEADERTYPE **ppLcmlHdr); 1012/* =================================================================================== */ 1013/** 1014* NBAMRENC_LCMLCallback() Callback from LCML 1015* 1016* @param event Codec Event 1017* 1018* @param args Arguments from LCML 1019* 1020* @return OMX_ErrorNone = Successful 1021* Other error code = fail 1022*/ 1023/* =================================================================================== */ 1024OMX_ERRORTYPE NBAMRENC_LCMLCallback(TUsnCodecEvent event, 1025 void * args [10]); 1026/* =================================================================================== */ 1027/** 1028* NBAMRENC_FillLCMLInitParams() Fills the parameters needed 1029* to initialize the LCML 1030* 1031* @param pHandle OMX Handle 1032* 1033* @param plcml_Init LCML initialization parameters 1034* 1035* @return OMX_ErrorNone = Successful 1036* Other error code = fail 1037* 1038*/ 1039/* =================================================================================== */ 1040OMX_ERRORTYPE NBAMRENC_FillLCMLInitParams(OMX_HANDLETYPE pHandle, 1041 LCML_DSP *plcml_Init, 1042 OMX_U16 arr[]); 1043/* =================================================================================== */ 1044/** 1045* NBAMRENC_GetBufferDirection() Returns direction of pBufHeader 1046* 1047* @param pBufHeader Buffer header 1048* 1049* @param eDir Buffer direction 1050* 1051* @param pComponentPrivate Component private data 1052* 1053* @return OMX_ErrorNone = Successful 1054* Other error code = fail 1055*/ 1056/* =================================================================================== */ 1057OMX_ERRORTYPE NBAMRENC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, 1058 OMX_DIRTYPE *eDir); 1059/* =========================================================== */ 1060/** 1061* NBAMRENC_HandleCommand() Handles commands sent via SendCommand() 1062* 1063* @param pComponentPrivate Component private data 1064* 1065* @return OMX_ErrorNone = Successful 1066* Other error code = fail 1067* @return OMX_ErrorNone = Successful 1068* Other error code = fail 1069*/ 1070/* =================================================================================== */ 1071OMX_U32 NBAMRENC_HandleCommand(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1072/* =================================================================================== */ 1073/** 1074* NBAMRENC_HandleDataBufFromApp() Handles data buffers received 1075* from the IL Client 1076* 1077* @param pComponentPrivate Component private data 1078* 1079* @return OMX_ErrorNone = Successful 1080* Other error code = fail 1081* @return OMX_ErrorNone = Successful 1082* Other error code = fail 1083*/ 1084/* =================================================================================== */ 1085OMX_ERRORTYPE NBAMRENC_HandleDataBufFromApp(OMX_BUFFERHEADERTYPE *pBufHeader, 1086 AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1087/* =================================================================================== */ 1088/** 1089* NBAMRENC_GetLCMLHandle() Get the handle to the LCML 1090* 1091* 1092* @return OMX_ErrorNone = Successful 1093* Other error code = fail 1094*/ 1095/* =================================================================================== */ 1096OMX_HANDLETYPE NBAMRENC_GetLCMLHandle(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1097/* =================================================================================== */ 1098/** 1099* NBAMRENC_FreeLCMLHandle() Frees the handle to the LCML 1100* 1101* 1102* @return OMX_ErrorNone = Successful 1103* Other error code = fail 1104*/ 1105/* =================================================================================== */ 1106OMX_ERRORTYPE NBAMRENC_FreeLCMLHandle(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1107/* =================================================================================== */ 1108/** 1109* NBAMRENC_CleanupInitParams() Starts component thread 1110* 1111* @param pComponent OMX Handle 1112* 1113* @return OMX_ErrorNone = Successful 1114* Other error code = fail 1115*/ 1116/* =================================================================================== */ 1117OMX_ERRORTYPE NBAMRENC_CleanupInitParams(OMX_HANDLETYPE pHandle); 1118/* =================================================================================== */ 1119/** 1120* NBAMRENC_SetPending() Called when the component queues a buffer 1121* to the LCML 1122* 1123* @param pComponentPrivate Component private data 1124* 1125* @param pBufHdr Buffer header 1126* 1127* @param eDir Direction of the buffer 1128* 1129* @return None 1130*/ 1131/* =================================================================================== */ 1132void NBAMRENC_SetPending(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1133 OMX_BUFFERHEADERTYPE *pBufHdr, 1134 OMX_DIRTYPE eDir, 1135 OMX_U32 lineNumber); 1136/* =================================================================================== */ 1137/** 1138* NBAMRENC_ClearPending() Called when a buffer is returned 1139* from the LCML 1140* 1141* @param pComponentPrivate Component private data 1142* 1143* @param pBufHdr Buffer header 1144* 1145* @param eDir Direction of the buffer 1146* 1147* @return None 1148*/ 1149/* =================================================================================== */ 1150void NBAMRENC_ClearPending(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1151 OMX_BUFFERHEADERTYPE *pBufHdr, 1152 OMX_DIRTYPE eDir, 1153 OMX_U32 lineNumber); 1154/* =================================================================================== */ 1155/** 1156* NBAMRENC_IsPending() 1157* 1158* 1159* @param pComponentPrivate Component private data 1160* 1161* @return OMX_ErrorNone = Successful 1162* Other error code = fail 1163*/ 1164/* =================================================================================== */ 1165OMX_U32 NBAMRENC_IsPending(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1166 OMX_BUFFERHEADERTYPE *pBufHdr, 1167 OMX_DIRTYPE eDir); 1168/* =================================================================================== */ 1169/** 1170* NBAMRENC_FillLCMLInitParamsEx() Fills the parameters needed 1171* to initialize the LCML without recreating the socket node 1172* 1173* @param pComponent OMX Handle 1174* 1175* @return None 1176*/ 1177/* =================================================================================== */ 1178OMX_ERRORTYPE NBAMRENC_FillLCMLInitParamsEx(OMX_HANDLETYPE pComponent); 1179/* =================================================================================== */ 1180/** 1181* NBAMRENC_IsValid() Returns whether a buffer is valid 1182* 1183* 1184* @param pComponentPrivate Component private data 1185* 1186* @param pBuffer Data buffer 1187* 1188* @param eDir Buffer direction 1189* 1190* @return OMX_True = Valid 1191* OMX_False= Invalid 1192*/ 1193/* =================================================================================== */ 1194OMX_U32 NBAMRENC_IsValid(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1195 OMX_U8 *pBuffer, 1196 OMX_DIRTYPE eDir); 1197 1198#ifdef RESOURCE_MANAGER_ENABLED 1199void NBAMRENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData); 1200#endif 1201/* ======================================================================= */ 1202/** OMX_NBAMRENC_INDEXAUDIOTYPE Defines the custom configuration settings 1203* for the component 1204* 1205* @param OMX_IndexCustomNBAMRENCModeConfig Sets the DASF mode 1206* 1207* 1208*/ 1209/* ==================================================================== */ 1210typedef enum OMX_NBAMRENC_INDEXAUDIOTYPE { 1211 OMX_IndexCustomNBAMRENCModeConfig = 0xFF000001, 1212 OMX_IndexCustomNBAMRENCStreamIDConfig, 1213 OMX_IndexCustomNBAMRENCDataPath, 1214 OMX_IndexCustomDebug 1215}OMX_NBAMRENC_INDEXAUDIOTYPE; 1216 1217OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size, void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf, struct OMX_TI_Debug dbg); 1218OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr, struct OMX_TI_Debug dbg); 1219 1220void NBAMRENC_HandleUSNError (AMRENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 arg); 1221OMX_ERRORTYPE AddStateTransition(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1222OMX_ERRORTYPE RemoveStateTransition(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BOOL bEnableSignal); 1223 1224/*===============================================================*/ 1225 1226typedef enum { 1227 IUALG_CMD_STOP = 0, 1228 IUALG_CMD_PAUSE = 1, 1229 IUALG_CMD_GETSTATUS = 2, 1230 IUALG_CMD_SETSTATUS = 3, 1231 IUALG_CMD_USERSETCMDSTART = 100, 1232 IUALG_CMD_USERGETCMDSTART = 150, 1233 IUALG_CMD_FLUSH = 0x100 1234}IUALG_Cmd; 1235 1236typedef enum 1237{ 1238 ALGCMD_BITRATE = IUALG_CMD_USERSETCMDSTART, 1239 ALGCMD_DTX 1240 1241} eSPEECHENCODE_AlgCmd; 1242 1243#endif /* OMX_AMRENC_UTILS__H */ 1244