Statistics
| Branch: | Revision:

grapes / include / chunkiser.h @ 0c461e28

History | View | Annotate | Download (2.32 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 Cleanup a chunkiser.
38
 * 
39
 * Close an A/V stream, and cleanup all the data structures related to the
40
 * chunkiser.
41
 * 
42
 * @param c chunkiser's context.
43
 */
44
void input_stream_close(struct input_stream *c);
45

    
46
/**
47
 * @brief Read a chunk.
48
 * 
49
 * Read some data from the A/V stream, and generate a new chunk
50
 * 
51
 * @param s chunkiser's context.
52
 * @param c is a pointer to the chunk structure that has to be filled by the
53
 *        chunkiser. In particular, the chunk payload, the playload size, and
54
 *        the timestamp (chunk release time) will be filled.
55
 * @return a negative value on error, 0 if no chunk has been generated,
56
 *         (and chunkise() has to be invoked again), > 0 if a chunk has
57
 *         been succesfully generated
58
 */
59
int chunkise(struct input_stream *s, struct chunk *c);
60

    
61
/**
62
 * @brief Initialise a dechunkiser.
63
 * 
64
 * Open an A/V stream for output , and prepare it for writing chunks,
65
 * returning the dechunkiser's context.
66
 * 
67
 * @param config configuration string.
68
 * @return the pointer to the dechunkiser context on success, NULL on error
69
 */
70
struct output_stream *out_stream_init(const char *config);
71

    
72
/**
73
 * @brief Write a chunk.
74
 * 
75
 * Write some data (from a chunk's payload) to the A/V stream.
76
 * 
77
 * @param out dechunkiser's context.
78
 * @param id the chunk id.
79
 * @param data pointer to the chunk's payload.
80
 * @param size chunk size.
81
 */
82
void chunk_write(struct output_stream *out, const struct chunk *c);
83
#endif        /* CHUNKISER_H */