public FecDecode(int rxlimit, ReedSolomon codec, int mtu) { this.rxlimit = rxlimit; this.dataShards = codec.getDataShardCount(); this.parityShards = codec.getParityShardCount(); this.shardSize = dataShards + parityShards; if (dataShards <= 0 || parityShards <= 0) { throw new Exception("dataShards and parityShards can not less than 0"); } if (rxlimit < dataShards + parityShards) { throw new Exception(""); } this.codec = codec; this.decodeCache = new IByteBuffer[this.shardSize]; this.flagCache = new bool[this.shardSize]; this.rx = new List <FecPacket>(rxlimit); zeros = PooledByteBufferAllocator.Default.DirectBuffer(mtu); zeros.WriteBytes(new byte[mtu]); }
public FecEncode(int headerOffset, ReedSolomon codec, int mtu) { this.dataShards = codec.getDataShardCount(); this.parityShards = codec.getParityShardCount(); this.shardSize = this.dataShards + this.parityShards; //this.paws = (Integer.MAX_VALUE/shardSize - 1) * shardSize; this.paws = 0xffffffffL / shardSize * shardSize; this.headerOffset = headerOffset; this.payloadOffset = headerOffset + Fec.fecHeaderSize; this.codec = codec; this.shardCache = new IByteBuffer[shardSize]; this.encodeCache = new IByteBuffer[parityShards]; zeros = PooledByteBufferAllocator.Default.DirectBuffer(mtu); zeros.WriteBytes(new byte[mtu]); }