final Random rand = TestingCommon.newSeededRandom();
final byte[] data = TestingCommon.randomBytes(F, rand);
final int numESIs = K + overhead;
final Set<Integer> esis = randomESIs(rand, K, numESIs);
final SourceBlockEncoder enc = OpenRQ.newEncoder(data, fecParams).sourceBlock(0);
final ArraySourceBlockDecoder dec = (ArraySourceBlockDecoder) /* safe cast */
OpenRQ.newDecoder(fecParams, overhead).sourceBlock(0);
for (int esi : esis) {
if (dec.putEncodingPacket(enc.encodingPacket(esi)) == SourceBlockState.DECODING_FAILURE) {
throw new IllegalStateException("decoding failed, try using a different set of symbols");
}
}
return dec;
}