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_G729Enc_Utils.h 30 * 31 * This is an header file for an G729 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\g729_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_G729ENC_UTILS__H 60#define OMX_G729ENC_UTILS__H 61 62#include <pthread.h> 63#include "LCML_DspCodec.h" 64#include <OMX_Component.h> 65#include <TIDspOmx.h> 66 67#ifdef RESOURCE_MANAGER_ENABLED 68#include <ResourceManagerProxyAPI.h> 69#endif 70 71#undef __G729_EPRINT__ 72 73 74#ifndef UNDER_CE 75/* For printing errors */ 76#define __OMX_EPRINT__ 77#undef __G729_EPRINT__ 78#endif 79 80#ifdef __PERF_INSTRUMENTATION__ 81#include "perf.h" 82#endif 83 84/* ======================================================================= */ 85/** 86 * @def G729ENC_DEBUG Turns debug messaging on and off 87 */ 88/* ======================================================================= */ 89#undef G729ENC_DEBUG 90/* ======================================================================= */ 91/** 92 * @def G729ENC_MEMCHECK Turns memory messaging on and off 93 */ 94/* ======================================================================= */ 95#undef G729ENC_MEMCHECK 96 97#ifndef UNDER_CE 98/* 99 * ANSI escape sequences for outputing text in various colors 100 */ 101#ifdef OMX_PRINT_COLOR 102#define DBG_TEXT_WHITE "\x1b[1;37;40m" 103#define DBG_TEXT_YELLOW "\x1b[1;33;40m" /* reserved for OMX_G729Enc_Thread.c */ 104#define DBG_TEXT_MAGENTA "\x1b[1;35;40m" 105#define DBG_TEXT_GREEN "\x1b[1;32;40m" /* reserved for OMX_G729Encoder.c */ 106#define DBG_TEXT_CYAN "\x1b[1;36;40m" /* reserved for OMX_G729Enc_Utils.c */ 107#define DBG_TEXT_RED "\x1b[1;31;40m" /* reserved for test app */ 108#else 109#define DBG_TEXT_WHITE "" 110#define DBG_TEXT_YELLOW "" 111#define DBG_TEXT_MAGENTA "" 112#define DBG_TEXT_GREEN "" 113#define DBG_TEXT_CYAN "" 114#define DBG_TEXT_RED "" 115#endif 116 117void G729ENC_eprint(int iLineNum, const char *szFunctionName, const char *strFormat, ...); 118void G729ENC_Log(const char *szFileName, int iLineNum, const char *szFunctionName, const char *strFormat, ...); 119 120/* ======================================================================= */ 121/** 122 * @def G729ENC_DEBUG Debug print macro 123 */ 124/* ======================================================================= */ 125#ifdef G729ENC_DEBUG 126#define G729ENC_DPRINT(STR, ARG...) G729ENC_Log(__FILE__, __LINE__, __FUNCTION__, STR, ##ARG) 127#else 128#define G729ENC_DPRINT(...) 129#endif 130/* ======================================================================= */ 131/** 132 * @def G729ENC_MEMCHECK Memory print macro 133 */ 134/* ======================================================================= */ 135#ifdef G729ENC_MEMCHECK 136#define G729ENC_MEMPRINT(...) fprintf(stderr, __VA_ARGS__) 137#else 138#define G729ENC_MEMPRINT(...) 139#endif 140/* ======================================================================= */ 141/** 142 * @def OMX_EPRINT Error print macro 143 */ 144/* ======================================================================= */ 145#ifdef __OMX_EPRINT__ 146#define OMX_EPRINT(STR, ARG...) G729ENC_eprint(__LINE__, __FUNCTION__, STR, ##ARG) 147#else 148#define OMX_EPRINT(...) 149#endif 150/* ======================================================================= */ 151/** 152 * @def G729ENC_EPRINT Error print macro 153 */ 154/* ======================================================================= */ 155#ifdef __G729_EPRINT__ 156#define G729ENC_EPRINT(...) fprintf(stderr,__VA_ARGS__) 157#else 158#define G729ENC_EPRINT(...) 159#endif 160 161 162#else /*UNDER_CE*/ 163/* ======================================================================= */ 164/** 165 * @def G729ENC_DEBUG Debug print macro 166 */ 167/* ======================================================================= */ 168#ifdef G729ENC_DEBUG 169#define G729ENC_DPRINT(STR, ARG...) printf() 170#endif 171/* ======================================================================= */ 172/** 173 * @def G729ENC_MEMCHECK Memory print macro 174 */ 175/* ======================================================================= */ 176#ifdef G729ENC_MEMCHECK 177#define G729ENC_MEMPRINT(STR, ARG...) printf() 178#endif 179 180#define G729ENC_EPRINT printf 181#define OMX_EPRINT G729ENC_EPRINT 182 183#ifdef DEBUG 184#define G729ENC_DPRINT printf 185#define G729ENC_MEMPRINT printf 186#else 187#define G729ENC_DPRINT 188#define G729ENC_MEMPRINT 189#endif 190 191#endif/*UNDER_CE*/ 192 193/* ======================================================================= */ 194/** 195 * M A C R O S FOR MALLOC and MEMORY FREE and CLOSING PIPES 196 */ 197/* ======================================================================= */ 198 199#define OMX_G729CONF_INIT_STRUCT(_s_, _name_) \ 200 memset((_s_), 0x0, sizeof(_name_)); \ 201 (_s_)->nSize = sizeof(_name_); \ 202 (_s_)->nVersion.s.nVersionMajor = 0x1; \ 203 (_s_)->nVersion.s.nVersionMinor = 0x1; \ 204 (_s_)->nVersion.s.nRevision = 0x0; \ 205 (_s_)->nVersion.s.nStep = 0x0 206 207#define OMX_G729MEMFREE_STRUCT(_pStruct_) \ 208 if(_pStruct_ != NULL) \ 209 { \ 210 G729ENC_MEMPRINT("%d :: [FREE] %p\n", __LINE__, _pStruct_); \ 211 free(_pStruct_); \ 212 _pStruct_ = NULL; \ 213 } 214 215#define OMX_G729CLOSE_PIPE(_pStruct_,err) \ 216 G729ENC_DPRINT("%d :: CLOSING PIPE \n", __LINE__); \ 217 err = close (_pStruct_); \ 218 if(0 != err && OMX_ErrorNone == eError) \ 219 { \ 220 eError = OMX_ErrorHardware; \ 221 printf("%d :: Error while closing pipe\n", __LINE__); \ 222 goto EXIT; \ 223 } 224 225#define OMX_G729MALLOC_STRUCT(_pStruct_, _sName_) \ 226 _pStruct_ = (_sName_*)malloc(sizeof(_sName_)); \ 227 if(_pStruct_ == NULL) \ 228 { \ 229 printf("***********************************\n"); \ 230 printf("%d :: Malloc Failed\n", __LINE__); \ 231 printf("***********************************\n"); \ 232 eError = OMX_ErrorInsufficientResources; \ 233 goto EXIT; \ 234 } \ 235 memset(_pStruct_, 0x0, sizeof(_sName_)); \ 236 G729ENC_MEMPRINT("%d :: [ALLOC] %p\n", __LINE__, _pStruct_); 237 238 239/* ======================================================================= */ 240/** 241 * @def G729ENC_NUM_INPUT_BUFFERS Default number of input buffers 242 */ 243/* ======================================================================= */ 244#define G729ENC_NUM_INPUT_BUFFERS 1 245/* ======================================================================= */ 246/** 247 * @def G729ENC_NUM_INPUT_BUFFERS_DASF Default No.of input buffers DASF 248 */ 249/* ======================================================================= */ 250#define G729ENC_NUM_INPUT_BUFFERS_DASF 2 251/* ======================================================================= */ 252/** 253 * @def G729ENC_NUM_OUTPUT_BUFFERS Default number of output buffers 254 */ 255/* ======================================================================= */ 256#define G729ENC_NUM_OUTPUT_BUFFERS 1 257/* ======================================================================= */ 258/** 259 * @def G729ENC_INPUT_BUFFER_SIZE Default input buffer size 260 * G729ENC_INPUT_BUFFER_SIZE_DASF Default input buffer size DASF 261 * G729ENC_INPUT_FRAME_SIZE Default input Frame Size 262 */ 263/* ======================================================================= */ 264#define G729ENC_INPUT_BUFFER_SIZE 160 265#define G729ENC_INPUT_BUFFER_SIZE_DASF 160 266#define G729ENC_INPUT_FRAME_SIZE 160 267/* ======================================================================= */ 268/** 269 * @def G729ENC_OUTPUT_BUFFER_SIZE Default output buffer size 270 * G729ENC_OUTPUT_FRAME_SIZE Default output frame size 271 */ 272/* ======================================================================= */ 273#define G729ENC_OUTPUT_BUFFER_SIZE 12 274#define G729ENC_OUTPUT_FRAME_SIZE 12 275#define G729ENC_HEADER_SIZE 2 276 277/* ======================================================================= */ 278/** 279 * @def G729ENC_OUTPUT_BUFFER_SIZE_MIME Default input buffer size MIME 280 */ 281/* ======================================================================= */ 282#define G729ENC_OUTPUT_BUFFER_SIZE_MIME 10 283 284/* ======================================================================= */ 285/* 286 * @def G729ENC_APP_ID App ID Value setting 287 */ 288/* ======================================================================= */ 289#define G729ENC_APP_ID 100 290 291/* ======================================================================= */ 292/** 293 * @def G729ENC_SAMPLING_FREQUENCY Sampling frequency 294 */ 295/* ======================================================================= */ 296#define G729ENC_SAMPLING_FREQUENCY 8000 297/* ======================================================================= */ 298/** 299 * @def G729ENC_MAX_NUM_OF_BUFS Maximum number of buffers 300 */ 301/* ======================================================================= */ 302#define G729ENC_MAX_NUM_OF_BUFS 10 303/* ======================================================================= */ 304/** 305 * @def G729ENC_NUM_OF_PORTS Number of ports 306 */ 307/* ======================================================================= */ 308#define G729ENC_NUM_OF_PORTS 2 309/* ======================================================================= */ 310/** 311 * @def G729ENC_XXX_VER Component version 312 */ 313/* ======================================================================= */ 314#define G729ENC_MAJOR_VER 0x1 315#define G729ENC_MINOR_VER 0x1 316/* ======================================================================= */ 317/** 318 * @def G729ENC_NOT_USED Defines a value for "don't care" parameters 319 */ 320/* ======================================================================= */ 321#define G729ENC_NOT_USED 10 322/* ======================================================================= */ 323/** 324 * @def G729ENC_NORMAL_BUFFER Defines flag value with all flags off 325 */ 326/* ======================================================================= */ 327#define G729ENC_NORMAL_BUFFER 0 328/* ======================================================================= */ 329/** 330 * @def OMX_G729ENC_DEFAULT_SEGMENT Default segment ID for the LCML 331 */ 332/* ======================================================================= */ 333#define G729ENC_DEFAULT_SEGMENT (0) 334/* ======================================================================= */ 335/** 336 * @def OMX_G729ENC_SN_TIMEOUT Timeout value for the socket node 337 */ 338/* ======================================================================= */ 339#define G729ENC_SN_TIMEOUT (-1) 340/* ======================================================================= */ 341/** 342 * @def OMX_G729ENC_SN_PRIORITY Priority for the socket node 343 */ 344/* ======================================================================= */ 345#define G729ENC_SN_PRIORITY (10) 346/* ======================================================================= */ 347/** 348 * @def OMX_G729ENC_NUM_DLLS number of DLL's 349 */ 350/* ======================================================================= */ 351#define G729ENC_NUM_DLLS (2) 352 353#define G729ENC_CPU 50 354/* ======================================================================= */ 355/** 356 * @def G729ENC_USN_DLL_NAME USN DLL name 357 */ 358/* ======================================================================= */ 359#ifdef UNDER_CE 360#define G729ENC_USN_DLL_NAME "\\windows\\usn.dll64P" 361#else 362#define G729ENC_USN_DLL_NAME "usn.dll64P" 363#endif 364 365/* ======================================================================= */ 366/** 367 * @def G729ENC_DLL_NAME G729 Encoder socket node dll name 368 */ 369/* ======================================================================= */ 370#ifdef UNDER_CE 371#define G729ENC_DLL_NAME "\\windows\\g729enc_sn.dll64P" 372#else 373#define G729ENC_DLL_NAME "g729enc_sn.dll64P" 374#endif 375 376/* ======================================================================= */ 377/** 378 * @def _ERROR_PROPAGATION__ Allow Logic to Detec&Report Arm Errors 379 */ 380/* ======================================================================= */ 381#define _ERROR_PROPAGATION__ 382 383/* ======================================================================= */ 384/** G729ENC_StreamType Stream types 385 * 386 * @param G729ENC_DMM DMM 387 * 388 * @param G729ENC_INSTRM Input stream 389 * 390 * @param G729ENC_OUTSTRM Output stream 391 */ 392/* ======================================================================= */ 393enum G729ENC_StreamType 394 { 395 G729ENC_DMM = 0, 396 G729ENC_INSTRM, 397 G729ENC_OUTSTRM 398 }; 399/* ======================================================================= */ 400/** G729ENC_EncodeType coding types 401 * 402 * @param G729ENC_G729 G729 mode 403 * 404 * @param G729ENC_EFR EFR mode 405 * 406 */ 407/* ======================================================================= */ 408enum G729ENC_EncodeType 409 { 410 G729ENC_G729 = 0, 411 G729ENC_EFR 412 }; 413/* ======================================================================= */ 414/** G729ENC_MimeMode format types 415 * 416 * @param G729ENC_MIMEMODE MIME 417 * 418 * @param G729ENC_NONMIMEMODE G729 mode 419 * 420 */ 421/* ======================================================================= */ 422enum G729ENC_MimeMode 423 { 424 G729ENC_NONMIMEMODE = 0, 425 G729ENC_MIMEMODE 426 }; 427 428/* ======================================================================= */ 429/* 430 * Different Frame sizes for different index in MIME Mode 431 */ 432/* ======================================================================= */ 433#define G729ENC_FRAME_SIZE_13 13 434#define G729ENC_FRAME_SIZE_14 14 435#define G729ENC_FRAME_SIZE_16 16 436#define G729ENC_FRAME_SIZE_18 18 437#define G729ENC_FRAME_SIZE_20 20 438#define G729ENC_FRAME_SIZE_21 21 439#define G729ENC_FRAME_SIZE_27 27 440#define G729ENC_FRAME_SIZE_32 32 441#define G729ENC_FRAME_SIZE_6 6 442#define G729ENC_FRAME_SIZE_1 1 443#define G729ENC_FRAME_SIZE_0 0 444/* ======================================================================= */ 445/** 446 * @def G729ENC_TIMEOUT Default timeout used to come out of blocking calls 447 */ 448/* ======================================================================= */ 449#define G729ENC_TIMEOUT 1000 450/* ======================================================================= */ 451/* 452 * @def G729ENC_OMX_MAX_TIMEOUTS Max Time Outs 453 * @def G729ENC_DONT_CARE Dont Care Condition 454 * @def G729ENC_NUM_CHANNELS Number of Channels 455 * @def G729ENC_APP_ID App ID Value setting 456 */ 457/* ======================================================================= */ 458#define G729ENC_OMX_MAX_TIMEOUTS 20 459#define G729ENC_DONT_CARE 0 460#define G729ENC_NUM_CHANNELS 1 461/* ======================================================================= */ 462/** 463 * @def G729ENC_STREAM_COUNT Number of streams 464 * G729ENC_INPUT_STREAM_ID Stream ID for Input Buffer 465 */ 466/* ======================================================================= */ 467#define G729ENC_STREAM_COUNT 2 468#define G729ENC_INPUT_STREAM_ID 0 469 470/* ======================================================================= */ 471/** G729ENC_COMP_PORT_TYPE Port types 472 * 473 * @param G729ENC_INPUT_PORT Input port 474 * 475 * @param G729ENC_OUTPUT_PORT Output port 476 */ 477/* ====================================================================== */ 478/*This enum must not be changed. */ 479typedef enum G729ENC_COMP_PORT_TYPE 480 { 481 G729ENC_INPUT_PORT = 0, 482 G729ENC_OUTPUT_PORT 483 } G729ENC_COMP_PORT_TYPE; 484 485/* ======================================================================= */ 486/** G729ENC_BUFFER_Dir Buffer Direction 487 * 488 * @param G729ENC_DIRECTION_INPUT Input direction 489 * 490 * @param G729ENC_DIRECTION_OUTPUT Output direction 491 * 492 */ 493/* ======================================================================= */ 494typedef enum G729ENC_BUFFER_Dir 495 { 496 G729ENC_DIRECTION_INPUT, 497 G729ENC_DIRECTION_OUTPUT 498 } G729ENC_BUFFER_Dir; 499 500/* ======================================================================= */ 501/** G729ENC_BUFFS Buffer details 502 * 503 * @param BufHeader Buffer header 504 * 505 * @param Buffer Buffer 506 * 507 */ 508/* ======================================================================= */ 509typedef struct G729ENC_BUFFS 510{ 511 char BufHeader; 512 char Buffer; 513} G729ENC_BUFFS; 514 515/* ======================================================================= */ 516/** G729ENC_BUFFERHEADERTYPE_INFO 517 * 518 * @param pBufHeader 519 * 520 * @param bBufOwner 521 * 522 */ 523/* ======================================================================= */ 524typedef struct G729ENC_BUFFERHEADERTYPE_INFO 525{ 526 OMX_BUFFERHEADERTYPE* pBufHeader[G729ENC_MAX_NUM_OF_BUFS]; 527 G729ENC_BUFFS bBufOwner[G729ENC_MAX_NUM_OF_BUFS]; 528} G729ENC_BUFFERHEADERTYPE_INFO; 529 530 531typedef OMX_ERRORTYPE (*G729ENC_fpo)(OMX_HANDLETYPE); 532 533/* =================================================================================== */ 534/** 535 * Socket node Audio Codec Configuration parameters. 536 */ 537/* =================================================================================== */ 538typedef struct G729ENC_AudioCodecParams 539{ 540 unsigned long iSamplingRate; 541 unsigned long iStrmId; 542 unsigned short iAudioFormat; 543} G729ENC_AudioCodecParams; 544 545/* =================================================================================== */ 546/** 547 * G729ENC_TALGCtrl Socket Node Alg Control parameters. 548 * G729ENC_UAlgInBufParamStruct Input Buffer Param Structure 549 * G729ENC_UAlgOutBufParamStruct Output Buffer Param Structure 550 */ 551/* =================================================================================== */ 552/* Algorithm specific command parameters */ 553typedef struct ISPHENC_DynamicParams 554{ 555 int size; /* not used */ 556 int frameSize; /* not used*/ 557 int bitRate; /* not used */ 558 int mode; /* not used */ 559 int vadFlag; /* VAD_On =1, VAD_OFF = 0 */ 560 int noiseSuppressionMode; /* not used */ 561 int ttyTddMode; /* not used */ 562 int dtmfMode; /* not used */ 563 int dataTransmit; /* not used */ 564} G729ENC_TALGCtrl; 565 566/* =================================================================================== */ 567/** 568 * G729ENC_UAlgInBufParamStruct Input Buffer Param Structure 569 * usEndOfFile To Send Last Buffer Flag 570 */ 571/* =================================================================================== */ 572typedef struct G729ENC_UAlgInBufParamStruct 573{ 574 unsigned long usEndOfFile; 575} G729ENC_UAlgInBufParamStruct; 576 577/* =================================================================================== */ 578/** 579 * G729ENC_UAlgOutBufParamStruct Output Buffer Param Structure 580 * ulFrameCount No.of Frames Encoded 581 */ 582/* =================================================================================== */ 583typedef struct G729ENC_UAlgOutBufParamStruct 584{ 585 unsigned long ulFrameCount; 586} G729ENC_UAlgOutBufParamStruct; 587 588/* =================================================================================== */ 589/** 590 * G729ENC_LCML_BUFHEADERTYPE Buffer Header Type 591 */ 592/* =================================================================================== */ 593typedef struct G729ENC_LCML_BUFHEADERTYPE { 594 G729ENC_BUFFER_Dir eDir; 595 G729ENC_UAlgInBufParamStruct *pIpParam; 596 G729ENC_UAlgOutBufParamStruct *pOpParam; 597 OMX_BUFFERHEADERTYPE* buffer; 598} G729ENC_LCML_BUFHEADERTYPE; 599 600 601typedef struct _G729ENC_BUFFERLIST G729ENC_BUFFERLIST; 602 603/* =================================================================================== */ 604/** 605 * _G729ENC_BUFFERLIST Structure for buffer list 606 */ 607/* ================================================================================== */ 608struct _G729ENC_BUFFERLIST 609{ 610 OMX_BUFFERHEADERTYPE sBufHdr; 611 OMX_BUFFERHEADERTYPE *pBufHdr[G729ENC_MAX_NUM_OF_BUFS]; 612 OMX_U32 bufferOwner[G729ENC_MAX_NUM_OF_BUFS]; 613 OMX_U32 bBufferPending[G729ENC_MAX_NUM_OF_BUFS]; 614 OMX_U32 numBuffers; 615 G729ENC_BUFFERLIST *pNextBuf; 616 G729ENC_BUFFERLIST *pPrevBuf; 617}; 618 619/* =================================================================================== */ 620/** 621 * G729ENC_PORT_TYPE Structure for PortFormat details 622 */ 623/* =================================================================================== */ 624typedef struct G729ENC_PORT_TYPE 625{ 626 OMX_HANDLETYPE hTunnelComponent; 627 OMX_U32 nTunnelPort; 628 OMX_BUFFERSUPPLIERTYPE eSupplierSetting; 629 OMX_U8 nBufferCnt; 630 OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat; 631} G729ENC_PORT_TYPE; 632 633#ifdef UNDER_CE 634/* =================================================================================== */ 635/** 636 * OMX_Event Structure for Mutex application under WinCE 637 */ 638/* =================================================================================== */ 639typedef struct OMX_Event 640{ 641 HANDLE event; 642} OMX_Event; 643 644int OMX_CreateEvent(OMX_Event *event); 645int OMX_SignalEvent(OMX_Event *event); 646int OMX_WaitForEvent(OMX_Event *event); 647int OMX_DestroyEvent(OMX_Event *event); 648#endif 649 650/* =================================================================================== */ 651/** 652 * G729ENC_COMPONENT_PRIVATE Component private data Structure 653 */ 654/* =================================================================================== */ 655typedef struct G729ENC_COMPONENT_PRIVATE 656{ 657 /** Array of pointers to BUFFERHEADERTYPE structues 658 This pBufHeader[INPUT_PORT] will point to all the 659 BUFFERHEADERTYPE structures related to input port, 660 not just one structure. Same is the case for output 661 port also. */ 662 OMX_BUFFERHEADERTYPE* pBufHeader[G729ENC_NUM_OF_PORTS]; 663 OMX_CALLBACKTYPE cbInfo; 664 OMX_PORT_PARAM_TYPE* sPortParam; 665 OMX_PRIORITYMGMTTYPE* sPriorityMgmt; 666 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[G729ENC_NUM_OF_PORTS]; 667 OMX_PORT_PARAM_TYPE* pPortParamType; 668 OMX_AUDIO_PARAM_G729TYPE* g729Params; 669 OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams; 670 G729ENC_BUFFERHEADERTYPE_INFO BufInfo[G729ENC_NUM_OF_PORTS]; 671 G729ENC_PORT_TYPE *pCompPort[G729ENC_NUM_OF_PORTS]; 672 G729ENC_LCML_BUFHEADERTYPE *pLcmlBufHeader[G729ENC_NUM_OF_PORTS]; 673 /** This is component handle */ 674 OMX_COMPONENTTYPE* pHandle; 675 /** Current state of this component */ 676 OMX_STATETYPE curState; 677 /** The component thread handle */ 678 pthread_t ComponentThread; 679 /** The pipes for sending buffers to the thread */ 680 int dataPipe[2]; 681 /** The pipes for sending command to the thread */ 682 int cmdPipe[2]; 683 /** The pipes for sending cmd data to the thread */ 684 int cmdDataPipe[2]; 685 /** The pipes for sending buffers to the thread */ 686 int lcml_Pipe[2]; 687 688 OMX_U32 efrMode; 689 690 OMX_U32 g729Mode; 691 692 OMX_U32 dasfMode; 693 694 OMX_U32 mimeMode; 695 696 OMX_U32 acdnMode; 697 698 OMX_U32 nMultiFrameMode; 699 700 OMX_U32 fdwrite; 701 702 OMX_U32 fdread; 703 704 OMX_U32 bLcmlHandleOpened; 705 706 /** Set to indicate component is stopping */ 707 OMX_U32 bIsStopping; 708 709 OMX_U32 bIsThreadstop; 710 711 OMX_U32 bIsEOFSent; 712 713 /** Count of number of buffers outstanding with bridge */ 714 OMX_U32 lcml_nIpBuf; 715 716 /** Count of number of buffers outstanding with bridge */ 717 OMX_U32 lcml_nOpBuf; 718 719 OMX_U32 app_nBuf; 720 721 OMX_U32 lcml_nCntIp; 722 723 OMX_U32 lcml_nCntOpReceived; 724 725 OMX_U32 lcml_nCntApp; 726 727 OMX_U32 lcml_compID; 728 729 OMX_U32 num_Reclaimed_Op_Buff; 730 731 OMX_U32 num_Sent_Ip_Buff; 732 733 OMX_U32 num_Op_Issued; 734 735 OMX_U32 bIsBufferOwned[G729ENC_NUM_OF_PORTS]; 736 737 OMX_U32 streamID; 738 739 OMX_U32 bPortDefsAllocated; 740 741 OMX_U32 bCompThreadStarted; 742 743 OMX_U32 bBypassDSP; 744 745 OMX_U32 nVersion; 746 747 OMX_U32 bInputBufferHeaderAllocated; 748 749 OMX_U32 bPlayCompleteFlag; 750 751 OMX_U32 g729MimeBytes[16]; 752 753 OMX_U32 iHoldLen; 754 755 OMX_U32 nHoldLength; 756 757 OMX_U32 nFillThisBufferCount; 758 759 OMX_U32 nFillBufferDoneCount; 760 761 OMX_U32 nEmptyThisBufferCount; 762 763 OMX_U32 nEmptyBufferDoneCount; 764 765 OMX_U32 bInitParamsInitialized; 766 767 OMX_U32 bIdleCommandPending; 768 769 OMX_U32 nNumInputBufPending; 770 771 OMX_U32 nNumOutputBufPending; 772 773 OMX_U32 bJustReenabled; 774 775 OMX_U32 nInvalidFrameCount; 776 777 OMX_U32 nDataWritesWhilePaused; 778 779 OMX_U32 bDisableCommandPending; 780 781 OMX_U32 bDisableCommandParam; 782 783 OMX_HANDLETYPE pLcmlHandle; 784 785 OMX_PTR pMarkData; 786 787 OMX_MARKTYPE *pMarkBuf; 788 789 OMX_HANDLETYPE hMarkTargetComponent; 790 791 G729ENC_BUFFERLIST *pInputBufferList; 792 793 G729ENC_BUFFERLIST *pOutputBufferList; 794 795 LCML_STRMATTR *strmAttr; 796 797 G729ENC_TALGCtrl *pAlgParam; 798 799 G729ENC_AudioCodecParams *pParams; 800 801 OMX_STRING cComponentName; 802 803 OMX_VERSIONTYPE ComponentVersion; 804 805 OMX_BUFFERHEADERTYPE *pInputBufHdrPending[G729ENC_MAX_NUM_OF_BUFS]; 806 807 OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[G729ENC_MAX_NUM_OF_BUFS]; 808 809 OMX_BUFFERHEADERTYPE *iMMFDataLastBuffer; 810 811 OMX_U8* pHoldBuffer; 812 813 OMX_U8* iHoldBuffer; 814 815 OMX_U32 nRuntimeInputBuffers; 816 817 OMX_U32 nRuntimeOutputBuffers; 818 819 TI_OMX_DSP_DEFINITION tiOmxDspDefinition; 820 821 /** Flag to set when socket node stop callback should not transition 822 component to OMX_StateIdle */ 823 OMX_U32 bNoIdleOnStop; 824 825 /** Flag set when socket node is stopped */ 826 OMX_U32 bDspStoppedWhileExecuting; 827 828 /** Number of outstanding FillBufferDone() calls */ 829 OMX_U32 nOutStandingFillDones; 830 831#ifndef UNDER_CE 832 pthread_mutex_t AlloBuf_mutex; 833 pthread_cond_t AlloBuf_threshold; 834 OMX_U8 AlloBuf_waitingsignal; 835 836 pthread_mutex_t InLoaded_mutex; 837 pthread_cond_t InLoaded_threshold; 838 OMX_U8 InLoaded_readytoidle; 839 840 pthread_mutex_t InIdle_mutex; 841 pthread_cond_t InIdle_threshold; 842 OMX_U8 InIdle_goingtoloaded; 843#else 844 OMX_Event AlloBuf_event; 845 OMX_U8 AlloBuf_waitingsignal; 846 847 OMX_Event InLoaded_event; 848 OMX_U8 InLoaded_readytoidle; 849 850 OMX_Event InIdle_event; 851 OMX_U8 InIdle_goingtoloaded; 852#endif 853#ifdef __PERF_INSTRUMENTATION__ 854 PERF_OBJHANDLE pPERF, pPERFcomp; 855 OMX_U32 nLcml_nCntIp; 856 OMX_U32 nLcml_nCntOpReceived; 857#endif 858 859 /** Holds the value of RT Mixer mode */ 860 OMX_U32 rtmx; 861 862 /** Flags to control port enable command **/ 863 OMX_U32 bEnableCommandPending; 864 OMX_U32 bEnableCommandParam; 865 866 OMX_U8 nUnhandledFillThisBuffers; 867 OMX_U8 nUnhandledEmptyThisBuffers; 868 OMX_BOOL bFlushOutputPortCommandPending; 869 OMX_BOOL bFlushInputPortCommandPending; 870 871 OMX_BOOL bLoadedCommandPending; 872 OMX_PARAM_COMPONENTROLETYPE componentRole; 873 OMX_STRING* sDeviceString; 874 875 /** Keep buffer timestamps **/ 876 OMX_S64 arrTimestamp[G729ENC_MAX_NUM_OF_BUFS]; 877 878 /** Keep buffer timestamps **/ 879 OMX_S64 arrTickCount[G729ENC_MAX_NUM_OF_BUFS]; 880 881 /** Index to arrBufIndex[], used for input buffer timestamps */ 882 OMX_U8 IpBufindex; 883 884 /** Index to arrBufIndex[], used for output buffer timestamps */ 885 OMX_U8 OpBufindex; 886 887 OMX_BOOL bPreempted; 888 889 /** Pointer to RM callback **/ 890#ifdef RESOURCE_MANAGER_ENABLED 891 RMPROXY_CALLBACKTYPE rmproxyCallback; 892#endif 893 894} G729ENC_COMPONENT_PRIVATE; 895 896 897#ifndef UNDER_CE 898OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 899#else 900/* WinCE Implicit Export Syntax */ 901#define OMX_EXPORT __declspec(dllexport) 902/* =================================================================================== */ 903/** 904 * OMX_ComponentInit() Initializes component 905 * 906 * 907 * @param hComp OMX Handle 908 * 909 * @return OMX_ErrorNone = Successful 910 * Other error code = fail 911 * 912 */ 913/* =================================================================================== */ 914OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 915#endif 916/* =================================================================================== */ 917/** 918 * G729ENC_StartComponentThread() Starts component thread 919 * 920 * 921 * @param hComp OMX Handle 922 * 923 * @return OMX_ErrorNone = Successful 924 * Other error code = fail 925 * 926 */ 927/* =================================================================================== */ 928OMX_ERRORTYPE G729ENC_StartComponentThread(OMX_HANDLETYPE pHandle); 929/* =================================================================================== */ 930/** 931 * G729ENC_StopComponentThread() Stops component thread 932 * 933 * 934 * @param hComp OMX Handle 935 * 936 * @return OMX_ErrorNone = Successful 937 * Other error code = fail 938 * 939 */ 940/* =================================================================================== */ 941OMX_ERRORTYPE G729ENC_StopComponentThread(OMX_HANDLETYPE pHandle); 942/* =================================================================================== */ 943/** 944 * G729ENC_FreeCompResources() Frees allocated memory 945 * 946 * 947 * @param hComp OMX Handle 948 * 949 * @return OMX_ErrorNone = Successful 950 * Other error code = fail 951 * 952 */ 953/* =================================================================================== */ 954OMX_ERRORTYPE G729ENC_FreeCompResources(OMX_HANDLETYPE pComponent); 955/* =================================================================================== */ 956/** 957 * G729ENC_GetCorrespondingLCMLHeader() Returns LCML header 958 * that corresponds to the given buffer 959 * 960 * @param pComponentPrivate Component private data 961 * 962 * @return OMX_ErrorNone = Successful 963 * Other error code = fail 964 */ 965/* =================================================================================== */ 966OMX_ERRORTYPE G729ENC_GetCorrespondingLCMLHeader(OMX_U8 *pBuffer, 967 OMX_DIRTYPE eDir, 968 G729ENC_LCML_BUFHEADERTYPE **ppLcmlHdr, 969 G729ENC_COMPONENT_PRIVATE* pComponentPrivate); 970/* =================================================================================== */ 971/** 972 * G729ENC_LCMLCallback() Callback from LCML 973 * 974 * @param event Codec Event 975 * 976 * @param args Arguments from LCML 977 * 978 * @return OMX_ErrorNone = Successful 979 * Other error code = fail 980 */ 981/* =================================================================================== */ 982OMX_ERRORTYPE G729ENC_LCMLCallback(TUsnCodecEvent event, 983 void * args [10]); 984/* =================================================================================== */ 985/** 986 * G729ENC_FillLCMLInitParams() Fills the parameters needed 987 * to initialize the LCML 988 * 989 * @param pHandle OMX Handle 990 * 991 * @param plcml_Init LCML initialization parameters 992 * 993 * @return OMX_ErrorNone = Successful 994 * Other error code = fail 995 * 996 */ 997/* =================================================================================== */ 998OMX_ERRORTYPE G729ENC_FillLCMLInitParams(OMX_HANDLETYPE pHandle, 999 LCML_DSP *plcml_Init, 1000 OMX_U16 arr[]); 1001/* =================================================================================== */ 1002/** 1003 * G729ENC_GetBufferDirection() Returns direction of pBufHeader 1004 * 1005 * @param pBufHeader Buffer header 1006 * 1007 * @param eDir Buffer direction 1008 * 1009 * @param pComponentPrivate Component private data 1010 * 1011 * @return OMX_ErrorNone = Successful 1012 * Other error code = fail 1013 */ 1014/* =================================================================================== */ 1015OMX_ERRORTYPE G729ENC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, 1016 OMX_DIRTYPE *eDir); 1017/* =========================================================== */ 1018/** 1019 * G729ENC_HandleCommand() Handles commands sent via SendCommand() 1020 * 1021 * @param pComponentPrivate Component private data 1022 * 1023 * @return OMX_ErrorNone = Successful 1024 * Other error code = fail 1025 * @return OMX_ErrorNone = Successful 1026 * Other error code = fail 1027 */ 1028/* =================================================================================== */ 1029OMX_U32 G729ENC_HandleCommand(G729ENC_COMPONENT_PRIVATE *pComponentPrivate); 1030/* =================================================================================== */ 1031/** 1032 * G729ENC_HandleDataBufFromApp() Handles data buffers received 1033 * from the IL Client 1034 * 1035 * @param pComponentPrivate Component private data 1036 * 1037 * @return OMX_ErrorNone = Successful 1038 * Other error code = fail 1039 * @return OMX_ErrorNone = Successful 1040 * Other error code = fail 1041 */ 1042/* =================================================================================== */ 1043OMX_ERRORTYPE G729ENC_HandleDataBufFromApp(OMX_BUFFERHEADERTYPE *pBufHeader, 1044 G729ENC_COMPONENT_PRIVATE *pComponentPrivate); 1045/* =================================================================================== */ 1046/** 1047 * G729ENC_HandleDataBufFromLCML() Handles data buffers received 1048 * from LCML 1049 * 1050 * @param pComponentPrivate Component private data 1051 * 1052 * @return OMX_ErrorNone = Successful 1053 * Other error code = fail 1054 * @return OMX_ErrorNone = Successful 1055 * Other error code = fail 1056 */ 1057/* =================================================================================== */ 1058OMX_ERRORTYPE G729ENC_HandleDataBufFromLCML(G729ENC_COMPONENT_PRIVATE* pComponentPrivate); 1059 1060/* =================================================================================== */ 1061/** 1062 * G729ENC_GetLCMLHandle() Get the handle to the LCML 1063 * 1064 * 1065 * @return OMX_ErrorNone = Successful 1066 * Other error code = fail 1067 */ 1068/* =================================================================================== */ 1069OMX_HANDLETYPE G729ENC_GetLCMLHandle(G729ENC_COMPONENT_PRIVATE* pComponentPrivate); 1070/* =================================================================================== */ 1071/** 1072 * G729ENC_FreeLCMLHandle() Frees the handle to the LCML 1073 * 1074 * 1075 * @return OMX_ErrorNone = Successful 1076 * Other error code = fail 1077 */ 1078/* =================================================================================== */ 1079OMX_ERRORTYPE G729ENC_FreeLCMLHandle(G729ENC_COMPONENT_PRIVATE* pComponentPrivate); 1080/* =================================================================================== */ 1081/** 1082 * G729ENC_CleanupInitParams() Starts component thread 1083 * 1084 * @param pComponent OMX Handle 1085 * 1086 * @return OMX_ErrorNone = Successful 1087 * Other error code = fail 1088 */ 1089/* =================================================================================== */ 1090OMX_ERRORTYPE G729ENC_CleanupInitParams(OMX_HANDLETYPE pHandle); 1091/* =================================================================================== */ 1092/** 1093 * G729ENC_SetPending() Called when the component queues a buffer 1094 * to the LCML 1095 * 1096 * @param pComponentPrivate Component private data 1097 * 1098 * @param pBufHdr Buffer header 1099 * 1100 * @param eDir Direction of the buffer 1101 * 1102 * @return None 1103 */ 1104/* =================================================================================== */ 1105void G729ENC_SetPending(G729ENC_COMPONENT_PRIVATE *pComponentPrivate, 1106 OMX_BUFFERHEADERTYPE *pBufHdr, 1107 OMX_DIRTYPE eDir, 1108 OMX_U32 lineNumber); 1109/* =================================================================================== */ 1110/** 1111 * G729ENC_ClearPending() Called when a buffer is returned 1112 * from the LCML 1113 * 1114 * @param pComponentPrivate Component private data 1115 * 1116 * @param pBufHdr Buffer header 1117 * 1118 * @param eDir Direction of the buffer 1119 * 1120 * @return None 1121 */ 1122/* =================================================================================== */ 1123void G729ENC_ClearPending(G729ENC_COMPONENT_PRIVATE *pComponentPrivate, 1124 OMX_BUFFERHEADERTYPE *pBufHdr, 1125 OMX_DIRTYPE eDir, 1126 OMX_U32 lineNumber); 1127/* =================================================================================== */ 1128/** 1129 * G729ENC_IsPending() 1130 * 1131 * 1132 * @param pComponentPrivate Component private data 1133 * 1134 * @return OMX_ErrorNone = Successful 1135 * Other error code = fail 1136 */ 1137/* =================================================================================== */ 1138OMX_U32 G729ENC_IsPending(G729ENC_COMPONENT_PRIVATE *pComponentPrivate, 1139 OMX_BUFFERHEADERTYPE *pBufHdr, 1140 OMX_DIRTYPE eDir); 1141/* =================================================================================== */ 1142/** 1143 * G729ENC_FillLCMLInitParamsEx() Fills the parameters needed 1144 * to initialize the LCML without recreating the socket node 1145 * 1146 * @param pComponent OMX Handle 1147 * 1148 * @return None 1149 */ 1150/* =================================================================================== */ 1151OMX_ERRORTYPE G729ENC_FillLCMLInitParamsEx(OMX_HANDLETYPE pComponent); 1152/* =================================================================================== */ 1153/** 1154 * G729ENC_IsValid() Returns whether a buffer is valid 1155 * 1156 * 1157 * @param pComponentPrivate Component private data 1158 * 1159 * @param pBuffer Data buffer 1160 * 1161 * @param eDir Buffer direction 1162 * 1163 * @return OMX_True = Valid 1164 * OMX_False= Invalid 1165 */ 1166/* =================================================================================== */ 1167OMX_U32 G729ENC_IsValid(G729ENC_COMPONENT_PRIVATE *pComponentPrivate, 1168 OMX_U8 *pBuffer, 1169 OMX_DIRTYPE eDir); 1170 1171 1172/* ======================================================================= */ 1173/** OMX_G729ENC_INDEXAUDIOTYPE Defines the custom configuration settings 1174 * for the component 1175 * 1176 * @param OMX_IndexCustomG729ENCModeConfig Sets the DASF mode 1177 * 1178 * 1179 */ 1180/* ==================================================================== */ 1181typedef enum OMX_G729ENC_INDEXAUDIOTYPE 1182{ 1183 OMX_IndexCustomG729ENCModeConfig = 0xFF000001, 1184 OMX_IndexCustomG729ENCHeaderInfoConfig, 1185 OMX_IndexCustomG729ENCStreamIDConfig, 1186 OMX_IndexCustomG729ENCDataPath 1187 1188} OMX_G729ENC_INDEXAUDIOTYPE; 1189 1190 1191/* =========================================================== */ 1192/** 1193 * G729ENC_TransitionToIdle() Transitions component to idle 1194 * 1195 * 1196 * @param pComponentPrivate Component private data 1197 * 1198 * @return OMX_ErrorNone = No error 1199 * OMX Error code = Error 1200 */ 1201/*================================================================== */ 1202OMX_ERRORTYPE G729ENC_TransitionToIdle(G729ENC_COMPONENT_PRIVATE *pComponentPrivate); 1203 1204#ifdef RESOURCE_MANAGER_ENABLED 1205/*********************************** 1206 * Callback to the RM * 1207 ***********************************/ 1208void G729ENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData); 1209#endif 1210 1211#endif /* OMX_G729ENC_UTILS__H */ 1212 1213