Revision f14985ba

View differences:

input-grapes.c
35 35
  if (res == NULL) {
36 36
    return NULL;
37 37
  }
38
  sprintf(cfg, "media=av");
38
  if (flags & INPUT_UDP) {
39
    sprintf(cfg, "chunkiser=udp");
40
    sprintf(cfg + strlen(cfg), ",%s", fname);
41
  } else {
42
    sprintf(cfg, "chunkiser=avf,media=av");
43
  }
39 44
  if (flags & INPUT_LOOP) {
40 45
    sprintf(cfg + strlen(cfg), ",loop=1");
41 46
  }
......
92 97
  if (s->first_ts == 0) {
93 98
    s->first_ts = c->timestamp;
94 99
  }
95
  delta = c->timestamp - s->first_ts + s->interframe;
96 100
  gettimeofday(&now, NULL);
97
  delta = delta + s->start_time - now.tv_sec * 1000000ULL - now.tv_usec;
98
  dprintf("Delta: %lld\n", delta);
99
  dprintf("Generate Chunk[%d] (TS: %llu)\n", c->id, c->timestamp);
100

  
101
  if (s->interframe) {
102
    delta = c->timestamp - s->first_ts + s->interframe;
103
    delta = delta + s->start_time - now.tv_sec * 1000000ULL - now.tv_usec;
104
    dprintf("Delta: %lld\n", delta);
105
    dprintf("Generate Chunk[%d] (TS: %llu)\n", c->id, c->timestamp);
106
    if (delta < 0) {
107
      delta = 0;
108
    }
109
  } else {
110
    delta = 999999;		/* FIXME */
111
  }
101 112
  c->timestamp = now.tv_sec * 1000000ULL + now.tv_usec;
102 113

  
103
  return delta > 0 ? delta : 0;
114
  return delta;
104 115
}
input.h
8 8
#define INPUT_H
9 9

  
10 10
#define INPUT_LOOP 0x0001
11
#define INPUT_UDP 0x0002
11 12

  
12 13
struct input_desc;
13 14
struct chunk;
output-grapes.c
29 29

  
30 30
void output_init(int bufsize, const char *config)
31 31
{
32
  out = out_stream_init(config, "media=av");
32
  char cfg[256];
33

  
34
  if (config && (strlen(config) > 4) && (memcmp(config, "udp:", 4) == 0)) {
35
    config += 4;
36
    sprintf(cfg, "dechunkiser=udp");
37
    sprintf(cfg + strlen(cfg), ",%s", config);
38
  } else {
39
    sprintf(cfg, "dechunkiser=avf,media=av");
40
  }
41
  out = out_stream_init(config, cfg);
33 42
  if (out == NULL) {
34 43
     fprintf(stderr, "Error: can't initialize output module\n");
35 44
     exit(1);
streaming.c
11 11
#include <stdbool.h>
12 12
#include <math.h>
13 13
#include <assert.h>
14
#include <string.h>
14 15

  
15 16
#include <net_helper.h>
16 17
#include <chunk.h> 
......
107 108

  
108 109
int source_init(const char *fname, struct nodeID *myID, bool loop, int *fds, int fds_size)
109 110
{
110
  input = input_open(fname, loop ? INPUT_LOOP : 0, fds, fds_size);
111
  int flags = 0;
112

  
113
  if (memcmp(fname, "udp:", 4) == 0) {
114
    fname += 4;
115
    flags = INPUT_UDP;
116
  }
117
  if (loop) {
118
    flags |= INPUT_LOOP;
119
  }
120
  input = input_open(fname, flags, fds, fds_size);
111 121
  if (input == NULL) {
112 122
    return -1;
113 123
  }

Also available in: Unified diff