Statistics
| Branch: | Revision:

grapes / src / Chunkiser / input-stream.c @ 91e9c5d5

History | View | Annotate | Download (723 Bytes)

1
#include <stdint.h>
2
#include <stdlib.h>
3

    
4
#include "chunk.h"
5
#include "chunkiser.h"
6
#include "chunkiser_iface.h"
7

    
8
extern struct chunkiser_iface in_avf;
9
extern struct chunkiser_iface in_dummy;
10

    
11
static struct chunkiser_iface *in;
12

    
13
struct input_stream *input_stream_open(const char *fname, int *period, const char *config)
14
{
15
#ifdef AVF
16
  in = &in_avf;
17
#else
18
  in = &in_dummy;
19
#endif
20

    
21
  return in->open(fname, period, config);
22
}
23

    
24
void input_stream_close(struct input_stream *s)
25
{
26
  return in->close(s);
27
}
28

    
29
int chunkise(struct input_stream *s, struct chunk *c)
30
{
31
  c->data = in->chunkise(s, c->id, &c->size, &c->timestamp);
32
  if (c->data == NULL) {
33
    if (c->size < 0) {
34
      return -1;
35
    }
36

    
37
    return 0;
38
  }
39

    
40
  return 1;
41
}