Revision 03de31e0

View differences:

input-grapes.c
27 27
  uint64_t first_ts;
28 28
};
29 29

  
30
struct input_desc *input_open(const char *fname, uint16_t flags, int *fds, int fds_size)
30
struct input_desc *input_open(const char *fname, int *fds, int fds_size)
31 31
{
32 32
  struct input_desc *res;
33 33
  struct timeval tv;
34
  char cfg[256];
34
  char *c;
35 35

  
36
  memset(cfg, 0, 256);
37 36
  res = malloc(sizeof(struct input_desc));
38 37
  if (res == NULL) {
39 38
    return NULL;
40 39
  }
41
  if (flags & INPUT_UDP) {
42
    sprintf(cfg, "chunkiser=udp");
43
    sprintf(cfg + strlen(cfg), ",%s", fname);
44
  } else if (flags & INPUT_IPB) {
45
    sprintf(cfg, "chunkiser=ipb,media=v");
46
  } else {
47
    sprintf(cfg, "chunkiser=avf,media=av");
48
  }
49
  if (flags & INPUT_LOOP) {
50
    sprintf(cfg + strlen(cfg), ",loop=1");
40

  
41
  c = strchr(fname,',');
42
  if (c) {
43
    *(c++) = 0;
51 44
  }
52
  res->s = input_stream_open(fname, &res->interframe, cfg);
45
  res->s = input_stream_open(fname, &res->interframe, c);
53 46
  if (res->s == NULL) {
54 47
    free(res);
55 48
    res = NULL;
input-http.c
100 100
  return 0;
101 101
}
102 102

  
103
struct input_desc *input_open(const char *fname, uint16_t flags, int *fds, int fds_size)
103
struct input_desc *input_open(const char *fname, int *fds, int fds_size)
104 104
{
105 105
  struct input_desc *res;
106 106

  
input.h
14 14
struct input_desc;
15 15
struct chunk;
16 16

  
17
struct input_desc *input_open(const char *fname, uint16_t flags, int *fds, int fds_size);
17
struct input_desc *input_open(const char *fname, int *fds, int fds_size);
18 18
void input_close(struct input_desc *s);
19 19

  
20 20
/*
loop-mt.c
197 197
  pthread_join(distributing_thread, NULL);
198 198
}
199 199

  
200
void source_loop(const char *fname, struct nodeID *s1, int csize, int chunks, bool loop, int buff_size)
200
void source_loop(const char *fname, struct nodeID *s1, int csize, int chunks, int buff_size)
201 201
{
202 202
  pthread_t generate_thread, receive_thread, gossiping_thread, distributing_thread;
203 203
  
......
210 210

  
211 211
//  sigInit(s);
212 212
  peers_init();
213
  if (source_init(fname, s, loop, fds, FDSSIZE, buff_size) < 0) {
213
  if (source_init(fname, s, fds, FDSSIZE, buff_size) < 0) {
214 214
    fprintf(stderr,"Cannot initialize source, exiting");
215 215
    return;
216 216
  }
loop.c
109 109
  }
110 110
}
111 111

  
112
void source_loop(const char *fname, struct nodeID *s, int csize, int chunks, bool loop, int buff_size)
112
void source_loop(const char *fname, struct nodeID *s, int csize, int chunks, int buff_size)
113 113
{
114 114
  int done = 0;
115 115
  static uint8_t buff[BUFFSIZE];
......
122 122
  
123 123
  peers_init();
124 124

  
125
  if (source_init(fname, s, loop, fds, FDSSIZE, buff_size) < 0) {
125
  if (source_init(fname, s, fds, FDSSIZE, buff_size) < 0) {
126 126
    fprintf(stderr,"Cannot initialize source, exiting");
127 127
    return;
128 128
  }
loop.h
8 8
#define LOOP_H
9 9

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

  
13 13
#endif	/* LOOP_H */
output-grapes.c
35 35

  
36 36
void output_init(int bufsize, const char *config)
37 37
{
38
  char cfg[256];
39

  
40
  if (config && (strlen(config) > 4) && (memcmp(config, "udp:", 4) == 0)) {
41
    config += 4;
42
    sprintf(cfg, "dechunkiser=udp");
43
    sprintf(cfg + strlen(cfg), ",%s", config);
44
  } else if (config && (strlen(config) >= 6) && (memcmp(config, "dummy:", 6) == 0)) {
45
    config += 6;
46
    sprintf(cfg, "dechunkiser=dummy,type=stats");
47
    sprintf(cfg + strlen(cfg), ",%s", config);
48
  } else {
49
    sprintf(cfg, "dechunkiser=avf,media=v");
38
  char *c;
39

  
40
  c = strchr(config,',');
41
  if (c) {
42
    *(c++) = 0;
50 43
  }
51
  out = out_stream_init(config, cfg);
44
  out = out_stream_init(config, c);
52 45
  if (out == NULL) {
53 46
     fprintf(stderr, "Error: can't initialize output module\n");
54 47
     exit(1);
streamer.c
53 53
static int buff_size = 50;
54 54
static int outbuff_size = 50;
55 55
static const char *fname = "/dev/stdin";
56
static const char *output_config;
57
static bool loop_input = false;
56
static const char *output_config ="";
58 57
static const char *net_helper_config = "";
59 58
static const char *topo_config = "";
60 59
unsigned char msgTypes[] = {MSG_TYPE_CHUNK,MSG_TYPE_SIGNALLING};
......
121 120
    "Special Source Peer options\n"
122 121
    "\t[-m chunks]: set the number of copies the source injects in the overlay.\n"
123 122
    "\t[-f filename]: name of the video stream file to transmit.\n"
124
    "\t[-l]: loop the video stream.\n"
125 123
    "\t[-S]: set initial chunk_id (source only).\n"
126 124
    "\t[-s]: set start_id from which to start output.\n"
127 125
    "\t[-e]: set end_id at which to end output.\n"
......
254 252
      case 'F':
255 253
        output_config = strdup(optarg);
256 254
        break;
257
      case 'l':
258
        loop_input = true;
259
        break;
260 255
      case 'C':
261 256
        channel_set_name(optarg);
262 257
        break;
......
403 398

  
404 399
    loop(my_sock, 1000000 / chunks_per_second, buff_size);
405 400
  } else {
406
    source_loop(fname, my_sock, period * 1000, multiply, loop_input, buff_size);
401
    source_loop(fname, my_sock, period * 1000, multiply, buff_size);
407 402
  }
408 403
  return 0;
409 404
}
streaming.c
111 111
  init_measures();
112 112
}
113 113

  
114
int source_init(const char *fname, struct nodeID *myID, bool loop, int *fds, int fds_size, int buff_size)
114
int source_init(const char *fname, struct nodeID *myID, int *fds, int fds_size, int buff_size)
115 115
{
116
  int flags = 0;
117

  
118
  if (memcmp(fname, "udp:", 4) == 0) {
119
    fname += 4;
120
    flags = INPUT_UDP;
121
  }
122
  if (memcmp(fname, "ipb:", 4) == 0) {
123
    fname += 4;
124
    flags = INPUT_IPB;
125
  }
126
  if (loop) {
127
    flags |= INPUT_LOOP;
128
  }
129

  
130
  input = input_open(fname, flags, fds, fds_size);
116
  input = input_open(fname, fds, fds_size);
131 117
  if (input == NULL) {
132 118
    return -1;
133 119
  }
streaming.h
10 10
#include <stdbool.h>
11 11

  
12 12
void stream_init(int size, struct nodeID *myID);
13
int source_init(const char *fname, struct nodeID *myID, bool loop, int *fds, int fds_size, int buff_size);
13
int source_init(const char *fname, struct nodeID *myID, int *fds, int fds_size, int buff_size);
14 14
void received_chunk(struct nodeID *from, const uint8_t *buff, int len);
15 15
void send_chunk();
16 16
struct chunk *generated_chunk(suseconds_t *delta);

Also available in: Unified diff