Revision 72f8e6fe

View differences:

Makefile
26 26
LDFLAGS = -L$(GRAPES)/som/TopologyManager -L$(GRAPES)/som/ChunkTrading -L$(GRAPES)/som/ChunkBuffer
27 27
LDLIBS = -ltrading -lcb -ltopman
28 28

  
29
OBJS = dumbstreamer.o streaming.o output.o net_helpers.o
29
OBJS = dumbstreamer.o streaming.o output.o net_helpers.o input.o
30 30
ifdef THREADS
31 31
OBJS += loop-mt.o
32 32
CFLAGS += -pthread
......
37 37

  
38 38
ifdef FFDIR
39 39
FFSRC ?= $(FFDIR)
40
OBJS += Chunkiser/input-avs.o
40
OBJS += Chunkiser/input-stream-avs.o
41 41
LDFLAGS += -L$(FFDIR)/libavcodec -L$(FFDIR)/libavformat -L$(FFDIR)/libavutil
42 42
LDLIBS += -lavformat -lavcodec -lavutil
43 43
LDLIBS += -lm
44 44
LDLIBS += $(call ld-option, -lz)
45 45
LDLIBS += $(call ld-option, -lbz2)
46 46
else
47
OBJS += input-dummy.o
47
OBJS += input-stream-dummy.o
48 48
endif
49 49

  
50 50
all: dumbstreamer
input-dummy.c
1
#include <stdint.h>
2
#include <stdio.h>
3
#include <string.h>
4

  
5
#include <chunk.h>
6

  
7
#include "input.h"
8
#include "dbg.h"
9

  
10
static struct input_desc {
11
} dummy_input;
12

  
13
struct input_desc *input_open(const char *fname)
14
{
15
  return &dummy_input;
16
}
17

  
18
void input_close(struct input_desc *s)
19
{
20
}
21

  
22
int input_get(struct input_desc *dummy, struct chunk *c)
23
{
24
  char buff[64];
25
  static int id;
26

  
27
  sprintf(buff, "Chunk %d", id);
28
  c->id = id;
29
  c->timestamp = 40 * id++;
30
  c->data = strdup(buff);
31
  c->size = strlen(c->data) + 1;
32
  c->attributes_size = 0;
33
  c->attributes = NULL;
34

  
35
  dprintf("Generate Chunk[%d] (TS: %llu): %s\n", c->id, c->timestamp, c->data);
36

  
37
  return 1;
38
}
input-stream-dummy.c
1
#include <stdint.h>
2
#include <stdio.h>
3
#include <string.h>
4

  
5
#include "input-stream.h"
6

  
7
static struct input_stream {
8
} fake_descriptor;
9

  
10
struct input_stream *input_stream_open(const char *fname)
11
{
12
  return &fake_descriptor;
13
}
14

  
15
void input_stream_close(struct input_stream *dummy)
16
{
17
}
18

  
19
uint8_t *chunkise(struct input_stream *dummy, int id, int *size, uint64_t *ts)
20
{
21
  static char buff[80];
22

  
23
  sprintf(buff, "Chunk %d", id);
24
  *ts = 40 * id;
25
  *size = strlen(buff) + 1;
26

  
27
  return strdup(buff);
28
}
input-stream.h
1
#ifndef INPUT_STREAM_H
2
#define INPUT_STREAM_H
3

  
4
struct input_stream;
5

  
6
struct input_stream *input_stream_open(const char *fname);
7
void input_stream_close(struct input_stream *dummy);
8
uint8_t *chunkise(struct input_stream *dummy, int id, int *size, uint64_t *ts);
9

  
10
#endif	/* INPUT_STREAM_H */
input.c
1
#include <stdlib.h>
2
#include <stdint.h>
3
#include <stdio.h>
4
#include <string.h>
5

  
6
#include <chunk.h>
7

  
8
#include "input.h"
9
#include "input-stream.h"
10
#include "dbg.h"
11

  
12
struct input_desc {
13
  struct input_stream *s;
14
  int id;
15
};
16

  
17
struct input_desc *input_open(const char *fname)
18
{
19
  struct input_desc *res;
20

  
21
  res = malloc(sizeof(struct input_desc));
22
  if (res == NULL) {
23
    return NULL;
24
  }
25
  res->id = 0;
26
  res->s = input_stream_open(fname);
27
  if (res->s == NULL) {
28
    free(res);
29
    res = NULL;
30
  }
31

  
32
  return res;
33
}
34

  
35
void input_close(struct input_desc *s)
36
{
37
  input_stream_close(s->s);
38
  free(s);
39
}
40

  
41
int input_get(struct input_desc *s, struct chunk *c)
42
{
43
  c->data = chunkise(s->s, s->id, &c->size, &c->timestamp);
44
  c->id = s->id++;
45
  c->attributes_size = 0;
46
  c->attributes = NULL;
47

  
48
  dprintf("Generate Chunk[%d] (TS: %llu): %s\n", c->id, c->timestamp, c->data);
49

  
50
  return 1;
51
}
52

  

Also available in: Unified diff