Skip to content

Refactor DelayedReader startup #771

@gavv

Description

@gavv

DelayedReader is pipeline elements that inserts initial delay in the stream, by accumulating packets until there is enough of them, and only then forwarding them.

LatencyTuner is a class that monitors and adjusts latency on fly.

Currently, they work independently. DelayedReader unconditionally inserts initial delay and then enters "normal" mode (just forwards packets through it). We want to change it, so that LatencyTuner will decide when initial delay is done and tell DelayedReader to finish delay and enter normal mode.

This refactoring would allow us (in future) to control initial delay dynamically (#712, #127).

Steps

  • Rework DelayedReader. Remove target_delay parameter and instead add new methods is_started() and start(). Until start() is called, DelayedReader accumulates packets. When it's called, it enters normal mode.

    • Unit tests for DelayedReader should be updated as well.
  • Update LatencyTuner. Add new method can_start(). It starts returning true when actual_latency calculated in update_stream() became >= target_latency.

  • Update LatencyMonitor. It is a class that glues multiple latency-related classes together. Pass a reference to DelayedReader to LatencyMonitor. In pre_read_(), check if DelayedReader is_started(). If not, ask LatencyTuner if we can_start(). If yes, start() Delay reader.

After this, all tests (except unit tests for DelayedReader) should continue working without modification. roc_pipeline tests cover initial delay, so if they pass, we've done everything right.

Metadata

Metadata

Assignees

Labels

C-refactoringcategory: Refactoringeasy hacksSolution requires minimal project contexthelp wantedLooking for contributorsmost wantedNeeded most among other help-wanted issues

Projects

Status

Help wanted

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions