Revision 91e9c5d5

View differences:

src/Chunkiser/Makefile
5 5
endif
6 6
CFGDIR ?= ..
7 7

  
8
OBJS = input-stream.o output-stream.o
8
OBJS = input-stream.o input-stream-dummy.o output-stream-raw.o output-stream.o
9 9

  
10 10
ifdef FFDIR
11 11
OBJS += input-stream-avf.o output-stream-avf.o
src/Chunkiser/input-stream-dummy.c
1
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6

  
7
#include <stdint.h>
8
#include <stdlib.h>
9
#include <string.h>
10
#include <stdio.h>
11

  
12
#include "chunkiser_iface.h"
13

  
14
struct input_stream {
15
  char buff[80];
16
};
17

  
18
static struct input_stream *open(const char *fname, int *period, const char *config)
19
{
20
  fprintf(stderr, "WARNING: This is a dummy chunkiser, only good for debugging! Do not expect anything good from it!\n");
21
  *period = 40000;
22
  return malloc(sizeof(struct input_stream));
23
}
24

  
25
static void close(struct input_stream *s)
26
{
27
  free(s);
28
}
29

  
30
static uint8_t *chunkise(struct input_stream *s, int id, int *size, uint64_t *ts)
31
{
32
  sprintf(s->buff, "Chunk %d", id);
33
  *ts = 40 * id * 1000;
34
  *size = strlen(s->buff);
35

  
36
  return strdup(s->buff);
37
}
38

  
39
struct chunkiser_iface in_dummy = {
40
  .open = open,
41
  .close = close,
42
  .chunkise = chunkise,
43
};
44

  
src/Chunkiser/input-stream.c
6 6
#include "chunkiser_iface.h"
7 7

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

  
10 11
static struct chunkiser_iface *in;
11 12

  
......
14 15
#ifdef AVF
15 16
  in = &in_avf;
16 17
#else
17
  return NULL;
18
  in = &in_dummy;
18 19
#endif
20

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

  
src/Chunkiser/output-stream-raw.c
1
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6

  
7
#include <unistd.h>
8
#include <stdint.h>
9
#include <stdlib.h>
10
#include <stdio.h>
11

  
12
#include "dechunkiser_iface.h"
13

  
14
struct output_stream {
15
  int fd;
16
};
17

  
18
static struct output_stream *raw_open(const char *config)
19
{
20
  struct output_stream *res;
21

  
22
  res = malloc(sizeof(struct output_stream));
23
  if (res == NULL) {
24
    return NULL;
25
  }
26
  res->fd = 1;
27

  
28
  return res;
29
}
30

  
31
static void raw_write(struct output_stream *o, int id, uint8_t *data, int size)
32
{
33
  write(o->fd, data, size);
34
}
35

  
36
struct dechunkiser_iface out_raw = {
37
  .open = raw_open,
38
  .write = raw_write,
39
};
src/Chunkiser/output-stream.c
6 6
#include "dechunkiser_iface.h"
7 7

  
8 8
extern struct dechunkiser_iface out_avf;
9
extern struct dechunkiser_iface out_raw;
9 10
static struct dechunkiser_iface *out;
10 11

  
11 12
struct output_stream *out_stream_init(const char *config)
......
13 14
#ifdef AVF
14 15
  out = &out_avf;
15 16
#else
16
  return NULL;
17
  out = &out_raw;
17 18
#endif
18 19

  
19 20
  return out->open(config);

Also available in: Unified diff