roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Add tests for rate and timestamp mapping in transcoder source and sink #577

Open gavv opened 1 year ago

gavv commented 1 year ago

TranscoderSource is an implementation of source that reads samples from another source, applies transcoding, and returns them. Similarly, TranscoderSink applies transcoding to samples and writes them to another sink.

Transcoding may include sample rate mapping (e.g. convert 44100Hz to 48000Hz), channel mapping (e.g. convert stereo to mono), and other.

We already have tests (1, 2) for some of the features, but some tests are missing:

We already have tests with the same names (sample_rate_mapping, timestamp_mapping, etc) for receiver source and sender sink (1, 2). Tests for transcoder source/sink will have similar logic and can be based on them.

Before adding these tests, we'll first need to refactor existing tests for transcoder source. Both transcoder source and sink tests have init() method invoked from beginning of each test. In transcoder sink tests, this method allows to configure both sample rate and channel count of underlying and transcoder sink. However, in transcoder source tests it allows to configure only channel count. We should upgrade it to configure sample rate too.

To implement new tests, we'll also need to refactor MockSource and MockSink helpers in pipeline tests:

Tests that use MockSink should then be reworked to use new methods: