Revision 5f0575fb

View differences:

loop.c
30 30
#define FDSSIZE 16
31 31
static struct timeval period = {0, 500000};
32 32
static struct timeval tnext;
33
int fixed_offer_threads = 0;
33 34

  
34 35
void tout_init(struct timeval *tv)
35 36
{
......
46 47
  }
47 48
}
48 49

  
49
void loop(struct nodeID *s, int csize, int buff_size)
50
void loop(struct nodeID *s, int polling_time, int buff_size, int offer_threads)
50 51
{
51 52
  int done = 0;
52 53
  static uint8_t buff[BUFFSIZE];
53 54
  int cnt = 0;
54 55
  
55
  period.tv_sec = csize / 1000000;
56
  period.tv_usec = csize % 1000000;
56
  period.tv_sec = polling_time / 1000000;
57
  period.tv_usec = polling_time % 1000000;
57 58
  
58 59
  peers_init();
59 60
  stream_init(buff_size, s);
60 61
  update_peers(NULL, NULL, 0);
62
  
63
  	fixed_offer_threads = offer_threads;
64
   
65
   // Start all offer threads once forever
66
   send_offer();
67
  
61 68
  while (!done) {
62 69
    int len, res;
63 70
    struct timeval tv;
......
176 183
        for (i = 0; i < chunks; i++) {	// @TODO: why this cycle?
177 184
          send_chunk();
178 185
        }
179
        send_offer();
180 186
        if (cnt++ % 10 == 0) {
181 187
            update_peers(NULL, NULL, 0);
182 188
        }
......
186 192
    }
187 193
  }
188 194
}
195

  
196
int get_fixed_offer_threads(void) {
197
	return fixed_offer_threads;
198
	}
loop.h
7 7
#ifndef LOOP_H
8 8
#define LOOP_H
9 9

  
10
void loop(struct nodeID *s, int period, int buff_size);
10
void loop(struct nodeID *s, int period, int buff_size,  int offer_threads);
11 11
void source_loop(const char *fname, struct nodeID *s, int csize, int chunks, int buff_size);
12
int get_fixed_offer_threads(void);
12 13

  
13 14
#endif	/* LOOP_H */
streamer.c
43 43

  
44 44
static const char *my_iface = NULL;
45 45
static int port = 6666;
46
static int srv_port;
46
static int srv_port = 0;
47 47
static const char *srv_ip = "";
48 48
static int period = 40;
49 49
static int chunks_per_second = 25;
......
53 53
static int outbuff_size = 50;
54 54
static const char *fname = "/dev/stdin";
55 55
static const char *output_config ="";
56
static bool loop_input = false;
56 57
static const char *net_helper_config = "";
57 58
static const char *topo_config = "";
58 59
unsigned char msgTypes[] = {MSG_TYPE_CHUNK,MSG_TYPE_SIGNALLING};
59 60
bool chunk_log = false;
61
static int number_offer_thread = 1;
60 62
static int randomize_start = 0;
61 63
int start_id = -1;
62 64
int end_id = -1;
......
94 96
    "\t[-b size]: set the peer Chunk Buffer size.\n"
95 97
    "\t           This is also the chunk trading window size.\n"
96 98
    "\t[-o size]: set the Output Buffer size.\n"
97
    "\t[-c chunks]: set the number of chunks a peer can send per seconds.\n"
98
    "\t             it controls the upload capacity of peer as well.\n"
99
    "\t[-c thread]: set the number of signalling threads a peer can send per seconds.\n"
99 100
    "\t[-M peers]: neighbourhood target size.\n"
100 101
    "\t[-t config]: topology config.\n"
101 102
    "\t[-P port]: local UDP port to be used by the peer.\n"
......
119 120
    "Special Source Peer options\n"
120 121
    "\t[-m chunks]: set the number of copies the source injects in the overlay.\n"
121 122
    "\t[-f filename]: name of the video stream file to transmit.\n"
123
    "\t[-l]: loop the video stream.\n"
122 124
    "\t[-S]: set initial chunk_id (source only).\n"
123 125
    "\t[-s]: set start_id from which to start output.\n"
124 126
    "\t[-e]: set end_id at which to end output.\n"
......
228 230
      case 'o':
229 231
        outbuff_size = atoi(optarg);
230 232
        break;
231
        case 'c':
232
        chunks_per_second = atoi(optarg);
233
      case 'c':
234
        number_offer_thread = atoi(optarg);
233 235
        break;
234 236
      case 'm':
235 237
        multiply = atoi(optarg);
......
252 254
      case 'F':
253 255
        output_config = strdup(optarg);
254 256
        break;
257
      case 'l':
258
        loop_input = true;
259
        break;
255 260
      case 'C':
256 261
        channel_set_name(optarg);
257 262
        break;
......
398 403

  
399 404
      return -1;
400 405
    }
406
    
401 407
    topoAddNeighbour(srv, NULL, 0);
402

  
403
    loop(my_sock, 1000000 / chunks_per_second, buff_size);
408
    loop(my_sock, period * 1000, buff_size, number_offer_thread);
404 409
  } else {
405 410
    source_loop(fname, my_sock, period * 1000, multiply, buff_size);
406 411
  }
......
417 422
  return buff_size;
418 423
}
419 424

  
420
int get_chunks_per_sec()
421
{
422
  return chunks_per_second;
423
}
424

  
425 425
//capacity in bits/s, or NAN if unknown
426 426
double get_capacity()
427 427
{

Also available in: Unified diff