1 /* 2 * Copyright 2020 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 * author: <martin.cheng@rock-chips.com> 17 * date: 2020-05-20 18 * module: RTNodeCommon 19 */ 20 21 #ifndef SRC_RT_TASK_APP_GRAPH_RTNODECOMMON_H 22 #define SRC_RT_TASK_APP_GRAPH_RTNODECOMMON_H 23 24 #include <iterator> 25 #include <list> 26 #include <vector> 27 28 #include "rt_string_utils.h" 29 30 /* 31 * "node_0": { 32 * "node_name": "source_stream", 33 * "node_opts": { "node_type": "rkisp" }, 34 * "node_stream": { "name": "v4l2_capture" }, 35 * "node_stream_opts": { "device": "/dev/video0" } 36 * } 37 */ 38 39 #define NODE_NAME_RKISP "rkisp" 40 #define NODE_NAME_FREAD "fread" 41 #define NODE_NAME_RKMPP_ENC "rkmpp_enc" 42 #define NODE_NAME_RKMPP_DEC "rkmpp_dec" 43 #define NODE_NAME_ROCKX "rockx" 44 #define NODE_NAME_FWRITE "fwrite" 45 #define NODE_NAME_RKRGA "rkrga" 46 #define NODE_NAME_EPTZ "rkeptz" 47 #define NODE_NAME_STASTERIA "st_asteria" // sensetime asteria 48 #define NODE_NAME_AIMATTING "ai_matting" 49 #define NODE_NAME_GLPSS "rkglpss" 50 #define NODE_NAME_VPSS "rkvpss" 51 #define NODE_NAME_AVS "rkavs" 52 53 #define NODE_NAME_RESAMPLE "resample" 54 #define NODE_NAME_ALSA_CAPTURE "alsa_capture" 55 #define NODE_NAME_ALSA_PLAYBACK "alsa_playback" 56 #define NODE_NAME_MULTI_CAPTURE "multi_cap" 57 #define NODE_NAME_ALGORITHM_3A "alg_3a" 58 #define NODE_NAME_ALGORITHM_3A_ANR "alg_anr" 59 #define NODE_NAME_ALGORITHM_SKV "skv" 60 #define NODE_NAME_ALGORITHM_SKV_AEC "skv_aec" 61 #define NODE_NAME_ALGORITHM_SKV_AGC "skv_agc" 62 #define NODE_NAME_ALGORITHM_SKV_BF "skv_bf" 63 #define NODE_NAME_ALGORITHM_SKV_DOA "skv_doa" 64 #define NODE_NAME_AUDIO_TRACK_MODE "track_mode" 65 66 #define NODE_NAME_RKNN "rknn" 67 #define NODE_NAME_FFM_DEMUXER "ffm_demuxer" 68 #define NODE_NAME_VIDEO_SINK "video_sink" 69 #define NODE_NAME_FILTER_IMAGE "filter_image" 70 #define NODE_NAME_FILTER_SCALER "filter_scaler" 71 #define NODE_NAME_VOLUME "filter_volume" 72 #define NODE_NAME_LINK_OUTPUT "link_output" 73 #define NODE_NAME_SOURCE_EXTERNAL "external_source" 74 #define NODE_NAME_AUDIO_DEC "audio_dec" 75 #define NODE_NAME_AUDIO_ENC "audio_enc" 76 77 #define NODE_PORT_SOURCE "source" 78 #define NODE_PORT_DEVICE "device" 79 #define NODE_PORT_SINK "sink" 80 81 // task node names supported by rockchip co. 82 #define RT_NODE_DEVICE_RKISP "node_rkisp" 83 #define RT_NODE_DEVICE_ALSA_CAPTURE "node_alsa_capture" 84 #define RT_NODE_DEVICE_ALSA_PLAYBACK "node_alsa_playback" 85 #define RT_NODE_CODEC_RKMPP "node_rkmpp" 86 #define RT_NODE_CODEC_FFVIDEO "node_ffvideo" // tmedia codec video 87 #define RT_NODE_CODEC_FFAUDIO "node_ffaudio" // tmedia codec audio 88 #define RT_NODE_FILTER_RKRGA "node_rkrga" 89 #define RT_NODE_FILTER_RKNN "node_rknn" 90 #define RT_NODE_FILTER_RKFACE "node_rkface" 91 #define RT_NODE_FILTER_RESAMPLE "node_resample" 92 93 // common root types for task node. 94 #define KEY_ROOT_PIPE_ID "pipe_" 95 #define KEY_ROOT_NODE_ID "node_" 96 #define KEY_ROOT_EXEC_ID "executor_" 97 #define KEY_ROOT_LINK_MODE_ID "link_" 98 #define KEY_ROOT_INPUT_STREAM_ID "stream_input_" 99 #define KEY_ROOT_OUTPUT_STREAM_ID "stream_output_" 100 #define KEY_ROOT_NODE_OPTS "node_opts" 101 #define KEY_ROOT_NODE_OPTS_EXTRA "node_opts_extra" 102 #define KEY_ROOT_STREAM_OPTS "stream_opts" 103 #define KEY_ROOT_STREAM_OPTS_EXTRA "stream_opts_extra" 104 #define KEY_ROOT_THREAD_OPTS "thread_opts" 105 #define KEY_ROOT_EXEC_OPTS "executor_opts" 106 #define KEY_ROOT_DEFAULT_LINK_MODE "default_mode_link" 107 108 // common parameters for task node. subnodes of KEY_ROOT_NODE_OPTS 109 #define OPT_NODE_NAME "node_name" 110 111 #define OPT_LINK_NAME "link_name" 112 #define OPT_LINK_SHIP "link_ship" 113 114 // extra parameters for task node. subnodes of KEY_ROOT_NODE_OPTS_EXTRA 115 #define OPT_NODE_SOURCE_URI "node_source_uri" 116 #define OPT_NODE_BUFFER_COUNT "node_buff_count" 117 #define OPT_NODE_BUFFER_TYPE "node_buff_type" 118 #define OPT_NODE_BUFFER_SIZE "node_buff_size" 119 #define OPT_NODE_BUFFER_ALLOC_TYPE "node_buff_alloc_type" 120 #define OPT_NODE_TRANS_RECT "node_trans_rect" 121 #define OPT_NODE_DISPATCH_EXEC "node_disp_exec" 122 #define OPT_NODE_MAX_INPUT_COUNT "node_max_input_count" 123 #define OPT_NODE_GATE_MODE "node_gate_mode" 124 #define OPT_NODE_BATCH_SIZE "node_batch_size" 125 #define OPT_NODE_SRC_MB_TYPE "node_src_mbtype" 126 #define OPT_NODE_DST_MB_TYPE "node_dst_mbtype" 127 128 #define OPT_FILE_READ_SIZE "opt_read_size" 129 130 // common parameters for node stream. subnodes of KEY_ROOT_NODE_STREAM 131 #define OPT_STREAM_UID "stream_uid" 132 #define OPT_STREAM_INPUT_NAME "stream_input" 133 #define OPT_STREAM_OUTPUT_NAME "stream_output" 134 #define OPT_STREAM_FMT_IN "stream_fmt_in" 135 #define OPT_STREAM_FMT_OUT "stream_fmt_out" 136 #define OPT_STREAM_FMT_IN_PREFIX "stream_fmt_in_" 137 #define OPT_STREAM_FMT_OUT_PREFIX "stream_fmt_out_" 138 #define OPT_STREAM_INPUT_MODE "stream_mode_in" 139 140 // common parameters for codec video. subnodes of KEY_ROOT_NODE_STREAM_OPTS 141 #define OPT_VIDEO_SVC "opt_svc" 142 #define OPT_VIDEO_SMART "opt_smart" 143 #define OPT_VIDEO_GOP "opt_gop" 144 #define OPT_VIDEO_BITRATE "opt_bitrate" 145 #define OPT_VIDEO_STREAMSMOOTH "opt_smooth" 146 #define OPT_VIDEO_LEVEL "opt_level" 147 #define OPT_VIDEO_PROFILE "opt_profile" 148 #define OPT_VIDEO_TRANS_8x8 "opt_trans8x8" 149 #define OPT_VIDEO_ENTROPY_EN "opt_cabac_en" 150 #define OPT_VIDEO_ENTROPY_IDC "opt_cabac_idc" 151 #define OPT_VIDEO_FRAME_RATE "opt_frame_rate" 152 #define OPT_VIDEO_DIMENS "opt_dimens" // veried, fixed 153 #define OPT_VIDEO_WIDTH "opt_width" 154 #define OPT_VIDEO_HEIGHT "opt_height" 155 #define OPT_VIDEO_VIR_WIDTH "opt_vir_width" 156 #define OPT_VIDEO_VIR_HEIGHT "opt_vir_height" 157 #define OPT_VIDEO_HOR_STRIDE "opt_hor_stride" 158 #define OPT_VIDEO_VER_STRIDE "opt_ver_stride" 159 #define OPT_VIDEO_PIX_FORMAT "opt_pix_format" 160 #define OPT_VIDEO_QUALITY_INIT "opt_qp_init" 161 #define OPT_VIDEO_QUALITY_STEP "opt_qp_step" 162 #define OPT_VIDEO_QUALITY_MIN "opt_qp_min" 163 #define OPT_VIDEO_QUALITY_MAX "opt_qp_max" 164 #define OPT_VIDEO_QUALITY_MIN_H265 "opt_qp_min_h265" 165 #define OPT_VIDEO_QUALITY_MAX_H265 "opt_qp_max_h265" 166 #define OPT_VIDEO_RC_MODE "opt_rc_mode" 167 #define OPT_VIDEO_RC_QUALITY "opt_rc_mode" 168 #define OPT_VIDEO_REGIONS_ROI "opt_regions_roi" 169 #define OPT_VIDEO_REGIONS_RI "opt_regions_ri" 170 #define OPT_VIDEO_TRANS_RECT "opt_trans_rect" 171 #define OPT_VIDEO_COLOR_RANGE "opt_color_range" 172 #define OPT_VIDEO_TIME_REF "opt_time_ref" 173 #define OPT_VIDEO_COLOR "opt_color" 174 #define OPT_VIDEO_SPLIT_MODE "opt_split_mode" 175 #define OPT_VIDEO_OUTPUT_MODE "opt_output_mode" 176 #define OPT_VIDEO_DROP_ERR_FRAME "opt_drop_err_frame" 177 #define OPT_VIDEO_NALU_TYPE "opt_nalu_type" 178 #define OPT_VIDEO_EN_DEI "opt_en_dei" 179 #define OPT_VIDEO_EN_COLMV "opt_en_colmv" 180 #define OPT_VIDEO_MAX_DEC_BUFFERING "opt_max_dec_buffering" 181 182 /* draw line in picture */ 183 #define OPT_LINE_START_X "opt_line_startx" 184 #define OPT_LINE_START_Y "opt_line_starty" 185 #define OPT_LINE_END_X "opt_line_endx" 186 #define OPT_LINE_END_Y "opt_line_endy" 187 #define OPT_LINE_THICK "opt_line_thick" 188 189 /* mosaic in picture */ 190 #define OPT_MOSAIC_X "opt_mosaic_x" 191 #define OPT_MOSAIC_Y "opt_mosaic_y" 192 #define OPT_MOSAIC_W "opt_mosaic_w" 193 #define OPT_MOSAIC_H "opt_mosaic_h" 194 #define OPT_MOSAIC_BLK_SIZE "opt_mosaic_blk_size" 195 196 // common parameters for codec audio. subnodes of KEY_ROOT_NODE_STREAM_OPTS 197 #define OPT_AUDIO_CHANNEL "opt_channel" 198 #define OPT_AUDIO_CHANNEL_LAYOUT "opt_channel_layout" 199 #define OPT_AUDIO_SAMPLE_RATE "opt_samaple_rate" 200 #define OPT_AUDIO_BITRATE "opt_bitrate" 201 #define OPT_AUDIO_SOURCE_URI "opt_source_uri" 202 #define OPT_AUDIO_ANS "opt_ans" 203 #define OPT_AUDIO_FORMAT "opt_format" 204 #define OPT_AUDIO_REF_CHANNEL_LAYOUT "opt_ref_channel_layout" /*aec process of 3a filter*/ 205 #define OPT_AUDIO_REC_CHANNEL_LAYOUT "opt_rec_channel_layout" 206 #define OPT_AUDIO_REF_VOLUME "opt_ref_volume" 207 #define OPT_AUDIO_REC_VOLUME "opt_rec_volume" 208 #define OPT_AUDIO_ALSA_MODE "opt_alsa_mode" 209 #define OPT_AUDIO_AGC_LEVEL "opt_agc_level" 210 #define OPT_AUDIO_AGC_IS_SPEECH "opt_agc_is_speech" 211 #define OPT_AUDIO_BF_MODE "opt_bf_mode" 212 #define OPT_AUDIO_DOA_DISTANCE "opt_doa_distance" 213 #define OPT_AUDIO_DOA_TARG "opt_doa_targ" 214 #define OPT_AUDIO_ANR_DEGREE "opt_anr_degree" 215 #define OPT_AUDIO_AEC_ENABLE "opt_aec_enable" 216 #define OPT_AUDIO_AEC_DELAY "opt_aec_delay" 217 #define OPT_AUDIO_AEC_NLP_URI "opt_aec_nlp_uri" 218 #define OPT_AUDIO_AEC_NLP_PLUS_URI "opt_aec_nlp_plus_uri" 219 220 #define OPT_PEROID_SIZE "opt_peroid_size" 221 #define OPT_PEROID_COUNT "opt_peroid_count" 222 #define OPT_AUDIO_MUTE "opt_mute" 223 #define OPT_AUDIO_VOLUME "opt_volume" 224 #define OPT_AUDIO_START_DELAY "opt_start_delay" 225 #define OPT_AUDIO_STOP_DELAY "opt_stop_delay" 226 227 // define new option begin here 228 #define OPT_NODE_ID "opt_node_id" 229 #define OPT_NODE_CMD "opt_node_cmd" 230 #define OPT_NODE_OP "opt_node_op" 231 #define OPT_NODE_PRIOR_TYPE "opt_node_prior" 232 #define OPT_NODE_BYPASS "opt_node_bypass" 233 234 #define OPT_AV_PTS "opt_av_pts" 235 #define OPT_AV_BPM "opt_av_dts" 236 #define OPT_AV_SEQ "opt_av_seq" 237 #define OPT_AV_EOS "opt_av_eos" 238 #define OPT_AV_ERR "opt_av_err" 239 #define OPT_AV_DURATION "opt_av_duration" 240 #define OPT_AV_TIMEOUT "opt_av_timeout" 241 #define OPT_AV_BUF_STATUS "opt_av_buf_status" 242 243 #define OPT_CODEC_ID "opt_codec_id" 244 #define OPT_CODEC_TYPE "opt_codec_type" 245 #define OPT_CODEC_DEC_MODE "opt_dec_mode" 246 #define OPT_CODEC_EXT_DATA "opt_ext_data" 247 #define OPT_CODEC_EXT_SIZE "opt_ext_size" 248 #define OPT_CODEC_BITS_PER_SAMPLE "opt_bits_per_sample" 249 250 // define new option end here 251 #define OPT_FILTER_WIDTH "opt_width" 252 #define OPT_FILTER_HEIGHT "opt_height" 253 #define OPT_FILTER_VIR_WIDTH "opt_vir_width" 254 #define OPT_FILTER_VIR_HEIGHT "opt_vir_height" 255 #define OPT_FILTER_TRANS_RECT "opt_trans_rect" 256 #define OPT_FILTER_TRANS_ROTATE "opt_trans_rotate" 257 #define OPT_FILTER_MOSAIC "opt_mosaic" 258 #define OPT_FILTER_MIRROR "opt_mirror" 259 #define OPT_FILTER_FLIP "opt_flip" 260 261 #define OPT_FILTER_MD_DS_WIDTH "opt_md_ds_width" 262 #define OPT_FILTER_MD_DS_HEIGHT "opt_md_ds_height" 263 #define OPT_FILTER_MD_ORI_WIDTH "opt_md_ori_width" 264 #define OPT_FILTER_MD_ORI_HEIGHT "opt_md_ori_height" 265 #define OPT_FILTER_MD_ROI_CNT "opt_md_roi_cnt" 266 #define OPT_FILTER_MD_ROI_RECT "opt_md_roi_rect" 267 #define OPT_FILTER_MD_SINGLE_REF "opt_md_single" 268 #define OPT_FILTER_RECT_X "opt_rect_x" 269 #define OPT_FILTER_RECT_Y "opt_rect_y" 270 #define OPT_FILTER_RECT_W "opt_rect_w" 271 #define OPT_FILTER_RECT_H "opt_rect_h" 272 #define OPT_FILTER_RECT_MODE "opt_rect_mode" 273 #define OPT_FILTER_DST_RECT_X "opt_dst_rect_x" 274 #define OPT_FILTER_DST_RECT_Y "opt_dst_rect_y" 275 #define OPT_FILTER_DST_RECT_W "opt_dst_rect_w" 276 #define OPT_FILTER_DST_RECT_H "opt_dst_rect_h" 277 #define OPT_FILTER_DST_RECT_MODE "opt_dst_rect_mode" 278 #define OPT_FILTER_DST_VIR_WIDTH "opt_dst_vir_width" 279 #define OPT_FILTER_DST_VIR_HEIGHT "opt_dst_vir_height" 280 #define OPT_FILTER_DST_PIX_FORMAT "opt_dst_pix_format" 281 #define OPT_FILTER_COMPRESS "opt_compress_mode" 282 #define OPT_FILTER_DST_COMPRESS "opt_dst_compress_mode" 283 #define OPT_FILTER_FADE_RATE "opt_fade_rate" 284 #define OPT_FILTER_FG_ALPHA "opt_fg_alpha" 285 #define OPT_FILTER_BG_ALPHA "opt_bg_alpha" 286 287 #define OPT_V4L2_BUF_TYPE "opt_buf_type" 288 #define OPT_V4L2_MEM_TYPE "opt_mem_type" 289 #define OPT_V4L2_USE_LIBV4L2 "opt_use_libv4l2" 290 #define OPT_V4L2_COLORSPACE "opt_colorspace" 291 #define OPT_V4L2_WIDTH "opt_width" 292 #define OPT_V4L2_HEIGHT "opt_height" 293 #define OPT_V4L2_ENTITY_NAME "opt_entity_name" 294 #define OPT_V4L2_QUANTIZATION "opt_quantiztion" 295 #define OPT_V4L2_CAMERA_INDEX "opt_camera_index" 296 297 #define OPT_ROCKX_MODEL "opt_rockx_model" 298 299 #define OPT_ROCKX_LIB_PATH "opt_rockx_lib_path" 300 #define OPT_ROCKX_SKIP_FRAME "opt_rockx_skip_frame" 301 302 #define OPT_AI_DETECT_RESULT "opt_ai_detect_result" 303 #define OPT_AI_ALGORITHM "opt_ai_algorithm" 304 305 #define OPT_AIMATTING_OUT_RESULT "aimatting_out_result" 306 307 #define OPT_EPTZ_CLIP_RATIO "opt_clip_ratio" 308 #define OPT_EPTZ_CLIP_WIDTH "opt_clip_width" 309 #define OPT_EPTZ_CLIP_HEIGHT "opt_clip_height" 310 311 #define OPT_AUDIO_ALGORITHM "opt_audio_algorithm" 312 313 #define OPT_EXEC_THREAD_NUM "exec_thread_num" 314 #define OPT_EXEC_THREAD_NAME "exec_name" 315 316 #define OPT_RGA_BLEND "opt_rga_blend" 317 #define OPT_MPP_MPI_TYPE "opt_mpp_mpi_type" 318 319 /* 320 * AI Server -- {DBUS | RNDIS} -- Remote HOST(TV AI) 321 * 322 * We communicate with the remote HOST through RNDIS. 323 * DBus is an interactive interface, CMDs are as follows 324 */ 325 #define OPT_DBUS_LEVEL_HIGHEST "dbus_highest" 326 #define OPT_DBUS_LEVEL_HIGHER "dbus_higher" 327 #define OPT_DBUS_LEVEL_HIGH "dbus_high" 328 #define OPT_DBUS_LEVEL_MEDIUM "dbus_medium" 329 #define OPT_DBUS_LEVEL_LOW "dbus_low" 330 #define OPT_DBUS_LEVEL_LOWER "dbus_lower" 331 #define OPT_DBUS_LEVEL_LOWEST "dbus_lowest" 332 #define OPT_DBUS_RC_MODE_CBR "dbus_rc_mode_cbr" 333 #define OPT_DBUS_RC_MODE_VBR "dbus_rc_mode_vbr" 334 335 #define OPT_DBUS_ENCORDE_TYPE_H264 "H.264" 336 #define OPT_DBUS_ENCORDE_TYPE_H265 "H.265" 337 #define OPT_DBUS_ENCORDE_TYPE_MJPEG "MJPEG" 338 #define OPT_DBUS_ENCORDE_TYPE_MPEG4 "MPEG4" 339 340 #define RT_MAX_CAM_NUM 4 341 #define RT_MAX_SOUND_NUM 3 342 #define RT_MAX_OSD_REGION_NUM 15 343 #define RT_MAX_ROI_REGION_NUM 4 344 345 #define RT_PARAM_STRING_APPEND(s, s1, s2) \ 346 s.append(s1).append("=").append(s2).append("\n") 347 348 #define RT_STRING_LINK_STREAM(s, format, upNodeId, downNodeId) \ 349 s.append(format).append("_").append(util_to_string(upNodeId)) \ 350 .append("_").append(util_to_string(downNodeId)) 351 352 #define RT_NODE_CONFIG_STRING_APPEND(s, key, value) \ 353 s.append("\"").append(key).append("\"") \ 354 .append(" : ").append("\"").append(value).append("\",\n") 355 356 #define RT_NODE_CONFIG_NUMBER_APPEND(s, key, value) \ 357 s.append("\"").append(key).append("\"") \ 358 .append(" : ").append(util_to_string(value)).append(",\n") 359 360 #define RT_NODE_CONFIG_STRING_LAST_APPEND(s, key, value) \ 361 s.append("\"").append(key).append("\"") \ 362 .append(" : ").append("\"").append(value).append("\"\n") 363 364 #define RT_NODE_CONFIG_NUMBER_LAST_APPEND(s, key, value) \ 365 s.append("\"").append(key).append("\"") \ 366 .append(" : ").append(util_to_string(value)).append("\n") 367 368 #define RT_NODE_TAG_APPEND(s, id) \ 369 s.append("\"").append(KEY_ROOT_NODE_ID).append(util_to_string(id)).append("\": {\n") 370 371 #define RT_PIPE_TAG_APPEND(s, id) \ 372 s.append("\"").append(KEY_ROOT_PIPE_ID).append(util_to_string(id)).append("\": {\n") 373 374 #define RT_NODE_OPTS_APPEND(s) \ 375 s.append("\"").append(KEY_ROOT_NODE_OPTS).append("\": {\n") 376 377 #define RT_STREAM_OPTS_APPEND(s) \ 378 s.append("\"").append(KEY_ROOT_STREAM_OPTS).append("\": {\n") 379 380 #define RT_TAG_END(s) \ 381 s.append("},\n") 382 383 #define RT_TAG_LAST_END(s) \ 384 s.append("}\n") 385 386 typedef enum _RTStreamId { 387 RT_STREAM_ID_MAIN = 0, 388 RT_STREAM_ID_2ND, 389 RT_STREAM_ID_3RD, 390 RT_STREAM_ID_4TH, 391 } RTStreamId; 392 393 typedef enum _RTStreamType { 394 RT_STM_TYPE_UNKNOW, 395 RT_STM_TYPE_VIDEO, 396 RT_STM_TYPE_AUDIO, 397 RT_STM_TYPE_SUBTI, 398 RT_STM_TYPE_IMAGE, 399 RT_STM_TYPE_GENERAL, 400 RT_STM_TYPE_MAX, 401 } RTStreamType; 402 403 typedef enum _RTNodeGateMode { 404 RT_NODE_GATE_NORMAL = 0, 405 RT_NODE_GATE_AUTO, 406 RT_NODE_GATE_DELAYOPEN, 407 RT_NODE_GATE_MAX, 408 } RTNodeGateMode; 409 410 #endif // SRC_RT_TASK_APP_GRAPH_RTNODECOMMON_H 411