Revision 9c68eee7 src/Tests/chunkiser_test.c

View differences:

src/Tests/chunkiser_test.c
14 14
#include "chunk.h"
15 15
#include "chunkiser.h"
16 16

  
17
static char out_opts[1024];
18
static char *out_ptr = out_opts;
19
static char in_opts[1024];
20
static char *in_ptr = in_opts;
21

  
22
static char *addopt(char *opts, char *opts_ptr, const char *tag, const char *value)
23
{
24
  if (opts_ptr != opts) {
25
    *opts_ptr++ = ',';
26
  }
27
  opts_ptr += sprintf(opts_ptr, "%s=%s", tag, value);
28
  return opts_ptr;
29
}
30

  
31
static int cmdline_parse(int argc, char *argv[])
32
{
33
  int o;
34

  
35
  while ((o = getopt(argc, argv, "f:rRdlavV")) != -1) {
36
    switch(o) {
37
      case 'f':
38
        out_ptr = addopt(out_opts, out_ptr, "format", optarg);
39
        break;
40
      case 'r':
41
        out_ptr = addopt(out_opts, out_ptr, "dechunkiser", "raw");
42
        break;
43
      case 'R':
44
        out_ptr = addopt(out_opts, out_ptr, "dechunkiser", "raw");
45
        out_ptr = addopt(out_opts, out_ptr, "payload", "avf");
46
        break;
47
      case 'd':
48
        in_ptr = addopt(in_opts, in_ptr, "chunkiser", "dummy");
49
        break;
50
      case 'a':
51
        in_ptr = addopt(in_opts, in_ptr, "media", "audio");
52
        out_ptr = addopt(out_opts, out_ptr, "media", "audio");
53
        break;
54
      case 'v':
55
        in_ptr = addopt(in_opts, in_ptr, "media", "video");
56
        out_ptr = addopt(out_opts, out_ptr, "media", "video");
57
        break;
58
      case 'V':
59
        in_ptr = addopt(in_opts, in_ptr, "media", "av");
60
        out_ptr = addopt(out_opts, out_ptr, "media", "av");
61
        break;
62
      default:
63
        fprintf(stderr, "Error: unknown option %c\n", o);
64

  
65
        exit(-1);
66
    }
67
  }
68

  
69
  return optind - 1;
70
}
71

  
17 72
int main(int argc, char *argv[])
18 73
{
19 74
  int period, done, id;
......
25 80

  
26 81
    return -1;
27 82
  }
28
  input = input_stream_open(argv[1], &period, NULL);
83
  argv += cmdline_parse(argc, argv);
84
  input = input_stream_open(argv[1], &period, in_opts);
29 85
  if (input == NULL) {
30 86
    fprintf(stderr, "Cannot open input %s\n", argv[1]);
31 87

  
32 88
    return -1;
33 89
  }
34
  output = out_stream_init(argv[2], NULL);
90
  output = out_stream_init(argv[2], out_opts);
35 91
  if (output == NULL) {
36 92
    fprintf(stderr, "Cannot open output %s\n", argv[2]);
37 93

  

Also available in: Unified diff