Revision a2fa286f

View differences:

input-grapes.c
17 17
#include "input.h"
18 18
#include "dbg.h"
19 19

  
20
extern int initial_id;
21

  
20 22
struct input_desc {
21 23
  struct input_stream *s;
22 24
  int id;
......
71 73
    res->start_time = tv.tv_usec + tv.tv_sec * 1000000ULL;
72 74
    res->first_ts = 0;
73 75
    res->id = 0; //(res->start_time / res->interframe) % INT_MAX; //TODO: verify 32/64 bit
76

  
77
    if(initial_id == -1) {
78
      res->id = (res->start_time / res->interframe) % INT_MAX; //TODO: verify 32/64 bit
79
    } else {
80
      res->id = initial_id;
81
    }
82

  
83
    fprintf(stderr,"Initial Chunk Id %d\n", res->id);
74 84
  }
75 85

  
76 86
  return res;
output-grapes.c
17 17
#include "measures.h"
18 18
#include "dbg.h"
19 19

  
20
static int last_chunk = -1;
20 21
static int next_chunk = -1;
21 22
static int buff_size;
22 23
extern bool chunk_log;
24
extern int start_id;
25
extern int end_id;
26

  
27
static char sflag = 0;
28
static char eflag = 0;
23 29

  
24 30
struct outbuf {
25 31
  struct chunk c;
......
89 95
static void buffer_free(int i)
90 96
{
91 97
  dprintf("\t\tFlush Buf %d: %s\n", i, buff[i].c.data);
92
  chunk_write(out, &buff[i].c);
98
  if(start_id == -1 || buff[i].c.id >= start_id) {
99
    if(end_id == -1 || buff[i].c.id <= end_id) {
100
      if(sflag == 0) {
101
        fprintf(stderr, "\nFirst chunk id played out: %d\n\n",buff[i].c.id);
102
        sflag = 1;
103
      }
104
      chunk_write(out, &buff[i].c);
105
      last_chunk = buff[i].c.id;
106
    } else if (eflag == 0 && last_chunk != -1) {
107
      fprintf(stderr, "\nLast chunk id played out: %d\n\n", last_chunk);
108
      eflag = 1;
109
    }
110
  }
111

  
93 112
  free(buff[i].c.data);
94 113
  buff[i].c.data = NULL;
95 114
  dprintf("Next Chunk: %d -> %d\n", next_chunk, buff[i].c.id + 1);
......
126 145
  /* Initialize buffer with first chunk */
127 146
  if (next_chunk == -1) {
128 147
    next_chunk = c->id; // FIXME: could be anything between c->id and (c->id - buff_size + 1 > 0) ? c->id - buff_size + 1 : 0
148
    fprintf(stderr,"First RX Chunk ID: %d\n", c->id);
129 149
  }
130 150

  
131 151
  if (c->id >= next_chunk + buff_size) {
......
149 169
  dprintf("%d == %d?\n", c->id, next_chunk);
150 170
  if (c->id == next_chunk) {
151 171
    dprintf("\tOut Chunk[%d] - %d: %s\n", c->id, c->id % buff_size, c->data);
152
    chunk_write(out, c);
172

  
173
    if(start_id == -1 || c->id >= start_id) {
174
      if(end_id == -1 || c->id <= end_id) {
175
        if(sflag == 0) {
176
          fprintf(stderr, "\nFirst chunk id played out: %d\n\n",c->id);
177
          sflag = 1;
178
        }
179
        chunk_write(out, c);
180
        last_chunk = c->id;
181
      } else if (eflag == 0 && last_chunk != -1) {
182
        fprintf(stderr, "\nLast chunk id played out: %d\n\n", last_chunk);
183
        eflag = 1;
184
      }
185
    }
153 186
    reg_chunk_playout(c->id, true, c->timestamp);
154 187
    next_chunk++;
155 188
    buffer_flush(next_chunk);
streamer.c
53 53
unsigned char msgTypes[] = {MSG_TYPE_CHUNK,MSG_TYPE_SIGNALLING};
54 54
bool chunk_log = false;
55 55
static int randomize_start = 0;
56
int start_id = -1;
57
int end_id = -1;
58
int initial_id = -1;
56 59

  
57 60
extern int NEIGHBORHOOD_TARGET_SIZE;
58 61
extern uint64_t CB_SIZE_TIME;
......
99 102
    "\t[-m chunks]: set the number of copies the source injects in the overlay.\n"
100 103
    "\t[-f filename]: name of the video stream file to transmit.\n"
101 104
    "\t[-l]: loop the video stream.\n"
105
    "\t[-S]: set initial chunk_id (source only).\n"
106
    "\t[-s]: set start_id from which to start output.\n"
107
    "\t[-e]: set end_id at which to end output.\n"
102 108
    "\n"
103 109
    "Special options\n"
104 110
    "\t[--randomize_start ms]: random wait before starting in to ms millisecs.\n"
......
136 142
	{0, 0, 0, 0}
137 143
  };
138 144

  
139
    while ((o = getopt_long (argc, argv, "r:a:b:o:c:p:i:P:I:f:F:m:lC:N:n:M:t:",long_options, &option_index)) != -1) { //use this function to manage long options
145
    while ((o = getopt_long (argc, argv, "r:a:b:o:c:p:i:P:I:f:F:m:lC:N:n:M:t:s:e:S:",long_options, &option_index)) != -1) { //use this function to manage long options
140 146
    switch(o) {
141 147
      case 0: //for long options
142 148
        if( strcmp( "chunk_log", long_options[option_index].name ) == 0 ) { chunk_log = true; }
......
201 207
      case 't':
202 208
        topo_config = strdup(optarg);
203 209
        break;
210
      case 'S':
211
        initial_id = atoi(optarg);
212
        break;
213
      case 's':
214
        start_id = atoi(optarg);
215
        break;
216
      case 'e':
217
        end_id = atoi(optarg);
218
        break;
204 219
      default:
205 220
        fprintf(stderr, "Error: unknown option %c\n", o);
206 221
        print_usage(argc, argv);

Also available in: Unified diff