streamers / input-stream-dummy.c @ 74ff12bb
History | View | Annotate | Download (1.18 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 |
|
14 |
static struct input_stream { |
15 |
} fake_descriptor; |
16 |
|
17 |
struct input_stream *input_stream_open(const char *fname, int *period, uint16_t flags) |
18 |
{ |
19 |
*period = 40000;
|
20 |
return &fake_descriptor;
|
21 |
} |
22 |
|
23 |
void input_stream_close(struct input_stream *dummy) |
24 |
{ |
25 |
} |
26 |
|
27 |
uint8_t *chunkise(struct input_stream *dummy, int id, int *size, uint64_t *ts) |
28 |
{ |
29 |
uint8_t *res; |
30 |
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 |
31 |
static char buff[80]; |
32 |
|
33 |
sprintf(buff, "Chunk %d", id);
|
34 |
*ts = 40 * id * 1000; |
35 |
*size = strlen(buff) + 1 + header_size + 2; |
36 |
res = malloc(*size); |
37 |
res[0] = 1; |
38 |
res[1] = 352 >> 8; |
39 |
res[2] = 352 & 0xFF; |
40 |
res[3] = 288 >> 8; |
41 |
res[4] = 288 & 0xFF; |
42 |
res[5] = 0; |
43 |
res[6] = 1; |
44 |
res[7] = 0; |
45 |
res[8] = 25; |
46 |
res[9] = 1; |
47 |
res[10] = (*size - header_size - 2) >> 8; |
48 |
res[11] = (*size - header_size - 2) & 0xFF; |
49 |
memcpy(res + header_size + 2, buff, *size - header_size - 2); |
50 |
|
51 |
return res;
|
52 |
} |