Crate audiopus

Source
Expand description

Audiopus is a high level abstraction over the Opus library.

This crate uses its own implementation of TryInto/TryFrom attempting to convert to newtypes (Packet, MutPacket, and MutSignals) ensuring Opus’ restrictions will be kept in mind by checking these on construction. Without these restrictions, crashes would occur because Opus does not know any types larger than i32 and does not expect empty packets. Hence our own TryInto/TryFrom allows us to couple restriction-checks with actual types and yet remaining stable Rust. Packet, MutPacket, MutSignals implement conversions from &Vec[T]/&[T], they do not move or destroy the original type.

A Packet references an underlying buffer of type &[u8], it cannot be empty and not longer than std::i32::MAX.

Same goes for MutPacket, except the type mutably borrows the buffer thus checks length before handing out the length-value as Result.

MutSignals wraps around a generic buffer and represents Opus’ output. E.g. when encoding, Opus will fill the buffer with the encoded data.

Audiopus aims to never panic or crash when interacting with Opus, if either occurs, consider this a bug.

Re-exports§

Modules§

Structs§

  • A newtype wrapping around a mutable buffer. They represent mutably borrowed arguments that will be filled by Opus. E.g. you pass this to an encode-method and Opus encodes data into the underlying buffer.

Enums§

  • Represents possible application-types for Opus.
  • Represents possible bandwidths of an Opus-stream.
  • Represents possible audio channels Opus can use.
  • Represents possible sample rates Opus can use. Values represent Hertz.

Traits§

  • While TryFrom is nightly, we use our own implementation to stay stable.
  • While TryInto is nightly, we use our own implementation to stay stable.