Revision f57424db

View differences:

src/Chunkiser/Makefile
11 11
       input-stream-udp.o       \
12 12
       output-stream.o          \
13 13
       output-stream-raw.o      \
14
       output-stream-udp.o 
14
       output-stream-udp.o      \
15
       output-stream-dummy.o 
15 16

  
16 17
ifdef FFDIR
17 18
OBJS += input-stream-avf.o output-stream-avf.o
src/Chunkiser/output-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 <stdio.h>
10
#include <string.h>
11

  
12
#include "config.h"
13
#include "dechunkiser_iface.h"
14

  
15
enum output_type {
16
  chunk_id,
17
  stats,
18
};
19

  
20
struct dechunkiser_ctx {
21
  enum output_type type;
22
  int last_id;
23
};
24

  
25
static struct dechunkiser_ctx *dummy_open(const char *fname, const char *config)
26
{
27
  struct dechunkiser_ctx *res;
28
  struct tag *cfg_tags;
29

  
30
  res = malloc(sizeof(struct dechunkiser_ctx));
31
  if (res == NULL) {
32
    return NULL;
33
  }
34
  res->type = chunk_id;
35
  res->last_id = -1;
36
  cfg_tags = config_parse(config);
37
  if (cfg_tags) {
38
    const char *pt;
39

  
40
    pt = config_value_str(cfg_tags, "type");
41
    if (pt) {
42
      if (!strcmp(pt, "stats")) {
43
        res->type = stats;
44
      }
45
    }
46
  }
47
  free(cfg_tags);
48

  
49
  return res;
50
}
51

  
52
static void dummy_write(struct dechunkiser_ctx *o, int id, uint8_t *data, int size)
53
{
54
  switch (o->type) {
55
    case chunk_id:
56
      printf("Chunk %d: size %d\n", id, size);
57
      break;
58
    case stats:
59
      if (o->last_id >= 0) {
60
        int i;
61

  
62
        for (i = 1; i < id - o->last_id; i++) {
63
          printf("Lost chunk %d\n", o->last_id + i);
64
        }
65
      }
66
      break;
67
    default:
68
      fprintf(stderr, "Internal error!\n");
69
      exit(-1);
70
  }
71
  o->last_id = id;
72
}
73

  
74
static void dummy_close(struct dechunkiser_ctx *s)
75
{
76
  free(s);
77
}
78

  
79
struct dechunkiser_iface out_dummy = {
80
  .open = dummy_open,
81
  .write = dummy_write,
82
  .close = dummy_close,
83
};
src/Chunkiser/output-stream.c
10 10
extern struct dechunkiser_iface out_avf;
11 11
extern struct dechunkiser_iface out_raw;
12 12
extern struct dechunkiser_iface out_udp;
13
extern struct dechunkiser_iface out_dummy;
13 14

  
14 15
struct output_stream {
15 16
  struct dechunkiser_ctx *c;
......
40 41
      res->out = &out_raw;
41 42
    } else if (type && !strcmp(type, "udp")) {
42 43
      res->out = &out_udp;
44
    } else if (type && !strcmp(type, "dummy")) {
45
      res->out = &out_dummy;
43 46
    } else if (type && !strcmp(type, "avf")) {
44 47
#ifdef AVF
45 48
      res->out = &out_avf;

Also available in: Unified diff