Skip to content

Commit

Permalink
tx audio: warn if Reed-Solomon is inadequate
Browse files Browse the repository at this point in the history
refer to GH-408
  • Loading branch information
MartinPulec committed Sep 11, 2024
1 parent 215b823 commit 8ff8a78
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#include "tv.h"
#include "types.h"
#include "utils/jpeg_reader.h"
#include "utils/macros.h"
#include "utils/misc.h" // unit_evaluate
#include "utils/random.h"
#include "video.h"
Expand Down Expand Up @@ -871,9 +872,9 @@ audio_tx_send_chan(struct tx *tx, struct rtp *rtp_session, uint32_t timestamp,
}

long data_sent = 0;
int data_len = tx->mtu - hdrs_len;
do {
const char *data = chan_data + pos;
int data_len = tx->mtu - hdrs_len;
if (pos + data_len >=
(unsigned int) buffer->get_data_len(channel)) {
data_len = buffer->get_data_len(channel) - pos;
Expand Down Expand Up @@ -908,6 +909,23 @@ audio_tx_send_chan(struct tx *tx, struct rtp *rtp_session, uint32_t timestamp,
} while (pos < buffer->get_data_len(channel));

report_stats(tx, rtp_session, data_sent);

if (buffer->get_fec_params(0).type == FEC_NONE) {
return;
}
// issue a warning if R-S is inadequate
const int packet_count =
(buffer->get_data_len(channel) + data_len - 1) / data_len;
if (packet_count > 3) {
return;
}
const char *pl_suffix = packet_count == 1 ? "" : "s";
log_msg_once(LOG_LEVEL_WARNING, to_fourcc('t', 'x', 'a', 'F'),
MOD_NAME
"[audio] %d packet%s per audio channel may be too low "
"for Reed Solomon, consider mult instead!%s\n",
packet_count, pl_suffix,
packet_count == 3 ? " (Or increase the redundancy.)" : "");
}

static bool
Expand Down

0 comments on commit 8ff8a78

Please sign in to comment.