161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/*--------------------------------------------------------------------------
261e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiCopyright (c) 2010-2014, The Linux Foundation. All rights reserved.
361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
461e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiRedistribution and use in source and binary forms, with or without
561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletimodification, are permitted provided that the following conditions are met:
661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    * Redistributions of source code must retain the above copyright
761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti      notice, this list of conditions and the following disclaimer.
861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    * Redistributions in binary form must reproduce the above copyright
961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti      notice, this list of conditions and the following disclaimer in the
1061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti      documentation and/or other materials provided with the distribution.
1161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    * Neither the name of The Linux Foundation nor
1261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti      the names of its contributors may be used to endorse or promote
1361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti      products derived from this software without specific prior written
1461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti      permission.
1561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
1661e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1761e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1861e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1961e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiNON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2061e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2161e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2261e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2361e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiOR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2461e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2561e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiOTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2661e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti--------------------------------------------------------------------------*/
2861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#ifndef _AAC_ENC_H_
2961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define _AAC_ENC_H_
3061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/*============================================================================
3161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                    Audio Encoder
3261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti@file omx_aac_aenc.h
3461e21a4fe27118141afc13323807f83b733cf426Uday Kishore PasupuletiThis module contains the class definition for openMAX encoder component.
3561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti============================================================================*/
3961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
4061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//////////////////////////////////////////////////////////////////////////////
4161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//                             Include Files
4261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//////////////////////////////////////////////////////////////////////////////
4361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
4461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/* Uncomment out below line #define LOG_NDEBUG 0 if we want to see
4561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti *  all DEBUG_PRINT or LOGV messaging */
4661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include<stdlib.h>
4761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <stdio.h>
4861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <pthread.h>
4961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <time.h>
5061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <inttypes.h>
5161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <unistd.h>
5261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "QOMX_AudioExtensions.h"
5361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "QOMX_AudioIndexExtensions.h"
5461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "OMX_Core.h"
5561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "OMX_Audio.h"
5661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "aenc_svr.h"
5761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "qc_omx_component.h"
5861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include "Map.h"
5961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <semaphore.h>
6061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <linux/msm_audio.h>
6161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#include <linux/msm_audio_aac.h>
6261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiextern "C" {
6361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void * get_omx_component_factory_fn(void);
6461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti}
6561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
6661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
6761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//////////////////////////////////////////////////////////////////////////////
6861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//                       Module specific globals
6961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//////////////////////////////////////////////////////////////////////////////
7061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
7161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
7261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
7361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_SPEC_VERSION  0x00000101
7461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define min(x,y) (((x) < (y)) ? (x) : (y))
7561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define MAX(x,y) (x >= y?x:y)
7661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
7761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//////////////////////////////////////////////////////////////////////////////
7861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//               Macros
7961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//////////////////////////////////////////////////////////////////////////////
8061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//
8161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
8261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
8361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define PrintFrameHdr(i,bufHdr) \
8461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           DEBUG_PRINT("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
8561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           i,\
8661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           bufHdr,                                     \
8761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           ((OMX_BUFFERHEADERTYPE *)bufHdr)->pBuffer,   \
8861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->nFilledLen,\
8961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           ((OMX_BUFFERHEADERTYPE *)bufHdr)->nTimeStamp, \
9061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                           (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->nFlags)
9161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
9261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
9361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti// BitMask Management logic
9461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITS_PER_BYTE 8
9561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_SIZE(mIndex) \
9661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            (((mIndex) + BITS_PER_BYTE - 1)/BITS_PER_BYTE)
9761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_OFFSET(mIndex)\
9861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            ((mIndex)/BITS_PER_BYTE)
9961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_FLAG(mIndex) \
10061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            (1 << ((mIndex) % BITS_PER_BYTE))
10161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_CLEAR(mArray,mIndex)\
10261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            (mArray)[BITMASK_OFFSET(mIndex)] &=  ~(BITMASK_FLAG(mIndex))
10361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_SET(mArray,mIndex)\
10461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            (mArray)[BITMASK_OFFSET(mIndex)] |=  BITMASK_FLAG(mIndex)
10561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_PRESENT(mArray,mIndex)\
10661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            ((mArray)[BITMASK_OFFSET(mIndex)] & BITMASK_FLAG(mIndex))
10761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BITMASK_ABSENT(mArray,mIndex)\
10861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            (((mArray)[BITMASK_OFFSET(mIndex)] & \
10961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti            BITMASK_FLAG(mIndex)) == 0x0)
11061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
11161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_CORE_NUM_INPUT_BUFFERS    2
11261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_CORE_NUM_OUTPUT_BUFFERS   16
11361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
11461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_CORE_INPUT_BUFFER_SIZE    8192
11561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_CORE_CONTROL_CMDQ_SIZE   100
11661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_AENC_VOLUME_STEP         0x147
11761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_AENC_MIN                 0
11861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_AENC_MAX                 100
11961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define NON_TUNNEL                   1
12061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define TUNNEL                       0
12161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define IP_PORT_BITMASK                 0x02
12261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OP_PORT_BITMASK                 0x01
12361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define IP_OP_PORT_BITMASK              0x03
12461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
12561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define DEFAULT_SF            44100
12661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define DEFAULT_CH_CFG        2
12761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define DEFAULT_BITRATE       64000
12861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_AAC_DEFAULT_VOL         25
12961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti// 14 bytes for input meta data
13061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_AENC_SIZEOF_META_BUF     (OMX_CORE_INPUT_BUFFER_SIZE+14)
13161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
13261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define TRUE 1
13361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define FALSE 0
13461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
13561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
13661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define NUMOFFRAMES                   1
13761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define MAXFRAMELENGTH                1536
13861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define OMX_AAC_OUTPUT_BUFFER_SIZE    ((NUMOFFRAMES * (sizeof(ENC_META_OUT)+ MAXFRAMELENGTH + 1)\
13961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                          + 1023) & (~1023))
14061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//Raw Header
14161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_MAX_MP4FF_HEADER_LENGTH  2
14261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
14361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_MP4FF_OBJ_TYPE           5
14461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_MP4FF_FREQ_IDX           4
14561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_MP4FF_CH_CONFIG          4
14661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
14761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//ADIF Header
14861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_MAX_ADIF_HEADER_LENGTH 17
14961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
15061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_COPYRIGHT_PRESENT_SIZE    1
15161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_ORIGINAL_COPY_SIZE        1
15261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_HOME_SIZE                 1
15361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_BITSTREAM_TYPE_SIZE               1
15461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_BITRATE_SIZE                     23
15561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_PFE_SIZE                      4
15661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_BUFFER_FULLNESS_SIZE             20
15761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_ELEMENT_INSTANCE_TAG_SIZE         4
15861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_FRONT_CHANNEL_ELEMENTS_SIZE   4
15961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_SIDE_CHANNEL_ELEMENTS_SIZE    4
16061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_BACK_CHANNEL_ELEMENTS_SIZE    4
16161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_LFE_CHANNEL_ELEMENTS_SIZE     2
16261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_ASSOC_DATA_ELEMENTS_SIZE      3
16361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_NUM_VALID_CC_ELEMENTS_SIZE        4
16461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_MONO_MIXDOWN_PRESENT_SIZE         1
16561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_MONO_MIXDOWN_ELEMENT_SIZE         4
16661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_STEREO_MIXDOWN_PRESENT_SIZE       1
16761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_STEREO_MIXDOWN_ELEMENT_SIZE       4
16861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_MATRIX_MIXDOWN_PRESENT_SIZE       1
16961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_MATRIX_MIXDOWN_SIZE               3
17061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_FCE_SIZE                          5
17161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_SCE_SIZE                          5
17261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_BCE_SIZE                          5
17361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_LFE_SIZE                          4
17461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_ADE_SIZE                          4
17561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_VCE_SIZE                          5
17661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_COMMENT_FIELD_BYTES_SIZE          8
17761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_COMMENT_FIELD_DATA_SIZE           8
17861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_SAMPLING_FREQ_INDEX_SIZE          4
17961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AAC_PROFILE_SIZE                      2
18061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
18161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
18261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
18361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti//Raw Header
18461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_MAX_RAW_HEADER_LENGTH  8
18561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
18661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_OBJ_TYPE          8
18761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_FREQ_IDX          8
18861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_CH_CONFIG         8
18961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_SBR_PRESENT       8
19061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_SBR_PS_PRESENT    8
19161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_EXT_OBJ_TYPE      8
19261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_EXT_FREQ_IDX      8
19361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDAAC_RAW_EXT_CH_CONFIG     8
19461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
19561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct sample_rate_idx {
19661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U32 sample_rate;
19761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U32 sample_rate_idx;
19861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
19961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistatic struct sample_rate_idx sample_idx_tbl[10] = {
20061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {8000, 0x0b},
20161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {11025, 0x0a},
20261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {12000, 0x09},
20361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {16000, 0x08},
20461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {22050, 0x07},
20561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {24000, 0x06},
20661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {32000, 0x05},
20761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {44100, 0x04},
20861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {48000, 0x03},
20961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {64000, 0x02},
21061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
21161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleticlass omx_aac_aenc;
21261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
21361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti// OMX AAC audio encoder class
21461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleticlass omx_aac_aenc: public qc_omx_component
21561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti{
21661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletipublic:
21761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_aac_aenc();                             // constructor
21861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    virtual ~omx_aac_aenc();                    // destructor
21961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
22061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE allocate_buffer(OMX_HANDLETYPE             hComp,
22161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                  OMX_BUFFERHEADERTYPE **bufferHdr,
22261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                  OMX_U32                     port,
22361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                  OMX_PTR                  appData,
22461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                  OMX_U32                    bytes);
22561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
22661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
22761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE component_deinit(OMX_HANDLETYPE hComp);
22861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
22961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE component_init(OMX_STRING role);
23061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
23161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE component_role_enum(OMX_HANDLETYPE hComp,
23261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                      OMX_U8         *role,
23361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                      OMX_U32        index);
23461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
23561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE component_tunnel_request(OMX_HANDLETYPE             hComp,
23661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                           OMX_U32                     port,
23761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                           OMX_HANDLETYPE     peerComponent,
23861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                           OMX_U32                 peerPort,
23961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                           OMX_TUNNELSETUPTYPE *tunnelSetup);
24061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
24161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE empty_this_buffer(OMX_HANDLETYPE         hComp,
24261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    OMX_BUFFERHEADERTYPE *buffer);
24361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
24461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
24561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE empty_this_buffer_proxy(OMX_HANDLETYPE         hComp,
24661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                          OMX_BUFFERHEADERTYPE *buffer);
24761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
24861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
24961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE fill_this_buffer(OMX_HANDLETYPE         hComp,
25061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   OMX_BUFFERHEADERTYPE *buffer);
25161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
25261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
25361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE free_buffer(OMX_HANDLETYPE         hComp,
25461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                              OMX_U32                 port,
25561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                              OMX_BUFFERHEADERTYPE *buffer);
25661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
25761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE get_component_version(OMX_HANDLETYPE              hComp,
25861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_STRING          componentName,
25961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_VERSIONTYPE *componentVersion,
26061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_VERSIONTYPE *     specVersion,
26161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_UUIDTYPE       *componentUUID);
26261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
26361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE get_config(OMX_HANDLETYPE      hComp,
26461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_INDEXTYPE configIndex,
26561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_PTR        configData);
26661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
26761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE get_extension_index(OMX_HANDLETYPE     hComp,
26861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                      OMX_STRING     paramName,
26961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                      OMX_INDEXTYPE *indexType);
27061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
27161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE get_parameter(OMX_HANDLETYPE hComp,
27261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_INDEXTYPE paramIndex,
27361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_PTR paramData);
27461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
27561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE get_state(OMX_HANDLETYPE hComp,
27661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                            OMX_STATETYPE *state);
27761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
27861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    static void process_in_port_msg(void          *client_data,
27961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    unsigned char id);
28061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
28161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    static void process_out_port_msg(void          *client_data,
28261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                     unsigned char id);
28361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
28461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    static void process_command_msg(void          *client_data,
28561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    unsigned char id);
28661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
28761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    static void process_event_cb(void          *client_data,
28861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   unsigned char id);
28961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
29061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
29161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE set_callbacks(OMX_HANDLETYPE hComp,
29261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_CALLBACKTYPE *callbacks,
29361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_PTR appData);
29461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
29561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE set_config(OMX_HANDLETYPE hComp,
29661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_INDEXTYPE configIndex,
29761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_PTR configData);
29861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
29961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE set_parameter(OMX_HANDLETYPE hComp,
30061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_INDEXTYPE paramIndex,
30161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_PTR paramData);
30261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
30361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE use_buffer(OMX_HANDLETYPE             hComp,
30461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_BUFFERHEADERTYPE **bufferHdr,
30561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_U32                     port,
30661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_PTR                  appData,
30761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_U32                    bytes,
30861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                             OMX_U8                  *buffer);
30961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
31061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE use_EGL_image(OMX_HANDLETYPE             hComp,
31161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_BUFFERHEADERTYPE **bufferHdr,
31261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_U32                     port,
31361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                OMX_PTR                  appData,
31461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                void *                  eglImage);
31561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
31661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool post_command(unsigned int p1, unsigned int p2,
31761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned char id);
31861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
31961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Deferred callback identifiers
32061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    enum
32161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
32261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        //Event Callbacks from the component thread context
32361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_EVENT       = 0x1,
32461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        //Buffer Done callbacks from component thread context
32561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_BUFFER_DONE = 0x2,
32661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_ETB         = 0x3,
32761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        //Command
32861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_COMMAND     = 0x4,
32961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_FRAME_DONE  = 0x05,
33061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_FTB         = 0x06,
33161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_GENERATE_EOS         = 0x07,
33261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_PORTSETTINGS_CHANGED = 0x08,
33361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_SUSPEND              = 0x09,
33461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_RESUME               = 0x0a
33561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    };
33661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiprivate:
33761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
33861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    ///////////////////////////////////////////////////////////
33961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Type definitions
34061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    ///////////////////////////////////////////////////////////
34161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Bit Positions
34261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    enum flags_bit_positions
34361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
34461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        // Defer transition to IDLE
34561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_IDLE_PENDING            =0x1,
34661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        // Defer transition to LOADING
34761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_LOADING_PENDING         =0x2,
34861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
34961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_MUTED                   =0x3,
35061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
35161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        // Defer transition to Enable
35261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_INPUT_ENABLE_PENDING    =0x4,
35361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        // Defer transition to Enable
35461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_OUTPUT_ENABLE_PENDING   =0x5,
35561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        // Defer transition to Disable
35661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_INPUT_DISABLE_PENDING   =0x6,
35761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        // Defer transition to Disable
35861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_COMPONENT_OUTPUT_DISABLE_PENDING  =0x7
35961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    };
36061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
36161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    #define MIN_BITRATE 24000
36261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    #define MAX_BITRATE 192000
36361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    #define MAX_BITRATE_MULFACTOR 12
36461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    #define BITRATE_DIVFACTOR 2
36561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    typedef Map<OMX_BUFFERHEADERTYPE*, OMX_BUFFERHEADERTYPE*>
36661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    input_buffer_map;
36761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
36861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    typedef Map<OMX_BUFFERHEADERTYPE*, OMX_BUFFERHEADERTYPE*>
36961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    output_buffer_map;
37061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
37161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    enum port_indexes
37261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
37361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_CORE_INPUT_PORT_INDEX        =0,
37461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_CORE_OUTPUT_PORT_INDEX       =1
37561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    };
37661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
37761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct omx_event
37861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
37961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned long param1;
38061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned long param2;
38161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned char id;
38261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    };
38361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
38461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct omx_cmd_queue
38561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
38661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        omx_event m_q[OMX_CORE_CONTROL_CMDQ_SIZE];
38761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned m_read;
38861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned m_write;
38961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned m_size;
39061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
39161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        omx_cmd_queue();
39261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        ~omx_cmd_queue();
39361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        bool insert_entry(unsigned long p1, unsigned long p2, unsigned char id);
39461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        bool pop_entry(unsigned long *p1,unsigned long *p2, unsigned char *id);
39561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        bool get_msg_id(unsigned char *id);
39661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        bool get_msg_with_id(unsigned *p1,unsigned *p2, unsigned id);
39761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    };
39861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
39961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    typedef struct TIMESTAMP
40061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
40161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int LowPart;
40261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int HighPart;
40361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    }__attribute__((packed)) TIMESTAMP;
40461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
40561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    typedef struct metadata_input
40661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
40761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned short offsetVal;
40861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        TIMESTAMP      nTimeStamp;
40961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int   nFlags;
41061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    }__attribute__((packed)) META_IN;
41161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
41261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    typedef struct enc_meta_out
41361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
41461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int offset_to_frame;
41561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int frame_size;
41661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int encoded_pcm_samples;
41761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int msw_ts;
41861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int lsw_ts;
41961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        unsigned int nflags;
42061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    } __attribute__ ((packed))ENC_META_OUT;
42161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
42261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    typedef struct
42361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    {
42461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_U32 tot_in_buf_len;
42561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_U32 tot_out_buf_len;
42661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_TICKS tot_pb_time;
42761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_U32 fbd_cnt;
42861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_U32 ftb_cnt;
42961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_U32 etb_cnt;
43061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti        OMX_U32 ebd_cnt;
43161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    }AAC_PB_STATS;
43261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
43361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    ///////////////////////////////////////////////////////////
43461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Member variables
43561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    ///////////////////////////////////////////////////////////
43661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         *m_tmp_meta_buf;
43761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         *m_tmp_out_meta_buf;
43861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         m_flush_cnt ;
43961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         m_comp_deinit;
44061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
44161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // the below var doesnt hold good if combo of use and alloc bufs are used
44261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         m_eos_bm;
44361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_S32                        m_volume;//Unit to be determined
44461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         audaac_header_adif[AUDAAC_MAX_ADIF_HEADER_LENGTH];
44561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U8                         audaac_header_mp4ff[AUDAAC_MAX_MP4FF_HEADER_LENGTH];
44661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U16                        audaac_hdr_bit_index;
44761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_S32                        sample_idx;
44861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_S32                        adif_flag;
44961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_S32                        mp4ff_flag;
45061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_PTR                        m_app_data;// Application data
45161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int                            nNumInputBuf;
45261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int                            nNumOutputBuf;
45361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int                            m_drv_fd;   // Kernel device node file handle
45461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool                           bFlushinprogress;
45561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool                           is_in_th_sleep;
45661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool                           is_out_th_sleep;
45761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   m_flags;      //encapsulate the waiting states.
45861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U64                        nTimestamp;
45961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_U64                        ts;
46061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    uint32_t                       m_frame_count;
46161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   frameduration;
46261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   pcm_input; //tunnel or non-tunnel
46361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   m_inp_act_buf_count;    // Num of Input Buffers
46461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   m_out_act_buf_count;    // Numb of Output Buffers
46561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   m_inp_current_buf_count;    // Num of Input Buffers
46661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   m_out_current_buf_count;    // Numb of Output Buffers
46761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   output_buffer_size;
46861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned int                   input_buffer_size;
46961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    unsigned short                 m_session_id;
47061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // store I/P PORT state
47161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_BOOL                       m_inp_bEnabled;
47261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // store O/P PORT state
47361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_BOOL                       m_out_bEnabled;
47461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    //Input port Populated
47561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_BOOL                       m_inp_bPopulated;
47661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    //Output port Populated
47761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_BOOL                       m_out_bPopulated;
47861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    sem_t                          sem_States;
47961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    sem_t                          sem_read_msg;
48061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    sem_t                          sem_write_msg;
48161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
48261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    volatile int                   m_is_event_done;
48361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    volatile int                   m_is_in_th_sleep;
48461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    volatile int                   m_is_out_th_sleep;
48561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    input_buffer_map               m_input_buf_hdrs;
48661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    output_buffer_map              m_output_buf_hdrs;
48761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_input_q;
48861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_input_ctrl_cmd_q;
48961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_input_ctrl_ebd_q;
49061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_command_q;
49161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_output_q;
49261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_output_ctrl_cmd_q;
49361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    omx_cmd_queue                  m_output_ctrl_fbd_q;
49461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_outputlock_attr;
49561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_commandlock_attr;
49661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_lock_attr;
49761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_state_attr;
49861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_flush_attr;
49961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_in_th_attr_1;
50061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_out_th_attr_1;
50161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_event_attr;
50261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_in_th_attr;
50361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            m_out_th_attr;
50461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            out_buf_count_lock_attr;
50561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutexattr_t            in_buf_count_lock_attr;
50661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_cond_t                 cond;
50761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_cond_t                 in_cond;
50861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_cond_t                 out_cond;
50961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_lock;
51061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_commandlock;
51161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_outputlock;
51261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Mutexes for state change
51361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_state_lock;
51461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Mutexes for  flush acks from input and output threads
51561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_flush_lock;
51661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_event_lock;
51761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_in_th_lock;
51861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_out_th_lock;
51961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_in_th_lock_1;
52061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                m_out_th_lock_1;
52161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                out_buf_count_lock;
52261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    pthread_mutex_t                in_buf_count_lock;
52361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
52461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_STATETYPE                  m_state;      // OMX State
52561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_STATETYPE                  nState;
52661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_CALLBACKTYPE               m_cb;         // Application callbacks
52761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    AAC_PB_STATS                  m_aac_pb_stats;
52861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct aac_ipc_info           *m_ipc_to_in_th;    // for input thread
52961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct aac_ipc_info           *m_ipc_to_out_th;    // for output thread
53061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct aac_ipc_info           *m_ipc_to_cmd_th;    // for command thread
53161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_PRIORITYMGMTTYPE           m_priority_mgm ;
53261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_AUDIO_PARAM_AACPROFILETYPE m_aac_param; // Cache AAC encoder parameter
53361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_AUDIO_PARAM_PCMMODETYPE    m_pcm_param;  // Cache pcm  parameter
53461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_PARAM_COMPONENTROLETYPE    component_Role;
53561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_PARAM_BUFFERSUPPLIERTYPE   m_buffer_supplier;
53661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
53761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    ///////////////////////////////////////////////////////////
53861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    // Private methods
53961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    ///////////////////////////////////////////////////////////
54061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE allocate_output_buffer(OMX_HANDLETYPE       hComp,
54161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                         OMX_BUFFERHEADERTYPE **bufferHdr,
54261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                         OMX_U32 port,OMX_PTR appData,
54361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                         OMX_U32              bytes);
54461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
54561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE allocate_input_buffer(OMX_HANDLETYPE       hComp,
54661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_BUFFERHEADERTYPE **bufferHdr,
54761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_U32              port,
54861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_PTR              appData,
54961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                        OMX_U32              bytes);
55061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
55161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE use_input_buffer(OMX_IN OMX_HANDLETYPE          hComp,
55261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   OMX_INOUT OMX_BUFFERHEADERTYPE **bufHdr,
55361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   OMX_IN OMX_U32                 port,
55461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   OMX_IN OMX_PTR                 appData,
55561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   OMX_IN OMX_U32                 bytes,
55661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                   OMX_IN OMX_U8*                 buffer);
55761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
55861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE use_output_buffer(OMX_IN OMX_HANDLETYPE          hComp,
55961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    OMX_INOUT OMX_BUFFERHEADERTYPE **bufHdr,
56061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    OMX_IN OMX_U32                 port,
56161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    OMX_IN OMX_PTR                 appData,
56261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    OMX_IN OMX_U32                 bytes,
56361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                    OMX_IN OMX_U8*                 buffer);
56461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
56561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE fill_this_buffer_proxy(OMX_HANDLETYPE       hComp,
56661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                         OMX_BUFFERHEADERTYPE *buffer);
56761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
56861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE send_command_proxy(OMX_HANDLETYPE  hComp,
56961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                     OMX_COMMANDTYPE cmd,
57061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                     OMX_U32         param1,
57161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                     OMX_PTR         cmdData);
57261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
57361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    OMX_ERRORTYPE send_command(OMX_HANDLETYPE hComp,
57461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                               OMX_COMMANDTYPE  cmd,
57561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                               OMX_U32       param1,
57661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                               OMX_PTR      cmdData);
57761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
57861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool allocate_done(void);
57961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
58061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool release_done(OMX_U32         param1);
58161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
58261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool execute_omx_flush(OMX_IN OMX_U32 param1, bool cmd_cmpl=true);
58361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
58461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool execute_input_omx_flush(void);
58561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
58661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool execute_output_omx_flush(void);
58761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
58861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool search_input_bufhdr(OMX_BUFFERHEADERTYPE *buffer);
58961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
59061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool search_output_bufhdr(OMX_BUFFERHEADERTYPE *buffer);
59161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
59261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool post_input(unsigned long p1, unsigned long p2,
59361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                    unsigned char id);
59461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
59561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool post_output(unsigned long p1, unsigned long p2,
59661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                     unsigned char id);
59761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
59861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void process_events(omx_aac_aenc *client_data);
59961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
60061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void buffer_done_cb(OMX_BUFFERHEADERTYPE *bufHdr);
60161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
60261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void frame_done_cb(OMX_BUFFERHEADERTYPE *bufHdr);
60361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
60461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void wait_for_event();
60561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
60661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void event_complete();
60761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
60861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void in_th_goto_sleep();
60961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
61061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void in_th_wakeup();
61161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
61261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void out_th_goto_sleep();
61361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
61461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void out_th_wakeup();
61561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
61661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void flush_ack();
61761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void deinit_encoder();
61861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void audaac_rec_install_adif_header_variable (OMX_U16  byte_num,
61961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                        OMX_U32 sample_index, OMX_U8 channel_config);
62061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void  audaac_rec_install_mp4ff_header_variable (OMX_U16  byte_num,
62161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                        OMX_U32 sample_index,OMX_U8 channel_config);
62261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    void audaac_rec_install_bits(OMX_U8 *input,
62361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                OMX_U8 num_bits_reqd,
62461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                OMX_U32  value,
62561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                OMX_U16 *hdr_bit_index);
62661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int get_updated_bit_rate(int bitrate);
62761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
62861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
62961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#endif
630