Statistics
| Branch: | Revision:

streamers / input-stream-dummy.c @ 421c2dc2

History | View | Annotate | Download (1.46 KB)

1
/*
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
#include <stdint.h>
8
#include <stdlib.h>
9
#include <stdio.h>
10
#include <string.h>
11

    
12
#include "input-stream.h"
13
#include "payload.h"
14

    
15
static struct input_stream {
16
} fake_descriptor;
17

    
18
struct input_stream *input_stream_open(const char *fname, int *period, uint16_t flags)
19
{
20
  *period = 40000;
21
  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
  uint8_t *res;
31
  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
  static char buff[80];
33

    
34
  sprintf(buff, "Chunk %d", id);
35
  *ts = 40 * id * 1000;
36
  *size = strlen(buff) + 1 + header_size + FRAME_HEADER_SIZE;
37
  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
  res[5] = 0;
44
  res[6] = 1;
45
  res[7] = 0;
46
  res[8] = 25;
47
  res[9] = 1;
48
  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

    
58
  return res;
59
}