1
0
wangyu- 8 жил өмнө
parent
commit
a5c26c5814
3 өөрчлөгдсөн 35 нэмэгдсэн , 10 устгасан
  1. 2 5
      fec_manager.cpp
  2. 19 5
      fec_manager.h
  3. 14 0
      main.cpp

+ 2 - 5
fec_manager.cpp

@@ -17,6 +17,8 @@ const int decode_fast_send=1;
 int short_packet_optimize=1;
 int short_packet_optimize=1;
 int header_overhead=40;
 int header_overhead=40;
 
 
+u32_t fec_buff_num=2000;// how many packet can fec_decode_manager hold. shouldnt be very large,or it will cost huge memory
+
 blob_encode_t::blob_encode_t()
 blob_encode_t::blob_encode_t()
 {
 {
 	clear();
 	clear();
@@ -465,11 +467,6 @@ int fec_encode_manager_t::output(int &n,char ** &s_arr,int *&len)
 	return 0;
 	return 0;
 }
 }
 
 
-fec_decode_manager_t::fec_decode_manager_t()
-{
-	re_init();
-}
-
 int fec_decode_manager_t::re_init()
 int fec_decode_manager_t::re_init()
 {
 {
 	for(int i=0;i<(int)fec_buff_num;i++)
 	for(int i=0;i<(int)fec_buff_num;i++)

+ 19 - 5
fec_manager.h

@@ -12,11 +12,11 @@
 #include "log.h"
 #include "log.h"
 #include "lib/rs.h"
 #include "lib/rs.h"
 
 
-const int max_blob_packet_num=20000;//how many packet can be contain in a blob_t ,can be set very large
-const u32_t anti_replay_buff_size=20000;//can be set very large
+const int max_blob_packet_num=30000;//how many packet can be contain in a blob_t ,can be set very large
+const u32_t anti_replay_buff_size=30000;//can be set very large
 
 
 const int max_fec_packet_num=255;// this is the limitation of the rs lib
 const int max_fec_packet_num=255;// this is the limitation of the rs lib
-const u32_t fec_buff_num=2000;// how many packet can fec_decode_manager hold. shouldnt be very large,or it will cost huge memory
+extern u32_t fec_buff_num;
 
 
 
 
 struct anti_replay_t
 struct anti_replay_t
@@ -162,20 +162,34 @@ struct fec_group_t
 class fec_decode_manager_t
 class fec_decode_manager_t
 {
 {
 	anti_replay_t anti_replay;
 	anti_replay_t anti_replay;
-	fec_data_t fec_data[fec_buff_num+10];
+	fec_data_t *fec_data;
 	int index;
 	int index;
 	unordered_map<u32_t, fec_group_t> mp;
 	unordered_map<u32_t, fec_group_t> mp;
 	blob_decode_t blob_decode;
 	blob_decode_t blob_decode;
 
 
 
 
+
 	int output_n;
 	int output_n;
 	char ** output_s_arr;
 	char ** output_s_arr;
 	int * output_len_arr;
 	int * output_len_arr;
 	char *output_s_arr_buf[max_fec_packet_num+100];
 	char *output_s_arr_buf[max_fec_packet_num+100];
 	int output_len_arr_buf[max_fec_packet_num+100];
 	int output_len_arr_buf[max_fec_packet_num+100];
 	int ready_for_output;
 	int ready_for_output;
+
 public:
 public:
-	fec_decode_manager_t();
+	fec_decode_manager_t()
+	{
+		fec_data=new fec_data_t[fec_buff_num+5];
+		re_init();
+	}
+	fec_decode_manager_t(const fec_decode_manager_t &b)
+	{
+		assert(0==1);//not allowed to copy
+	}
+	~fec_decode_manager_t()
+	{
+		delete fec_data;
+	}
 	int re_init();
 	int re_init();
 	int input(char *s,int len);
 	int input(char *s,int len);
 	int output(int &n,char ** &s_arr,int* &len_arr);
 	int output(int &n,char ** &s_arr,int* &len_arr);

+ 14 - 0
main.cpp

@@ -1183,6 +1183,7 @@ void print_help()
 	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 1\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 1\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");
@@ -1218,9 +1219,11 @@ void process_arg(int argc, char *argv[])
 		{"mtu", required_argument,    0, 1},
 		{"mtu", required_argument,    0, 1},
 		{"mode", required_argument,   0,1},
 		{"mode", required_argument,   0,1},
 		{"timeout", required_argument,   0,1},
 		{"timeout", required_argument,   0,1},
+		{"--decode-buf", required_argument,   0,1},
 		{"queue-len", required_argument,   0,'q'},
 		{"queue-len", required_argument,   0,'q'},
 		{"fec", required_argument,   0,'f'},
 		{"fec", required_argument,   0,'f'},
 		{"jitter", required_argument,   0,'j'},
 		{"jitter", required_argument,   0,'j'},
+
 		{NULL, 0, 0, 0}
 		{NULL, 0, 0, 0}
       };
       };
     int option_index = 0;
     int option_index = 0;
@@ -1456,6 +1459,7 @@ void process_arg(int argc, char *argv[])
 					mylog(log_fatal,"random_drop must be between 0 10000 \n");
 					mylog(log_fatal,"random_drop must be between 0 10000 \n");
 					myexit(-1);
 					myexit(-1);
 				}
 				}
+				mylog(log_info,"random_drop=%d\n",random_drop);
 			}
 			}
 			else if(strcmp(long_options[option_index].name,"delay-capacity")==0)
 			else if(strcmp(long_options[option_index].name,"delay-capacity")==0)
 			{
 			{
@@ -1491,6 +1495,16 @@ void process_arg(int argc, char *argv[])
 					myexit(-1);
 					myexit(-1);
 				}
 				}
 			}
 			}
+			else if(strcmp(long_options[option_index].name,"decode-buf")==0)
+			{
+				sscanf(optarg,"%d",&fec_buff_num);
+				if(fec_buff_num<100 || fec_buff_num>20000)
+				{
+					mylog(log_fatal,"decode-buf value must be between 100 and 20000 (kbyte) \n");
+					myexit(-1);
+				}
+				mylog(log_info,"decode-buf=%d\n",fec_buff_num);
+			}
 			else if(strcmp(long_options[option_index].name,"mode")==0)
 			else if(strcmp(long_options[option_index].name,"mode")==0)
 			{
 			{
 				sscanf(optarg,"%d",&fec_type);
 				sscanf(optarg,"%d",&fec_type);