|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object anon.mixminion.fec.FECCode
public abstract class FECCode
This class provides the main API/SPI for the FEC library. You cannot
construct an FECCode directly, rather you must use an FECCodeFactory.
For example:
int k = 32;
int n = 256;
FECCode code = FECCodeFactory.getDefault().createFECCode(k,n);
All FEC
implementations will sublcass FECCode and implement the encode/decode
methods. All codes implemented by this interface are assumed to be
systematic codes which means that the first k repair packets will be
the same as the original source packets.
(c) Copyright 2001 Onion Networks
(c) Copyright 2000 OpenCola
Field Summary | |
---|---|
protected int |
k
|
protected int |
n
|
Constructor Summary | |
---|---|
protected |
FECCode(int k,
int n)
Construct a new FECCode given k and n |
Method Summary | |
---|---|
abstract void |
decode(byte[][] pkts,
int[] pktsOff,
int[] index,
int packetLength,
boolean shuffled)
This method takes an array of encoded packets and decodes them. |
abstract void |
encode(byte[][] src,
int[] srcOff,
byte[][] repair,
int[] repairOff,
int[] index,
int packetLength)
This method takes an array of source packets and generates a number of repair packets from them. |
protected static void |
shuffle(byte[][] pkts,
int[] pktsOff,
int[] index,
int k)
shuffle move src packets in their position |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int k
protected int n
Constructor Detail |
---|
protected FECCode(int k, int n)
k
and n
k
- The number of source packets to be encoded/decoded.n
- The number of packets that the source packets will be encoded
to.Method Detail |
---|
public abstract void encode(byte[][] src, int[] srcOff, byte[][] repair, int[] repairOff, int[] index, int packetLength)
src
- An array of k
byte[]'s that contain the source
packets to be encoded. Often these byte[]'s are actually references
to a single byte[] that contains the entire source block, then you must
simply vary the srcOff's to pass it in in this fashion. src[0] will
point to the 1st packet, src[1] to the second, etc.srcOff
- An array of integers which specifies the offset of each
each packet within its associated byte[].repair
- Much like src, variable points to a number of buffers
to which the encoded repair packets will be written. This array should
be the same length as repairOff and index.repairOff
- This is the repair analog to srcOff.index
- This int[] specifies the indexes of the packets to be
encoded and written to repair
. These indexes must be
between 0..n (should probably be k..n, because encoding < k is a NOP)packetLength
- the packetLength in bytes. All of the buffers
in src and repair are assumed to be this long.public abstract void decode(byte[][] pkts, int[] pktsOff, int[] index, int packetLength, boolean shuffled)
shuffled
flag is set to true then it is assumed that
the packets are already in the proper order. If not then they will
have the references of the byte[]'s shuffled within the byte[][]. No
data will be copied, only references swapped. This means that if the
byte[][] is wrapping an underlying byte[] then the shuffling proceedure
may bring the byte[][] out of sync with the underlying data structure.
From an SPI perspective this means that the implementation is expected
to follow the exact same behavior as the shuffle() method in this class
which means that you should simply call shuffle() if the flag is false.
pkts
- An array of k
byte[]'s that contain the repair
packets to be decoded. The decoding proceedure will copy the decoded
data into the byte[]'s that are provided and will place them in order
within the byte[][]. If the byte[][] is already properly shuffled
then the byte[]'s will not be moved around in the byte[][].pktsOff
- An array of integers which specifies the offset of each
each packet within its associated byte[].index
- This int[] specifies the indexes of the packets to be
decoded. These indexes must be between 0..npacketLength
- the packetLength in bytes. All of the buffers
in pkts are assumed to be this long.protected static final void shuffle(byte[][] pkts, int[] pktsOff, int[] index, int k)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |