Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.18 KB)

1
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6
#include <unistd.h>
7
#include <stdint.h>
8
#include <stdio.h>
9

    
10
#include "out-stream.h"
11
#include "dbg.h"
12
#include "payload.h"
13

    
14
static int outfd = 1;
15

    
16
void chunk_write(int id, const uint8_t *data, int size)
17
{
18
  const int header_size = VIDEO_PAYLOAD_HEADER_SIZE;
19
  int width, height, frame_rate_n, frame_rate_d, frames;
20
  int i;
21
  uint8_t codec;
22

    
23
  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
    return;
27
  }
28
  dprintf("Frame size: %dx%d -- Frame rate: %d / %d\n", width, height, frame_rate_n, frame_rate_d);
29
  frames = data[9];
30
  for (i = 0; i < frames; i++) {
31
    int frame_size;
32
    int32_t pts, dts;
33

    
34
    frame_header_parse(data, &frame_size, &pts, &dts);
35
    dprintf("Frame %d has size %d\n", i, frame_size);
36
  }
37
#ifdef DEBUGOUT
38
#define buff_size 8 // HACK!
39
  fprintf(stderr, "\tOut Chunk[%d] - %d: %s\n", id, id % buff_size, data + header_size + frames * FRAME_HEADER_SIZE);
40
#else
41
  write(outfd, data + header_size + frames * FRAME_HEADER_SIZE, size - header_size - frames * FRAME_HEADER_SIZE);
42
#endif
43
}