Commit 656c9ed2 authored by Simon Morlat's avatar Simon Morlat

integrate with ortp's simulator new features.

parent 9d7cee2d
...@@ -205,10 +205,13 @@ const char *usage="mediastream --local <port> --remote <ip:port> \n" ...@@ -205,10 +205,13 @@ const char *usage="mediastream --local <port> --remote <ip:port> \n"
"[ --verbose (most verbose messages) ]\n" "[ --verbose (most verbose messages) ]\n"
"[ --video-windows-id <video surface:preview surface>]\n" "[ --video-windows-id <video surface:preview surface>]\n"
"[ --video-display-filter <name> ]\n" "[ --video-display-filter <name> ]\n"
"[ --srtp <local master_key> <remote master_key> (enable srtp, master key is generated if absent from comand line)\n" "[ --srtp <local master_key> <remote master_key> (enable srtp, master key is generated if absent from comand line)]\n"
"[ --netsim-bandwidth <bandwidth limit in bits/s> (simulates a network download bandwidth limit)\n" "[ --netsim-bandwidth <bandwidth limit in bits/s> (simulates a network download bandwidth limit)]\n"
"[ --netsim-lossrate <0-100> (simulates a network lost rate)\n" "[ --netsim-lossrate <0-100> (simulates a network lost rate)]\n"
"[ --netsim-latency <latency in ms> (simulates a network latency)\n" "[ --netsim-consecutive-loss-probability <0-1> (to simulate bursts of lost packets)]\n"
"[ --netsim-latency <latency in ms> (simulates a network latency)]\n"
"[ --netsim-jitter-strength <0-100> (strength of the jitter simulation)]\n"
"[ --netsim-jitter-burst-density <0-10> (density of gap/burst events, 1.0=one gap/burst per second in average)]\n"
"[ --zoom zoomfactor]\n" "[ --zoom zoomfactor]\n"
"[ --ice-local-candidate <ip:port:[host|srflx|prflx|relay]> ]\n" "[ --ice-local-candidate <ip:port:[host|srflx|prflx|relay]> ]\n"
"[ --ice-remote-candidate <ip:port:[host|srflx|prflx|relay]> ]\n" "[ --ice-remote-candidate <ip:port:[host|srflx|prflx|relay]> ]\n"
...@@ -496,25 +499,76 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) { ...@@ -496,25 +499,76 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
} }
} else if (strcmp(argv[i],"--netsim-bandwidth")==0){ } else if (strcmp(argv[i],"--netsim-bandwidth")==0){
i++; i++;
out->netsim.max_bandwidth=atoi(argv[i]); if (i<argc){
out->netsim.enabled=TRUE; out->netsim.max_bandwidth=atoi(argv[i]);
} else if (strcmp(argv[i],"--netsim-lossrate")==0){ out->netsim.enabled=TRUE;
}else{
ms_error("Missing argument for --netsim-bandwidth");
return FALSE;
}
}else if (strcmp(argv[i],"--netsim-lossrate")==0){
i++;
if (i<argc){
out->netsim.loss_rate=atoi(argv[i]);
if (out->netsim.loss_rate < 0 || out->netsim.loss_rate>100) {
ms_error("Loss rate must be between 0 and 100.");
return FALSE;
}
out->netsim.enabled=TRUE;
}else{
ms_error("Missing argument for --netsim-lossrate");
return FALSE;
}
}else if (strcmp(argv[i],"--netsim-consecutive-loss-probability")==0){
i++;
if (i<argc){
sscanf(argv[i],"%f",&out->netsim.consecutive_loss_probability);
if (out->netsim.consecutive_loss_probability < 0 || out->netsim.consecutive_loss_probability>1) {
ms_error("The consecutive loss probability must be between 0 and 1.");
return FALSE;
}
out->netsim.enabled=TRUE;
}else{
ms_error("Missing argument for --netsim-consecutive-loss-probability");
return FALSE;
}
}else if (strcmp(argv[i], "--netsim-latency") == 0) {
i++; i++;
out->netsim.loss_rate=atoi(argv[i]); if (i<argc){
if(out->netsim.loss_rate < 0) { out->netsim.latency = atoi(argv[i]);
ms_warning("%g < 0, wrong value for --lost-rate: set to 0", out->netsim.loss_rate); out->netsim.enabled=TRUE;
out->netsim.loss_rate=0; }else{
ms_error("Missing argument for --netsim-latency");
return FALSE;
} }
if(out->netsim.loss_rate > 100) { }else if (strcmp(argv[i], "--netsim-jitter-burst-density") == 0) {
ms_warning("%g > 100, wrong value for --lost-rate: set to 100", out->netsim.loss_rate); i++;
out->netsim.loss_rate=100; if (i<argc){
sscanf(argv[i],"%f",&out->netsim.jitter_burst_density);
if (out->netsim.jitter_burst_density<0 || out->netsim.jitter_burst_density>10){
ms_error("The jitter burst density must be between 0 and 10");
return FALSE;
}
out->netsim.enabled=TRUE;
}else{
ms_error("Missing argument for --netsim-jitter-burst-density");
return FALSE;
} }
out->netsim.enabled=TRUE; }else if (strcmp(argv[i], "--netsim-jitter-strength") == 0) {
} else if (strcmp(argv[i], "--netsim-latency") == 0) {
i++; i++;
out->netsim.latency = atoi(argv[i]); if (i<argc){
out->netsim.enabled=TRUE; sscanf(argv[i],"%f",&out->netsim.jitter_strength);
} else if (strcmp(argv[i],"--zoom")==0){ if (out->netsim.jitter_strength<0 || out->netsim.jitter_strength>100){
ms_error("The jitter strength must be between 0 and 100.");
return FALSE;
}
out->netsim.enabled=TRUE;
}else{
ms_error("Missing argument for --netsim-jitter-strength");
return FALSE;
}
}else if (strcmp(argv[i],"--zoom")==0){
i++; i++;
if (sscanf(argv[i], "%f,%f,%f", &out->zoom, &out->zoom_cx, &out->zoom_cy) != 3) { if (sscanf(argv[i], "%f,%f,%f", &out->zoom, &out->zoom_cx, &out->zoom_cy) != 3) {
ms_error("Invalid zoom triplet"); ms_error("Invalid zoom triplet");
...@@ -549,6 +603,10 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) { ...@@ -549,6 +603,10 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
return FALSE; return FALSE;
} }
} }
if (out->netsim.jitter_burst_density>0 && out->netsim.max_bandwidth==0){
ms_error("Jitter probability settings requires --netsim-bandwidth to be set.");
return FALSE;
}
return TRUE; return TRUE;
} }
...@@ -649,7 +707,7 @@ void setup_media_streams(MediastreamDatas* args) { ...@@ -649,7 +707,7 @@ void setup_media_streams(MediastreamDatas* args) {
if (args->bitrate>0) args->pt->normal_bitrate=args->bitrate; if (args->bitrate>0) args->pt->normal_bitrate=args->bitrate;
if (args->pt->normal_bitrate==0){ if (args->pt->normal_bitrate==0){
printf("Error: no default bitrate specified for codec %s/%i. " fprintf(stderr,"Error: no default bitrate specified for codec %s/%i. "
"Please specify a network bitrate with --bitrate option.\n",args->pt->mime_type,args->pt->clock_rate); "Please specify a network bitrate with --bitrate option.\n",args->pt->mime_type,args->pt->clock_rate);
exit(-1); exit(-1);
} }
...@@ -829,7 +887,6 @@ void setup_media_streams(MediastreamDatas* args) { ...@@ -829,7 +887,6 @@ void setup_media_streams(MediastreamDatas* args) {
if (args->netsim.enabled){ if (args->netsim.enabled){
rtp_session_enable_network_simulation(args->session,&args->netsim); rtp_session_enable_network_simulation(args->session,&args->netsim);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment