Skip to content

Return status code instead of bool in IParser #737

@gavv

Description

@gavv

Summary

packet::IParser is interface for protocol-specific deserializators. See documentation.

Currently its methods return bool (true on success or false on error). We need to replace bool with status::StatusCode and return code that described why the operation failed.

Implementation

  • Update IParser interface and implementations:
    • rtp::Parser
    • fec::Parser
    • rtcp::Parser
  • Report appropriate statuses:
    • when allocation failed, return StatusNoMem
    • when buffer is too small, return StatusBadBuffer
    • when packet is malformed, return StatusBadPacket
    • on success, return StatusOK
  • Update users of parsers and composers. They should forward status to upper level:
    • fec::BlockReader
    • rtcp::Communicator

Testing

  • Add unit tests for rtp::Parser and fec::Parser that check returned statuses in case of errors.
  • Add unit tests for components which use parsers, and check that they forward statuses from parser to the upper level (e.g. if Parser fails with StatusNoMem, BlockReader::read() returns StatusNoMem). One test per component should be enough.

Metadata

Metadata

Assignees

Labels

C-refactoringcategory: Refactoringeasy hacksSolution requires minimal project contexthelp wantedLooking for contributors

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions