com.onionnetworks.fec
Class FECCode

java.lang.Object
  extended by com.onionnetworks.fec.FECCode
Direct Known Subclasses:
Native16Code, Native8Code, PureCode

public abstract class FECCode
extends java.lang.Object

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

Author:
Justin F. Chapweske (justin@chapweske.com)

Method Summary
 void decode(com.onionnetworks.util.Buffer[] pkts, int[] index)
          This method takes an array of encoded packets and decodes them.
 void encode(com.onionnetworks.util.Buffer[] src, com.onionnetworks.util.Buffer[] repair, int[] index)
          This method takes an array of source packets and generates a number of repair packets from them.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public void encode(com.onionnetworks.util.Buffer[] src,
                   com.onionnetworks.util.Buffer[] repair,
                   int[] index)
This method takes an array of source packets and generates a number of repair packets from them. This method could have taken in only one repair packet to be generated, but in many cases it is more efficient (and convenient) to encode multiple packets at once. This is especially true of the NativeCode implementation where data must be copied and the Java->Native->Java transition is expensive.

Parameters:
src - An array of k Buffers that contain the source packets to be encoded. Often these Buffers are actually references to a single byte[] that contains the entire source block.
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 index.
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)

decode

public void decode(com.onionnetworks.util.Buffer[] pkts,
                   int[] index)
This method takes an array of encoded packets and decodes them. Before the packets are decoded, they are shuffled so that packets that are original source packets (index < k) are positioned so that their index within the byte[][] is the same as their packet index. We shuffle the packets using the copy mechanism to allow API users to be guarenteed that the Buffer[] references will not be shuffled around. This allows the Buffer[] to wrap an underlying byte[], and once decoding is complete the entire block will be in the proper order in the underlying byte[]. If the packets are already in the proper position then no copying will take place.

Parameters:
pkts - An array of k Buffers that contain the repair packets to be decoded. The decoding proceedure will copy the decoded data into the Buffers that are provided and will place them in order within the Buffer[]. If the Buffers are already properly shuffled then no data will be copied around during the shuffle proceedure.
index - This int[] specifies the indexes of the packets to be decoded. These indexes must be between 0..n


Copyright © 2002 Onion Networks. All Rights Reserved.