Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.46 KB)

1 eb39805a Luca Abeni
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *  Copyright (c) 2010 Csaba Kiraly
4
 *
5
 *  This is free software; see gpl-3.0.txt
6
 */
7 72f8e6fe Luca Abeni
#include <stdint.h>
8 3ee4345d Luca Abeni
#include <stdlib.h>
9 72f8e6fe Luca Abeni
#include <stdio.h>
10
#include <string.h>
11
12
#include "input-stream.h"
13 421c2dc2 Luca Abeni
#include "payload.h"
14 b5e34f09 Luca Abeni
15 72f8e6fe Luca Abeni
static struct input_stream {
16
} fake_descriptor;
17
18 30a6e902 Csaba Kiraly
struct input_stream *input_stream_open(const char *fname, int *period, uint16_t flags)
19 72f8e6fe Luca Abeni
{
20 ce80b058 Luca Abeni
  *period = 40000;
21 72f8e6fe Luca Abeni
  return &fake_descriptor;
22
}
23
24
void input_stream_close(struct input_stream *dummy)
25
{
26
}
27
28
uint8_t *chunkise(struct input_stream *dummy, int id, int *size, uint64_t *ts)
29
{
30 3ee4345d Luca Abeni
  uint8_t *res;
31 74ff12bb Luca Abeni
  const int header_size = 1 + 2 + 2 + 2 + 2 + 1; // 1 Frame type + 2 width + 2 height + 2 frame rate num + 2 frame rate den + 1 number of frames
32 72f8e6fe Luca Abeni
  static char buff[80];
33
34
  sprintf(buff, "Chunk %d", id);
35 ce80b058 Luca Abeni
  *ts = 40 * id * 1000;
36 b5e34f09 Luca Abeni
  *size = strlen(buff) + 1 + header_size + FRAME_HEADER_SIZE;
37 3ee4345d Luca Abeni
  res = malloc(*size);
38
  res[0] = 1;
39
  res[1] = 352 >> 8;
40
  res[2] = 352 & 0xFF;
41
  res[3] = 288 >> 8;
42
  res[4] = 288 & 0xFF;
43 74ff12bb Luca Abeni
  res[5] = 0;
44
  res[6] = 1;
45
  res[7] = 0;
46
  res[8] = 25;
47
  res[9] = 1;
48 b5e34f09 Luca Abeni
  res[10] = ((*size - header_size - FRAME_HEADER_SIZE)) >> 16 & 0xFF;
49
  res[11] = ((*size - header_size - FRAME_HEADER_SIZE)) >> 8 & 0xFF;
50
  res[12] = (*size - header_size - FRAME_HEADER_SIZE) & 0xFF;
51
  res[13] = *ts >> 24;
52
  res[14] = *ts >> 16;
53
  res[15] = *ts >> 8;
54
  res[16] = *ts & 0xFF;
55
  res[17] = 0;
56
  memcpy(res + header_size + FRAME_HEADER_SIZE, buff, *size - header_size - FRAME_HEADER_SIZE);
57 72f8e6fe Luca Abeni
58 3ee4345d Luca Abeni
  return res;
59 72f8e6fe Luca Abeni
}