algesten / str0m

A synchronous sans I/O WebRTC implementation in Rust.
MIT License
280 stars 45 forks source link

Opus DTX support #492

Closed OxleyS closed 3 months ago

OxleyS commented 3 months ago

This adds support for an Opus format param usedtx, which signals a receiver's preference for DTX. DTX stands for Discontinuous Transmission, and it's a feature in Opus that lowers the packet rate, not just the bitrate, during periods of silence. For instance, in my WebRTC environment, Chrome and Firefox will reduce the packet rate from 50 packets per second to 4 during silence. This makes it ideal for SFU-type applications, where any particular person spends most of the time not talking, and so we can save the CPU time spent processing such packets.

As mentioned in the above link, it does have slight effects on the resulting audio, and browsers don't currently negotiate it without SDP munging, so here I've set it off by default.

Known caveat: at a reduced rate of 4 packets per second, if your StreamRx.pause_threshold is less than 250 ms, str0m will emit stream pause/unpause events between each packet. That said, this could be considered expected behavior.

algesten commented 3 months ago

Thanks!