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