steam-audio-codec 0.1.1

parser for steams voice packets
Documentation
# 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](https://opus-codec.org/)

## 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](./examples/demo_voice.rs) 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](https://crates.io/crates/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

- The
  ["Reversing Steam Voice Codec" blog post]https://zhenyangli.me/posts/reversing-steam-voice-codec/
  by Zhenyang Li has been the primary source of information during the
  development