|
|
Paraslash Audio Streaming |
| About News Download Documentation Development |
Forward Error Correction: API.
This implementation of forward error correction employs the Reed Solomon error-correcting code, which is based on Galois field algebra and Vandermonde matrices. The algorithm is implemented in fec.c. The two users are the virtual streaming system (vss.h), which fec-encodes data chunks before sending them over the network, and the fecdec filter (fecdec_filter.c), which decodes fec-encoded chunks and feeds the decoded chunks to the output channel of the buffer tree node for subordinated buffer tree nodes to process.
The API is relatively simple as it contains only the few non-static functions described here. Both the sending and the receiving side first call fec_new() to obtain a reference to an opaque fec handle. The virtual streaming system calls fec_encode() while the fecdec filter calls fec_decode().
Functions | |
| int | fec_new (int k, int n, struct fec_parms **parms) |
| void | fec_free (struct fec_parms *p) |
| void | fec_encode (struct fec_parms *parms, const unsigned char *const *src, unsigned char *dst, int idx, int sz) |
| int | fec_decode (struct fec_parms *parms, unsigned char **data, int *idx, int sz) |
Macros | |
| #define | FEC_HEADER_SIZE |
| #define | FEC_MAGIC |
| int fec_new | ( | int | k, |
| int | n, | ||
| struct fec_parms ** | result | ||
| ) |
Create a new encoder and return an opaque descriptor to it.
| k | Number of input slices. |
| n | Number of output slices. |
| result | On success the Fec descriptor is returned here. |
This creates the k*n encoding matrix. It is computed starting with a Vandermonde matrix, and then transformed into a systematic matrix.
| void fec_free | ( | struct fec_parms * | p | ) |
Deallocate a fec params structure.
| p | The structure to free. |
| void fec_encode | ( | struct fec_parms * | parms, |
| const unsigned char *const * | src, | ||
| unsigned char * | dst, | ||
| int | idx, | ||
| int | sz | ||
| ) |
Compute one encoded slice of the given input.
| parms | The fec parameters returned earlier by fec_new(). |
| src | The k data slices to encode. |
| dst | Result pointer. |
| idx | The index of the slice to compute. |
| sz | The size of the input data packets. |
Encode k source slices of size sz and return the slice identified by idx.
| int fec_decode | ( | struct fec_parms * | parms, |
| unsigned char ** | data, | ||
| int * | idx, | ||
| int | sz | ||
| ) |
Decode one slice from the group of received slices.
| parms | Pointer to fec params structure. |
| data | Pointers to received packets. |
| idx | Pointer to packet indices (gets modified). |
| sz | Size of each packet. |
The data vector of received slices and the indices of slices are used to produce the correct output slice. The data slices are modified in-place.
| #define FEC_HEADER_SIZE |
Each FEC slice contains a FEC header of this size.
The value is needed by the virtual streaming system and the fec decoder implemented in fecdec_filter.c.
| #define FEC_MAGIC |
The FEC header starts with this magic value.