roc-toolkit icon indicating copy to clipboard operation
roc-toolkit copied to clipboard

Add integration tests for resampler profiles

Open gavv opened this issue 1 year ago • 0 comments

Add integration tests for C API for resampler backends and profiles.

Current tests: https://github.com/roc-streaming/roc-toolkit/blob/develop/src/tests/public_api/test_loopback_sender_2_receiver.cpp API documentation: https://roc-streaming.org/toolkit/docs/api.html

We need to add tests (to test_loopback_sender_2_receiver.cpp) that will cover all resampler backends:

  • ROC_RESAMPLER_BACKEND_DEFAULT
  • ROC_RESAMPLER_BACKEND_BUILTIN
  • ROC_RESAMPLER_BACKEND_SPEEX
  • ROC_RESAMPLER_BACKEND_SPEEXDEC

and for each backend, all resampler profiles:

  • ROC_RESAMPLER_PROFILE_DEFAULT
  • ROC_RESAMPLER_PROFILE_HIGH
  • ROC_RESAMPLER_PROFILE_MEDIUM
  • ROC_RESAMPLER_PROFILE_LOW

(We can do it in a single test that will iterate over backends and profiles).

To make tests meaningful, we'll need to configure sender and receiver to perform actual resampling. To make it happen, we should set sample rate of frames passes to sender different from sample rate of network packets, as well as rate of network packets different from rate of frames retrieved from receiver.

For example, test (test::Sender) passes frames with rate 48000 to sender, it resamples them to 44100 and sends to receiver, receiver resamples 44100 again to 48000 to test (test::Receiver).

Sample rates are configured in init_config(). Related options are:

  • sender_conf.frame_encoding.rate (rate of frames passed to sender)
  • sender_conf.packet_encoding (encoding of packets which defines sample rate too)
  • receiver_conf.frame_encoding.rate (rate of frames retrieved from receiver)

We already pass channel counts to init_config() (channel count of frames and channel count of packets). Now we can upgrade it and pass sample rates too. In existing tests we will pass to it same rate for frames and packets, so that there is no resampling. In new tests we will pass to it different rates for frames and packets.

Tests for resampling will need to use FlagNonStrict. It will instruct test::Receiver that it should not expect exact match of sample stream. Exact match is not possible because resampler changes amplitudes of samples.

Background: #328.

gavv avatar Sep 25 '23 11:09 gavv