Revision 4536b69e
streamer.c | ||
---|---|---|
49 | 49 |
static const char *topo_config = ""; |
50 | 50 |
unsigned char msgTypes[] = {MSG_TYPE_CHUNK,MSG_TYPE_SIGNALLING}; |
51 | 51 |
bool chunk_log = false; |
52 |
static int randomize_start = 0; |
|
52 | 53 |
|
53 | 54 |
extern int NEIGHBORHOOD_TARGET_SIZE; |
54 | 55 |
|
... | ... | |
89 | 90 |
"\t[-f filename]: name of the video stream file to transmit.\n" |
90 | 91 |
"\t[-l]: loop the video stream.\n" |
91 | 92 |
"\n" |
93 |
"Special options\n" |
|
94 |
"\t[--randomize_start ms]: random wait before starting in to ms millisecs.\n" |
|
95 |
"\n" |
|
92 | 96 |
"NOTE: by deafult the peer will dump the received video on STDOUT in raw format\n" |
93 | 97 |
" it can be played by your favourite player simply using a pipe\n" |
94 | 98 |
" e.g., | cvlc /dev/stdin\n" |
... | ... | |
117 | 121 |
{"chunk_log", no_argument, 0, 0}, |
118 | 122 |
{"measure_start", required_argument, 0, 0}, |
119 | 123 |
{"measure_every", required_argument, 0, 0}, |
124 |
{"randomize_start", required_argument, 0, 0}, |
|
120 | 125 |
{0, 0, 0, 0} |
121 | 126 |
}; |
122 | 127 |
|
... | ... | |
126 | 131 |
if( strcmp( "chunk_log", long_options[option_index].name ) == 0 ) { chunk_log = true; } |
127 | 132 |
if( strcmp( "measure_start", long_options[option_index].name ) == 0 ) { tstartdiff.tv_sec = atoi(optarg); } |
128 | 133 |
if( strcmp( "measure_every", long_options[option_index].name ) == 0 ) { print_tdiff.tv_sec = atoi(optarg); } |
134 |
if( strcmp( "randomize_start", long_options[option_index].name ) == 0 ) { randomize_start = atoi(optarg); } |
|
129 | 135 |
break; |
130 | 136 |
case 'b': |
131 | 137 |
buff_size = atoi(optarg); |
... | ... | |
250 | 256 |
exit(sig); |
251 | 257 |
} |
252 | 258 |
|
259 |
static void random_wait(int max) { |
|
260 |
struct timespec t; |
|
261 |
uint64_t ms; |
|
262 |
|
|
263 |
ms = (rand()/(RAND_MAX + 1.0)) * max; |
|
264 |
t.tv_sec = ms / 1000000; |
|
265 |
t.tv_nsec = (ms % 1000000) * 1000; |
|
266 |
nanosleep(&t, NULL); |
|
267 |
} |
|
268 |
|
|
253 | 269 |
int main(int argc, char *argv[]) |
254 | 270 |
{ |
255 | 271 |
struct nodeID *my_sock; |
... | ... | |
266 | 282 |
struct nodeID *srv; |
267 | 283 |
|
268 | 284 |
//random wait a bit before starting |
269 |
struct timespec t; |
|
270 |
t.tv_sec = 0; |
|
271 |
t.tv_nsec = (rand()/(RAND_MAX + 1.0)) * 2e8; |
|
272 |
nanosleep(&t, NULL); |
|
285 |
if (randomize_start) random_wait(randomize_start); |
|
273 | 286 |
|
274 | 287 |
output_init(outbuff_size, output_config); |
275 | 288 |
|
Also available in: Unified diff