Skip to content

Commit

Permalink
DO NOT MERGE Increase FEC resilliancy with low traffic
Browse files Browse the repository at this point in the history
Duplicate first packet to increase resilliancy in cases when the traffic
is low, usually a single packet of some inter-frame compression like
H.264/HEVC. But it will similarly do the job when more packets per frame
are used.

First packet is duplicated instead of the last one because the last packet
can have less symbols than the first if there is more than 1
packet, eg. `DDDD|DF` (D - primary data; F - FEC, | - packet bounadry).
  • Loading branch information
MartinPulec committed Jan 19, 2024
1 parent 66b17a4 commit b257d13
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,13 @@ tx_send_base(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session,
}

vector<int> packet_sizes = get_packet_sizes(frame, substream, tx->mtu - hdrs_len);
const long mult_pkt_cnt = (long) packet_sizes.size() * tx->mult_count;
long mult_pkt_cnt = (long) packet_sizes.size() * tx->mult_count;
const long packet_rate =
get_packet_rate(tx, frame, (int) substream, mult_pkt_cnt);

// initialize header array with values (except offset which is different among
// different packts)
void *rtp_headers = malloc(mult_pkt_cnt * rtp_hdr_len);
void *rtp_headers = malloc((mult_pkt_cnt + 1) * rtp_hdr_len);
uint32_t *rtp_hdr_packet = (uint32_t *) rtp_headers;
for (int m = 0; m < tx->mult_count; ++m) {
unsigned pos = 0;
Expand All @@ -704,6 +704,11 @@ tx_send_base(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session,
pos += packet_sizes.at(i);
}
}
if (frame->fec_params.type != FEC_NONE) { // dup 1st pkt with RS/LDGM
mult_pkt_cnt += 1;
memcpy(rtp_hdr_packet, rtp_hdr, rtp_hdr_len);
rtp_hdr_packet[1] = htonl(0);
}

if (!tx->encryption) {
rtp_async_start(rtp_session, mult_pkt_cnt);
Expand Down

0 comments on commit b257d13

Please sign in to comment.