1/*--------------------------------------------------------------------------
2Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are met:
6    * Redistributions of source code must retain the above copyright
7      notice, this list of conditions and the following disclaimer.
8    * Redistributions in binary form must reproduce the above copyright
9      notice, this list of conditions and the following disclaimer in the
10      documentation and/or other materials provided with the distribution.
11    * Neither the name of Code Aurora nor
12      the names of its contributors may be used to endorse or promote
13      products derived from this software without specific prior written
14      permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27--------------------------------------------------------------------------*/
28
29#ifndef __OMX_VIDEO_BASE_H__
30#define __OMX_VIDEO_BASE_H__
31/*============================================================================
32                            O p e n M A X   Component
33                                Video Encoder
34
35*//** @file comx_video_base.h
36  This module contains the class definition for openMAX decoder component.
37
38*//*========================================================================*/
39
40//////////////////////////////////////////////////////////////////////////////
41//                             Include Files
42//////////////////////////////////////////////////////////////////////////////
43
44#include<stdlib.h>
45#include <stdio.h>
46#include <sys/mman.h>
47#ifdef _ANDROID_
48  #include <binder/MemoryHeapBase.h>
49#ifdef _ANDROID_ICS_
50  #include "QComOMXMetadata.h"
51#endif
52#endif // _ANDROID_
53#include <pthread.h>
54#include <semaphore.h>
55#include <linux/msm_vidc_enc.h>
56#include "OMX_Core.h"
57#include "OMX_QCOMExtns.h"
58#include "qc_omx_component.h"
59#include "omx_video_common.h"
60#include "extra_data_handler.h"
61#include <linux/videodev2.h>
62#include <dlfcn.h>
63#include "C2DColorConverter.h"
64
65#ifdef _ANDROID_
66using namespace android;
67// local pmem heap object
68class VideoHeap : public MemoryHeapBase
69{
70public:
71  VideoHeap(int fd, size_t size, void* base);
72  virtual ~VideoHeap() {}
73};
74
75#include <utils/Log.h>
76#define LOG_TAG "OMX-VENC-720p"
77#ifdef ENABLE_DEBUG_LOW
78#define DEBUG_PRINT_LOW ALOGV
79#else
80#define DEBUG_PRINT_LOW
81#endif
82#ifdef ENABLE_DEBUG_HIGH
83#define DEBUG_PRINT_HIGH  ALOGV
84#else
85#define DEBUG_PRINT_HIGH
86#endif
87#ifdef ENABLE_DEBUG_ERROR
88#define DEBUG_PRINT_ERROR ALOGE
89#else
90#define DEBUG_PRINT_ERROR
91#endif
92
93#else //_ANDROID_
94#define DEBUG_PRINT_LOW
95#define DEBUG_PRINT_HIGH
96#define DEBUG_PRINT_ERROR
97#endif // _ANDROID_
98
99#ifdef USE_ION
100    static const char* MEM_DEVICE = "/dev/ion";
101    #define MEM_HEAP_ID ION_CP_MM_HEAP_ID
102#elif MAX_RES_720P
103static const char* MEM_DEVICE = "/dev/pmem_adsp";
104#elif MAX_RES_1080P_EBI
105static const char* MEM_DEVICE  = "/dev/pmem_adsp";
106#elif MAX_RES_1080P
107static const char* MEM_DEVICE = "/dev/pmem_smipool";
108#else
109#error MEM_DEVICE cannot be determined.
110#endif
111
112//////////////////////////////////////////////////////////////////////////////
113//                       Module specific globals
114//////////////////////////////////////////////////////////////////////////////
115
116#define OMX_SPEC_VERSION  0x00000101
117
118
119//////////////////////////////////////////////////////////////////////////////
120//               Macros
121//////////////////////////////////////////////////////////////////////////////
122#define PrintFrameHdr(bufHdr) DEBUG_PRINT("bufHdr %x buf %x size %d TS %d\n",\
123                       (unsigned) bufHdr,\
124                       (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->pBuffer,\
125                       (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->nFilledLen,\
126                       (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->nTimeStamp)
127
128// BitMask Management logic
129#define BITS_PER_BYTE        32
130#define BITMASK_SIZE(mIndex) (((mIndex) + BITS_PER_BYTE - 1)/BITS_PER_BYTE)
131#define BITMASK_OFFSET(mIndex) ((mIndex)/BITS_PER_BYTE)
132#define BITMASK_FLAG(mIndex) (1 << ((mIndex) % BITS_PER_BYTE))
133#define BITMASK_CLEAR(mArray,mIndex) (mArray)[BITMASK_OFFSET(mIndex)] \
134        &=  ~(BITMASK_FLAG(mIndex))
135#define BITMASK_SET(mArray,mIndex)  (mArray)[BITMASK_OFFSET(mIndex)] \
136        |=  BITMASK_FLAG(mIndex)
137#define BITMASK_PRESENT(mArray,mIndex) ((mArray)[BITMASK_OFFSET(mIndex)] \
138        & BITMASK_FLAG(mIndex))
139#define BITMASK_ABSENT(mArray,mIndex) (((mArray)[BITMASK_OFFSET(mIndex)] \
140        & BITMASK_FLAG(mIndex)) == 0x0)
141#define BITMASK_PRESENT(mArray,mIndex) ((mArray)[BITMASK_OFFSET(mIndex)] \
142        & BITMASK_FLAG(mIndex))
143#define BITMASK_ABSENT(mArray,mIndex) (((mArray)[BITMASK_OFFSET(mIndex)] \
144        & BITMASK_FLAG(mIndex)) == 0x0)
145#ifdef _ANDROID_ICS_
146#define MAX_NUM_INPUT_BUFFERS 32
147#endif
148void* message_thread(void *);
149// OMX video class
150class omx_video: public qc_omx_component
151{
152protected:
153#ifdef _ANDROID_ICS_
154  bool meta_mode_enable;
155  bool c2d_opened;
156  encoder_media_buffer_type meta_buffers[MAX_NUM_INPUT_BUFFERS];
157  OMX_BUFFERHEADERTYPE *opaque_buffer_hdr[MAX_NUM_INPUT_BUFFERS];
158  bool mUseProxyColorFormat;
159  OMX_BUFFERHEADERTYPE  *psource_frame;
160  OMX_BUFFERHEADERTYPE  *pdest_frame;
161  bool secure_session;
162  int secure_color_format;
163  class omx_c2d_conv {
164  public:
165    omx_c2d_conv();
166    ~omx_c2d_conv();
167	bool init();
168	bool open(unsigned int height,unsigned int width,
169			  ColorConvertFormat src,
170			  ColorConvertFormat dest);
171	bool convert(int src_fd, void *src_base, void *src_viraddr,
172	             int dest_fd, void* dest_base, void *dest_viraddr);
173	bool get_buffer_size(int port,unsigned int &buf_size);
174	int get_src_format();
175	void close();
176  private:
177     C2DColorConverterBase *c2dcc;
178    void *mLibHandle;
179	ColorConvertFormat src_format;
180    createC2DColorConverter_t *mConvertOpen;
181    destroyC2DColorConverter_t *mConvertClose;
182  };
183  omx_c2d_conv c2d_conv;
184#endif
185public:
186  omx_video();  // constructor
187  virtual ~omx_video();  // destructor
188
189  // virtual int async_message_process (void *context, void* message);
190  void process_event_cb(void *ctxt,unsigned char id);
191
192  OMX_ERRORTYPE allocate_buffer(
193                               OMX_HANDLETYPE hComp,
194                               OMX_BUFFERHEADERTYPE **bufferHdr,
195                               OMX_U32 port,
196                               OMX_PTR appData,
197                               OMX_U32 bytes
198                               );
199
200
201  virtual OMX_ERRORTYPE component_deinit(OMX_HANDLETYPE hComp)= 0;
202
203  virtual OMX_ERRORTYPE component_init(OMX_STRING role)= 0;
204
205  virtual OMX_U32 dev_stop(void) = 0;
206  virtual OMX_U32 dev_pause(void) = 0;
207  virtual OMX_U32 dev_start(void) = 0;
208  virtual OMX_U32 dev_flush(unsigned) = 0;
209  virtual OMX_U32 dev_resume(void) = 0;
210  virtual OMX_U32 dev_start_done(void) = 0;
211  virtual OMX_U32 dev_stop_done(void) = 0;
212  virtual bool dev_use_buf(void *,unsigned,unsigned) = 0;
213  virtual bool dev_free_buf(void *,unsigned) = 0;
214  virtual bool dev_empty_buf(void *, void *,unsigned,unsigned) = 0;
215  virtual bool dev_fill_buf(void *buffer, void *,unsigned,unsigned) = 0;
216  virtual bool dev_get_buf_req(OMX_U32 *,OMX_U32 *,OMX_U32 *,OMX_U32) = 0;
217  virtual bool dev_get_seq_hdr(void *, unsigned, unsigned *) = 0;
218  virtual bool dev_loaded_start(void) = 0;
219  virtual bool dev_loaded_stop(void) = 0;
220  virtual bool dev_loaded_start_done(void) = 0;
221  virtual bool dev_loaded_stop_done(void) = 0;
222  virtual bool is_secure_session(void) = 0;
223#ifdef _ANDROID_ICS_
224  void omx_release_meta_buffer(OMX_BUFFERHEADERTYPE *buffer);
225#endif
226  OMX_ERRORTYPE component_role_enum(
227                                   OMX_HANDLETYPE hComp,
228                                   OMX_U8 *role,
229                                   OMX_U32 index
230                                   );
231
232  OMX_ERRORTYPE component_tunnel_request(
233                                        OMX_HANDLETYPE hComp,
234                                        OMX_U32 port,
235                                        OMX_HANDLETYPE  peerComponent,
236                                        OMX_U32 peerPort,
237                                        OMX_TUNNELSETUPTYPE *tunnelSetup
238                                        );
239
240  OMX_ERRORTYPE empty_this_buffer(
241                                 OMX_HANDLETYPE hComp,
242                                 OMX_BUFFERHEADERTYPE *buffer
243                                 );
244
245
246
247  OMX_ERRORTYPE fill_this_buffer(
248                                OMX_HANDLETYPE hComp,
249                                OMX_BUFFERHEADERTYPE *buffer
250                                );
251
252
253  OMX_ERRORTYPE free_buffer(
254                           OMX_HANDLETYPE hComp,
255                           OMX_U32 port,
256                           OMX_BUFFERHEADERTYPE *buffer
257                           );
258
259  OMX_ERRORTYPE get_component_version(
260                                     OMX_HANDLETYPE hComp,
261                                     OMX_STRING componentName,
262                                     OMX_VERSIONTYPE *componentVersion,
263                                     OMX_VERSIONTYPE *specVersion,
264                                     OMX_UUIDTYPE *componentUUID
265                                     );
266
267  OMX_ERRORTYPE get_config(
268                          OMX_HANDLETYPE hComp,
269                          OMX_INDEXTYPE configIndex,
270                          OMX_PTR configData
271                          );
272
273  OMX_ERRORTYPE get_extension_index(
274                                   OMX_HANDLETYPE hComp,
275                                   OMX_STRING paramName,
276                                   OMX_INDEXTYPE *indexType
277                                   );
278
279  OMX_ERRORTYPE get_parameter(OMX_HANDLETYPE hComp,
280                              OMX_INDEXTYPE  paramIndex,
281                              OMX_PTR        paramData);
282
283  OMX_ERRORTYPE get_state(OMX_HANDLETYPE hComp,
284                          OMX_STATETYPE *state);
285
286
287
288  OMX_ERRORTYPE send_command(OMX_HANDLETYPE  hComp,
289                             OMX_COMMANDTYPE cmd,
290                             OMX_U32         param1,
291                             OMX_PTR         cmdData);
292
293
294  OMX_ERRORTYPE set_callbacks(OMX_HANDLETYPE   hComp,
295                              OMX_CALLBACKTYPE *callbacks,
296                              OMX_PTR          appData);
297
298  virtual OMX_ERRORTYPE set_config(OMX_HANDLETYPE hComp,
299                           OMX_INDEXTYPE  configIndex,
300                           OMX_PTR        configData) = 0;
301
302  virtual OMX_ERRORTYPE set_parameter(OMX_HANDLETYPE hComp,
303                                      OMX_INDEXTYPE  paramIndex,
304                                      OMX_PTR        paramData) =0;
305
306  OMX_ERRORTYPE use_buffer(OMX_HANDLETYPE      hComp,
307                           OMX_BUFFERHEADERTYPE **bufferHdr,
308                           OMX_U32              port,
309                           OMX_PTR              appData,
310                           OMX_U32              bytes,
311                           OMX_U8               *buffer);
312
313
314  OMX_ERRORTYPE use_EGL_image(OMX_HANDLETYPE     hComp,
315                              OMX_BUFFERHEADERTYPE **bufferHdr,
316                              OMX_U32              port,
317                              OMX_PTR              appData,
318                              void *               eglImage);
319
320
321
322  int  m_pipe_in;
323  int  m_pipe_out;
324
325  pthread_t msg_thread_id;
326  pthread_t async_thread_id;
327
328  OMX_U8 m_nkind[128];
329
330
331  //int *input_pmem_fd;
332  //int *output_pmem_fd;
333  struct pmem *m_pInput_pmem;
334  struct pmem *m_pOutput_pmem;
335#ifdef USE_ION
336  struct venc_ion *m_pInput_ion;
337  struct venc_ion *m_pOutput_ion;
338#endif
339
340
341
342public:
343  // Bit Positions
344  enum flags_bit_positions
345  {
346    // Defer transition to IDLE
347    OMX_COMPONENT_IDLE_PENDING            =0x1,
348    // Defer transition to LOADING
349    OMX_COMPONENT_LOADING_PENDING         =0x2,
350    // First  Buffer Pending
351    OMX_COMPONENT_FIRST_BUFFER_PENDING    =0x3,
352    // Second Buffer Pending
353    OMX_COMPONENT_SECOND_BUFFER_PENDING   =0x4,
354    // Defer transition to Enable
355    OMX_COMPONENT_INPUT_ENABLE_PENDING    =0x5,
356    // Defer transition to Enable
357    OMX_COMPONENT_OUTPUT_ENABLE_PENDING   =0x6,
358    // Defer transition to Disable
359    OMX_COMPONENT_INPUT_DISABLE_PENDING   =0x7,
360    // Defer transition to Disable
361    OMX_COMPONENT_OUTPUT_DISABLE_PENDING  =0x8,
362    //defer flush notification
363    OMX_COMPONENT_OUTPUT_FLUSH_PENDING    =0x9,
364    OMX_COMPONENT_INPUT_FLUSH_PENDING    =0xA,
365    OMX_COMPONENT_PAUSE_PENDING          =0xB,
366    OMX_COMPONENT_EXECUTE_PENDING        =0xC,
367    OMX_COMPONENT_LOADED_START_PENDING = 0xD,
368    OMX_COMPONENT_LOADED_STOP_PENDING = 0xF,
369
370  };
371
372  // Deferred callback identifiers
373  enum
374  {
375    //Event Callbacks from the venc component thread context
376    OMX_COMPONENT_GENERATE_EVENT       = 0x1,
377    //Buffer Done callbacks from the venc component thread context
378    OMX_COMPONENT_GENERATE_BUFFER_DONE = 0x2,
379    //Frame Done callbacks from the venc component thread context
380    OMX_COMPONENT_GENERATE_FRAME_DONE  = 0x3,
381    //Buffer Done callbacks from the venc component thread context
382    OMX_COMPONENT_GENERATE_FTB         = 0x4,
383    //Frame Done callbacks from the venc component thread context
384    OMX_COMPONENT_GENERATE_ETB         = 0x5,
385    //Command
386    OMX_COMPONENT_GENERATE_COMMAND     = 0x6,
387    //Push-Pending Buffers
388    OMX_COMPONENT_PUSH_PENDING_BUFS    = 0x7,
389    // Empty Buffer Done callbacks
390    OMX_COMPONENT_GENERATE_EBD         = 0x8,
391    //Flush Event Callbacks from the venc component thread context
392    OMX_COMPONENT_GENERATE_EVENT_FLUSH       = 0x9,
393    OMX_COMPONENT_GENERATE_EVENT_INPUT_FLUSH = 0x0A,
394    OMX_COMPONENT_GENERATE_EVENT_OUTPUT_FLUSH = 0x0B,
395    OMX_COMPONENT_GENERATE_FBD = 0xc,
396    OMX_COMPONENT_GENERATE_START_DONE = 0xD,
397    OMX_COMPONENT_GENERATE_PAUSE_DONE = 0xE,
398    OMX_COMPONENT_GENERATE_RESUME_DONE = 0xF,
399    OMX_COMPONENT_GENERATE_STOP_DONE = 0x10,
400    OMX_COMPONENT_GENERATE_HARDWARE_ERROR = 0x11,
401    OMX_COMPONENT_GENERATE_ETB_OPQ = 0x12
402  };
403
404  struct omx_event
405  {
406    unsigned param1;
407    unsigned param2;
408    unsigned id;
409  };
410
411  struct omx_cmd_queue
412  {
413    omx_event m_q[OMX_CORE_CONTROL_CMDQ_SIZE];
414    unsigned m_read;
415    unsigned m_write;
416    unsigned m_size;
417
418    omx_cmd_queue();
419    ~omx_cmd_queue();
420    bool insert_entry(unsigned p1, unsigned p2, unsigned id);
421    bool pop_entry(unsigned *p1,unsigned *p2, unsigned *id);
422    // get msgtype of the first ele from the queue
423    unsigned get_q_msg_type();
424
425  };
426
427  bool allocate_done(void);
428  bool allocate_input_done(void);
429  bool allocate_output_done(void);
430
431  OMX_ERRORTYPE free_input_buffer(OMX_BUFFERHEADERTYPE *bufferHdr);
432  OMX_ERRORTYPE free_output_buffer(OMX_BUFFERHEADERTYPE *bufferHdr);
433
434  OMX_ERRORTYPE allocate_input_buffer(OMX_HANDLETYPE       hComp,
435                                      OMX_BUFFERHEADERTYPE **bufferHdr,
436                                      OMX_U32              port,
437                                      OMX_PTR              appData,
438                                      OMX_U32              bytes);
439#ifdef _ANDROID_ICS_
440  OMX_ERRORTYPE allocate_input_meta_buffer(OMX_HANDLETYPE       hComp,
441                                      OMX_BUFFERHEADERTYPE **bufferHdr,
442                                      OMX_PTR              appData,
443                                      OMX_U32              bytes);
444#endif
445  OMX_ERRORTYPE allocate_output_buffer(OMX_HANDLETYPE       hComp,
446                                       OMX_BUFFERHEADERTYPE **bufferHdr,
447                                       OMX_U32 port,OMX_PTR appData,
448                                       OMX_U32              bytes);
449
450  OMX_ERRORTYPE use_input_buffer(OMX_HANDLETYPE hComp,
451                                 OMX_BUFFERHEADERTYPE  **bufferHdr,
452                                 OMX_U32               port,
453                                 OMX_PTR               appData,
454                                 OMX_U32               bytes,
455                                 OMX_U8                *buffer);
456
457  OMX_ERRORTYPE use_output_buffer(OMX_HANDLETYPE hComp,
458                                  OMX_BUFFERHEADERTYPE   **bufferHdr,
459                                  OMX_U32                port,
460                                  OMX_PTR                appData,
461                                  OMX_U32                bytes,
462                                  OMX_U8                 *buffer);
463
464  bool execute_omx_flush(OMX_U32);
465  bool execute_output_flush(void);
466  bool execute_input_flush(void);
467  OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE hComp,
468                                  OMX_BUFFERHEADERTYPE * buffer);
469
470  OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE hComp,
471                                 OMX_BUFFERHEADERTYPE * buffer);
472  OMX_ERRORTYPE empty_this_buffer_proxy(OMX_HANDLETYPE hComp,
473                                        OMX_BUFFERHEADERTYPE *buffer);
474  OMX_ERRORTYPE empty_this_buffer_opaque(OMX_HANDLETYPE hComp,
475                                  OMX_BUFFERHEADERTYPE *buffer);
476  OMX_ERRORTYPE push_input_buffer(OMX_HANDLETYPE hComp);
477  OMX_ERRORTYPE convert_queue_buffer(OMX_HANDLETYPE hComp,
478     struct pmem &Input_pmem_info,unsigned &index);
479  OMX_ERRORTYPE queue_meta_buffer(OMX_HANDLETYPE hComp,
480     struct pmem &Input_pmem_info);
481  OMX_ERRORTYPE fill_this_buffer_proxy(OMX_HANDLETYPE       hComp,
482                                       OMX_BUFFERHEADERTYPE *buffer);
483  bool release_done();
484
485  bool release_output_done();
486  bool release_input_done();
487
488  OMX_ERRORTYPE send_command_proxy(OMX_HANDLETYPE  hComp,
489                                   OMX_COMMANDTYPE cmd,
490                                   OMX_U32         param1,
491                                   OMX_PTR         cmdData);
492  bool post_event( unsigned int p1,
493                   unsigned int p2,
494                   unsigned int id
495                 );
496  OMX_ERRORTYPE get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType);
497  inline void omx_report_error ()
498  {
499    if(m_pCallbacks.EventHandler && !m_error_propogated)
500    {
501      m_error_propogated = true;
502      m_pCallbacks.EventHandler(&m_cmp,m_app_data,
503                                OMX_EventError,OMX_ErrorHardware,0,NULL);
504    }
505  }
506
507  void complete_pending_buffer_done_cbs();
508
509  //*************************************************************
510  //*******************MEMBER VARIABLES *************************
511  //*************************************************************
512
513  pthread_mutex_t       m_lock;
514  sem_t                 m_cmd_lock;
515  bool              m_error_propogated;
516
517  //sem to handle the minimum procesing of commands
518
519
520  // compression format
521  //OMX_VIDEO_CODINGTYPE eCompressionFormat;
522  // OMX State
523  OMX_STATETYPE m_state;
524  // Application data
525  OMX_PTR m_app_data;
526  OMX_BOOL m_use_input_pmem;
527  OMX_BOOL m_use_output_pmem;
528  // Application callbacks
529  OMX_CALLBACKTYPE m_pCallbacks;
530  OMX_PORT_PARAM_TYPE m_sPortParam;
531  OMX_VIDEO_PARAM_PROFILELEVELTYPE m_sParamProfileLevel;
532  OMX_VIDEO_PARAM_PORTFORMATTYPE m_sInPortFormat;
533  OMX_VIDEO_PARAM_PORTFORMATTYPE m_sOutPortFormat;
534  OMX_PARAM_PORTDEFINITIONTYPE m_sInPortDef;
535  OMX_PARAM_PORTDEFINITIONTYPE m_sOutPortDef;
536  OMX_VIDEO_PARAM_MPEG4TYPE m_sParamMPEG4;
537  OMX_VIDEO_PARAM_H263TYPE m_sParamH263;
538  OMX_VIDEO_PARAM_AVCTYPE m_sParamAVC;
539  OMX_PORT_PARAM_TYPE m_sPortParam_img;
540  OMX_PORT_PARAM_TYPE m_sPortParam_audio;
541  OMX_VIDEO_CONFIG_BITRATETYPE m_sConfigBitrate;
542  OMX_CONFIG_FRAMERATETYPE m_sConfigFramerate;
543  OMX_VIDEO_PARAM_BITRATETYPE m_sParamBitrate;
544  OMX_PRIORITYMGMTTYPE m_sPriorityMgmt;
545  OMX_PARAM_BUFFERSUPPLIERTYPE m_sInBufSupplier;
546  OMX_PARAM_BUFFERSUPPLIERTYPE m_sOutBufSupplier;
547  OMX_CONFIG_ROTATIONTYPE m_sConfigFrameRotation;
548  OMX_CONFIG_INTRAREFRESHVOPTYPE m_sConfigIntraRefreshVOP;
549  OMX_VIDEO_PARAM_QUANTIZATIONTYPE m_sSessionQuantization;
550  OMX_VIDEO_PARAM_AVCSLICEFMO m_sAVCSliceFMO;
551  QOMX_VIDEO_INTRAPERIODTYPE m_sIntraperiod;
552  OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE m_sErrorCorrection;
553  OMX_VIDEO_PARAM_INTRAREFRESHTYPE m_sIntraRefresh;
554  OMX_U32 m_sExtraData;
555  OMX_U32 m_sDebugSliceinfo;
556  OMX_U32 m_input_msg_id;
557  // fill this buffer queue
558  omx_cmd_queue         m_ftb_q;
559  // Command Q for rest of the events
560  omx_cmd_queue         m_cmd_q;
561  omx_cmd_queue         m_etb_q;
562  omx_cmd_queue         m_opq_meta_q;
563  omx_cmd_queue         m_opq_pmem_q;
564  // Input memory pointer
565  OMX_BUFFERHEADERTYPE  *m_inp_mem_ptr;
566  OMX_BUFFERHEADERTYPE meta_buffer_hdr[MAX_NUM_INPUT_BUFFERS];
567  // Output memory pointer
568  OMX_BUFFERHEADERTYPE  *m_out_mem_ptr;
569
570  bool input_flush_progress;
571  bool output_flush_progress;
572  bool input_use_buffer;
573  bool output_use_buffer;
574  int pending_input_buffers;
575  int pending_output_buffers;
576
577  unsigned int m_out_bm_count;
578  unsigned int m_inp_bm_count;
579  unsigned int m_flags;
580  unsigned int m_etb_count;
581  unsigned int m_fbd_count;
582#ifdef _ANDROID_
583  // Heap pointer to frame buffers
584  sp<MemoryHeapBase>    m_heap_ptr;
585#endif //_ANDROID_
586  // to know whether Event Port Settings change has been triggered or not.
587  bool m_event_port_settings_sent;
588  OMX_U8                m_cRole[OMX_MAX_STRINGNAME_SIZE];
589  extra_data_handler extra_data_handle;
590
591private:
592#ifdef USE_ION
593  int alloc_map_ion_memory(int size,struct ion_allocation_data *alloc_data,
594                                    struct ion_fd_data *fd_data,int flag);
595  void free_ion_memory(struct venc_ion *buf_ion_info);
596#endif
597};
598
599#endif // __OMX_VIDEO_BASE_H__
600