Statistics
| Branch: | Revision:

grapes / include / chunkiser.h @ 2b424777

History | View | Annotate | Download (3.05 KB)

1
/** @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
 * @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 s 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
 * @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
 * @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
 */
72
int chunkise(struct input_stream *s, struct chunk *c);
73

    
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
 * @param fname output file name (if NULL, output goes to stdout).
81
 * @param config configuration string.
82
 * @return the pointer to the dechunkiser context on success, NULL on error
83
 */
84
struct output_stream *out_stream_init(const char *fname, const char *config);
85

    
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 c pointer to the chunk structure containing the data to write in the
93
 *        A/V stream.
94
 */
95
void chunk_write(struct output_stream *out, const struct chunk *c);
96

    
97
/**
98
 * @brief Cleanup a dechunkiser.
99
 * 
100
 * Close an A/V stream, and cleanup all the data structures related to the
101
 * dechunkiser.
102
 * 
103
 * @param c dechunkiser's context.
104
 */
105
void out_stream_close(struct output_stream *c);
106

    
107
#endif        /* CHUNKISER_H */