mirror of
https://github.com/wangyu-/UDPspeeder.git
synced 2025-01-19 06:19:34 +08:00
fix bug for --fix-latency
This commit is contained in:
parent
fa8ac0ac3b
commit
4cba1d36de
@ -373,6 +373,7 @@ int fec_encode_manager_t::input(char *s,int len/*,int &is_first_packet*/)
|
|||||||
assert(ready_for_output==0);
|
assert(ready_for_output==0);
|
||||||
ready_for_output=1;
|
ready_for_output=1;
|
||||||
first_packet_time_for_output=first_packet_time;
|
first_packet_time_for_output=first_packet_time;
|
||||||
|
first_packet_time=0;
|
||||||
seq++;
|
seq++;
|
||||||
counter=0;
|
counter=0;
|
||||||
output_n=actual_data_num+actual_redundant_num;
|
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;
|
int input_buf_idx=counter-1;
|
||||||
assert(ready_for_output==0);
|
assert(ready_for_output==0);
|
||||||
ready_for_output=1;
|
ready_for_output=1;
|
||||||
//first_packet_time_for_output=0;
|
first_packet_time_for_output=0;
|
||||||
output_n=1;
|
output_n=1;
|
||||||
|
|
||||||
|
|
||||||
int tmp_idx=0;
|
int tmp_idx=0;
|
||||||
write_u32(input_buf[input_buf_idx]+tmp_idx,seq);
|
write_u32(input_buf[input_buf_idx]+tmp_idx,seq);
|
||||||
tmp_idx+=sizeof(u32_t);
|
tmp_idx+=sizeof(u32_t);
|
||||||
|
@ -129,7 +129,7 @@ public:
|
|||||||
fec_encode_manager_t();
|
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;
|
return first_packet_time_for_output;
|
||||||
}
|
}
|
||||||
|
11
main.cpp
11
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 common_latency=0;
|
||||||
my_time_t first_packet_time=conn_info.fec_encode_manager.get_first_packet_time();
|
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 current_time=get_current_time_us();
|
||||||
my_time_t tmp;
|
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))
|
if((my_time_t)fec_pending_time >=(current_time - first_packet_time))
|
||||||
{
|
{
|
||||||
tmp=(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
|
else
|
||||||
{
|
{
|
||||||
tmp=0;
|
tmp=0;
|
||||||
|
//mylog(log_info,"0\n");
|
||||||
}
|
}
|
||||||
common_latency+=tmp;
|
common_latency+=tmp;
|
||||||
}
|
}
|
||||||
@ -1186,9 +1189,9 @@ void print_help()
|
|||||||
printf("developer options:\n");
|
printf("developer options:\n");
|
||||||
printf(" -j ,--jitter jmin:jmax similiar to -j above,but create jitter randomly between jmin and jmax\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(" -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(" --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(" --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(" --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");
|
printf(" --sock-buf <number> buf size for socket,>=10 and <=10240,unit:kbyte,default:1024\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user