Skip to content

Commit

Permalink
fix bug for --fix-latency
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu- committed Oct 18, 2017
1 parent fa8ac0a commit 4cba1d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion fec_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fec_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class fec_encode_manager_t
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;
}
Expand Down
11 changes: 7 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 <number> max fec queue len,only for mode 1\n");
printf(" -q,--queue-len <number> max fec queue len,only for mode 0\n");
printf(" --decode-buf <number> size of buffer of fec decoder,unit:packet,default:2000\n");
printf(" --fix-latency <number> try to stabilize latency,only for mode 1\n");
printf(" --fix-latency <number> try to stabilize latency,only for mode 0\n");
printf(" --delay-capacity <number> max number of delayed packets\n");
printf(" --disable-fec <number> completely disable fec,turn the program into a normal udp tunnel\n");
printf(" --sock-buf <number> buf size for socket,>=10 and <=10240,unit:kbyte,default:1024\n");
Expand Down

0 comments on commit 4cba1d3

Please sign in to comment.