From 4cba1d36ded83e927f92a8836ba83f9adf0e2e6b Mon Sep 17 00:00:00 2001 From: wangyu- Date: Wed, 18 Oct 2017 10:09:50 -0500 Subject: [PATCH] fix bug for --fix-latency --- fec_manager.cpp | 4 +++- fec_manager.h | 2 +- main.cpp | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fec_manager.cpp b/fec_manager.cpp index adadfc5..99a6b91 100644 --- a/fec_manager.cpp +++ b/fec_manager.cpp @@ -373,6 +373,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) assert(ready_for_output==0); ready_for_output=1; first_packet_time_for_output=first_packet_time; + first_packet_time=0; seq++; counter=0; output_n=actual_data_num+actual_redundant_num; @@ -413,9 +414,10 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/) int input_buf_idx=counter-1; assert(ready_for_output==0); ready_for_output=1; - //first_packet_time_for_output=0; + first_packet_time_for_output=0; output_n=1; + int tmp_idx=0; write_u32(input_buf[input_buf_idx]+tmp_idx,seq); tmp_idx+=sizeof(u32_t); diff --git a/fec_manager.h b/fec_manager.h index f099223..801801f 100644 --- a/fec_manager.h +++ b/fec_manager.h @@ -129,7 +129,7 @@ public: fec_encode_manager_t(); ~fec_encode_manager_t(); - int get_first_packet_time() + my_time_t get_first_packet_time() { return first_packet_time_for_output; } diff --git a/main.cpp b/main.cpp index 3a99638..c21e1d3 100644 --- a/main.cpp +++ b/main.cpp @@ -190,18 +190,21 @@ int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,ch my_time_t common_latency=0; my_time_t first_packet_time=conn_info.fec_encode_manager.get_first_packet_time(); - if(fix_latency==1&&conn_info.fec_encode_manager.get_type()==0&&first_packet_time!=0) + if(fix_latency==1&&conn_info.fec_encode_manager.get_type()==0) { my_time_t current_time=get_current_time_us(); my_time_t tmp; + assert(first_packet_time!=0); + //mylog(log_info,"current_time=%llu first_packlet_time=%llu fec_pending_time=%llu\n",current_time,first_packet_time,(my_time_t)fec_pending_time); if((my_time_t)fec_pending_time >=(current_time - first_packet_time)) { tmp=(my_time_t)fec_pending_time-(current_time - first_packet_time); - mylog(log_info,"delay=%llu\n",tmp); + //mylog(log_info,"tmp=%llu\n",tmp); } else { tmp=0; + //mylog(log_info,"0\n"); } common_latency+=tmp; } @@ -1186,9 +1189,9 @@ void print_help() printf("developer options:\n"); printf(" -j ,--jitter jmin:jmax similiar to -j above,but create jitter randomly between jmin and jmax\n"); printf(" -i,--interval imin:imax similiar to -i above,but scatter randomly between imin and imax\n"); - printf(" -q,--queue-len max fec queue len,only for mode 1\n"); + printf(" -q,--queue-len max fec queue len,only for mode 0\n"); printf(" --decode-buf size of buffer of fec decoder,unit:packet,default:2000\n"); - printf(" --fix-latency try to stabilize latency,only for mode 1\n"); + printf(" --fix-latency try to stabilize latency,only for mode 0\n"); printf(" --delay-capacity max number of delayed packets\n"); printf(" --disable-fec completely disable fec,turn the program into a normal udp tunnel\n"); printf(" --sock-buf buf size for socket,>=10 and <=10240,unit:kbyte,default:1024\n");