Home | History | Annotate | Download | only in inc
      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_G711Dec_Utils.h
     30  *
     31  * This is an header file for an audio PCM decoder that is fully
     32  * compliant with the OMX Audio specification.
     33  * This the header file with the utils necesary to for the G711_DEC component.
     34  * in its code.
     35  *
     36  * @path $(CSLPATH)\
     37  *
     38  * @rev 0.1
     39  */
     40 /* --------------------------------------------------------------------------- */
     41 
     42 #ifndef OMX_G711DEC_UTILS__H
     43 #define OMX_G711DEC_UTILS__H
     44 
     45 #include "LCML_DspCodec.h"
     46 #include <OMX_Component.h>
     47 #include <pthread.h>
     48 
     49 #ifdef RESOURCE_MANAGER_ENABLED
     50 #include <ResourceManagerProxyAPI.h>
     51 #endif
     52 
     53 
     54 /* ======================================================================= */
     55 /**
     56  * @def    G711DEC_MAJOR_VER              Define value for "major" version
     57  */
     58 /* ======================================================================= */
     59 #define  G711DEC_MAJOR_VER 0xF1
     60 
     61 /* ======================================================================= */
     62 /**
     63  * @def    G711DEC_MINOR_VER              Define value for "minor" version
     64  */
     65 /* ======================================================================= */
     66 #define  G711DEC_MINOR_VER 0xF2
     67 
     68 /* ======================================================================= */
     69 /**
     70  * @def    NOT_USED                            Define a not used value
     71  */
     72 /* ======================================================================= */
     73 #define NOT_USED 10
     74 
     75 /* ======================================================================= */
     76 /**
     77  * @def    NORMAL_BUFFER                       Define a normal buffer value
     78  */
     79 /* ======================================================================= */
     80 #define NORMAL_BUFFER 0
     81 
     82 /* ======================================================================= */
     83 /**
     84  * @def    OMX_G711DEC_DEFAULT_SEGMENT        Define the default segment
     85  */
     86 /* ======================================================================= */
     87 #define OMX_G711DEC_DEFAULT_SEGMENT (0)
     88 
     89 /* ======================================================================= */
     90 /**
     91  * @def    OMX_G711DEC_SN_TIMEOUT            Define a value for SN Timeout
     92  */
     93 /* ======================================================================= */
     94 #define OMX_G711DEC_SN_TIMEOUT (-1)
     95 
     96 /* ======================================================================= */
     97 /**
     98  * @def    OMX_G711DEC_SN_PRIORITY           Define a value for SN Priority
     99  */
    100 /* ======================================================================= */
    101 #define OMX_G711DEC_SN_PRIORITY (10)
    102 
    103 /* ======================================================================= */
    104 /**
    105  * @def    OMX_G711DEC_CPU   TBD, 50MHz for the moment
    106  */
    107 /* ======================================================================= */
    108 #define OMX_G711DEC_CPU (50)
    109 
    110 /* ======================================================================= */
    111 /**
    112  * @def    G711DEC_USN_DLL_NAME             Path & Name of USN DLL to be used
    113  *                                           at initialization
    114  */
    115 /* ======================================================================= */
    116 #ifdef UNDER_CE
    117 #define G711DEC_USN_DLL_NAME "\\windows\\usn.dll64P"
    118 #else
    119 #define G711DEC_USN_DLL_NAME "usn.dll64P"
    120 #endif
    121 
    122 /* ======================================================================= */
    123 /**
    124  * @def    G711DEC_USN_DLL_NAME             Path & Name of DLL to be useda
    125  *                                           at initialization
    126  */
    127 /* ======================================================================= */
    128 #ifdef UNDER_CE
    129 #define G711DEC_DLL_NAME "\\windows\\g711dec_sn.dll64P"
    130 #else
    131 #define G711DEC_DLL_NAME "g711dec_sn.dll64P"
    132 #endif
    133 
    134 
    135 
    136 /* ======================================================================= */
    137 /**
    138  * @def    EXTRA_BUFFBYTES                Num of Extra Bytes to be allocated
    139  */
    140 /* ======================================================================= */
    141 #define EXTRA_BUFFBYTES (256)
    142 
    143 /* ======================================================================= */
    144 /**
    145  * @def    G711D_TIMEOUT   Default timeout used to come out of blocking calls
    146  */
    147 /* ======================================================================= */
    148 #define G711D_TIMEOUT (1000) /* millisecs */
    149 
    150 /* ======================================================================= */
    151 /**
    152  * @def    NUM_G711DEC_INPUT_BUFFERS              Number of Input Buffers
    153  */
    154 /* ======================================================================= */
    155 #define NUM_G711DEC_INPUT_BUFFERS 1
    156 
    157 /* ======================================================================= */
    158 /**
    159  * @def    NUM_G711DEC_OUTPUT_BUFFERS              Number of Output Buffers
    160  */
    161 /* ======================================================================= */
    162 #define NUM_G711DEC_OUTPUT_BUFFERS 1
    163 
    164 /* ======================================================================= */
    165 /**
    166  * @def    NUM_G711DEC_OUTPUT_BUFFERS_DASF         Number of Output Buffers
    167  *                                                  on DASF mode
    168  */
    169 /* ======================================================================= */
    170 #define NUM_G711DEC_OUTPUT_BUFFERS_DASF 2
    171 
    172 /* ======================================================================= */
    173 /**
    174  * @def    OUTPUT_G711DEC_BUFFER_SIZE           Standart Output Buffer Size
    175  */
    176 /* ======================================================================= */
    177 #define OUTPUT_G711DEC_BUFFER_SIZE 160
    178 
    179 /* ======================================================================= */
    180 /**
    181  * @def    INPUT_G711DEC_BUFFER_SIZE             Standart Input Buffer Size
    182  *
    183  */
    184 /* ======================================================================= */
    185 #define INPUT_G711DEC_BUFFER_SIZE 80
    186 /* ========================================================================== */
    187 /**
    188  * @def    RTP_Framesize                          Size in Bytes of determined
    189  *                                               frame. Not change it
    190  */
    191 /* ========================================================================== */
    192 #define RTP_Framesize 80
    193 /* ========================================================================== */
    194 /**
    195  * @def    STD_GSMFRDEC_BUF_SIZE                  Standart Input Buffer Size
    196  */
    197 /* ========================================================================== */
    198 #define STD_G711DEC_BUF_SIZE 80
    199 
    200 /* ======================================================================= */
    201 /**
    202  * @def    STREAM_COUNT                         Stream Count value for
    203  *                                              LCML init.
    204  */
    205 /* ======================================================================= */
    206 #define STREAM_COUNT 2
    207 
    208 /* ======================================================================= */
    209 /**
    210  * @def    INPUT_STREAM_ID                      Input Stream ID
    211  */
    212 /* ======================================================================= */
    213 #define INPUT_STREAM_ID 0
    214 
    215 /* ======================================================================= */
    216 /**
    217  * @def    MAX_NUM_OF_BUFS                      Max Num of Bufs Allowed
    218  */
    219 /* ======================================================================= */
    220 #define MAX_NUM_OF_BUFS 10
    221 /*========================================================================*/
    222 /** DEBUG PRINT's MACROS
    223  *@Memory check; printf's; component debug                                                           */
    224 /*========================================================================*/
    225 #undef G711DEC_DEBUG
    226 #undef G711DEC_PRINT
    227 #undef G711DEC_MEMCHECK
    228 /*========================================================================*/
    229 #define EXIT_COMPONENT_THRD  10
    230 void* ComponentThread (void* pThreadData);
    231 /*======================================================================*/
    232 #ifndef UNDER_CE
    233 #ifdef  G711DEC_DEBUG
    234 #define G711DEC_DPRINT(...)    fprintf(stderr,__VA_ARGS__)
    235 #else
    236 #define G711DEC_DPRINT(...)
    237 #endif
    238 
    239 #ifdef  G711DEC_MEMCHECK
    240 #define G711DEC_MEMPRINT(...)    fprintf(stderr,__VA_ARGS__)
    241 #else
    242 #define G711DEC_MEMPRINT(...)
    243 #endif
    244 
    245 
    246 #ifdef  G711DEC_DEBUG_MCP
    247 #define G711DEC_MCP_DPRINT(...)    fprintf(stderr,__VA_ARGS__)
    248 #else
    249 #define G711DEC_MCP_DPRINT(...)
    250 #endif
    251 
    252 #else /*UNDER_CE*/
    253 #ifdef  G711DEC_DEBUG
    254 #define G711DEC_DPRINT(STR, ARG...) printf()
    255 #else
    256 #endif
    257 
    258 #ifdef G711DEC_MEMCHECK
    259 #define G711DEC_MEMPRINT(STR, ARG...) printf()
    260 #else
    261 #endif
    262 #ifdef UNDER_CE
    263 
    264 #ifdef DEBUG
    265 #define G711DEC_DPRINT   printf
    266 #define G711DEC_MEMPRINT   printf
    267 #else
    268 #define G711DEC_DPRINT
    269 #define G711DEC_MEMPRINT
    270 #endif
    271 
    272 #endif  /*UNDER_CE*/
    273 
    274 #endif
    275 /**************************************************************/
    276 #ifdef  G711DEC_PRINT
    277 #define G711DEC_PRINT(...)    printf(stderr,__VA_ARGS__)
    278 #else
    279 #define G711DEC_PRINT(...)
    280 #endif
    281 
    282 /* ======================================================================= */
    283 /**
    284  * @def    WMADEC_MEMDEBUG   Enable memory leaks debuf info
    285  */
    286 /* ======================================================================= */
    287 #undef G711DEC_MEMDEBUG
    288 
    289 /* ======================================================================= */
    290 /**
    291  * @def  CACHE_ALIGNMENT                           Buffer Cache Alignment
    292  */
    293 /* ======================================================================= */
    294 #define CACHE_ALIGNMENT 128
    295 
    296 /* ======================================================================= */
    297 /**
    298  * @def    NUM_OF_PORTS                       Number of Comunication Port
    299  */
    300 /* ======================================================================= */
    301 #define NUM_OF_PORTS 2
    302 
    303 
    304 /* ======================================================================= */
    305 /**
    306  *  M A C R O S FOR MALLOC and MEMORY FREE and CLOSING PIPES
    307  */
    308 /* ======================================================================= */
    309 
    310 #define OMX_NBCONF_INIT_STRUCT(_s_, _name_)     \
    311     memset((_s_), 0x0, sizeof(_name_));         \
    312     (_s_)->nSize = sizeof(_name_);              \
    313     (_s_)->nVersion.s.nVersionMajor = 0x1;      \
    314     (_s_)->nVersion.s.nVersionMinor = 0x0;      \
    315     (_s_)->nVersion.s.nRevision = 0x0;          \
    316     (_s_)->nVersion.s.nStep = 0x0
    317 
    318 #define G711D_OMX_MALLOC(_pStruct_, _sName_)                        \
    319     _pStruct_ = (_sName_*)newmalloc(sizeof(_sName_));               \
    320     if(_pStruct_ == NULL){                                          \
    321         printf("***********************************\n");            \
    322         printf("%d :: Malloc Failed\n",__LINE__);                   \
    323         printf("***********************************\n");            \
    324         eError = OMX_ErrorInsufficientResources;                    \
    325         goto EXIT;                                                  \
    326     }                                                               \
    327     memset(_pStruct_,0,sizeof(_sName_));                            \
    328     G711DEC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_pStruct_);
    329 
    330 #define G711D_OMX_MALLOC_SIZE(_ptr_, _size_,_name_)             \
    331     _ptr_ = (_name_ *)newmalloc(_size_);                        \
    332     if(_ptr_ == NULL){                                          \
    333         printf("***********************************\n");        \
    334         printf("%d :: Malloc Failed\n",__LINE__);               \
    335         printf("***********************************\n");        \
    336         eError = OMX_ErrorInsufficientResources;                \
    337         goto EXIT;                                              \
    338     }                                                           \
    339     memset(_ptr_,0,_size_);                                     \
    340     G711DEC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_ptr_);
    341 
    342 #define OMX_G711DECMEMFREE_STRUCT(_pStruct_)                    \
    343     if(_pStruct_ != NULL){                                      \
    344     G711DEC_MEMPRINT("%d :: [FREE] %p\n",__LINE__,_pStruct_);   \
    345         newfree(_pStruct_);                                     \
    346         _pStruct_ = NULL;                                       \
    347     }
    348 
    349 #define OMX_NBCLOSE_PIPE(_pStruct_,err)                         \
    350     G711DEC_DPRINT("%d :: CLOSING PIPE \n",__LINE__);           \
    351     err = close (_pStruct_);                                    \
    352     if(0 != err && OMX_ErrorNone == eError){                    \
    353         eError = OMX_ErrorHardware;                             \
    354         printf("%d :: Error while closing pipe\n",__LINE__);    \
    355         goto EXIT;                                              \
    356     }
    357 
    358 /* ======================================================================= */
    359 /** G711DEC_COMP_PORT_TYPE  Port Type
    360  *
    361  *  @param  G711DEC_INPUT_PORT                   Port Type Input
    362  *
    363  *  @param  G711DEC_OUTPUT_PORT                  Port Type Output
    364  *
    365  */
    366 /*  ==================================================================== */
    367 typedef enum G711DEC_COMP_PORT_TYPE {
    368     G711DEC_INPUT_PORT = 0,
    369     G711DEC_OUTPUT_PORT
    370 }G711DEC_COMP_PORT_TYPE;
    371 
    372 /* ======================================================================= */
    373 /** G711DEC_StreamType  StreamType
    374  *
    375  *  @param  G711DEC_DMM                  Stream Type DMM
    376  *
    377  *  @param  G711DEC_INSTRM               Stream Type Input
    378  *
    379  *  @param  G711DEC_OUTSTRM             Stream Type Output
    380  */
    381 /*  ==================================================================== */
    382 enum G711DEC_StreamType
    383     {
    384         G711DEC_DMM,
    385         G711DEC_INSTRM,
    386         G711DEC_OUTSTRM
    387     };
    388 
    389 /* ======================================================================= */
    390 /** G711DEC_BUFFER_Dir  Direction of the Buffer
    391  *
    392  *  @param  G711DEC_DIRECTION_INPUT              Direction Input
    393  *
    394  *  @param  G711DEC_DIRECTION_INPUT              Direction Output
    395  */
    396 /*  ==================================================================== */
    397 typedef enum {
    398     G711DEC_DIRECTION_INPUT,
    399     G711DEC_DIRECTION_OUTPUT
    400 }G711DEC_BUFFER_Dir;
    401 
    402 
    403 /* =================================================================================== */
    404 /**
    405  *
    406  */
    407 /* ================================================================================== */
    408 typedef struct G711DEC_FTYPES{
    409     OMX_S16     FrameSizeType;
    410     OMX_S16     NmuNLvl;
    411     OMX_S16     NoiseLp;
    412     OMX_S16     dBmNoise;
    413     OMX_S16     plc;
    414 }G711DEC_FTYPES;
    415 /* =================================================================================== */
    416 /**
    417  * Socket node input parameters.
    418  */
    419 /* ================================================================================== */
    420 typedef struct G711DEC_AudioCodecParams
    421 {
    422     unsigned long iSamplingRate;
    423     unsigned long iStrmId;
    424     unsigned short iAudioFormat;
    425 }G711DEC_AudioCodecParams;
    426 
    427 /* =================================================================================== */
    428 /**
    429  * Socket node alg parameters..
    430  */
    431 /* ================================================================================== */
    432 typedef struct {
    433     unsigned long usEndOfFile;
    434     unsigned long usFrameLost;
    435 }G711DEC_UAlgInBufParamStruct;
    436 
    437 /* ========================================================================== */
    438 /**
    439  * Socket node alg parameters..
    440  * frameType @ Type of packaging per frame number
    441  * usLastFrame @ End of decoding
    442  */
    443 /* ========================================================================== */
    444 typedef struct G711DEC_FrameStruct{
    445     unsigned long   frameType; /* 0: voice frame (80 bytes), 1: SID frame (22 bytes), 2: No Data (0 bytes), 3: Frame lost */
    446     unsigned long   usLastFrame;
    447 } G711DEC_FrameStruct;
    448 
    449 typedef struct G711DEC_ParamStruct{
    450     unsigned long int usNbFrames;
    451     G711DEC_FrameStruct *pParamElem;
    452 } G711DEC_ParamStruct;
    453 
    454 /* =================================================================================== */
    455 /**
    456  * LCML_G711DEC_BUFHEADERTYPE
    457  */
    458 /* ================================================================================== */
    459 typedef struct LCML_G711DEC_BUFHEADERTYPE {
    460     G711DEC_BUFFER_Dir eDir;
    461     OMX_BUFFERHEADERTYPE* buffer;
    462     G711DEC_UAlgInBufParamStruct *pIpParam;
    463     G711DEC_FrameStruct *pFrameParam;
    464     G711DEC_ParamStruct *pBufferParam;
    465     DMM_BUFFER_OBJ* pDmmBuf;
    466 }LCML_G711DEC_BUFHEADERTYPE;
    467 
    468 #ifndef UNDER_CE
    469 
    470 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    471 
    472 #else
    473 /* =================================================================================== */
    474 /**
    475  *   OMX_EXPORT                                           WinCE Implicit Export Syntax
    476  */
    477 /* ================================================================================== */
    478 #define OMX_EXPORT __declspec(dllexport)
    479 
    480 OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    481 
    482 #endif
    483 
    484 OMX_ERRORTYPE G711DEC_StartComponentThread(OMX_HANDLETYPE pHandle);
    485 OMX_ERRORTYPE G711DEC_StopComponentThread(OMX_HANDLETYPE pHandle);
    486 OMX_ERRORTYPE G711DEC_FreeCompResources(OMX_HANDLETYPE pComponent);
    487 
    488 typedef struct _G711DEC_BUFFERLIST G711DEC_BUFFERLIST;
    489 
    490 /* =================================================================================== */
    491 /**
    492  * Structure for buffer list
    493  */
    494 /* ================================================================================== */
    495 struct _G711DEC_BUFFERLIST{
    496     OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS]; /* records buffer header send by client */
    497     OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
    498     OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
    499     OMX_U32 numBuffers;
    500 };
    501 
    502 /* =================================================================================== */
    503 /**
    504  * G711ENC_PORT_TYPE Structure for PortFormat details
    505  */
    506 /* =================================================================================== */
    507 typedef struct G711DEC_PORT_TYPE {
    508     OMX_HANDLETYPE hTunnelComponent;
    509     OMX_U32 nTunnelPort;
    510     OMX_BUFFERSUPPLIERTYPE eSupplierSetting;
    511     OMX_U8 nBufferCnt;
    512     OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat;
    513 } G711DEC_PORT_TYPE;
    514 
    515 OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size,
    516                          void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf);
    517 OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr,
    518                            void* pResPtr);
    519 /* =================================================================================== */
    520 /**
    521  * Component private data
    522  */
    523 /* ================================================================================== */
    524 typedef struct G711DEC_COMPONENT_PRIVATE
    525 {
    526 #ifdef UNDER_CE
    527     OMX_BUFFERHEADERTYPE* pBufHeader[NUM_OF_PORTS];
    528 #endif
    529 
    530     /** Structure of callback pointers */
    531     OMX_CALLBACKTYPE cbInfo;
    532 
    533     G711DEC_PORT_TYPE *pCompPort[NUM_OF_PORTS];
    534 
    535     /** Handle for use with async callbacks */
    536     OMX_PORT_PARAM_TYPE sPortParam;
    537 
    538     /** Input port parameters */
    539     OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
    540 
    541     /** Output port parameters */
    542     OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
    543 
    544     /** This will contain info like how many buffers
    545         are there for input/output ports, their size etc, but not
    546         BUFFERHEADERTYPE POINTERS. */
    547     OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
    548 
    549     /** G711 Component Parameters */
    550     OMX_AUDIO_PARAM_PCMMODETYPE* g711Params[NUM_OF_PORTS];
    551 
    552     /** This is component handle */
    553     OMX_COMPONENTTYPE* pHandle;
    554 
    555     /** Current state of this component */
    556     OMX_STATETYPE curState;
    557 
    558     /** The component thread handle */
    559     pthread_t ComponentThread;
    560 
    561     /** The pipes for sending buffers to the thread */
    562     int dataPipe[2];
    563 
    564     /** The pipes for sending buffers to the thread */
    565     int cmdPipe[2];
    566 
    567     /** The pipes for sending buffers to the thread */
    568     int cmdDataPipe[2];
    569 
    570     /** Set to indicate component is stopping */
    571     OMX_U32 bIsStopping;
    572 
    573     /** Flag set when the EOS marker is sent */
    574     OMX_U32 bIsEOFSent;
    575 
    576     /** Count of number of buffers outstanding with bridge */
    577     OMX_U32 lcml_nIpBuf;
    578 
    579     /** Count of number of buffers outstanding with bridge */
    580     OMX_U32 lcml_nOpBuf;
    581 
    582     /** Number of Buffers In the Application*/
    583     OMX_U32 app_nBuf;
    584 
    585     /** LCML Number Input Buffer Received*/
    586     OMX_U32 lcml_nCntIp;
    587 
    588     /** LCML Number Output Buffer Received*/
    589     OMX_U32 lcml_nCntOpReceived;
    590 
    591     /** Num Reclaimed OutPut Buff    */
    592     OMX_U32 num_Reclaimed_Op_Buff;
    593 
    594     /** Num Sent Input Buff   */
    595     OMX_U32 num_Sent_Ip_Buff;
    596 
    597     /** Num Sent Output Buff Issued   */
    598     OMX_U32 num_Op_Issued;
    599 
    600     /** LCML Handle */
    601     OMX_HANDLETYPE pLcmlHandle;
    602 
    603     /** LCML Buffer Header */
    604     LCML_G711DEC_BUFHEADERTYPE *pLcmlBufHeader[2];
    605 
    606     /** Flag for G711 mode */
    607     OMX_S16 iG711Mode;
    608 
    609     /** Flag for DASF mode */
    610     OMX_S16 dasfmode;
    611 
    612     /** Flag for ACDN mode */
    613     OMX_S16 acdnmode;
    614 
    615     /** Flag for frame size type mode */
    616     OMX_S16 fsizemode;
    617     /** Flag for fram type mode */
    618     OMX_S16 ftype;
    619     /** Flag for Noise Level NMU */
    620     OMX_S16 nmulevel;
    621     /** Flag for Noise LP  */
    622     OMX_S16 noiselp;
    623     /** Flag for Noise level in dBm */
    624     OMX_S16 dbmnoise;
    625     /** Flag for Noise level in dBm */
    626     OMX_S16 packetlostc;
    627 
    628     /** Writing pipe Used for DSP_RENDERING_ON */
    629     int fdwrite;
    630 
    631     /** Reading pipe Used for DSP_RENDERING_ON */
    632     int fdread;
    633 
    634     /* ID stream ID*/
    635     OMX_U32 streamID;
    636 
    637     /* Flag for Port Defs Allocated*/
    638     OMX_U32 bPortDefsAllocated;
    639 
    640     /* Flag for Component Thread Started*/
    641     OMX_U32 bCompThreadStarted;
    642 
    643     /** Mark data */
    644     OMX_PTR pMarkData;
    645 
    646     /** Mark buffer */
    647     OMX_MARKTYPE *pMarkBuf;
    648 
    649     /** Mark target component */
    650     OMX_HANDLETYPE hMarkTargetComponent;
    651 
    652     /** Flag set when buffer should not be queued to the DSP */
    653     OMX_U32 bBypassDSP;
    654 
    655     /** Input buffer list */
    656     G711DEC_BUFFERLIST *pInputBufferList;
    657 
    658     /** Output buffer list */
    659     G711DEC_BUFFERLIST *pOutputBufferList;
    660 
    661     /** LCML stream attributes */
    662     LCML_STRMATTR *strmAttr;
    663 
    664     /** Component version */
    665     OMX_U32 nVersion;
    666 
    667     /** Play Complete Flag */
    668     OMX_U32 bPlayCompleteFlag;
    669 
    670     /** Number of Bytes holding to be sent*/
    671     OMX_U32 nHoldLength;
    672 
    673     /** Pointer to the data holding to be sent*/
    674     OMX_U8* pHoldBuffer;
    675 
    676     /** Flag set when LCML handle is opened */
    677     OMX_S16 bLcmlHandleOpened;
    678 
    679     /** Keeps track of the number of nFillThisBufferCount() calls */
    680     OMX_U32 nFillThisBufferCount;
    681 
    682     /** Keeps track of the number of nFillBufferDoneCount() calls */
    683     OMX_U32 nFillBufferDoneCount;
    684 
    685     /** Keeps track of the number of nEmptyThisBufferCount() calls */
    686     OMX_U32 nEmptyThisBufferCount;
    687 
    688     /** Keeps track of the number of nEmptyBufferDoneCount() calls */
    689     OMX_U32 nEmptyBufferDoneCount;
    690 
    691     /** Parameters for the Audio Codec */
    692     G711DEC_AudioCodecParams *pParams;
    693 
    694     /** Flag for Init Params Initialized */
    695     OMX_U32 bInitParamsInitialized;
    696 
    697     /** Flag for bIdleCommandPending */
    698     OMX_U32 bIdleCommandPending;
    699 
    700     /** Array of Input Buffers that are pending to sent due State = Idle */
    701     OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];
    702 
    703     /** Number of Input Buffers that are pending to sent due State = Idle */
    704     OMX_U32 nNumInputBufPending;
    705 
    706     /** Array of Output Buffers that are pending to sent due State = Idle */
    707     OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];
    708 
    709     /** Number of Output Buffers that are pending to sent due State = Idle */
    710     OMX_U32 nNumOutputBufPending;
    711 
    712     /** Flag for Reenabling Ports*/
    713     OMX_U32 bJustReenabled;
    714 
    715     /** Flag for Invalid Frame Count*/
    716     OMX_U32 nInvalidFrameCount;
    717 
    718     /** Flag for Writes While Paused   */
    719     OMX_U32 nDataWritesWhilePaused;
    720 
    721     /** Flag for bDisableCommandPending*/
    722     OMX_U32 bDisableCommandPending;
    723 
    724     /** Flag for bDisableCommandParam*/
    725     OMX_U32 bDisableCommandParam;
    726 
    727     /** Flag for Enabling the port*/
    728     OMX_U32 bEnableCommandPending;
    729 
    730     /** Flag for Enabling the port*/
    731     OMX_U32 bEnableCommandParam;
    732 
    733     /** Flag to set when socket node stop callback should not transition
    734         component to OMX_StateIdle */
    735     OMX_U32 bNoIdleOnStop;
    736 
    737     /** Flag set when socket node is stopped */
    738     OMX_U32 bDspStoppedWhileExecuting;
    739 
    740     /** Number of outstanding FillBufferDone() calls */
    741     OMX_S32 nOutStandingFillDones;
    742 
    743     /** Stop Codec Command Sent Flag*/
    744     OMX_U8 bStopSent;
    745 
    746     OMX_BOOL bLoadedCommandPending;
    747 
    748     OMX_PARAM_COMPONENTROLETYPE componentRole;
    749 
    750     /* Device string */
    751     OMX_STRING* sDeviceString;
    752     /* Removing sleep() calls. Definition. */
    753 #ifndef UNDER_CE
    754     pthread_mutex_t AlloBuf_mutex;
    755     pthread_cond_t AlloBuf_threshold;
    756     OMX_U8 AlloBuf_waitingsignal;
    757 
    758     pthread_mutex_t InLoaded_mutex;
    759     pthread_cond_t InLoaded_threshold;
    760     OMX_U8 InLoaded_readytoidle;
    761 
    762     pthread_mutex_t InIdle_mutex;
    763     pthread_cond_t InIdle_threshold;
    764     OMX_U8 InIdle_goingtoloaded;
    765 #else
    766     OMX_Event AlloBuf_event;
    767     OMX_U8 AlloBuf_waitingsignal;
    768 
    769     OMX_Event InLoaded_event;
    770     OMX_U8 InLoaded_readytoidle;
    771 
    772     OMX_Event InIdle_event;
    773     OMX_U8 InIdle_goingtoloaded;
    774 #endif
    775     /**************************/
    776     OMX_U8 nUnhandledFillThisBuffers;
    777 
    778     /**Keep buffer tickcount*/
    779     OMX_U32 arrBufIndexTick[MAX_NUM_OF_BUFS];
    780 
    781     /** Keep buffer timestamps **/
    782     OMX_U32 arrBufIndex[MAX_NUM_OF_BUFS];
    783 
    784     /** Index to arrBufIndex[], used for input buffer timestamps */
    785     OMX_U8 IpBufindex;
    786 
    787     /** Index to arrBufIndex[], used for output buffer timestamps */
    788     OMX_U8 OpBufindex;
    789 
    790     /** Number of input buffers at runtime **/
    791     OMX_U32 nRuntimeInputBuffers;
    792 
    793     /** Pointer to RM callback **/
    794 #ifdef RESOURCE_MANAGER_ENABLED
    795     RMPROXY_CALLBACKTYPE rmproxyCallback;
    796 #endif
    797 
    798     OMX_BOOL bPreempted;
    799 
    800 
    801 } G711DEC_COMPONENT_PRIVATE;
    802 
    803 typedef enum OMX_G711DEC_INDEXAUDIOTYPE {
    804     OMX_IndexCustomG711DecModeAcdnConfig = 0xFF000001,
    805     OMX_IndexCustomG711DecModeDasfConfig,
    806     OMX_IndexCustomG711DecHeaderInfoConfig,
    807     OMX_IndexCustomG711DecFrameParams,
    808     OMX_IndexCustomG711DecDataPath
    809 }OMX_G711DEC_INDEXAUDIOTYPE;
    810 
    811 #ifdef RESOURCE_MANAGER_ENABLED
    812 /*========================================================================*/
    813 /** RESOURCE MANAGER CALLBACK                                                                    */
    814 /*=======================================================================*/
    815 void G711DEC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
    816 /* ========================================================================*/
    817 #endif
    818 
    819 OMX_ERRORTYPE G711DECGetCorresponding_LCMLHeader(OMX_U8 *pBuffer,
    820                                                  OMX_DIRTYPE eDir,
    821                                                  LCML_G711DEC_BUFHEADERTYPE **ppLcmlHdr);
    822 /***********CALLBACK EVENT TO SN**********/
    823 OMX_ERRORTYPE G711DECLCML_Callback (TUsnCodecEvent event,void * args [10]);
    824 
    825 OMX_ERRORTYPE G711DECFill_LCMLInitParams(OMX_HANDLETYPE pHandle,
    826                                          LCML_DSP *plcml_Init,OMX_U16 arr[]);
    827 
    828 OMX_ERRORTYPE G711DECGetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, OMX_DIRTYPE *eDir);
    829 
    830 OMX_U32 G711DECHandleCommand (G711DEC_COMPONENT_PRIVATE *pComponentPrivate);
    831 
    832 OMX_ERRORTYPE G711DECHandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
    833                                            G711DEC_COMPONENT_PRIVATE *pComponentPrivate);
    834 
    835 OMX_ERRORTYPE G711DECHandleDataBuf_FromLCML(G711DEC_COMPONENT_PRIVATE* pComponentPrivate,
    836                                             LCML_G711DEC_BUFHEADERTYPE* msgBuffer);
    837 
    838 void  AddHeader(BYTE **pFileBuf);
    839 void  ResetPtr(BYTE **pFileBuf);
    840 
    841 OMX_HANDLETYPE G711DECGetLCMLHandle();
    842 OMX_ERRORTYPE G711DECFreeLCMLHandle();
    843 OMX_ERRORTYPE G711DEC_CleanupInitParams(OMX_HANDLETYPE pComponent);
    844 
    845 void G711DEC_SetPending(G711DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
    846 void G711DEC_ClearPending(G711DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir) ;
    847 
    848 OMX_U32 G711DEC_IsPending(G711DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
    849 OMX_ERRORTYPE G711DECFill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent);
    850 OMX_U32 G711DEC_IsValid(G711DEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer, OMX_DIRTYPE eDir) ;
    851 OMX_ERRORTYPE G711DEC_TransitionToIdle(G711DEC_COMPONENT_PRIVATE *pComponentPrivate);
    852 
    853 #endif /* OMX_G711DECODER_H*/
    854