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