1 /*-------------------------------------------------------------------------- 2 Copyright (c) 2014-2017, 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 #ifndef __OMX_VENC__H 30 #define __OMX_VENC__H 31 32 #include <unistd.h> 33 #include "omx_video_base.h" 34 #ifdef _MSM8974_ 35 #include "video_encoder_device_v4l2.h" 36 #else 37 #include "video_encoder_device.h" 38 #endif 39 40 #include "swvenc_api.h" 41 #include "swvenc_types.h" 42 43 extern "C" { 44 OMX_API void * get_omx_component_factory_fn(void); 45 } 46 47 struct swvenc_video_capability { 48 unsigned int min_width; 49 unsigned int max_width; 50 unsigned int min_height; 51 unsigned int max_height; 52 }; 53 54 55 class omx_venc: public omx_video 56 { 57 public: 58 omx_venc(); 59 ~omx_venc(); 60 OMX_ERRORTYPE component_init(OMX_STRING role); 61 OMX_ERRORTYPE set_parameter(OMX_HANDLETYPE hComp, 62 OMX_INDEXTYPE paramIndex, 63 OMX_PTR paramData); 64 OMX_ERRORTYPE set_config(OMX_HANDLETYPE hComp, 65 OMX_INDEXTYPE configIndex, 66 OMX_PTR configData); 67 OMX_ERRORTYPE component_deinit(OMX_HANDLETYPE hComp); 68 bool is_secure_session(); 69 //OMX strucutres 70 OMX_U32 m_nVenc_format; 71 72 SWVENC_HANDLE m_hSwVenc; 73 SWVENC_CODEC m_codec; 74 swvenc_video_capability m_capability; 75 bool m_max_allowed_bitrate_check; 76 bool m_stopped; 77 bool set_format; 78 79 int dev_handle_output_extradata(void *, int); 80 int dev_handle_input_extradata(void *, int, int); 81 bool dev_buffer_ready_to_queue(OMX_BUFFERHEADERTYPE *buffer); 82 void dev_set_extradata_cookie(void *); 83 int dev_set_format(int); 84 85 static SWVENC_STATUS swvenc_empty_buffer_done_cb 86 ( 87 SWVENC_HANDLE swvenc, 88 SWVENC_IPBUFFER *p_ipbuffer, 89 void *p_client 90 ); 91 SWVENC_STATUS swvenc_empty_buffer_done 92 ( 93 SWVENC_IPBUFFER *p_ipbuffer 94 ); 95 static SWVENC_STATUS swvenc_fill_buffer_done_cb 96 ( 97 SWVENC_HANDLE swvenc, 98 SWVENC_OPBUFFER *p_opbuffer, 99 void *p_client 100 ); 101 static SWVENC_STATUS swvenc_handle_event_cb 102 ( 103 SWVENC_HANDLE swvenc, 104 SWVENC_EVENT event, 105 void *p_client 106 ); 107 108 private: 109 venc_debug_cap m_debug; 110 bool m_bSeqHdrRequested; 111 112 OMX_U32 dev_stop(void); 113 OMX_U32 dev_pause(void); 114 OMX_U32 dev_start(void); 115 OMX_U32 dev_flush(unsigned); 116 OMX_U32 dev_resume(void); 117 OMX_U32 dev_start_done(void); 118 OMX_U32 dev_set_message_thread_id(pthread_t); 119 bool dev_use_buf( void *,unsigned,unsigned); 120 bool dev_free_buf( void *,unsigned); 121 bool dev_empty_buf(void *, void *,unsigned,unsigned); 122 bool dev_fill_buf(void *, void *,unsigned,unsigned); 123 bool dev_get_buf_req(OMX_U32 *,OMX_U32 *,OMX_U32 *,OMX_U32); 124 bool dev_set_buf_req(OMX_U32 const *,OMX_U32 const *,OMX_U32 const *,OMX_U32); 125 bool dev_get_seq_hdr(void *, unsigned, unsigned *); 126 bool dev_loaded_start(void); 127 bool dev_loaded_stop(void); 128 bool dev_loaded_start_done(void); 129 bool dev_loaded_stop_done(void); 130 bool dev_get_capability_ltrcount(OMX_U32 *, OMX_U32 *, OMX_U32 *); 131 bool dev_get_performance_level(OMX_U32 *); 132 bool dev_get_vui_timing_info(OMX_U32 *); 133 bool dev_get_vqzip_sei_info(OMX_U32 *); 134 bool dev_get_peak_bitrate(OMX_U32 *); 135 bool dev_get_batch_size(OMX_U32 *); dev_get_temporal_layer_caps(OMX_U32 *,OMX_U32 *)136 bool dev_get_temporal_layer_caps(OMX_U32 * /*nMaxLayers*/, 137 OMX_U32 * /*nMaxBLayers*/) { 138 return false; 139 } dev_get_pq_status(OMX_BOOL *)140 bool dev_get_pq_status(OMX_BOOL *) { 141 return false; 142 } 143 bool dev_is_video_session_supported(OMX_U32 width, OMX_U32 height); 144 bool dev_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width, 145 OMX_U32 height); 146 bool dev_get_output_log_flag(); 147 int dev_output_log_buffers(const char *buffer_addr, int buffer_len); 148 int dev_extradata_log_buffers(char *buffer); 149 bool swvenc_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width, 150 OMX_U32 height); 151 152 SWVENC_STATUS swvenc_set_rc_mode(OMX_VIDEO_CONTROLRATETYPE eControlRate); 153 SWVENC_STATUS swvenc_set_profile_level(OMX_U32 eProfile,OMX_U32 eLevel); 154 SWVENC_STATUS swvenc_set_intra_refresh(OMX_VIDEO_PARAM_INTRAREFRESHTYPE *IntraRefresh); 155 SWVENC_STATUS swvenc_set_frame_rate(OMX_U32 nFrameRate); 156 SWVENC_STATUS swvenc_set_bit_rate(OMX_U32 nTargetBitrate); 157 SWVENC_STATUS swvenc_set_intra_period(OMX_U32 nPFrame,OMX_U32 nBFrame); 158 SWVENC_STATUS swvenc_set_color_format(OMX_COLOR_FORMATTYPE); 159 SWVENC_STATUS swvenc_get_buffer_req 160 ( 161 OMX_U32 *min_buff_count, 162 OMX_U32 *actual_buff_count, 163 OMX_U32 *buff_size, 164 OMX_U32 *buff_alignment, 165 OMX_U32 port 166 ); 167 int swvenc_input_log_buffers(const char *buffer, int bufferlen); 168 169 }; 170 171 #endif //__OMX_VENC__H 172