Skip to content

Commit f96fb97

Browse files
committed
Increase FEC resilliancy with low traffic
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). refers to GH-361
1 parent a287166 commit f96fb97

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/transmit.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,13 @@ tx_send_base(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session,
687687
}
688688

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

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

708713
if (!tx->encryption) {
709714
rtp_async_start(rtp_session, mult_pkt_cnt);

0 commit comments

Comments
 (0)