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

Implement simplest "beep" and "echo" PLC #305

Closed gavv closed 3 months ago

gavv commented 4 years ago

Intro

Packet loss concealment (PLC) is a technique to mask the effects of packet loss. It comes into play when a packet is lost and can't be recovered using FEC. In this case we can at least make the loss less noticeable.

Currently we just play zeros instead of the lost samples. The simplest PLC technique is just to repeat last frame, but a little quieter. In this task we want to implement this technique.

We also have "beeping mode", useful for debugging. In this mode, when a packet is lost, we insert a loud beep instead of zeros, to make the loss more noticeable, which also may be considered as a kind of PLC. This feature is currently implemented as a part of Depacketizer class. In this task we want to extract it to a separate PLC-like element.

Task

Notes

It probably makes sense to split the implementation into a few pull requests:

Info

Related docs: https://roc-streaming.org/toolkit/docs/internals/data_flow.html

fusuiyi123 commented 4 years ago

I can take a look at this:D

gavv commented 4 years ago

You're welcome.

fusuiyi123 commented 4 years ago

Hi @gavv if I understand correctly, https://github.com/roc-project/roc/blob/develop/src/modules/roc_audio/depacketizer.cpp#L108-L114 each time we should either read_missing_samples_ or read_packet_samples_ so that each time it is either FlagBlank or not FlagBlank?

gavv commented 4 years ago

each time we should either read_missingsamples or read_packetsamples

Yes. Note that during each Depacketizer::read() we may call read_packetsamples() and read_missingsamples() multiple times, depending on whether we have gaps (missing packets) and how much.

so that each time it is either FlagBlank or not FlagBlank?

Not quite.

We set FlagBlank if the frame was completely filled with read_missingsamples(). We set FlagIncomplete is the frame was partially filled with read_missingsamples() and partially with read_packetsamples(). And we set none of these two flags if the frame was completely filled with read_packetsamples().

BTW, take a look at depacketizer unit tests, they may help to understand its behavior.

gavv commented 4 years ago

BTW, forgot to mention, did you see this notice in the issue?

First we should finish #302 because we need partial reads support to implement PLC. See below why.

302 is in progress, @aj-thomas-8 works on it.

fusuiyi123 commented 4 years ago

yes I saw #302 , cool I will take a look at the unit test:)

fusuiyi123 commented 4 years ago

since this is a task after #302 may I look at this other issues first:)

gavv commented 4 years ago

302 is unassigned again

gavv commented 3 months ago

Moved to #731