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_G726Enc_Utils.h
     30 *
     31 * This is an header file for an G726 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\g726_enc\inc
     36 *
     37 * @rev 1.0
     38 */
     39 /* --------------------------------------------------------------------------- */
     40 /* ----------------------------------------------------------------------------
     41 *!
     42 *! Revision History
     43 *! ===================================
     44 *! Gyancarlo Garcia: Initial Verision
     45 *! 05-Oct-2007
     46 *!
     47 * =========================================================================== */
     48 #ifndef OMX_G726ENC_UTILS__H
     49 #define OMX_G726ENC_UTILS__H
     50 
     51 #include <pthread.h>
     52 #include "LCML_DspCodec.h"
     53 #include <OMX_Component.h>
     54 #include <TIDspOmx.h>
     55 
     56 #ifdef RESOURCE_MANAGER_ENABLED
     57 #include <ResourceManagerProxyAPI.h>
     58 #endif
     59 
     60 #ifdef UNDER_CE
     61 	#define sleep Sleep
     62 #endif
     63 
     64 
     65 /* ======================================================================= */
     66 /**
     67  * @def    G726ENC_DEBUG   Turns debug messaging on and off
     68  */
     69 /* ======================================================================= */
     70 #undef G726ENC_DEBUG
     71 /*#define G726ENC_DEBUG*/
     72 /* ======================================================================= */
     73 /**
     74  * @def    G726ENC_MEMCHECK   Turns memory messaging on and off
     75  */
     76 /* ======================================================================= */
     77 #undef G726ENC_MEMCHECK
     78 
     79 #ifndef UNDER_CE
     80 /* ======================================================================= */
     81 /**
     82  * @def    G726ENC_DEBUG   Debug print macro
     83  */
     84 /* ======================================================================= */
     85 #ifdef  G726ENC_DEBUG
     86         #define G726ENC_DPRINT(...)    fprintf(stderr,__VA_ARGS__)
     87 #else
     88         #define G726ENC_DPRINT(...)
     89 #endif
     90 /* ======================================================================= */
     91 /**
     92  * @def    G726ENC_MEMCHECK   Memory print macro
     93  */
     94 /* ======================================================================= */
     95 #ifdef  G726ENC_MEMCHECK
     96         #define G726ENC_MEMPRINT(...)    fprintf(stderr,__VA_ARGS__)
     97 #else
     98         #define G726ENC_MEMPRINT(...)
     99 #endif
    100 
    101 #else   /*UNDER_CE*/
    102 /* ======================================================================= */
    103 /**
    104  * @def    G726ENC_DEBUG   Debug print macro
    105  */
    106 /* ======================================================================= */
    107 #ifdef  G726ENC_DEBUG
    108     #define G726ENC_DPRINT(STR, ARG...) printf()
    109 #else
    110 
    111 #endif
    112 
    113 /* ======================================================================= */
    114 /**
    115  * @def    G726ENC_MEMCHECK   Memory print macro
    116  */
    117 /* ======================================================================= */
    118 #ifdef  G726ENC_MEMCHECK
    119 		#define G726ENC_MEMPRINT(STR, ARG...) printf()
    120 #else
    121 
    122 #endif
    123 
    124 #endif
    125 
    126 #ifdef DEBUG
    127 		#define G726ENC_DPRINT(...)    fprintf(stderr,__VA_ARGS__)
    128 		#define G726ENC_MEMPRINT(...)    fprintf(stderr,__VA_ARGS__)
    129 		#define G726ENC_EPRINT(...)    fprintf(stderr,__VA_ARGS__)
    130 #else
    131 		#define G726ENC_DPRINT(...)
    132 		#define G726ENC_MEMPRINT(...)
    133 		#define G726ENC_EPRINT(...)
    134 #endif
    135 
    136 /* ======================================================================= */
    137 /**
    138  * @def    G726ENC_DEBUGMEM   Turns memory leaks messaging on and off.
    139  *         APP_DEBUGMEM must be defined in Test App in order to get
    140  *         this functionality On.
    141  */
    142 /* ======================================================================= */
    143 #undef G726ENC_DEBUGMEM
    144 /*#define G726ENC_DEBUGMEM*/
    145 
    146 /* ======================================================================= */
    147 /**
    148  *  M A C R O S FOR MALLOC and MEMORY FREE and CLOSING PIPES
    149  */
    150 /* ======================================================================= */
    151 
    152 #define OMX_NBCONF_INIT_STRUCT(_s_, _name_)	\
    153     memset((_s_), 0x0, sizeof(_name_));	\
    154     (_s_)->nSize = sizeof(_name_);		\
    155     (_s_)->nVersion.s.nVersionMajor = 0x1;	\
    156     (_s_)->nVersion.s.nVersionMinor = 0x0;	\
    157     (_s_)->nVersion.s.nRevision = 0x0;		\
    158     (_s_)->nVersion.s.nStep = 0x0
    159 
    160 #define OMX_NBMEMFREE_STRUCT(_pStruct_)\
    161 	G726ENC_MEMPRINT("%d :: [FREE] %p\n",__LINE__,_pStruct_);\
    162     if(_pStruct_ != NULL){\
    163         SafeFree(_pStruct_);\
    164 	    _pStruct_ = NULL;\
    165 	}
    166 
    167 #define OMX_NBCLOSE_PIPE(_pStruct_,err)\
    168 	G726ENC_DPRINT("%d :: CLOSING PIPE \n",__LINE__);\
    169 	err = close (_pStruct_);\
    170     if(0 != err && OMX_ErrorNone == eError){\
    171 		eError = OMX_ErrorHardware;\
    172 		printf("%d :: Error while closing pipe\n",__LINE__);\
    173 		goto EXIT;\
    174 	}
    175 
    176 #define OMX_NBMALLOC_STRUCT(_pStruct_, _sName_)   \
    177     _pStruct_ = (_sName_*)SafeMalloc(sizeof(_sName_));      \
    178     if(_pStruct_ == NULL){      \
    179         printf("***********************************\n"); \
    180         printf("%d :: Malloc Failed\n",__LINE__); \
    181         printf("***********************************\n"); \
    182         eError = OMX_ErrorInsufficientResources; \
    183         goto EXIT;      \
    184     } \
    185     G726ENC_MEMPRINT("%d :: [ALLOC] %p\n",__LINE__,_pStruct_);
    186 
    187 
    188 /* ======================================================================= */
    189 /**
    190  * @def G726ENC_NUM_INPUT_BUFFERS   Default number of input buffers
    191  */
    192 /* ======================================================================= */
    193 #define G726ENC_NUM_INPUT_BUFFERS 1
    194 /* ======================================================================= */
    195 /**
    196  * @def G726ENC_NUM_INPUT_BUFFERS_DASF  Default No.of input buffers DASF
    197  */
    198 /* ======================================================================= */
    199 #define G726ENC_NUM_INPUT_BUFFERS_DASF 2
    200 /* ======================================================================= */
    201 /**
    202  * @def G726ENC_NUM_OUTPUT_BUFFERS   Default number of output buffers
    203  */
    204 /* ======================================================================= */
    205 #define G726ENC_NUM_OUTPUT_BUFFERS 1
    206 /* ======================================================================= */
    207 /**
    208  * @def G726ENC_INPUT_BUFFER_SIZE_DASF  Default input buffer size DASF
    209  */
    210 /* ======================================================================= */
    211 #define G726ENC_INPUT_BUFFER_SIZE_DASF 80
    212 /*16*/
    213 /* ======================================================================= */
    214 /**
    215  * @def G726ENC_INPUT_BUFFER_SIZE  Default input buffer size DASF
    216  */
    217 /* ======================================================================= */
    218 #define G726ENC_INPUT_BUFFER_SIZE 16
    219 /* ======================================================================= */
    220 /**
    221  * @def G726ENC_OUTPUT_BUFFER_SIZE   Default output buffer size
    222  */
    223 /* ======================================================================= */
    224 #define G726ENC_OUTPUT_BUFFER_SIZE 60
    225 
    226 /* ======================================================================= */
    227 /**
    228  * @def	G726ENC_APP_ID  App ID Value setting
    229  */
    230 /* ======================================================================= */
    231 #define G726ENC_APP_ID 100
    232 
    233 /* ======================================================================= */
    234 /**
    235  * @def    G726ENC_SAMPLING_FREQUENCY   Sampling frequency
    236  */
    237 /* ======================================================================= */
    238 #define G726ENC_SAMPLING_FREQUENCY 8000
    239 /* ======================================================================= */
    240 /**
    241  * @def    G726ENC_MAX_NUM_OF_BUFS   Maximum number of buffers
    242  */
    243 /* ======================================================================= */
    244 #define G726ENC_MAX_NUM_OF_BUFS 10
    245 /* ======================================================================= */
    246 /**
    247  * @def    G726ENC_NUM_OF_PORTS   Number of ports
    248  */
    249 /* ======================================================================= */
    250 #define G726ENC_NUM_OF_PORTS 2
    251 /* ======================================================================= */
    252 /**
    253  * @def    G726ENC_XXX_VER    Component version
    254  */
    255 /* ======================================================================= */
    256 #define G726ENC_MAJOR_VER 0xF1
    257 #define G726ENC_MINOR_VER 0xF2
    258 /* ======================================================================= */
    259 /**
    260  * @def    G726ENC_NOT_USED    Defines a value for "don't care" parameters
    261  */
    262 /* ======================================================================= */
    263 #define G726ENC_NOT_USED 10
    264 /* ======================================================================= */
    265 /**
    266  * @def    G726ENC_NORMAL_BUFFER  Defines flag value with all flags off
    267  */
    268 /* ======================================================================= */
    269 #define G726ENC_NORMAL_BUFFER 0
    270 /* ======================================================================= */
    271 /**
    272  * @def    OMX_G726ENC_DEFAULT_SEGMENT    Default segment ID for the LCML
    273  */
    274 /* ======================================================================= */
    275 #define G726ENC_DEFAULT_SEGMENT (0)
    276 /* ======================================================================= */
    277 /**
    278  * @def    OMX_G726ENC_SN_TIMEOUT    Timeout value for the socket node
    279  */
    280 /* ======================================================================= */
    281 #define G726ENC_SN_TIMEOUT (-1)
    282 /* ======================================================================= */
    283 /**
    284  * @def    OMX_G726ENC_SN_PRIORITY   Priority for the socket node
    285  */
    286 /* ======================================================================= */
    287 #define G726ENC_SN_PRIORITY (10)
    288 /* ======================================================================= */
    289 /**
    290  * @def    G726ENC_CPU   TBD, 50MHz for the moment
    291  */
    292 /* ======================================================================= */
    293 #define G726ENC_CPU (50)
    294 /* ======================================================================= */
    295 /**
    296  * @def    OMX_G726ENC_NUM_DLLS   number of DLL's
    297  */
    298 /* ======================================================================= */
    299 #define G726ENC_NUM_DLLS (2)
    300 /* ======================================================================= */
    301 /**
    302  * @def    G726ENC_USN_DLL_NAME   USN DLL name
    303  */
    304 /* ======================================================================= */
    305 #ifdef UNDER_CE
    306 	#define G726ENC_USN_DLL_NAME "\\windows\\usn.dll64P"
    307 #else
    308 	#define G726ENC_USN_DLL_NAME "usn.dll64P"
    309 #endif
    310 
    311 /* ======================================================================= */
    312 /**
    313  * @def    G726ENC_DLL_NAME   G726 Encoder socket node dll name
    314  */
    315 /* ======================================================================= */
    316 #ifdef UNDER_CE
    317 	#define G726ENC_DLL_NAME "\\windows\\g726enc_sn.dll64P"
    318 #else
    319 	#define G726ENC_DLL_NAME "g726enc_sn.dll64P"
    320 #endif
    321 
    322 /* ======================================================================= */
    323 /** G726ENC_StreamType  Stream types
    324 *
    325 *  @param  G726ENC_DMM					DMM
    326 *
    327 *  @param  G726ENC_INSTRM				Input stream
    328 *
    329 *  @param  G726ENC_OUTSTRM				Output stream
    330 */
    331 /* ======================================================================= */
    332 enum G726ENC_StreamType {
    333     G726ENC_DMM = 0,
    334     G726ENC_INSTRM,
    335     G726ENC_OUTSTRM
    336 };
    337 
    338 /* ======================================================================= */
    339 /**
    340  * @def G726ENC_TIMEOUT Default timeout used to come out of blocking calls
    341  */
    342 /* ======================================================================= */
    343 #define G726ENC_TIMEOUT 1000
    344 /* ======================================================================= */
    345 /*
    346  * @def	G726ENC_OMX_MAX_TIMEOUTS   Max Time Outs
    347  * @def	G726ENC_DONT_CARE 			Dont Care Condition
    348  * @def	G726ENC_NUM_CHANNELS 		Number of Channels
    349  * @def	G726ENC_APP_ID 			App ID Value setting
    350  */
    351 /* ======================================================================= */
    352 #define G726ENC_OMX_MAX_TIMEOUTS 20
    353 #define G726ENC_DONT_CARE 0
    354 #define G726ENC_NUM_CHANNELS 1
    355 /* ======================================================================= */
    356 /**
    357  * @def    G726ENC_STREAM_COUNT    Number of streams
    358  * 		   G726ENC_INPUT_STREAM_ID Stream ID for Input Buffer
    359  */
    360 /* ======================================================================= */
    361 #define G726ENC_STREAM_COUNT 2
    362 #define G726ENC_INPUT_STREAM_ID 0
    363 
    364 /* ======================================================================= */
    365 /** G726ENC_COMP_PORT_TYPE  Port types
    366  *
    367  *  @param  G726ENC_INPUT_PORT				Input port
    368  *
    369  *  @param  G726ENC_OUTPUT_PORT			Output port
    370  */
    371 /*  ====================================================================== */
    372 /*This enum must not be changed. */
    373 typedef enum G726ENC_COMP_PORT_TYPE {
    374     G726ENC_INPUT_PORT = 0,
    375     G726ENC_OUTPUT_PORT
    376 }G726ENC_COMP_PORT_TYPE;
    377 
    378 /* ======================================================================= */
    379 /** G726ENC_BUFFER_Dir  Buffer Direction
    380 *
    381 *  @param  G726ENC_DIRECTION_INPUT		Input direction
    382 *
    383 *  @param  G726ENC_DIRECTION_OUTPUT	Output direction
    384 *
    385 */
    386 /* ======================================================================= */
    387 typedef enum {
    388     G726ENC_DIRECTION_INPUT,
    389     G726ENC_DIRECTION_OUTPUT
    390 }G726ENC_BUFFER_Dir;
    391 
    392 
    393 
    394 /* ======================================================================= */
    395 /** G726ENC_BUFFS  Buffer details
    396 *
    397 *  @param  BufHeader Buffer header
    398 *
    399 *  @param  Buffer	Buffer
    400 *
    401 */
    402 /* ======================================================================= */
    403 typedef struct G726ENC_BUFFS {
    404     char BufHeader;
    405     char Buffer;
    406 }G726ENC_BUFFS;
    407 
    408 /* ======================================================================= */
    409 /** G726ENC_BUFFERHEADERTYPE_INFO
    410 *
    411 *  @param  pBufHeader
    412 *
    413 *  @param  bBufOwner
    414 *
    415 */
    416 /* ======================================================================= */
    417 typedef struct G726ENC_BUFFERHEADERTYPE_INFO {
    418     OMX_BUFFERHEADERTYPE* pBufHeader[G726ENC_MAX_NUM_OF_BUFS];
    419     G726ENC_BUFFS bBufOwner[G726ENC_MAX_NUM_OF_BUFS];
    420 }G726ENC_BUFFERHEADERTYPE_INFO;
    421 
    422 
    423 typedef OMX_ERRORTYPE (*G726ENC_fpo)(OMX_HANDLETYPE);
    424 
    425 /* =================================================================================== */
    426 /**
    427 * Socket node Audio Codec Configuration parameters.
    428 */
    429 /* =================================================================================== */
    430 typedef struct G726ENC_AudioCodecParams {
    431 	unsigned long  iSamplingRate;
    432 	unsigned long  iStrmId;
    433 	unsigned short iAudioFormat;
    434 }G726ENC_AudioCodecParams; /*Especified as USN_AudioCodecParams on SN Guide*/
    435 
    436 /* =================================================================================== */
    437 /**
    438 * G726ENC_ParamStruct		Input Buffer Param Structure
    439 * bLastBuffer 						To Send Last Buufer Flag
    440 */
    441 /* =================================================================================== */
    442 typedef struct G726ENC_ParamStruct {
    443     /*unsigned long bLastBuffer;	*/
    444     unsigned short bLastBuffer;
    445 } G726ENC_ParamStruct;
    446 
    447 /* =================================================================================== */
    448 /**
    449 * G726ENC_LCML_BUFHEADERTYPE Buffer Header Type
    450 */
    451 /* =================================================================================== */
    452 typedef struct G726ENC_LCML_BUFHEADERTYPE {
    453       G726ENC_BUFFER_Dir eDir;
    454       G726ENC_ParamStruct *pIpParam;
    455 /*      G726ENC_ParamStruct *pOpParam;*/ /*According SN guide, this should not be necessary*/
    456       OMX_BUFFERHEADERTYPE* buffer;
    457 }G726ENC_LCML_BUFHEADERTYPE;
    458 
    459 typedef struct _G726ENC_BUFFERLIST G726ENC_BUFFERLIST;
    460 
    461 /* =================================================================================== */
    462 /**
    463 * _G726ENC_BUFFERLIST Structure for buffer list
    464 */
    465 /* ================================================================================== */
    466 struct _G726ENC_BUFFERLIST{
    467 	OMX_BUFFERHEADERTYPE sBufHdr;
    468     OMX_BUFFERHEADERTYPE *pBufHdr[G726ENC_MAX_NUM_OF_BUFS];
    469 	OMX_U32 bufferOwner[G726ENC_MAX_NUM_OF_BUFS];
    470 	OMX_U32 bBufferPending[G726ENC_MAX_NUM_OF_BUFS];
    471 	OMX_U32 numBuffers;
    472     G726ENC_BUFFERLIST *pNextBuf;
    473     G726ENC_BUFFERLIST *pPrevBuf;
    474 };
    475 
    476 /* =================================================================================== */
    477 /**
    478 * G726ENC_PORT_TYPE Structure for PortFormat details
    479 */
    480 /* =================================================================================== */
    481 typedef struct G726ENC_PORT_TYPE {
    482     OMX_HANDLETYPE hTunnelComponent;
    483     OMX_U32 nTunnelPort;
    484     OMX_BUFFERSUPPLIERTYPE eSupplierSetting;
    485 	OMX_U8 nBufferCnt;
    486 	OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat;
    487 } G726ENC_PORT_TYPE;
    488 
    489 /* =================================================================================== */
    490 /**
    491 * G726ENC_COMPONENT_PRIVATE Component private data Structure
    492 */
    493 /* =================================================================================== */
    494 typedef struct G726ENC_COMPONENT_PRIVATE
    495 {
    496     /** callback Info */
    497     OMX_CALLBACKTYPE cbInfo;
    498 
    499     /** port parameters Info */
    500     OMX_PORT_PARAM_TYPE* sPortParam; /*Needed??*/
    501 
    502     /** priority management */
    503     OMX_PRIORITYMGMTTYPE* sPriorityMgmt;
    504 
    505     /** port definition structure */
    506     OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[G726ENC_NUM_OF_PORTS];
    507 
    508     /** port parameter structure */
    509     OMX_AUDIO_PARAM_G726TYPE* G726Params[G726ENC_NUM_OF_PORTS];
    510 
    511     /** Buffer info */
    512     G726ENC_BUFFERHEADERTYPE_INFO BufInfo[G726ENC_NUM_OF_PORTS];
    513 
    514     /** Component ports */
    515     G726ENC_PORT_TYPE *pCompPort[G726ENC_NUM_OF_PORTS];
    516 
    517     /** LCML headers */
    518     G726ENC_LCML_BUFHEADERTYPE *pLcmlBufHeader[G726ENC_NUM_OF_PORTS];
    519 
    520     /** This is component handle */
    521     OMX_COMPONENTTYPE* pHandle;
    522 
    523     /** Current state of this component */
    524     OMX_STATETYPE curState;
    525 
    526     /** The component thread handle */
    527     pthread_t ComponentThread;
    528 
    529     /** The pipes for sending buffers to the thread */
    530     int dataPipe[2];
    531 
    532     /** The pipes for sending command to the thread */
    533     int cmdPipe[2];
    534 
    535     /** The pipes for sending cmd data to the thread */
    536     int cmdDataPipe[2];
    537 
    538     /** dasf mode flag */
    539     OMX_U32 dasfMode;
    540 
    541     /** acdn mode flag */
    542     OMX_U32 acdnMode;
    543 
    544     /** rtp mode flag */
    545     OMX_U32 rtpMode;
    546 
    547     /** Set to indicate component is stopping */
    548     OMX_U32 bIsStopping;
    549 
    550     /** stream ID */
    551     OMX_U32 streamID;
    552 
    553     /** port defaults allocated */
    554     OMX_U32 bPortDefsAllocated;
    555 
    556     /** thread started flag */
    557     OMX_U32 bCompThreadStarted;
    558 
    559     /** version number */
    560     OMX_U32 nVersion;
    561 
    562     /** FillThisBufferCount */
    563     OMX_U32 nFillThisBufferCount;
    564 
    565     /** FillBufferDoneCount */
    566     OMX_U32 nFillBufferDoneCount;
    567 
    568     /** EmptyThisBufferCount */
    569     OMX_U32 nEmptyThisBufferCount;
    570 
    571     /** EmptyBufferDoneCount */
    572     OMX_U32 nEmptyBufferDoneCount;
    573 
    574     /** InitParamsInitialized */
    575     OMX_U32 bInitParamsInitialized;
    576 
    577     /** NumInputBufPending */
    578     OMX_U32 nNumInputBufPending;
    579 
    580     /** NumOutputBufPending */
    581     OMX_U32 nNumOutputBufPending;
    582 
    583     /** DisableCommandPending */
    584     OMX_U32 bDisableCommandPending;
    585 
    586     /** DisableCommandParam */
    587     OMX_U32 bDisableCommandParam;
    588 
    589     /** Lcml Handle */
    590     OMX_HANDLETYPE pLcmlHandle;
    591 
    592     /** Mark Data pointer */
    593     OMX_PTR pMarkData;
    594 
    595     /** Mark Buffer pointer */
    596     OMX_MARKTYPE *pMarkBuf;
    597 
    598     /** Mark Target component */
    599     OMX_HANDLETYPE hMarkTargetComponent;
    600 
    601     /** pointer to Input Buffer List */
    602     G726ENC_BUFFERLIST *pInputBufferList;
    603 
    604     /** pointer to Output Buffer List */
    605     G726ENC_BUFFERLIST *pOutputBufferList;
    606 
    607     /** LCML stream attributes */
    608     LCML_STRMATTR *strmAttr;
    609 
    610     /** pointer to audio codec parameters */
    611     G726ENC_AudioCodecParams *pParams;
    612 
    613     /** component name */
    614     OMX_STRING cComponentName;
    615 
    616     /** component version */
    617     OMX_VERSIONTYPE ComponentVersion;
    618 
    619     /** pending input buffer headers */
    620     OMX_BUFFERHEADERTYPE *pInputBufHdrPending[G726ENC_MAX_NUM_OF_BUFS];
    621 
    622     /** pending output buffer headers */
    623     OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[G726ENC_MAX_NUM_OF_BUFS];
    624 
    625     /** Flag to set when socket node stop callback should not transition
    626     component to OMX_StateIdle */
    627     OMX_U32 bNoIdleOnStop;
    628 
    629     /** Flag set when socket node is stopped */
    630     OMX_U32 bDspStoppedWhileExecuting;
    631 
    632     /** Number of outstanding FillBufferDone() calls */
    633     OMX_U32 nOutStandingFillDones;
    634 
    635 #ifndef UNDER_CE
    636     /** sync mutexes and signals */
    637     pthread_mutex_t AlloBuf_mutex;
    638     pthread_cond_t AlloBuf_threshold;
    639     OMX_U8 AlloBuf_waitingsignal;
    640 
    641     pthread_mutex_t InLoaded_mutex;
    642     pthread_cond_t InLoaded_threshold;
    643     OMX_U8 InLoaded_readytoidle;
    644 
    645     pthread_mutex_t InIdle_mutex;
    646     pthread_cond_t InIdle_threshold;
    647     OMX_U8 InIdle_goingtoloaded;
    648 #endif
    649     /** pointer to LCML lib */
    650     void* ptrLibLCML;
    651 
    652     /** frame size array */
    653     OMX_U8 G726FrameSize[4];
    654 
    655     /** component role */
    656     OMX_PARAM_COMPONENTROLETYPE componentRole;
    657 
    658     /** device string */
    659     OMX_STRING* sDeviceString;
    660 
    661     /** runtime input buffers */
    662     OMX_U8 nRuntimeInputBuffers;
    663 
    664     /** runtime output buffers */
    665     OMX_U8 nRuntimeOutputBuffers;
    666 
    667     /** hold buffer */
    668     OMX_U8 *pHoldBuffer;
    669 
    670     /** hold length */
    671     OMX_U16 nHoldLength;
    672 
    673     /** temp buffer */
    674     OMX_U8 *ptempBuffer;
    675 
    676     /** last out buffer arrived */
    677     OMX_BUFFERHEADERTYPE *lastOutBufArrived;
    678 
    679     /** last buffer sent */
    680     OMX_U8 LastBufSent;
    681 
    682     /** Keep buffer timestamps **/
    683     OMX_S64 arrTimestamp[G726ENC_MAX_NUM_OF_BUFS];
    684     /** Keep buffer nTickCounts **/
    685     OMX_S64 arrTickCount[G726ENC_MAX_NUM_OF_BUFS];
    686     /** Index to arrTimestamp[], used for input buffer timestamps */
    687     OMX_U8 IpBufindex;
    688     /** Index to arrTimestamp[], used for output buffer timestamps */
    689     OMX_U8 OpBufindex;
    690 
    691     /** preempted flag */
    692     OMX_BOOL bPreempted;
    693 
    694     /** Pointer to RM callback **/
    695 #ifdef RESOURCE_MANAGER_ENABLED
    696     RMPROXY_CALLBACKTYPE rmproxyCallback;
    697 #endif
    698 
    699 } G726ENC_COMPONENT_PRIVATE;
    700 
    701 
    702 #ifndef UNDER_CE
    703     OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    704 #else
    705 /*  WinCE Implicit Export Syntax */
    706 #define OMX_EXPORT __declspec(dllexport)
    707 /* =================================================================================== */
    708 /**
    709 *  OMX_ComponentInit()  Initializes component
    710 *
    711 *
    712 *  @param hComp			OMX Handle
    713 *
    714 *  @return OMX_ErrorNone = Successful
    715 *          Other error code = fail
    716 *
    717 */
    718 /* =================================================================================== */
    719 OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
    720 #endif
    721 
    722 #define G726ENC_EXIT_COMPONENT_THRD  10
    723 /* =================================================================================== */
    724 /**
    725 *  G726ENC_CompThread()  Component thread
    726 *
    727 *
    728 *  @param pThreadData		void*
    729 *
    730 *  @return void*
    731 *
    732 */
    733 /* =================================================================================== */
    734 void* G726ENC_CompThread(void* pThreadData);
    735 /* =================================================================================== */
    736 /**
    737 *  G726ENC_StartComponentThread()  Starts component thread
    738 *
    739 *
    740 *  @param hComp			OMX Handle
    741 *
    742 *  @return OMX_ErrorNone = Successful
    743 *          Other error code = fail
    744 *
    745 */
    746 /* =================================================================================== */
    747 OMX_ERRORTYPE G726ENC_StartComponentThread(OMX_HANDLETYPE pHandle);
    748 /* =================================================================================== */
    749 /**
    750 *  G726ENC_StopComponentThread()  Stops component thread
    751 *
    752 *
    753 *  @param hComp			OMX Handle
    754 *
    755 *  @return OMX_ErrorNone = Successful
    756 *          Other error code = fail
    757 *
    758 */
    759 /* =================================================================================== */
    760 OMX_ERRORTYPE G726ENC_StopComponentThread(OMX_HANDLETYPE pHandle);
    761 /* =================================================================================== */
    762 /**
    763 *  G726ENC_FreeCompResources()  Frees allocated memory
    764 *
    765 *
    766 *  @param hComp			OMX Handle
    767 *
    768 *  @return OMX_ErrorNone = Successful
    769 *          Other error code = fail
    770 *
    771 */
    772 /* =================================================================================== */
    773 OMX_ERRORTYPE G726ENC_FreeCompResources(OMX_HANDLETYPE pComponent);
    774 /* =================================================================================== */
    775 /**
    776 *  G726ENC_GetCorrespondingLCMLHeader()  Returns LCML header
    777 * that corresponds to the given buffer
    778 *
    779 *  @param pComponentPrivate	Component private data
    780 *
    781 *  @return OMX_ErrorNone = Successful
    782 *          Other error code = fail
    783 */
    784 /* =================================================================================== */
    785 OMX_ERRORTYPE G726ENC_GetCorrespondingLCMLHeader( G726ENC_COMPONENT_PRIVATE *pComponentPrivate,
    786                                                 OMX_U8 *pBuffer,
    787                                                 OMX_DIRTYPE eDir,
    788                                                 G726ENC_LCML_BUFHEADERTYPE **ppLcmlHdr);
    789 /* =================================================================================== */
    790 /**
    791 *  G726ENC_LCMLCallback() Callback from LCML
    792 *
    793 *  @param event		Codec Event
    794 *
    795 *  @param args		Arguments from LCML
    796 *
    797 *  @return OMX_ErrorNone = Successful
    798 *          Other error code = fail
    799 */
    800 /* =================================================================================== */
    801 OMX_ERRORTYPE G726ENC_LCMLCallback(TUsnCodecEvent event,
    802                                     void * args [10]);
    803 /* =================================================================================== */
    804 /**
    805 *  G726ENC_FillLCMLInitParams() Fills the parameters needed
    806 * to initialize the LCML
    807 *
    808 *  @param pHandle OMX Handle
    809 *
    810 *  @param plcml_Init LCML initialization parameters
    811 *
    812 *  @return OMX_ErrorNone = Successful
    813 *          Other error code = fail
    814 *
    815 */
    816 /* =================================================================================== */
    817 OMX_ERRORTYPE G726ENC_FillLCMLInitParams(OMX_HANDLETYPE pHandle,
    818                                           LCML_DSP *plcml_Init,
    819                                           OMX_U16 arr[]);
    820 /* =================================================================================== */
    821 /**
    822 *  G726ENC_GetBufferDirection() Returns direction of pBufHeader
    823 *
    824 *  @param pBufHeader		Buffer header
    825 *
    826 *  @param eDir				Buffer direction
    827 *
    828 *  @param pComponentPrivate	Component private data
    829 *
    830 *  @return OMX_ErrorNone = Successful
    831 *          Other error code = fail
    832 */
    833 /* =================================================================================== */
    834 OMX_ERRORTYPE G726ENC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader,
    835 										  OMX_DIRTYPE *eDir);
    836 /* ===========================================================  */
    837 /**
    838 *  G726ENC_HandleCommand()  Handles commands sent via SendCommand()
    839 *
    840 *  @param pComponentPrivate	Component private data
    841 *
    842 *  @return OMX_ErrorNone = Successful
    843 *          Other error code = fail
    844 *  @return OMX_ErrorNone = Successful
    845 *          Other error code = fail
    846 */
    847 /* =================================================================================== */
    848 OMX_U32 G726ENC_HandleCommand(G726ENC_COMPONENT_PRIVATE *pComponentPrivate);
    849 /* =================================================================================== */
    850 /**
    851 *  G726ENC_HandleDataBufFromApp()  Handles data buffers received
    852 * from the IL Client
    853 *
    854 *  @param pComponentPrivate	Component private data
    855 *
    856 *  @return OMX_ErrorNone = Successful
    857 *          Other error code = fail
    858 *  @return OMX_ErrorNone = Successful
    859 *          Other error code = fail
    860 */
    861 /* =================================================================================== */
    862 OMX_ERRORTYPE G726ENC_HandleDataBufFromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
    863                                            G726ENC_COMPONENT_PRIVATE *pComponentPrivate);
    864 /* =================================================================================== */
    865 /**
    866 *  G726ENC_GetLCMLHandle()  Get the handle to the LCML
    867 *
    868 *
    869 *  @return OMX_ErrorNone = Successful
    870 *          Other error code = fail
    871 */
    872 /* =================================================================================== */
    873 OMX_HANDLETYPE G726ENC_GetLCMLHandle(G726ENC_COMPONENT_PRIVATE *pComponentPrivate);
    874 /* =================================================================================== */
    875 /**
    876 *  G726ENC_FreeLCMLHandle()  Frees the handle to the LCML
    877 *
    878 *
    879 *  @return OMX_ErrorNone = Successful
    880 *          Other error code = fail
    881 */
    882 /* =================================================================================== */
    883 OMX_ERRORTYPE G726ENC_FreeLCMLHandle();
    884 /* =================================================================================== */
    885 /**
    886 *  G726ENC_CleanupInitParams()  Starts component thread
    887 *
    888 *  @param pComponent		OMX Handle
    889 *
    890 *  @return OMX_ErrorNone = Successful
    891 *          Other error code = fail
    892 */
    893 /* =================================================================================== */
    894 OMX_ERRORTYPE G726ENC_CleanupInitParams(OMX_HANDLETYPE pHandle);
    895 /* =================================================================================== */
    896 /**
    897 *  G726ENC_SetPending()  Called when the component queues a buffer
    898 * to the LCML
    899 *
    900 *  @param pComponentPrivate		Component private data
    901 *
    902 *  @param pBufHdr				Buffer header
    903 *
    904 *  @param eDir					Direction of the buffer
    905 *
    906 *  @return None
    907 */
    908 /* =================================================================================== */
    909 void G726ENC_SetPending(G726ENC_COMPONENT_PRIVATE *pComponentPrivate,
    910 						 OMX_BUFFERHEADERTYPE *pBufHdr,
    911 						 OMX_DIRTYPE eDir,
    912 						 OMX_U32 lineNumber);
    913 /* =================================================================================== */
    914 /**
    915 *  G726ENC_ClearPending()  Called when a buffer is returned
    916 * from the LCML
    917 *
    918 *  @param pComponentPrivate		Component private data
    919 *
    920 *  @param pBufHdr				Buffer header
    921 *
    922 *  @param eDir					Direction of the buffer
    923 *
    924 *  @return None
    925 */
    926 /* =================================================================================== */
    927 void G726ENC_ClearPending(G726ENC_COMPONENT_PRIVATE *pComponentPrivate,
    928 						   OMX_BUFFERHEADERTYPE *pBufHdr,
    929 						   OMX_DIRTYPE eDir,
    930 						   OMX_U32 lineNumber);
    931 /* =================================================================================== */
    932 /**
    933 *  G726ENC_IsPending()
    934 *
    935 *
    936 *  @param pComponentPrivate		Component private data
    937 *
    938 *  @return OMX_ErrorNone = Successful
    939 *          Other error code = fail
    940 */
    941 /* =================================================================================== */
    942 OMX_U32 G726ENC_IsPending(G726ENC_COMPONENT_PRIVATE *pComponentPrivate,
    943 						   OMX_BUFFERHEADERTYPE *pBufHdr,
    944 						   OMX_DIRTYPE eDir);
    945 /* =================================================================================== */
    946 /**
    947 *  G726ENC_FillLCMLInitParamsEx()  Fills the parameters needed
    948 * to initialize the LCML without recreating the socket node
    949 *
    950 *  @param pComponent			OMX Handle
    951 *
    952 *  @return None
    953 */
    954 /* =================================================================================== */
    955 OMX_ERRORTYPE G726ENC_FillLCMLInitParamsEx(OMX_HANDLETYPE pComponent);
    956 /* =================================================================================== */
    957 /**
    958 *  G726ENC_IsValid() Returns whether a buffer is valid
    959 *
    960 *
    961 *  @param pComponentPrivate		Component private data
    962 *
    963 *  @param pBuffer				Data buffer
    964 *
    965 *  @param eDir					Buffer direction
    966 *
    967 *  @return OMX_True = Valid
    968 *          OMX_False= Invalid
    969 */
    970 /* =================================================================================== */
    971 OMX_U32 G726ENC_IsValid(G726ENC_COMPONENT_PRIVATE *pComponentPrivate,
    972 						 OMX_U8 *pBuffer,
    973 						 OMX_DIRTYPE eDir);
    974 
    975 
    976 #ifdef RESOURCE_MANAGER_ENABLED
    977 /***********************************
    978  *  Callback to the RM                                       *
    979  ***********************************/
    980 void G726ENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
    981 #endif
    982 
    983 /* ======================================================================= */
    984 /** OMX_G726ENC_INDEXAUDIOTYPE  Defines the custom configuration settings
    985 *                              for the component
    986 *
    987 *  @param  OMX_IndexCustomG726ENCModeConfig      Sets the DASF mode
    988 *
    989 *
    990 */
    991 /*  ==================================================================== */
    992 typedef enum OMX_G726ENC_INDEXAUDIOTYPE {
    993 	OMX_IndexCustomG726ENCModeConfig = 0xFF000001,
    994 	OMX_IndexCustomG726ENCStreamIDConfig,
    995 	OMX_IndexCustomG726ENCDataPath
    996 }OMX_G726ENC_INDEXAUDIOTYPE;
    997 
    998 
    999 #endif  /* OMX_G726ENC_UTILS__H */
   1000