steam-audio-codec

Crates.iosteam-audio-codec
lib.rssteam-audio-codec
version0.1.1
created_at2025-05-05 17:28:59.52041+00
updated_at2025-05-25 15:40:31.9864+00
descriptionparser for steams voice packets
homepage
repositoryhttps://codeberg.org/demostf/steam-audio-codec
max_upload_size
id1660992
size37,136
Robin Appelman (icewind1991)

documentation

README

steam-audio-codec

Parser for steam's voice packets.

The "steam" audio codec is used by various voice chat application by steam and Source engine games.

The codec is a fairly thin wrapper around opus packets, so most of the heavy lifting is done by libopus

Usage

Voice data can be decoded with the following steps:

  • Create a SteamVoiceDecoder
  • For every voice packet create a SteamVoiceData from the raw binary data, this will validate that the packet is valid and extract the steam id of the account sending the voice from the header.
  • Pass the SteamVoiceData into SteamVoiceDecoder::decode which will write 16-bit PCM samples to the provided output buffer.
  • Play the PCM samples or encode them into a different format.

See the demo_voice example for a full example in the context of extracting voice chat from a TF2 demo.

Building

Note: this section only applies when using the, enabled by default, "opus" feature.

As this crate uses libopus to do the actual audio decoding you'll need either

  • pkg-config and libopus (including development headers)

or

  • cmake, make, and a C compiler to build libopus from scratch.

See the audiopus_sys documentation for more information.

Bring your own opus decoder

If you need more control over how the opus data is handled, you can disable the builtin opus decoder by removing the (on by default) opus cargo feature.

When this feature is disabled, the SteamVoiceDecoder struct is not available. You can instead access the sample rate, raw opus data and silence information in the voice data from SteamVoiceData::packets.

The opus data should be decoded as mono sound with the sample rate encoded in the packets.

Credits

Commit count: 0

cargo fmt