roc-streaming / roc-toolkit

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

Add integration tests for concurrently running senders #557

Open gavv opened 9 months ago

gavv commented 9 months ago

Add integration tests for C API for concurrently running senders.

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

What tests to add (to test_sender_receiver.cpp):

Note: existing tests run only one sender, or run senders sequentially. It means in existing tests, receiver always produces stream from only one sender, without mixing. Senders produce sequence of incrementing samples, and receiver checks that it also receives sequence of incremented samples.

These new tests will run senders concurrently, which means that receiver will mix samples from two senders. Further more, each sender will have its own (unknown) shift of its stream, and we can;t predict how exactly they can be mixed.

We'll need to adjust sender sample generation (test_helpers/sender.h) and receiver sample checks (test_helpers/receiver.h) for these two tests. For example, for this case we can do a simpler check: sender assigns all samples same constant value X; receiver checks that the stream looks like 0 0 0 ... X X X ... 2X 2X 2X ... X X X ... 0 0 0 (i.e. stream is first all zeros, while there are no senders, then it becomes X, when there is one sender, then 2X, when both senders are connected, then X again when one sender is disconnected, and then all zeros again when all senders are disconnected).

The new behavior can be enabled using some flag used specifically for the new tests. We already are passing flags from test to sender and receiver ctors.

Background: #328.