Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sending 0 sized payload is not how DTX is implemented in Opus
Instead
opus_encode
can return 1 for maximum of MAX_CONSECUTIVE_DTX frames and it means to transmit nothingAfter 10 frames not sent, the 11th frame is not empty but encoded silence frame. Then 10 frames not sent again.
ref: https://www.opus-codec.org/docs/html_api/group__opusencoder.html
If the return value is 1 byte, then the packet does not need to be transmitted (DTX).
Receiving end use
opus_decode
with packet loss concealment generating silence with (0, 0) parameters like already implemented, as the DTX packets are "lost".So
MAX_PACKET_LOSS
must align withMAX_CONSECUTIVE_DTX
Also Opus Compress function was non-functioning,
psRead
needs to be advanced forFRAME_SIZE*2
when you readFRAME_SIZE*2
, notMAX_FRAME_SIZE
. But it currently isn't used.Open Questions
There is currently a strange situation with codecs which doesn't really make sense
Currently only two types of client are detected, "speex" and "opus". Not silk, but its still used for compression but not decompression, for which opus is used.
"opus" clients are determined by sv_version cvar engine build >4554 (which also could be silk clients?).
Check the following chart
sender: "vct_speex"
-> for "vct_opus" clients transcoded to Silk -> can be heard by as long as support Silk
->passed as-is to "vct_speex" clients.
sender: "vct_silk"
-> for "opus" gets passed as-is -> can be heard by "vct_opus" client as long as support Silk
-> not transcoded, can't be heard by "vct_speex" clients.
sender: "vct_opus"
-> for "vct_opus" gets passed as-is -> can be heard by "vct_opus" client as long as support Opus_PLC
-> transcoded to Speex for "speex" clients.
So if aim was to use Silk for compatibility purposes, it doesn't quite hit the mark right now.
Because Silk clients are not detected (or detected as "opus"), nor are their packets transcoded to Speex.
Also I don't know if such client version exist with only Opus_PLC support, but those would only be able to speak to Speex/Opus, but only hear other Opus due to their packets received properly as Opus_PLC but when packets are sent to them, Silk is used.
receiver ↓
Again at least up-to-date Steam clients support both silk and opus_plc so it's not a problem for those clients, but it still doesn't make sense.
I think for maximum compatibility you should either always compress to Silk, which can be heard by all clients supporting Silk.
But if Silk is not to be used, like currently their speech is skipped for Speex clients, shouldn't the compression use opus_PLC like the decompression does?