IOS: playing RTP packets using an audio device

I am developing a VoIP application and must play back data from RTP packets that are sent by the server every 20 ms.

I have a buffer that accumulates samples from RTP packets. The sound block makes a callback, reads data from this buffer.

The problem is that I cannot synchronize the audio device with the RTP stream. The preferred duration of the IO buffer cannot be set to 20 ms. And the number of frames requested by the render callback also cannot be set to the number of packets in the sample.

As a result, two situations are possible (depending on the sampling frequency and the duration of the I / O buffer):

a) an audio device reads from my buffer faster than it is populated from RTP packets; in this case, the buffer periodically does not contain the requested number of samples, and I get a distorted sound;

b) the buffer fills faster than the sound unit reads from it; in this case, the buffer periodically overflows, and samples from new RTP packets are lost.

What should I do to avoid this problem?

+4
source share
2 answers

, " ". FIFO/buffer "" , FIFO/, . , ..

( PSOLA ..) , .

+1

, (, ), .

, 300 , , , 20 15000 / / .

, . , .

+1

All Articles