diff --git a/fec_manager.cpp b/fec_manager.cpp index 2ba92db..6fcf310 100644 --- a/fec_manager.cpp +++ b/fec_manager.cpp @@ -20,7 +20,8 @@ fec_parameter_t g_fec_par; -int debug_fec=0; +int debug_fec_enc=0; +int debug_fec_dec=0; //int dynamic_update_fec=1; const int encode_fast_send=1; @@ -322,10 +323,10 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) assert(blob_encode.output(actual_data_num,blob_output,fec_len)==0); - if(debug_fec) - mylog(log_debug,"x=%d y=%d len=%d cnt=%d\n",actual_data_num,actual_redundant_num,fec_len,counter); + if(debug_fec_enc) + mylog(log_debug,"[enc]seq=%08x x=%d y=%d len=%d cnt=%d\n",seq,actual_data_num,actual_redundant_num,fec_len,counter); else - mylog(log_trace,"x=%d y=%d len=%d cnt=%d\n",actual_data_num,actual_redundant_num,fec_len,counter); + mylog(log_trace,"[enc]seq=%08x x=%d y=%d len=%d cnt=%d\n",seq,actual_data_num,actual_redundant_num,fec_len,counter); } else { @@ -343,10 +344,10 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) int sum=fec_len*counter; - if(debug_fec) - mylog(log_debug,"x=%d y=%d len=%d sum_ori=%d sum=%d\n",actual_data_num,actual_redundant_num,fec_len,sum_ori,sum); + if(debug_fec_enc) + mylog(log_debug,"[enc]seq=%08x x=%d y=%d len=%d sum_ori=%d sum=%d\n",seq,actual_data_num,actual_redundant_num,fec_len,sum_ori,sum); else - mylog(log_trace,"x=%d y=%d len=%d sum_ori=%d sum=%d\n",actual_data_num,actual_redundant_num,fec_len,sum_ori,sum); + mylog(log_trace,"[enc]seq=%08x x=%d y=%d len=%d sum_ori=%d sum=%d\n",seq,actual_data_num,actual_redundant_num,fec_len,sum_ori,sum); } //mylog(log_trace,"%d %d %d\n",actual_data_num,actual_redundant_num,fec_len); @@ -638,9 +639,21 @@ int fec_decode_manager_t::input(char *s,int len) u32_t tmp_seq=fec_data[index].seq; anti_replay.set_invaild(tmp_seq); - if(mp.find(tmp_seq)!=mp.end()) + auto tmp_it=mp.find(tmp_seq); + if(tmp_it!=mp.end()) { - mp.erase(tmp_seq); + int x=tmp_it->second.data_num; + int y=tmp_it->second.redundant_num; + int cnt=tmp_it->second.group_mp.size(); + + if(cntfirst first]=fec_data[it->second].buf; } assert(rs_decode2(group_data_num,group_data_num+group_redundant_num,fec_tmp_arr,len)==0); //the input data has been modified in-place //this line should always succeed + if(debug_fec_dec) + mylog(log_debug,"[dec]seq=%08x x=%d y=%d len=%d cnt=%d X=%d Y=%d\n",seq,group_data_num,group_redundant_num,len,int(inner_mp.size()),x_got,y_got); + else + mylog(log_trace,"[dec]seq=%08x x=%d y=%d len=%d cnt=%d X=%d Y=%d\n",seq,group_data_num,group_redundant_num,len,int(inner_mp.size()),x_got,y_got); + blob_decode.clear(); for(int i=0;ifirst first]=fec_data[it->second].buf; if(fec_data[it->second].len<(int)sizeof(u16_t)) { @@ -790,9 +819,12 @@ int fec_decode_manager_t::input(char *s,int len) assert(rs_decode2(group_data_num,group_data_num+group_redundant_num,output_s_arr_buf,max_len)==0);//this should always succeed + int sum_ori=0; + for(int i=0;imax_data_len) { @@ -806,6 +838,14 @@ int fec_decode_manager_t::input(char *s,int len) //break; } } + + int sum=max_len*group_data_num; + + if(debug_fec_dec) + mylog(log_debug,"[dec]seq=%08x x=%d y=%d len=%d sum_ori=%d sum=%d X=%d Y=%d\n",seq,group_data_num,group_redundant_num,max_len,sum_ori,sum,x_got,y_got); + else + mylog(log_trace,"[dec]seq=%08x x=%d y=%d len=%d sum_ori=%d sum=%d X=%d Y=%d\n",seq,group_data_num,group_redundant_num,max_len,sum_ori,sum,x_got,y_got); + if(fec_result_ok) { diff --git a/fec_manager.h b/fec_manager.h index 449da44..d59e7a4 100644 --- a/fec_manager.h +++ b/fec_manager.h @@ -20,7 +20,8 @@ extern u32_t fec_buff_num; const int rs_str_len=max_fec_packet_num*10+100; extern int header_overhead; -extern int debug_fec; +extern int debug_fec_enc; +extern int debug_fec_dec; struct fec_parameter_t { diff --git a/misc.cpp b/misc.cpp index 39fbe9d..b3e0779 100644 --- a/misc.cpp +++ b/misc.cpp @@ -653,7 +653,9 @@ void process_arg(int argc, char *argv[]) {"fec", required_argument, 0,'f'}, {"jitter", required_argument, 0,'j'}, {"header-overhead", required_argument, 0, 1}, - {"debug-fec", no_argument, 0, 1}, + //{"debug-fec", no_argument, 0, 1}, + {"debug-fec-enc", no_argument, 0, 1}, + {"debug-fec-dec", no_argument, 0, 1}, {"fifo", required_argument, 0, 1}, {"sub-net", required_argument, 0, 1}, {"tun-dev", required_argument, 0, 1}, @@ -949,10 +951,15 @@ void process_arg(int argc, char *argv[]) } g_fec_par.timeout*=1000; } - else if(strcmp(long_options[option_index].name,"debug-fec")==0) + else if(strcmp(long_options[option_index].name,"debug-fec-enc")==0) { - debug_fec=1; - mylog(log_info,"debug_fec enabled\n"); + debug_fec_enc=1; + mylog(log_info,"debug_fec_enc enabled\n"); + } + else if(strcmp(long_options[option_index].name,"debug-fec-dec")==0) + { + debug_fec_dec=1; + mylog(log_info,"debug_fec_dec enabled\n"); } else if(strcmp(long_options[option_index].name,"fifo")==0) {