Statistics
| Branch: | Revision:

streamers / out-stream-dummy.c @ 913146ae

History | View | Annotate | Download (1.18 KB)

1 7f591208 Csaba Kiraly
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6 54b631d9 Luca Abeni
#include <unistd.h>
7
#include <stdint.h>
8
#include <stdio.h>
9
10
#include "out-stream.h"
11
#include "dbg.h"
12 421c2dc2 Luca Abeni
#include "payload.h"
13 54b631d9 Luca Abeni
14
static int outfd = 1;
15
16
void chunk_write(int id, const uint8_t *data, int size)
17
{
18 4f7ec627 Luca Abeni
  const int header_size = VIDEO_PAYLOAD_HEADER_SIZE;
19 74ff12bb Luca Abeni
  int width, height, frame_rate_n, frame_rate_d, frames;
20 e0f42ea7 Luca Abeni
  int i;
21 4f7ec627 Luca Abeni
  uint8_t codec;
22 e0f42ea7 Luca Abeni
23 4f7ec627 Luca Abeni
  payload_header_parse(data, &codec, &width, &height, &frame_rate_n, &frame_rate_d);
24
  if (codec != 1) {
25
    fprintf(stderr, "Error! Non video chunk: %x!!!\n", codec);
26 e0f42ea7 Luca Abeni
    return;
27
  }
28 74ff12bb Luca Abeni
  dprintf("Frame size: %dx%d -- Frame rate: %d / %d\n", width, height, frame_rate_n, frame_rate_d);
29
  frames = data[9];
30 e0f42ea7 Luca Abeni
  for (i = 0; i < frames; i++) {
31 b5e34f09 Luca Abeni
    int frame_size;
32 4f7ec627 Luca Abeni
    int32_t pts, dts;
33 b5e34f09 Luca Abeni
34 4f7ec627 Luca Abeni
    frame_header_parse(data, &frame_size, &pts, &dts);
35 b5e34f09 Luca Abeni
    dprintf("Frame %d has size %d\n", i, frame_size);
36 e0f42ea7 Luca Abeni
  }
37 60c05f2e Csaba Kiraly
#ifdef DEBUGOUT
38 54b631d9 Luca Abeni
#define buff_size 8 // HACK!
39 b5e34f09 Luca Abeni
  fprintf(stderr, "\tOut Chunk[%d] - %d: %s\n", id, id % buff_size, data + header_size + frames * FRAME_HEADER_SIZE);
40 54b631d9 Luca Abeni
#else
41 b5e34f09 Luca Abeni
  write(outfd, data + header_size + frames * FRAME_HEADER_SIZE, size - header_size - frames * FRAME_HEADER_SIZE);
42 54b631d9 Luca Abeni
#endif
43
}