Statistics
| Branch: | Revision:

streamers / out-stream.c @ e0f42ea7

History | View | Annotate | Download (888 Bytes)

1
#include <unistd.h>
2
#include <stdint.h>
3
#include <stdio.h>
4

    
5
#include "out-stream.h"
6
#include "dbg.h"
7

    
8
static int outfd = 1;
9

    
10
void chunk_write(int id, const uint8_t *data, int size)
11
{
12
  const int header_size = 1 + 2 + 2 + 1 + 2; // 1 Frame type + 2 width + 2 height + 1 number of frames + 2 frame len
13
  int width, height, frames;
14
  int i;
15

    
16
  if (data[0] != 1) {
17
    fprintf(stderr, "Error! Non video chunk!!!\n");
18
    return;
19
  }
20
  width = data[1] << 8 | data[2];
21
  height = data[3] << 8 | data[4];
22
  dprintf("Frame size: %dx%d\n", width, height);
23
  frames = data[5];
24
  for (i = 0; i < frames; i++) {
25
    dprintf("Frame %d has size %d\n", i, data[6 + 2 * i] << 8 | data[7 + 2 * i]);
26
  }
27
#ifdef DEBUG
28
#define buff_size 8 // HACK!
29
  fprintf(stderr, "\tOut Chunk[%d] - %d: %s\n", id, id % buff_size, data + header_size);
30
#else
31
  write(outfd, data + header_size, size - header_size);
32
#endif
33
}