Skip to content

Commit

Permalink
roc-streaminggh-183: Forward status codes in FEC reader & writer
Browse files Browse the repository at this point in the history
- forward internal failures via status codes (some were ignored,
  some were using panics)

- remove outdated is_alive() mechanism and rely on status
  codes instead

- expect that after reporting failure, read() and write()
  is never called again
  • Loading branch information
gavv authored and jeshwanthreddy13 committed Aug 6, 2024
1 parent aaca609 commit 2dd278f
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 451 deletions.
365 changes: 202 additions & 163 deletions src/internal_modules/roc_fec/block_reader.cpp

Large diffs are not rendered by default.

43 changes: 12 additions & 31 deletions src/internal_modules/roc_fec/block_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ struct BlockReaderConfig {
class BlockReader : public packet::IReader, public core::NonCopyable<> {
public:
//! Initialize.
//!
//! @b Parameters
//! - @p config contains FEC scheme parameters
//! - @p fec_scheme is FEC codec ID
//! - @p decoder is FEC codec implementation
//! - @p source_reader specifies input queue with data packets
//! - @p repair_reader specifies input queue with FEC packets
//! - @p parser specifies packet parser for restored packets
//! - @p packet_factory is used to allocate restored packets
//! - @p arena is used to initialize a packet array
BlockReader(const BlockReaderConfig& config,
packet::FecScheme fec_scheme,
IBlockDecoder& block_decoder,
Expand All @@ -76,9 +66,6 @@ class BlockReader : public packet::IReader, public core::NonCopyable<> {
//! Did decoder catch block beginning?
bool is_started() const;

//! Is decoder alive?
bool is_alive() const;

//! Get maximal FEC block duration seen since last block resize.
packet::stream_timestamp_t max_block_duration() const;

Expand All @@ -89,26 +76,24 @@ class BlockReader : public packet::IReader, public core::NonCopyable<> {
packet::PacketReadMode mode);

private:
status::StatusCode read_(packet::PacketPtr& packet, packet::PacketReadMode mode);

bool try_start_();
status::StatusCode try_start_();
status::StatusCode get_next_packet_(packet::PacketPtr& packet,
packet::PacketReadMode mode);
status::StatusCode next_block_();

void next_block_();
status::StatusCode try_repair_();

packet::PacketPtr parse_repaired_packet_(const core::Slice<uint8_t>& buffer);
status::StatusCode parse_repaired_packet_(const core::Slice<uint8_t>& buffer,
packet::PacketPtr& packet);

status::StatusCode fetch_all_packets_();
status::StatusCode fetch_packets_(packet::IReader&, packet::IWriter&);

void fill_block_();
void fill_source_block_();
void fill_repair_block_();
status::StatusCode fill_block_();
status::StatusCode fill_source_block_();
status::StatusCode fill_repair_block_();

bool process_source_packet_(const packet::PacketPtr&);
bool process_repair_packet_(const packet::PacketPtr&);
status::StatusCode process_source_packet_(const packet::PacketPtr&);
status::StatusCode process_repair_packet_(const packet::PacketPtr&);

bool validate_fec_packet_(const packet::PacketPtr&);
bool validate_sbn_sequence_(const packet::PacketPtr&);
Expand All @@ -120,16 +105,13 @@ class BlockReader : public packet::IReader, public core::NonCopyable<> {
bool can_update_source_block_size_(size_t);
bool can_update_repair_block_size_(size_t);

bool update_payload_size_(size_t);
bool update_source_block_size_(size_t);
bool update_repair_block_size_(size_t);
status::StatusCode update_payload_size_(size_t);
status::StatusCode update_source_block_size_(size_t);
status::StatusCode update_repair_block_size_(size_t);

void drop_repair_packets_from_prev_blocks_();

void update_block_duration_(const packet::PacketPtr& curr_block_pkt);

bool is_block_resized_() const;

IBlockDecoder& block_decoder_;

packet::IReader& source_reader_;
Expand All @@ -143,7 +125,6 @@ class BlockReader : public packet::IReader, public core::NonCopyable<> {
core::Array<packet::PacketPtr> source_block_;
core::Array<packet::PacketPtr> repair_block_;

bool alive_;
bool started_;
bool can_repair_;

Expand Down
Loading

0 comments on commit 2dd278f

Please sign in to comment.