Statistics
| Branch: | Revision:

grapes / include / chunkiser.h @ 4cdd16a7

History | View | Annotate | Download (3.06 KB)

1 1e8dedd8 Luca Abeni
/** @file chunkiser.h
2
 *
3
 * @brief Split an audio/video stream in chunks.
4
 *
5
 * The chunkisation functions (chunkiser) allow to split an A/V stream in
6
 * chunks, and to output the chunks payload...
7
 *
8
 */
9
 
10
#ifndef CHUNKISER_H
11
#define CHUNKISER_H
12
13
/**
14
 * Opaque data type representing the context for a chunkiser
15
 */
16
struct input_stream;
17
18
/**
19
 * Opaque data type representing the context for a de-chunkiser
20
 */
21
struct output_stream;
22
23
/**
24
 * @brief Initialise a chunkiser.
25
 * 
26
 * Open an A/V stream, and prepare it for reading chunks, returning the
27
 * chunkiser's context.
28
 * 
29
 * @param fname name of the file containing the A/V stream.
30
 * @param period desired input cycle size.
31
 * @param config configuration string.
32
 * @return the pointer to the chunkiser context on success, NULL on error
33
 */
34
struct input_stream *input_stream_open(const char *fname, int *period, const char *config);
35
36
/**
37 4cdd16a7 Luca Abeni
 * @brief Return the FDs used for input.
38
 *
39
 * Return a "-1 terminated" array of integers containing the FDs used for
40
 * reading an input stream. Such an array can be directly passed to wait4data()
41
 * as user_fds
42
 *
43
 * @param input_stream the pointer to the chunkiser context
44
 * @return the array with the input FDs on success, NULL on error or if
45
 *         such FDs are not available
46
 */
47
const int *input_get_fds(const struct input_stream *s);
48
49
/**
50 1e8dedd8 Luca Abeni
 * @brief Cleanup a chunkiser.
51
 * 
52
 * Close an A/V stream, and cleanup all the data structures related to the
53
 * chunkiser.
54
 * 
55
 * @param c chunkiser's context.
56
 */
57
void input_stream_close(struct input_stream *c);
58
59
/**
60
 * @brief Read a chunk.
61
 * 
62
 * Read some data from the A/V stream, and generate a new chunk
63
 * 
64 606948b2 Luca Abeni
 * @param s chunkiser's context.
65
 * @param c is a pointer to the chunk structure that has to be filled by the
66
 *        chunkiser. In particular, the chunk payload, the playload size, and
67
 *        the timestamp (chunk release time) will be filled.
68
 * @return a negative value on error, 0 if no chunk has been generated,
69
 *         (and chunkise() has to be invoked again), > 0 if a chunk has
70
 *         been succesfully generated
71 1e8dedd8 Luca Abeni
 */
72 606948b2 Luca Abeni
int chunkise(struct input_stream *s, struct chunk *c);
73 1e8dedd8 Luca Abeni
74
/**
75
 * @brief Initialise a dechunkiser.
76
 * 
77
 * Open an A/V stream for output , and prepare it for writing chunks,
78
 * returning the dechunkiser's context.
79
 * 
80 e296176d Luca Abeni
 * @param fname output file name (if NULL, output goes to stdout).
81 1e8dedd8 Luca Abeni
 * @param config configuration string.
82
 * @return the pointer to the dechunkiser context on success, NULL on error
83
 */
84 e296176d Luca Abeni
struct output_stream *out_stream_init(const char *fname, const char *config);
85 1e8dedd8 Luca Abeni
86
/**
87
 * @brief Write a chunk.
88
 * 
89
 * Write some data (from a chunk's payload) to the A/V stream.
90
 * 
91
 * @param out dechunkiser's context.
92
 * @param id the chunk id.
93
 * @param data pointer to the chunk's payload.
94
 * @param size chunk size.
95
 */
96 0c461e28 Luca Abeni
void chunk_write(struct output_stream *out, const struct chunk *c);
97 386bce8c Luca Abeni
98
/**
99
 * @brief Cleanup a dechunkiser.
100
 * 
101
 * Close an A/V stream, and cleanup all the data structures related to the
102
 * dechunkiser.
103
 * 
104
 * @param c dechunkiser's context.
105
 */
106
void out_stream_close(struct output_stream *c);
107
108 1e8dedd8 Luca Abeni
#endif        /* CHUNKISER_H */