Statistics
| Branch: | Revision:

grapes / include / chunkiser.h @ master

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