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:
sample_rate_mapping - test case when sample rate of underlying source/sink and transcoder source/sink are different and resampling is applied
This test should be similar to channel_mapping_* tests for transcoder source/sink, but instead of setting different channel count on underlying source/sink, it should set different sample rate on it. Since sample rate conversion modifies samples quite unpredictably, this test should not check for exact sample values like in channel_mapping_*, but instead just check that transcoder produces some non-zero samples.
timestamp_mapping - test how transcoder source/sink forwards timestamps from underlying source/sink
This test should configure underlying source/sink to produce frames with non-zero capture timestamps, and then check that frames returned by transcoder source/sink have corresponding timestamps.
timestamp_mapping_remixing - same as previous one, but in addition sample rate and channel count of underlying source/sink are different
This test should do everything like timestamp_mapping, but in addition configure underlying source/sink to have different channel count and sample rate, so that transcoder will perform remixing (i.e. rate and channel mapping)
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:
Add capture_timestamp support to MockSource. Its read() method should set capture_timestamp of returned frames the same way as we do it in MockReader from roc_audio test helpers. This is needed for timestamp mapping tests.
Rework MockSink interface. Currently MockSink checks samples passed to it right inside its write() method. Instead of that, it should remember samples, flags, and capture timestamps from frames, and provide methods for checking that remembered data, like we do it in MockWriter from roc_audio test helpers.
Tests that use MockSink should then be reworked to use new methods:
timestamp mapping tests will check remembered capture timestamps
sample rate mapping test will check only that samples are non-zero, but won't check exact sample values, because resampling changes them unpredictably
the rest of the tests will check exact sample values, as it done currently inside MockSink::write()
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:
sample_rate_mapping
- test case when sample rate of underlying source/sink and transcoder source/sink are different and resampling is appliedtimestamp_mapping
- test how transcoder source/sink forwards timestamps from underlying source/sinktimestamp_mapping_remixing
- same as previous one, but in addition sample rate and channel count of underlying source/sink are differentWe 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:
Add capture_timestamp support to MockSource. Its read() method should set capture_timestamp of returned frames the same way as we do it in MockReader from roc_audio test helpers. This is needed for timestamp mapping tests.
Rework MockSink interface. Currently MockSink checks samples passed to it right inside its write() method. Instead of that, it should remember samples, flags, and capture timestamps from frames, and provide methods for checking that remembered data, like we do it in MockWriter from roc_audio test helpers.
Tests that use MockSink should then be reworked to use new methods: