File: libfec.h

package info (click to toggle)
poc-streamer 0.4.2-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,000 kB
  • sloc: ansic: 8,782; makefile: 307; ruby: 152; perl: 135; yacc: 115; lex: 36; sh: 30
file content (89 lines) | stat: -rw-r--r-- 2,799 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef LIBFEC_H__
#define LIBFEC_H__

struct fec_group_s;
typedef struct fec_group_s fec_decode_t;

struct fec_encode_s;
typedef struct fec_encode_s fec_encode_t;

/*
 * Initialize the library. Must be called before using any other call
 * of the library.
 *
 * If infile is not NULL, the given file is opened ("-" for
 * stdin). Further calls to libfec_read_adu() will return the next
 * adu in the file.
 *
 * If outfile is not NULL, the given file is opened ("-" for
 * stdout). Further calls to libfec_write_adu() will write the given
 * ADU to the file (after conversion to MP3 frames).
 */
void libfec_init(char *infile, char *outfile);
void libfec_close(void);

int libfec_read_adu(unsigned char *dst, unsigned int len);
void libfec_write_adu(unsigned char *buf, unsigned int len);

/* fec_len is the maximum packet size in the group */
fec_decode_t *libfec_new_group(unsigned char fec_k,
                               unsigned char fec_n,
                               unsigned long fec_len);
void libfec_delete_group(fec_decode_t *group);

fec_encode_t *libfec_new_encode(unsigned char fec_k,
                                unsigned char fec_n);
void libfec_delete_encode(fec_encode_t *encode);

/****** Decoding routines ******/

/*
 * Add the packet with sequence number (0 <= pkt_seq < fec_n) to the
 * FEC group.
 */
void libfec_add_pkt(fec_decode_t *group,
                    unsigned char pkt_seq,
                    unsigned long len,
                    unsigned char *data);
/*
 * Decode the FEC group and extract the packet with seq idx. Note
 * that the original length information can not be recovered from the
 * encoded data. The resulting data can be padded with 0s.
 *
 * Return 1 on success, 0 on error
 */
unsigned int libfec_decode(fec_decode_t *group,
                           unsigned char *dst,
                           unsigned int idx,
                           unsigned int len);

/****** Encoding routines ******/

/*
 * Add an ADU (in sequence) into the encoding buffer.
 *
 * Return 0 on error, 1 on success.
 */
int libfec_add_adu(fec_encode_t *encode,
                   unsigned long len,
                   unsigned char *data);
/*
 * after fec_k adus have been added, encode the packet with index IDX
 * into dst, with maximal length len.
 *
 * If idx < fec_k, then the original ADUs is copied.
 *
 * Returns 0 on error, length of the packet on success.
 */
unsigned int libfec_encode(fec_encode_t *encode,
                           unsigned char *dst,
                           unsigned int idx,
                           unsigned int len);

/*
 * Return the length of the biggest ADU in the group (and thus the
 * length of the FEC pkts with index >= fec_k.
 */
unsigned int libfec_max_length(fec_encode_t *encode);

#endif /* LIBFEC_H__ */