- // Now construct RS packets.
- vector<string> rs_packets;
- for (int i = 0; i < RS_PARITY_SIZE; ++i) {
- string p;
- p.resize(max_length + 4);
- memset(&p[0], 0, max_length + 4);
- rs_packets.push_back(p);
- }
- string data, parity;
- data.resize(RS_PAYLOAD_SIZE);
- parity.resize(RS_PARITY_SIZE);
- for (int i = 0; i < max_length + 4; ++i) {
- for (int j = 0; j < packet_history.size(); ++j) {
- data[j] = packet_history[j].data[i];
- }
- encode_rs_char(rs,
- reinterpret_cast<unsigned char *>(&data[0]),
- reinterpret_cast<unsigned char *>(&parity[0]));
- for (int j = 0; j < RS_PARITY_SIZE; ++j) {
- rs_packets[j][i] = parity[j];
- }
- }
+ // Now construct and send RS packets.
+ rs.encode(reinterpret_cast<const fecpp::byte*>(padded_packets.data()),
+ padded_packets.size(),
+ [&](size_t packet_num, size_t num_packets, const fecpp::byte data[], size_t size) {
+ // The first N packets are just the original ones; ignore them.
+ if (packet_num < RS_PAYLOAD_SIZE) {
+ return;
+ }