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#ifndef OMX_AACENC_UTILS__H
22#define OMX_AACENC_UTILS__H
23
24#include <OMX_Component.h>
25#include <OMX_TI_Common.h>
26#include <OMX_TI_Debug.h>
27#include "LCML_DspCodec.h"
28#include "OMX_AacEncoder.h"
29
30#ifdef RESOURCE_MANAGER_ENABLED
31#include <ResourceManagerProxyAPI.h>
32#endif
33
34#define AACENC_MAJOR_VER 0x0001
35#define AACENC_MINOR_VER 0x0001
36#define NOT_USED 10
37#define NORMAL_BUFFER 0
38#define OMX_AACENC_DEFAULT_SEGMENT (0)
39#define OMX_AACENC_SN_TIMEOUT (1000)
40#define OMX_AACENC_SN_PRIORITY (10)
41#define OMX_AACENC_NUM_DLLS (2)
42#define AACENC_CPU_USAGE 45
43#define _ERROR_PROPAGATION__
44#define MPEG4AACENC_MAX_OUTPUT_FRAMES 24
45
46#ifndef ANDROID
47    #define ANDROID
48#endif
49
50#ifdef ANDROID
51    #undef LOG_TAG
52    #define LOG_TAG "OMX_AACENC"
53
54/* PV opencore capability custom parameter index */
55    #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347
56#endif
57
58#ifdef __PERF_INSTRUMENTATION__
59    #include "perf.h"
60#endif
61#include <OMX_Component.h>
62
63#define OMX_CONF_INIT_STRUCT(_s_, _name_)   \
64    memset((_s_), 0x0, sizeof(_name_)); \
65    (_s_)->nSize = sizeof(_name_);      \
66    (_s_)->nVersion.s.nVersionMajor = AACENC_MAJOR_VER;  \
67    (_s_)->nVersion.s.nVersionMinor = AACENC_MINOR_VER;  \
68    (_s_)->nVersion.s.nRevision = 0x0001;      \
69    (_s_)->nVersion.s.nStep = 0x0
70
71#define OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3) \
72{                       \
73    if(!_ptr1 || !_ptr2 || !_ptr3){     \
74        OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d :: Error bad parameter \n",__LINE__);\
75        eError = OMX_ErrorBadParameter;     \
76    goto EXIT;          \
77    }                       \
78}
79
80#define OMX_CONF_SET_ERROR_BAIL(_eError, _eCode)\
81{                       \
82    _eError = _eCode;               \
83    goto OMX_CONF_CMD_BAIL;         \
84}
85
86#define OMX_CLOSE_PIPE(_pStruct_,err)\
87    OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "%d :: CLOSING PIPE \n",__LINE__);\
88    err = close (_pStruct_);\
89    if(0 != err && OMX_ErrorNone == eError){\
90        eError = OMX_ErrorHardware;\
91        OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d :: Error while closing pipe\n",__LINE__);\
92        goto EXIT;\
93    }
94
95#define OMX_DPRINT_ADDRESS(_s_, _ptr_)  \
96    OMXDBG_PRINT(stderr, PRINT, 2, 0, "%s = %p\n", _s_, _ptr_);
97
98
99#undef SWAT_ANALYSIS
100
101/* debug message */
102#undef AACENC_DEBUG
103#define AACENC_ERROR
104
105
106#ifndef UNDER_CE
107#ifdef  AACENC_ERROR
108     #define AACENC_EPRINT(...) fprintf(stderr,__VA_ARGS__)
109#else
110     #define AACENC_EPRINT(...)
111#endif /* AAC_ERROR*/
112
113
114#ifdef  AACENC_DEBUG
115     #define AACENC_DPRINT(...) fprintf(stderr,__VA_ARGS__)
116#else
117     #define AACENC_DPRINT(...)
118#endif
119
120#else /*UNDER_CE*/
121
122#ifdef  AACENC_DEBUG
123 #define AACENC_DPRINT(STR, ARG...) printf()
124#else
125#endif
126
127#endif /*UNDER_CE*/
128
129/* ======================================================================= */
130/**
131 * @def    AACENC_USN_DLL_NAME   USN DLL name
132 */
133/* ======================================================================= */
134#ifdef UNDER_CE
135#define AACENC_USN_DLL_NAME "\\windows\\usn.dll64P"
136#else
137#define AACENC_USN_DLL_NAME "usn.dll64P"
138#endif
139
140/* ======================================================================= */
141/**
142 * @def    AACENC_DLL_NAME   AAC Enc Encoder socket node DLL name
143 */
144/* ======================================================================= */
145#ifdef UNDER_CE
146#define AACENC_DLL_NAME "\\windows\\mpeg4aacenc_sn.dll64P"
147#else
148#define AACENC_DLL_NAME "mpeg4aacenc_sn.dll64P"
149#endif
150
151typedef struct
152{
153    OMX_BOOL bLastBuffer;
154}AACENC_UAlgInBufParamStruct;
155
156typedef struct
157{
158    unsigned long unNumFramesEncoded;
159    unsigned long unFrameSizes[MPEG4AACENC_MAX_OUTPUT_FRAMES];
160}AACENC_UAlgOutBufParamStruct;
161
162
163typedef struct PV_OMXComponentCapabilityFlagsType
164{
165        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability)
166        OMX_BOOL iIsOMXComponentMultiThreaded;
167        OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
168        OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
169        OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
170        OMX_BOOL iOMXComponentSupportsPartialFrames;
171        OMX_BOOL iOMXComponentNeedsNALStartCode;
172        OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
173} PV_OMXComponentCapabilityFlagsType;
174
175/*This enum must not be changed.*/
176typedef enum COMP_PORT_TYPE
177{
178    INPUT_PORT = 0,
179    OUTPUT_PORT
180}COMP_PORT_TYPE;
181
182typedef enum
183{
184    DIRECTION_INPUT,
185    DIRECTION_OUTPUT
186}BUFFER_Dir;
187
188typedef struct BUFFS
189{
190    char BufHeader;
191    char Buffer;
192}BUFFS;
193
194typedef struct BUFFERHEADERTYPE_INFO
195{
196    OMX_BUFFERHEADERTYPE* pBufHeader[MAX_NUM_OF_BUFS];
197    BUFFS bBufOwner[MAX_NUM_OF_BUFS];
198}BUFFERHEADERTYPE_INFO;
199
200typedef OMX_ERRORTYPE (*fpo)(OMX_HANDLETYPE);
201
202typedef struct AACENC_AudioCodecParams
203{
204    unsigned long  iSamplingRate;
205    unsigned long  iStrmId;
206    unsigned short iAudioFormat;
207}AACENC_AudioCodecParams;
208
209/* enum AACENC_BOOL_TYPE                        */
210/* brief Enumerated type for Boolean decision   */
211
212typedef enum
213{
214    AACENC_FALSE = 0,     /*!< To indicate False  */
215    AACENC_TRUE  = 1      /*!< To indicate True   */
216} AACENC_BOOL_TYPE;
217
218/*! \enum AACENC_OBJ_TYP  */
219/*! \brief enumerated type for output format */
220typedef enum
221{
222  AACENC_OBJ_TYP_LC           = 2,   /*!< AAC Low Complexity  */
223  AACENC_OBJ_TYP_HEAAC        = 5,   /*!< HE AAC              */
224  AACENC_OBJ_TYP_PS           = 29   /*!< AAC LC + SBR + PS   */
225} AACENC_OBJ_TYP;
226
227/*! \enum  AACENC_TRANSPORT_TYPE */
228/*! \brief Enumerated type for output file format */
229typedef enum
230{
231  AACENC_TT_RAW    = 0,              /*!< Raw Output Format   */
232  AACENC_TT_ADIF   = 1,              /*!< ADIF File Format    */
233  AACENC_TT_ADTS   = 2               /*!< ADTS File Format    */
234} AACENC_TRANSPORT_TYPE;
235
236/* ======================================================================= */
237/** MPEG4AACENC_UALGParams
238 *
239 * @param lOutputFormat - To set interleaved/Block format:Refer to IAUDIO_PcmFormat.
240 * @param DownSampleSbr -
241 */
242/* ==================================================================== */
243typedef struct
244{
245    long size;           /* size of this structure */
246    long bitRate;        /* Average bit rate in bits per second */
247    long sampleRate;     /* Samplling frequency in Hz */
248    long numChannels;    /* Number of Channels: IAUDIO_ChannelId */
249
250}MPEG4AUDENC_UALGdynamicparams;
251
252
253typedef struct MPEG4AACENC_UALGParams
254{
255    int size;
256    MPEG4AUDENC_UALGdynamicparams audenc_dynamicparams;
257                                            /*!< generic encoder dynamic parameters  */
258
259    /* For RESET Command */
260    AACENC_BOOL_TYPE        useTns;         /*!< Flag for activating TNS feature     */
261    AACENC_BOOL_TYPE        usePns;         /*!< Flag for activating PNS feature     */
262
263    AACENC_OBJ_TYP          outObjectType;  /*!< Output Object Type LC/HE/HEv2     */
264    AACENC_TRANSPORT_TYPE   outFileFormat;  /*!< Output File Format            */
265
266} MPEG4AACENC_UALGParams;
267
268typedef enum {
269    IUALG_CMD_STOP          = 0,
270    IUALG_CMD_PAUSE         = 1,
271    IUALG_CMD_GETSTATUS     = 2,
272    IUALG_CMD_SETSTATUS     = 3,
273    IUALG_CMD_USERCMDSTART  = 100
274}IUALG_Cmd;
275
276typedef enum {
277    IAUDIO_BLOCK=0,
278    IAUDIO_INTERLEAVED
279} IAUDIO_AacFormat;
280
281typedef struct LCML_AACENC_BUFHEADERTYPE
282{
283      BUFFER_Dir eDir;
284      OMX_BUFFERHEADERTYPE* buffer;
285      AACENC_UAlgInBufParamStruct *pIpParam;
286      AACENC_UAlgOutBufParamStruct *pOpParam;
287}LCML_AACENC_BUFHEADERTYPE;
288
289
290
291typedef struct _BUFFERLIST BUFFERLIST;
292
293struct _BUFFERLIST
294{
295    OMX_BUFFERHEADERTYPE sBufHdr;                   /* actual buffer header */
296    OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS]; /* records buffer header send by client */
297    OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
298    OMX_U16 numBuffers;
299    OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
300    BUFFERLIST *pNextBuf;
301    BUFFERLIST *pPrevBuf;
302};
303
304#ifdef UNDER_CE
305    #ifndef _OMX_EVENT_
306        #define _OMX_EVENT_
307        typedef struct OMX_Event {
308            HANDLE event;
309        } OMX_Event;
310    #endif
311    int OMX_CreateEvent(OMX_Event *event);
312    int OMX_SignalEvent(OMX_Event *event);
313    int OMX_WaitForEvent(OMX_Event *event);
314    int OMX_DestroyEvent(OMX_Event *event);
315#endif
316
317/* ======================================================================= */
318/**
319 * pthread variable to indicate OMX returned all buffers to app
320 */
321/* ======================================================================= */
322pthread_mutex_t bufferReturned_mutex;
323pthread_cond_t bufferReturned_condition;
324
325
326typedef struct AACENC_COMPONENT_PRIVATE
327{
328    /** Array of pointers to BUFFERHEADERTYPE structues
329       This pBufHeader[INPUT_PORT] will point to all the
330       BUFFERHEADERTYPE structures related to input port,
331       not just one structure. Same is for output port
332       also. */
333    OMX_BUFFERHEADERTYPE* pBufHeader[NUM_OF_PORTS];
334
335    BUFFERHEADERTYPE_INFO BufInfo[NUM_OF_PORTS];
336
337    OMX_CALLBACKTYPE cbInfo;
338    /** Handle for use with async callbacks */
339    OMX_PORT_PARAM_TYPE sPortParam;
340
341    OMX_PRIORITYMGMTTYPE* sPriorityMgmt;
342
343#ifdef RESOURCE_MANAGER_ENABLED
344    RMPROXY_CALLBACKTYPE rmproxyCallback;
345#endif
346
347    OMX_BOOL bPreempted;
348
349    OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
350
351    OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
352
353    OMX_U32 bIsBufferOwned[NUM_OF_PORTS];
354    /** This will contain info like how many buffers
355        are there for input/output ports, their size etc, but not
356        BUFFERHEADERTYPE POINTERS. */
357    OMX_U32 abc;
358
359    OMX_U32 def;
360
361    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
362
363    OMX_AUDIO_PARAM_AACPROFILETYPE* aacParams[NUM_OF_PORTS];
364
365    OMX_AUDIO_PARAM_PCMMODETYPE* pcmParam[NUM_OF_PORTS];
366
367    /** This is component handle */
368    OMX_COMPONENTTYPE* pHandle;
369
370    /** Current state of this component */
371    OMX_STATETYPE curState;
372
373    /** The component thread handle */
374    pthread_t ComponentThread;
375
376    /** The pipes for sending buffers to the thread */
377    int dataPipe[2];
378
379    /** The pipes for sending buffers to the thread */
380    int cmdPipe[2];
381    /** The pipes for sending buffers to the thread */
382    int cmdDataPipe[2];
383
384    /** Set to indicate component is stopping */
385    OMX_U32 bIsStopping;
386
387    /** Number of input buffers at runtime */
388    OMX_U32 nRuntimeInputBuffers;
389
390    /** Number of output buffers at runtime */
391    OMX_U32 nRuntimeOutputBuffers;
392
393    OMX_U32 bIsThreadstop;
394
395    OMX_U32 bIsEOFSent;
396
397    /** Count of number of buffers outstanding with bridge */
398    OMX_U32 lcml_nIpBuf;
399
400    OMX_BOOL CustomConfiguration;
401
402#ifdef __PERF_INSTRUMENTATION__
403        PERF_OBJHANDLE pPERF, pPERFcomp;
404        OMX_U32 nLcml_nCntIp;
405        OMX_U32 nLcml_nCntOpReceived;
406#endif
407
408    /** Count of number of buffers outstanding with bridge */
409    OMX_U32 lcml_nOpBuf;
410
411    OMX_U32 app_nBuf;
412
413    OMX_U32 lcml_nCntIp;
414
415    OMX_U32 lcml_nCntOpReceived;
416
417    OMX_U32 lcml_nCntApp;
418
419    OMX_U32 lcml_compID;
420
421    OMX_U32 num_Reclaimed_Op_Buff;
422
423    OMX_U32 num_Sent_Ip_Buff;
424
425    OMX_U32 num_Op_Issued;
426
427    OMX_HANDLETYPE pLcmlHandle;
428
429    LCML_AACENC_BUFHEADERTYPE *pLcmlBufHeader[2];
430
431    MPEG4AACENC_UALGParams* ptAlgDynParams;
432
433    AACENC_AudioCodecParams* pParams;
434
435    OMX_U16 ulSamplingRate;
436
437    OMX_U16 unNumChannels;
438
439    OMX_U32 unBitrate;
440
441    OMX_U16 nObjectType;
442
443    OMX_U32 bitRateMode;
444
445    OMX_U16 File_Format;
446
447    OMX_U32 dasfmode;
448
449    OMX_U32 EmptybufferdoneCount;
450
451    OMX_U32 EmptythisbufferCount;
452
453    OMX_U32 FillbufferdoneCount;
454
455    OMX_U32 FillthisbufferCount;
456
457    OMX_U32 bPortDefsAllocated;
458
459    OMX_U32 bCompThreadStarted;
460
461    OMX_PTR pMarkData;
462
463    OMX_MARKTYPE *pMarkBuf;
464
465    OMX_HANDLETYPE hMarkTargetComponent;
466
467    OMX_U32 bBypassDSP;
468
469    BUFFERLIST *pInputBufferList;
470
471    BUFFERLIST *pOutputBufferList;
472
473    LCML_STRMATTR *strmAttr;
474
475    OMX_U32 nVersion;
476
477    OMX_STRING cComponentName;
478
479    OMX_VERSIONTYPE ComponentVersion;
480
481    OMX_U32 streamID;
482
483    OMX_U32 bInputBufferHeaderAllocated;
484    /** Stores input buffers while paused */
485    OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];
486
487    /** Number of input buffers received while paused */
488    OMX_U32 nNumInputBufPending;
489
490    /** Stores output buffers while paused */
491    OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];
492
493    /** Number of output buffers received while paused */
494    OMX_U32 nNumOutputBufPending;
495
496
497    OMX_U8 PendingInPausedBufs;
498    OMX_BUFFERHEADERTYPE *pInBufHdrPausedPending[MAX_NUM_OF_BUFS];
499    OMX_U8 PendingOutPausedBufs;
500    OMX_BUFFERHEADERTYPE *pOutBufHdrPausedPending[MAX_NUM_OF_BUFS];
501
502
503
504    OMX_U32 bPlayCompleteFlag;
505
506    /** Flag set when a disable command is pending */
507    OMX_U32 bDisableCommandPending;
508
509    /** Parameter for pending disable command */
510    OMX_U32 bDisableCommandParam;
511
512    /** Flag set when a disable command is pending */
513    OMX_U32 bEnableCommandPending;
514
515    /** Parameter for pending disable command */
516    OMX_U32 nEnableCommandParam;
517
518    /** Flag to set when socket node stop callback should not transition
519        component to OMX_StateIdle */
520    OMX_U32 bNoIdleOnStop;
521
522    /** Flag set when idle command is pending */
523    /* OMX_U32 bIdleCommandPending; */
524
525    /** Flag set when pause command is pending */
526    OMX_U32 bPauseCommandPending;
527
528    /** Flag set when socket node is stopped */
529    OMX_U32 bDspStoppedWhileExecuting;
530
531    /** Number of outstanding FillBufferDone() calls */
532    OMX_S32 nOutStandingFillDones;
533
534    /** Number of outstanding EmptyBufferDone() calls */
535    OMX_S32 nOutStandingEmptyDones;
536
537    OMX_BUFFERHEADERTYPE *LastOutputBufferHdrQueued;
538
539#ifndef UNDER_CE
540    pthread_mutex_t AlloBuf_mutex;
541    pthread_cond_t AlloBuf_threshold;
542    OMX_U8 AlloBuf_waitingsignal;
543
544    pthread_mutex_t codecStop_mutex;
545    pthread_cond_t codecStop_threshold;
546    OMX_U8 codecStop_waitingsignal;
547
548    pthread_mutex_t codecFlush_mutex;
549    pthread_cond_t codecFlush_threshold;
550    OMX_U8 codecFlush_waitingsignal;
551
552    pthread_mutex_t InLoaded_mutex;
553    pthread_cond_t InLoaded_threshold;
554    OMX_U8 InLoaded_readytoidle;
555
556    pthread_mutex_t InIdle_mutex;
557    pthread_cond_t InIdle_threshold;
558    OMX_U8 InIdle_goingtoloaded;
559
560    OMX_U8 nUnhandledFillThisBuffers;
561    OMX_U8 nUnhandledEmptyThisBuffers;
562    OMX_BOOL bFlushOutputPortCommandPending;
563    OMX_BOOL bFlushInputPortCommandPending;
564
565#else
566    OMX_Event AlloBuf_event;
567    OMX_U8 AlloBuf_waitingsignal;
568
569    OMX_Event InLoaded_event;
570    OMX_U8 InLoaded_readytoidle;
571
572    OMX_Event InIdle_event;
573    OMX_U8 InIdle_goingtoloaded;
574
575
576#endif
577    OMX_BOOL bLoadedCommandPending;
578    OMX_BOOL bIsInvalidState;
579    void* PtrCollector[6];
580
581    OMX_BUFFERHEADERTYPE *LastOutbuf;
582    OMX_PARAM_COMPONENTROLETYPE componentRole;
583    OMX_U16 FramesPer_OutputBuffer;
584
585    /* backup pointer for LCML */
586    void* ptrLibLCML;
587
588    OMX_BOOL bCodecDestroyed;
589    OMX_BOOL bGotLCML;
590
591    OMX_STRING* sDeviceString;
592    OMX_BOOL bFirstOutputBuffer;
593
594    /** Keep buffer timestamps **/
595    OMX_S64 timestampBufIndex[MAX_NUM_OF_BUFS];
596    /** Index to arrBufIndex[], used for input buffer timestamps */
597    OMX_U8 IpBufindex;
598    /** Index to arrBufIndex[], used for output buffer timestamps */
599    OMX_U8 OpBufindex;
600
601    /** Keep buffer tickcount **/
602    OMX_U32 tickcountBufIndex[MAX_NUM_OF_BUFS];
603
604    PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
605
606    struct OMX_TI_Debug dbg;
607
608    /* Reference count for pending state change requests */
609    OMX_U32 nPendingStateChangeRequests;
610    pthread_mutex_t mutexStateChangeRequest;
611    pthread_cond_t StateChangeCondition;
612
613} AACENC_COMPONENT_PRIVATE;
614
615OMX_ERRORTYPE AACENCGetCorresponding_LCMLHeader(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer,
616                                                  OMX_DIRTYPE eDir,
617                                                  LCML_AACENC_BUFHEADERTYPE **ppLcmlHdr);
618
619OMX_ERRORTYPE AACENCLCML_Callback(TUsnCodecEvent event,void * args [10]);
620
621OMX_ERRORTYPE AACENCFill_LCMLInitParams(OMX_HANDLETYPE pHandle,
622                                          LCML_DSP *plcml_Init,OMX_U16 arr[]);
623
624OMX_ERRORTYPE AACENCGetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, OMX_DIRTYPE *eDir);
625
626OMX_U32 AACENCHandleCommand(AACENC_COMPONENT_PRIVATE *pComponentPrivate);
627
628OMX_ERRORTYPE AACENCHandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
629                                            AACENC_COMPONENT_PRIVATE *pComponentPrivate);
630
631int AACEnc_GetSampleRateIndexL( const int aRate);
632
633OMX_HANDLETYPE AACENCGetLCMLHandle(AACENC_COMPONENT_PRIVATE *pComponentPrivate);
634
635OMX_ERRORTYPE AACENC_CleanupInitParams(OMX_HANDLETYPE pHandle);
636
637void AACENC_SetPending(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber);
638
639void AACENC_ClearPending(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) ;
640
641OMX_U32 AACENC_IsPending(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
642
643/* ===========================================================  */
644/**
645*  AACENC_TransitionToIdle() Transitions component to idle
646*
647*
648*  @param pComponentPrivate     Component private data
649*
650*  @return OMX_ErrorNone = No error
651*          OMX Error code = Error
652*/
653/*================================================================== */
654
655OMX_ERRORTYPE AACENC_TransitionToPause(AACENC_COMPONENT_PRIVATE *pComponentPrivate);
656
657OMX_ERRORTYPE AACENCFill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent);
658
659OMX_ERRORTYPE AACENCWriteConfigHeader(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr);
660
661#ifdef RESOURCE_MANAGER_ENABLED
662void AACENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
663#endif
664
665#ifndef UNDER_CE
666OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
667#else
668/*  WinCE Implicit Export Syntax */
669#define OMX_EXPORT __declspec(dllexport)
670OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
671#endif
672
673
674OMX_ERRORTYPE AACENC_StartComponentThread(OMX_HANDLETYPE pHandle);
675
676OMX_ERRORTYPE AACENC_StopComponentThread(OMX_HANDLETYPE pHandle);
677
678OMX_ERRORTYPE AACENC_FreeCompResources(OMX_HANDLETYPE pComponent);
679
680OMX_ERRORTYPE AddStateTransition(AACENC_COMPONENT_PRIVATE* pComponentPrivate);
681OMX_ERRORTYPE RemoveStateTransition(AACENC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BOOL bEnableSignal);
682
683/*  =========================================================================*/
684/**  func    AACENC_HandleUSNError
685 *
686 *  desc    Handles error messages returned by the dsp
687 *
688 *@return n/a
689 */
690/*  =========================================================================*/
691void AACENC_HandleUSNError (AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 arg);
692
693
694#endif
695
696
697/*=======================================================================*/
698/** @fn SignalIfAllBuffersAreReturned
699 * @brief Sends pthread signal to indicate OMX has returned all buffers to app
700 *
701 * @param  none
702 *
703 * @Return none
704 *
705 */
706/*=======================================================================*/
707void SignalIfAllBuffersAreReturned(AACENC_COMPONENT_PRIVATE *pComponentPrivate);
708
709/* ====================================================================== */
710/*@AACENC_IncrementBufferCounterByOne() This function is used by the component
711 * to atomically increment some input or output buffer counter
712 *
713 * @param mutex pointer to mutex for synchronizing the value change on
714 *              the counter
715 * @param counter the buffer counter to be changed
716 *
717 * @post the buffer counter's value will be incremented by one.
718 * @return None
719 */
720/* ====================================================================== */
721void AACENC_IncrementBufferCounterByOne(pthread_mutex_t* mutex, OMX_U32 *counter);
722