From 19cfcaf353ae4488927fc250361f8baa48f9ffb9 Mon Sep 17 00:00:00 2001 From: lishu Date: Sat, 29 Sep 2018 14:57:32 +0800 Subject: 20180929 first commit --- src/main.c | 1304 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1304 insertions(+) create mode 100644 src/main.c (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..d8885f5 --- /dev/null +++ b/src/main.c @@ -0,0 +1,1304 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "MESA_handle_logger.h" +#include "MESA_prof_load.h" +#include "MESA_trace.h" +#include "soqav_dedup.h" +#include "app_detect.h" + +#include "main.h" +#include "common.h" +#include "frag_reassembly_in.h" +#include "frag_recv.h" +#include "frag_proc.h" +#include "frag_json.h" +#include "frag_app.h" +#include "service.h" +#include "message.h" +#include "av_record.h" + +#include "bizman.h" +#include "AV_interface.h" +#include "field_stat2.h" +#include "my_socket.h" +#include "usm_api.h" +#include "asmis_log.h" +#include "wired_cfg.h" +#include "wiredLB.h" +#include "hard_keepalive.h" + +const char* frag_rssb_version = "2018-08-13T09:00:00"; +const char* frag_rssb_version_time = "2018-08-13T09:00:00"; +const char* frag_rssb_version_des = "MESA@iie rssb_maskey"; + +int FRAG_RSSB_VERSION_1_0_20180927 = 0; +const char* frag_rssb_version_time_in = "2018-09-27"; +const char* frag_rssb_version_des_in = "hard balance"; +void frag_rssb_history() +{ + //2015.11.15 v1.0 create the project + //2016.04.15 v1.0 converge , can return index info + //2016.05.11 v1.0 add live heart beat; + //2016.05.31 v1.0 local file use aboffset_in; stat orderby day + //2016.06.15 v1.0 change log level; index_hash + //2016.08.16 v1.0 add content-type, support netdisk and webmail + //2016.09.03 v1.0 av record + //2016.09.07 v1.0 frag removal + //2016.09.22 v1.0 modify maat init + //2016.10.10 v1.0 IVI bug + //2016.11.03 v1.0 1. av_record add SFH 2. delete HLS relative offset + //2016.11.08 v1.0 1. monitor file name use hash + //2016.11.11 v1.0 1. add digiest_len + //2016.12.15 v1.0 1. add more detail log 2. hash expire not free because of return 1 3. change whitelist and wins addr + //2016.12.22 v1.0 1. bizman_recv uncomplete_chunk. 2. no mediainfo , not create media when muti-down 3. add renew media + //2017.01.09 v1.0 1. trace log 2. add field_stat + //2017.02.13 v1.0 1. add Transfer Descriptor + //2017.02.23 v1.0 1. support APP + //2017.02.24 v1.0 1. time bug 2. dedup tuple4 3. modift create and expire 4 dedup addr + //2017.02.25 v1.0 1, log level + //2017.03.03 v1.0 1, monitor: data_flag, not hitservice + //2017.03.06 v1.0 1. av_dedup , set media_len + //2017.03.09 v2.0 use redis to query + //2017.03.14 v2.0 1. mulit-bizman 多个bizman接受数据,与线程数保持一致,监听端口BizmanPort->BizmanPort+thread_num-1 + //2. json to kafka 将粗瓶装信息以JSON文件回传给KAFKA,供跨媒体分析 + //3. redis connect bug 解决redis 段错误的问题 + //4. send mateinfo add localIP 回传的元信息增加IP选项 + //2017.03.15 v2.0 合并共享内存版本 + //2017.02.14 v1.0 alter unix socket to usm by dumeijie + //2017.03.09 v1.0 add lqnum opt by dumeijie + //2017.03.14 v1.0 support switch usm or unix socket + //2017.03.16 V2.0 + //fuzzy_hash增加开关FuzzyDigestSwitch + //没有元信息不创建frag_unit + //hash thread_safe = 512 + //2017.03.17 V2.0 + //JSON增加开关 + //2017.03.28 V2.0 + //log file open and close thread safe + //query fail or succ when once and twice + //record maxoffset + //pid and offset ack to do + //prog sync to do + //2017.03.31 V2.0 + //dedup permit media_len=0 + //2017.04.01 V3.0 + //create media by metainfo + //2017.04.06 v3.0 + //set_frag_unit_after_sifter bug + //2017.04.07 v3.0 + //redis replay is REDIS_REPLY_STRING not REDIS_REPLY_INTEGER + //2017.04.10 v3.0 + //distinguish http and frag + //2017.04.11 v3.0 + //avdedup bug: too much query + //2017.04.14 v3.0 + //1. redis 2. hls and osmf don't avdedup query 3. Rediscommandv + //2017.04.26 v3.0 + //stat create_media who is not hls_osmf + //2017.05.02 V3.0 + //redis master and slave mode + //2017.05.04 V3.0 + //IVI memsize + //2017.05.22 V3.0 + //FRAG_FD: survey add opt, frag index add CAPIP + //2017.05.31 V3.0 + //IVI seg merge + //APP asynchronous call + //2017.06.07 V3.0 + //create media and recv survey time to usec + //2017.06.12 V3.0 + //media_create.json media_expire.json + //2017.06.14 V3.0 + //support SIP + //2017.06.21 V3.0 + //wait queue add limit + //2017.06.23 V3.0 + //add wait queue try_join; mid insert JSON + //2017.07.03 V3.0 + //writing error : pid pid_array + //2017.07.13 V3.0 + //frag survey opt OPT_FRAG_URL not OPT_FRAG_SUBSTR + //picture_service set opt_num==0 + //2017.07.13 V3.0 + //frag survey opt OPT_FRAG_URL not OPT_FRAG_SUBSTR + //picture_service set opt_num==0 + //2017.07.24 V3.0 + //kafka json add cpz_ip + //2017.07.30 V4.0 + //send VOIP log + //2017.08.01 V4.0 + //support multi-source + //2017.08.16 V4.0 + //renew_media only reset IVI and so on + //2017.08.18 V4.0 + //soq_dedup_query interface + //2017.08.23 V4.0 + //multisrc : change mid according urlid + //2017.08.29 V4.0 + //dedup interface: return mid + //2017.09.04 V4.0 + //add fwdIP + //2017.09.07 V4.0 + //recv multi_src survey and send survey + //2017.09.08 V4.0 + //stat log + //2017.09.19 V4.0 + //fieldstat + //2017.09.20 V4.0 + //1. pic do not need IVI 2. only common av renew pid + //2017.09.22 V4.0 + //1. add frag survey stats 2. add voip full and survey + //2017.09.23 V4.0 + //1. voip data_sip_dir as rtp_tuple4 + //2017.09.29 V4.0 + //1. voip survey dedup + //2017.10.09 V4.0 + //1. voip send fdlog and jclog when expire + //2017.10.13 V4.0 + //1. set bizman maxnum 2. free_frag_unit + //2017.10.16 V4.0 + //1. sip add query stat + //2017.10.26 V4.0 + //1. dedup + //2017.11.14 V4.0 + //1. add TD record 2. voip log configID 3. do not send VOIP whose media_type unknown + //2017.11.30 v4.0 //1. redis switch 2. redis reconnect + //2017.12.01 v4.0 //1. queue->bloclk_queue + //2017.12.05 v4.0 //1. add voip_json 2.dedup query_flag 3. voip cmmd prit + //2017.12.07 v4.0 //1. VOIP full_log add pid as opt + //2017.12.11 v4.0 //1. add network admin and HeartBeat + //2017.12.13 v4.0 //1. TD data write into json kafka + //2017.12.14 v4.0 //1. add voip fulllog duration time opt + //2017.12.18 v4.0 //1. multi_src 2.redis interfece change + //2017.12.22 v4.0 //1. query stat 2.voip pid 3. voip query + //2017.12.25 v4.0 //1. redis addr_len 2. change_pid log + //2017.12.26 v4.0 //1. voip add duration 2. send voip_log when expire + //2017.12.27 v4.0 //1. free_frag_in when is dedup 2. bizman queue + //2018.01.02 v4.0 //1. support VOIP, timer support multi-thread + //2018.01.14 v4.0 //1. frag_cnvg_query usr av_query 2.send muliti even if dedup is not send + //2018.01.15 v4.0 //1. add cnvg_query_fail + //2018.01.17 v4.0 //1. voip query 3 times 2. VOIP monitor: data contain seq 3. data_log:record seq + //2018.01.18 v4.0 //1. query log : query_1 query_2 + //2018.01.31 v4.0 //1. av query all but use the first url ack + //2018.02.06 v4.0 //1. add asmis + //2018.02.08 v4.0 //1. sip first query when create_media + //2018.02.28 v4.0 //1. record all monitor file, but not send monitor suvey. implement this fuc when setting AllHitMonitorSwitch=2 + //2018.03.15 v4.0 //1. support frag whose offset is in URL and its media_type=0XA6 + //2018.04.24 v4.0 //1. add opt server and cont_type,ip port etc; 2.move genrate_td by dumeijie + //2018.04.27 v4.0 //1. add wired_cfg_create and init,2. add wiredLB report + //2018.05.09 v4.0 //1. frag forecast + //2018.05.10 v4.0 //1. add new sendback interface, defined in AV_sendback.h + //2018.05.17 v4.0 //1. modify VOIP_VERSION + //2018.05.28 v4.0 //1. add PIC_VERSION + //2018.06.01 v4.0 //1. multi-thread + //2018.06.04 v4.0 //1. set thread_safe of hash in conf + //2018.06.05 v4.0 //1. test dedup_query timeout + //2018.06.12 v4.0 //1. add mediatype to dump filename; main.conf add, close frag forecast ; json addr + //2018.06.27 v4.0 //1. store filename + //2018.06.28 v4.0 //1. add cross-media log to kafka 2. asmis flow 1min=60s + //2018.07.16 v4.0 //1. media_monitor_hash set thread_safe 2. add opt in AV_sendback.h + //2018.07.20 v4.0 //1. asmis_switch unit 1minutes + + //2018.07.24 v4.0 //1. voip add data_flag 2. service set int + //2018.07.30 v4.0 //1.add save_media by dmj + //2018.08.07 v4.0 //1. pic file monitor .jpeg 2. dumpfile before ivi + //2018.08.16 v4.0 //1. send config monitor when multisrc + //2018.09.01 v4.0 //1.alter voip sav_media; 2.add send_json_log for K_PROJECT + //2018.09.13 v4.0 //1.frag removal + //2018.09.20 v4.0//1 voip_fulllog add voice_dir opt + //2018.09.27 v4.0 //1. hard balance +} + +frag_rssb_parameter_t g_frag_run; +frag_rssb_configure_t g_frag_cfg; +frag_rssb_status_t g_frag_stat; + +const char* hash_eliminate_type[3] = +{ + "", + "ELIMINATE_TYPE_NUM", + "ELIMINATE_TYPE_TIME" +}; + +extern "C" void* frag_forward(void *param); +extern void read_app_to_decord(); + +int dedup_read_conf_and_init(const char* filename) +{ + int log_level = 0; + char conf_buf[MAX_PATH_LEN]={0}; + int value = 0; + + /*av_dedup log*/ + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_short_def(filename, "DEDUP", "DedupLogLevel", (short*)&log_level,30); + MESA_load_profile_string_def(filename, "DEDUP", "DedupLogPath", conf_buf , sizeof(conf_buf),"./log/dedup.log"); + g_frag_run.dedup_logger = MESA_create_runtime_log_handle(conf_buf,log_level); + if(NULL==g_frag_run.dedup_logger) + { + printf("[%s] dedup_logger MESA_create_runtime_log_handle error.\n", FRAG_REASSEMBLY_MODULE_NAME); + MESA_handle_runtime_log(g_frag_run.logger,RLOG_LV_FATAL,FRAG_REASSEMBLY_MODULE_NAME, + (char*)"[%s:%d] dedup_logger MESA_create_runtime_log_handle error." , __FILE__,__LINE__); + return -1; + } + + MESA_load_profile_short_def(filename, "DEDUP", "AVDedupSwitch", (short*)&g_frag_cfg.av_dedup_switch,0); + MESA_load_profile_short_def(filename, "DEDUP", "AVDedupInvalid", (short*)&g_frag_cfg.dedup_invalid,0); + MESA_load_profile_uint_def(filename, "DEDUP", "DedupTdDataSize", (uint32_t*)&g_frag_cfg.td_data_maxsize, 1024); + MESA_load_profile_short_def(filename, "DEDUP", "MultiWaitTimeout", (short*)&g_frag_cfg.multisrc_wait_timeout, 30); + MESA_load_profile_short_def(filename, "DEDUP", "MultiTimerCbMaxNum", (short*)&g_frag_cfg.multisrc_timer_cb_maxtime, 500); + for(uint32_t i=0;iKafkaConnection()) + { + printf("KafkaConnection %s error.\n", g_frag_cfg.kafka_brokers); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} KafkaConnection %s error.", + __FILE__,__LINE__, g_frag_cfg.kafka_brokers); + } + else + { + printf("KafkaConnection %s succ.\n", g_frag_cfg.kafka_brokers); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} KafkaConnection %s succ.", + __FILE__,__LINE__, g_frag_cfg.kafka_brokers); + } + //创建topic + if((g_frag_run.kafka_producer->CreateTopicHandle(TOPIC_MEDIA_CREATE_JSON)) == NULL) + { + printf("Kafka CreateTopicHandle %s failed.", TOPIC_MEDIA_CREATE_JSON); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} Kafka CreateTopicHandle %s failed.", + __FILE__,__LINE__, TOPIC_MEDIA_CREATE_JSON); + } + if((g_frag_run.kafka_producer->CreateTopicHandle(TOPIC_MEDIA_EXPIRE_JSON)) == NULL) + { + printf("Kafka CreateTopicHandle %s failed.", TOPIC_MEDIA_EXPIRE_JSON); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} Kafka CreateTopicHandle %s failed.", + __FILE__,__LINE__, TOPIC_MEDIA_EXPIRE_JSON); + } + if((g_frag_run.kafka_producer->CreateTopicHandle(TOPIC_SURVEY_JSON)) == NULL) + { + printf("Kafka CreateTopicHandle %s failed.", TOPIC_SURVEY_JSON); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} Kafka CreateTopicHandle %s failed.", + __FILE__,__LINE__, TOPIC_SURVEY_JSON); + } + if((g_frag_run.kafka_producer->CreateTopicHandle(TOPIC_VOIP_CREATE_JSON)) == NULL) + { + printf("Kafka CreateTopicHandle %s failed.", TOPIC_VOIP_CREATE_JSON); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} Kafka CreateTopicHandle %s failed.", + __FILE__,__LINE__, TOPIC_VOIP_CREATE_JSON); + } + if((g_frag_run.kafka_producer->CreateTopicHandle(TOPIC_VOIP_EXPIRE_JSON)) == NULL) + { + printf("Kafka CreateTopicHandle %s failed.", TOPIC_VOIP_EXPIRE_JSON); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} Kafka CreateTopicHandle %s failed.", + __FILE__,__LINE__, TOPIC_VOIP_EXPIRE_JSON); + } + if((g_frag_run.kafka_producer->CreateTopicHandle(TOPIC_VOIP_SURVEY_JSON)) == NULL) + { + printf("Kafka CreateTopicHandle %s failed.", TOPIC_VOIP_SURVEY_JSON); + MESA_handle_runtime_log(g_frag_run.logger, RLOG_LV_FATAL, FRAG_REASSEMBLY_MODULE_NAME, + "{%s:%d} Kafka CreateTopicHandle %s failed.", + __FILE__,__LINE__, TOPIC_VOIP_SURVEY_JSON); + } + return 0; +} + +int voip_read_conf_and_init(const char* filename) +{ + int log_level = 0; + char conf_buf[MAX_PATH_LEN]={0}; + + MESA_load_profile_short_def(filename, "VOIP", "VOIPFilterSwitch", (short*)&g_frag_cfg.voip_filter_switch,0); + /*voip log*/ + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_short_def(filename, "VOIP", "VOIPLogLevel", (short*)&log_level,30); + MESA_load_profile_string_def(filename, "VOIP", "VOIPLogPath", conf_buf , sizeof(conf_buf),"./log/voip.log"); + g_frag_run.voip_logger = MESA_create_runtime_log_handle(conf_buf,log_level); + if(NULL==g_frag_run.voip_logger) + { + printf("[%s] voip_logger MESA_create_runtime_log_handle error.\n", FRAG_REASSEMBLY_MODULE_NAME); + MESA_handle_runtime_log(g_frag_run.logger,RLOG_LV_FATAL,FRAG_REASSEMBLY_MODULE_NAME, + (char*)"[%s:%d] voip_logger MESA_create_runtime_log_handle error." , __FILE__,__LINE__); + return -1; + } + + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_short_def(filename, "VOIP", "VOIPSurveyLogPort", (short*)&g_frag_cfg.voip_survey_log_port,0); + MESA_load_profile_short_def(filename, "VOIP", "VOIPSurveyLogIPNum", (short*)&g_frag_cfg.voip_survey_log_ipnum,0); + g_frag_cfg.voip_survey_log_iplist= (uint32*)malloc(g_frag_cfg.voip_survey_log_ipnum*sizeof(unsigned int)); + MESA_load_profile_string_nodef(filename, "VOIP", "VOIPSurveyLogIP", conf_buf, sizeof(conf_buf)); + MESA_split_read_IP(conf_buf, g_frag_cfg.voip_survey_log_ipnum, g_frag_cfg.voip_survey_log_iplist); + + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_short_def(filename, "VOIP", "VOIPFullLogPort", (short*)&g_frag_cfg.voip_full_log_port,0); + MESA_load_profile_short_def(filename, "VOIP", "VOIPFullLogIPNum", (short*)&g_frag_cfg.voip_full_log_ipnum,0); + g_frag_cfg.voip_full_log_iplist= (uint32*)malloc(g_frag_cfg.voip_full_log_ipnum*sizeof(unsigned int)); + MESA_load_profile_string_nodef(filename, "VOIP", "VOIPSurveyLogIP", conf_buf, sizeof(conf_buf)); + MESA_split_read_IP(conf_buf, g_frag_cfg.voip_full_log_ipnum, g_frag_cfg.voip_full_log_iplist); + return 0; +} + +int app_read_conf_and_init(const char* filename) +{ + MESA_load_profile_short_def(filename, "SYSTEM", "AppSwitch", (short*)&g_frag_cfg.app_switch,0); + if(g_frag_cfg.app_switch) + { +#if APP_FUNC + g_frag_run.appdtc_handle = APPDETECT_PLUG_INIT(g_frag_cfg.thread_num, "./conf/app_detect.conf"); + if(NULL==g_frag_run.appdtc_handle) g_frag_cfg.app_switch = 0; +#endif + } + return 0; +} + +void rssb_stats_init(const char* filename) +{ + int value = 0; + char conf_buf[MAX_PATH_LEN]={0}; + + memset(conf_buf,0,sizeof(conf_buf)); + g_frag_stat.fs_handle = FS_create_handle(); + MESA_load_profile_string_def(filename, "LOG", "StatFile", conf_buf, sizeof(conf_buf), "./log/rssb_stat.log"); + FS_set_para(g_frag_stat.fs_handle, OUTPUT_DEVICE, conf_buf, strlen(conf_buf)+1); + value = 1;//flush by date + FS_set_para(g_frag_stat.fs_handle, FLUSH_BY_DATE, &value, sizeof(value)); + value = 2;//append + FS_set_para(g_frag_stat.fs_handle, PRINT_MODE, &value, sizeof(value)); + MESA_load_profile_short_def(filename, "LOG", "StatCycle", (short*)&g_frag_stat.stat_interval,0); + FS_set_para(g_frag_stat.fs_handle, STAT_CYCLE, &g_frag_stat.stat_interval, sizeof(g_frag_stat.stat_interval)); + value = (g_frag_stat.stat_interval!=0) ? 1 : 0; + FS_set_para(g_frag_stat.fs_handle, PRINT_TRIGGER, &value, sizeof(value)); + value = 0; + FS_set_para(g_frag_stat.fs_handle, CREATE_THREAD, &value, sizeof(value)); + MESA_load_profile_string_def(filename, "LOG", "AppName", g_frag_stat.fs_app, sizeof(g_frag_stat.fs_app), "rssb"); + FS_set_para(g_frag_stat.fs_handle, APP_NAME, g_frag_stat.fs_app, strlen(g_frag_stat.fs_app)+1); + MESA_load_profile_short_def(filename, "LOG", "StatRemoteSwitch", (short*)&g_frag_stat.fs_remote_switch,0); + if(g_frag_stat.fs_remote_switch) + { + MESA_load_profile_string_def(filename, "LOG", "StatServerIP", g_frag_stat.fs_ip, sizeof(g_frag_stat.fs_ip), "127.0.0.1"); + FS_set_para(g_frag_stat.fs_handle, STATS_SERVER_IP, g_frag_stat.fs_ip, strlen(g_frag_stat.fs_ip)+1); + MESA_load_profile_short_def(filename, "LOG", "StatServerPort", (short*)&g_frag_stat.fs_port,0); + FS_set_para(g_frag_stat.fs_handle, STATS_SERVER_PORT, &g_frag_stat.fs_port, sizeof(g_frag_stat.fs_port)); + } + + memset(conf_buf,0,sizeof(conf_buf)); + g_frag_stat.sysfs_handle = FS_create_handle(); + MESA_load_profile_string_def(filename, "LOG", "SysinfoFile", conf_buf, sizeof(conf_buf), "./log/rssb_sysinfo.log"); + FS_set_para(g_frag_stat.sysfs_handle, OUTPUT_DEVICE, conf_buf, strlen(conf_buf)+1); + value = 1;//flush by date + FS_set_para(g_frag_stat.sysfs_handle, FLUSH_BY_DATE, &value, sizeof(value)); + value = 2;//append + FS_set_para(g_frag_stat.sysfs_handle, PRINT_MODE, &value, sizeof(value)); + MESA_load_profile_short_def(filename, "LOG", "SysinfoCycle", (short*)&g_frag_stat.sysinfo_interval,0); + FS_set_para(g_frag_stat.sysfs_handle, STAT_CYCLE, &g_frag_stat.sysinfo_interval, sizeof(g_frag_stat.sysinfo_interval)); + value = (g_frag_stat.sysinfo_interval!=0) ? 1 : 0; + FS_set_para(g_frag_stat.sysfs_handle, PRINT_TRIGGER, &value, sizeof(value)); + value = 0; + FS_set_para(g_frag_stat.sysfs_handle, CREATE_THREAD, &value, sizeof(value)); +} + +int read_conf_and_init(const char* filename) +{ + int log_level = 0; + uint32_t i = 0; + uint32_t front_bizman_acc_msec = 0; + uint32_t front_bizman_acc_num = 0; + uint32_t front_bizman_smooth_msec = 0; + char conf_buf[MAX_PATH_LEN]={0}; + char buf[MAX_PATH_LEN]={0}; + char split_buf[DEST_MAXNUM][MAX_PATH_LEN]; + uint32_t special_media_type_num; + uint32_t special_media_type[SPECIAL_MEDIA_TYPE_MAXNUM] = {0}; + MESA_htable_create_args_t hash_args; + uint32_t hash_thread_safe = 512; + uint32_t hash_size = 0; + uint32_t hash_max_elem_num = 0; + uint32_t hash_expire_time = 0; + char table_info_filename [MAX_PATH_LEN]={0}; + + /*main log*/ + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_short_def(filename, "LOG", "LogLevel", (short*)&log_level,30); + MESA_load_profile_string_def(filename, "LOG", "LogPath", conf_buf , sizeof(conf_buf),"./log/runtime.log"); + g_frag_run.logger = MESA_create_runtime_log_handle(conf_buf,log_level); + if(NULL==g_frag_run.logger) + { + printf("[%s] MESA_create_runtime_log_handle error.\n", FRAG_REASSEMBLY_MODULE_NAME); + return -1; + } + + /*frag log*/ + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_short_def(filename, "LOG", "FragLogLevel", (short*)&g_frag_run.frag_loglevel,30); + MESA_load_profile_string_def(filename, "LOG", "FragLogPath", conf_buf , sizeof(conf_buf),"./log/frag.log"); + g_frag_run.frag_logger = MESA_create_runtime_log_handle(conf_buf,g_frag_run.frag_loglevel); + if(NULL==g_frag_run.frag_logger) + { + printf("[%s] frag_logger MESA_create_runtime_log_handle error.\n", FRAG_REASSEMBLY_MODULE_NAME); + MESA_handle_runtime_log(g_frag_run.logger,RLOG_LV_FATAL,FRAG_REASSEMBLY_MODULE_NAME, + (char*)"[%s:%d] frag_logger MESA_create_runtime_log_handle error." , __FILE__,__LINE__); + return -1; + } + + /*resp log*/ + MESA_load_profile_string_def(filename, "LOG", "RespLogPath", g_frag_cfg.resp_filename, sizeof(g_frag_cfg.resp_filename),"./log/survey.log"); + + /*create media log*/ + MESA_load_profile_string_def(filename, "LOG", "MediaCreateLogPath", g_frag_cfg.media_create_filename , sizeof(g_frag_cfg.media_create_filename),"./log/media_create.log"); + + /*expire media log*/ + MESA_load_profile_string_def(filename, "LOG", "MediaExpireLogPath", g_frag_cfg.media_expire_filename , sizeof(g_frag_cfg.media_expire_filename),"./log/media_expire.log"); + + /*stat log*/ + rssb_stats_init(filename); + + /*类型 0:AV_PIC 1:voip*/ + MESA_load_profile_short_def(filename, "SYSTEM", "CPZTpye", (short*)&g_frag_cfg.cpz_type, 0); + + /*thread_num*/ + MESA_load_profile_uint_def(filename, "SYSTEM", "ThreadNum", &g_frag_cfg.thread_num, 1); + if(MAX_THREAD_NUM0) + { + whitelist_ip_serial = (unsigned int *)malloc(g_frag_cfg.whitelist_addr_num*sizeof(unsigned int)); + MESA_split_read_IP(conf_buf, g_frag_cfg.whitelist_addr_num, whitelist_ip_serial); + for(i=0;i<(uint32_t)g_frag_cfg.whitelist_addr_num;i++) + { + g_frag_cfg.whitelist_addr[i].sin_addr.s_addr = whitelist_ip_serial[i]; + g_frag_cfg.whitelist_addr[i].sin_port = htons(whitelist_port); + } + if(NULL!=whitelist_ip_serial) + { + free(whitelist_ip_serial); + } + } + + /*udp socket : send av data by udp socket*/ + uint32_t* send_udp_ip_serial = NULL; + MESA_load_profile_uint_def(filename, "NETWORK", "UdpSendIPNum", (uint32_t*)&g_frag_cfg.send_dest_udp_ip_num,0); + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_string_nodef(filename, "NETWORK", "UdpSendPort", conf_buf, sizeof(conf_buf)); + memset(split_buf,0,sizeof(split_buf)); + string_split(conf_buf, split_buf, DEST_MAXNUM, ';'); + for(i=0;i<(uint32_t)g_frag_cfg.send_dest_udp_ip_num;i++) + { + g_frag_cfg.send_dest_udp_port[i] = htons(atoi(split_buf[i])); + } + memset(conf_buf,0,sizeof(conf_buf)); + MESA_load_profile_string_def(filename, "NETWORK", "UdpSendIP", conf_buf, sizeof(conf_buf),""); + if(g_frag_cfg.send_dest_udp_ip_num>0) + { + send_udp_ip_serial = (unsigned int *)malloc(g_frag_cfg.send_dest_udp_ip_num*sizeof(unsigned int)); + MESA_split_read_IP(conf_buf, g_frag_cfg.send_dest_udp_ip_num, send_udp_ip_serial); + for(i=0;i<(uint32_t)g_frag_cfg.send_dest_udp_ip_num;i++) + { + g_frag_cfg.send_dest_udp_iplist[i] = send_udp_ip_serial[i]; + } + if(NULL!=send_udp_ip_serial) + { + free(send_udp_ip_serial); + } + } + +#if K_PROJECT + if(g_frag_cfg.send_dest_udp_ip_num>0) + { + for(i=0; i0) + { + wins_ip_serial = (unsigned int *)malloc(g_frag_cfg.special_media_wins_ip_num*sizeof(unsigned int)); + MESA_split_read_IP(conf_buf, g_frag_cfg.special_media_wins_ip_num, wins_ip_serial); + for(i=0;i<(uint32_t)g_frag_cfg.special_media_wins_ip_num;i++) + { + g_frag_cfg.special_media_wins_ip[i] = wins_ip_serial[i]; + } + if(NULL!=wins_ip_serial) + { + free(wins_ip_serial); + } + } + if(g_frag_cfg.special_media_fwd_switch && g_frag_cfg.special_media_wins_ip_num>0 && g_frag_cfg.special_media_wins_port_num>0) + { + for(i=0; imagic_num = PROTO_MAGICNUM; + mh_ack->version = PROTO_VERSION; + mh_ack->msg_type = MSG_RESP_CHARACTER; + mh_ack->cont_len = sizeof(msg_data_ack_t); + } + } + + /*frag forward thread*/ + for(i=0;i0) + { + hard_keepalive_run(g_frag_cfg.hard_balance_port); + } + + while(1) + { + if(g_frag_cfg.asmis_switch) + { + sleep(10); + asmis_log_HeartBeat(g_frag_run.asmis_log_handle, "rssb_maskey heartbeat"); + } + else + { + pause(); + } + } + + return 0; +} + -- cgit v1.2.3