diff --git a/src/internal_modules/roc_fec/reader.cpp b/src/internal_modules/roc_fec/reader.cpp index ef17ac505..ebc04d244 100644 --- a/src/internal_modules/roc_fec/reader.cpp +++ b/src/internal_modules/roc_fec/reader.cpp @@ -803,18 +803,19 @@ void Reader::drop_repair_packets_from_prev_blocks_() { } void Reader::update_block_duration_(const packet::PacketPtr& ptr) { - if (!ptr->rtp()) { - return; - } packet::stream_timestamp_diff_t block_dur = 0; if (prev_block_timestamp_valid_) { - block_dur = packet::stream_timestamp_diff(ptr->rtp()->stream_timestamp, - prev_block_timestamp_); + block_dur = + packet::stream_timestamp_diff(ptr->stream_timestamp(), prev_block_timestamp_); + } + if (block_dur < 0) { + roc_log(LogTrace, "fec reader: negative block duration"); + prev_block_timestamp_valid_ = false; + } else { + block_max_duration_ = std::max(block_max_duration_, block_dur); + prev_block_timestamp_ = ptr->stream_timestamp(); + prev_block_timestamp_valid_ = true; } - roc_panic_if_msg(block_dur < 0, "fec reader: negative block duration"); - block_max_duration_ = std::max(block_max_duration_, block_dur); - prev_block_timestamp_ = ptr->rtp()->stream_timestamp; - prev_block_timestamp_valid_ = true; } packet::stream_timestamp_t Reader::max_block_duration() const { diff --git a/src/internal_modules/roc_fec/writer.cpp b/src/internal_modules/roc_fec/writer.cpp index b6f4cb1b2..93ec94691 100644 --- a/src/internal_modules/roc_fec/writer.cpp +++ b/src/internal_modules/roc_fec/writer.cpp @@ -112,7 +112,6 @@ status::StatusCode Writer::write(const packet::PacketPtr& pp) { } if (cur_packet_ == 0) { - update_block_duration_(pp); if (!begin_block_(pp)) { // TODO(gh-183): return status return status::StatusOK; @@ -139,6 +138,8 @@ status::StatusCode Writer::write(const packet::PacketPtr& pp) { } bool Writer::begin_block_(const packet::PacketPtr& pp) { + update_block_duration_(pp); + if (!apply_sizes_(next_sblen_, next_rblen_, pp->fec()->payload.size())) { return false; } @@ -347,19 +348,16 @@ bool Writer::validate_source_packet_(const packet::PacketPtr& pp) { } void Writer::update_block_duration_(const packet::PacketPtr& ptr) { - if (!ptr->rtp()) { - return; - } packet::stream_timestamp_diff_t block_dur = 0; if (prev_block_timestamp_valid_) { - block_dur = packet::stream_timestamp_diff(ptr->rtp()->stream_timestamp, - prev_block_timestamp_); + block_dur = + packet::stream_timestamp_diff(ptr->stream_timestamp(), prev_block_timestamp_); } if (block_dur < 0) { prev_block_timestamp_valid_ = false; } else { block_max_duration_ = std::max(block_max_duration_, block_dur); - prev_block_timestamp_ = ptr->rtp()->stream_timestamp; + prev_block_timestamp_ = ptr->stream_timestamp(); prev_block_timestamp_valid_ = true; } } diff --git a/src/tests/roc_fec/test_writer_reader.cpp b/src/tests/roc_fec/test_writer_reader.cpp index 59ab88f2c..ead50308a 100644 --- a/src/tests/roc_fec/test_writer_reader.cpp +++ b/src/tests/roc_fec/test_writer_reader.cpp @@ -270,7 +270,8 @@ TEST(writer_reader, no_losses) { } else { CHECK(reader.is_started()); if (i_block > 1) { -// CHECK(reader.max_block_duration() == NumSourcePackets * 10); + // CHECK(reader.max_block_duration() == + // NumSourcePackets * 10); } } CHECK(p);