class

FVoiceOpusCodec

Module
VoiceChat
Header
#include "VoiceChat/FVoiceOpusCodec.h"
Namespace
Mowo

Properties

TypeNameDescription
static constexpr uint32_tkSampleRateDefault 48000.
static constexpr uint32_tkFrameSamplesDefault 960.
static constexpr uint32_tkDefaultBitrate32 kbps, not the 24 speech alone would need: deep redundancy takes its share out of the same budget, and at 24 kbps libopus decides it cannot afford two DRED chunks and sends none at all. Default 32000.
static constexpr uint32_tkDefaultRedundancyMsHalf a second of deep redundancy covers the loss bursts a relayed session actually sees (a Wi-Fi retry storm, a route change) for a few kbps. Default 500.
static constexpr uint32_tkMaxEncodedBytesThe ceiling handed to opus_encode, so a VBR peak can never write past the reserve or overflow the wire header's 16-bit payload length. 400 bytes is Opus's own recommendation for a 20 ms mono packet. Default 400.
static constexpr size_tkDtxMaxBytesOpus emits one or two bytes for a frame it decided not to transmit. Default 2.

Constructors

SignatureNameDescription
~FVoiceOpusCodec() override~FVoiceOpusCodec
FVoiceOpusCodec(const FVoiceOpusCodec&) = deleteFVoiceOpusCodec

Public functions

ReturnsNameDescription
boolIsAvailableFalse when the Opus binaries were not vendored for this platform.
std::unique_ptr<FVoiceOpusCodec>TryCreatenullptr when Opus is unavailable or the encoder/decoder refused to come up.
FVoiceOpusCodec&operator=
EVoiceCodecIdGetCodecId
const char*GetName
uint32_tGetSampleRate
uint32_tGetFrameSamples
uint32_tGetMaxEncodedBytes
std::unique_ptr<IVoiceDecoder>CreateDecoderA stream decoder with its own Opus state, FEC, deep redundancy and packet-loss concealment.
boolEncodeFrame
boolDecodeFrame
boolSupportsInbandFec
boolDecodeFecFrame
voidSetBitrateTarget bitrate for the VBR encoder, redundancy included.
uint32_tGetBitrate
voidSetInbandFecEnabled
boolIsInbandFecEnabled
voidSetDtxEnabled
boolIsDtxEnabled
voidSetExpectedPacketLossWhat the encoder assumes about the channel.
uint32_tGetExpectedPacketLoss
boolSetRedundancyMillisecondsDeep redundancy (DRED): up to this many milliseconds of past speech ride in every packet at a low bitrate, so a burst of loss is rebuilt from the first packet after it instead of concealed.
uint32_tGetRedundancyMilliseconds
uint64_tGetDtxFrameCount

Function details

~FVoiceOpusCodec

C++
~FVoiceOpusCodec() override

FVoiceOpusCodec

C++
FVoiceOpusCodec(const FVoiceOpusCodec&) = delete

IsAvailable

C++
static bool IsAvailable()

False when the Opus binaries were not vendored for this platform. The class still links; every call simply fails.

TryCreate

C++
static std::unique_ptr<FVoiceOpusCodec> TryCreate(uint32_t bitsPerSecond = kDefaultBitrate)

nullptr when Opus is unavailable or the encoder/decoder refused to come up. Never silently degrades — the caller picks the fallback.

operator=

C++
FVoiceOpusCodec& operator=(const FVoiceOpusCodec&) = delete

GetCodecId

C++
EVoiceCodecId GetCodecId() const override

GetName

C++
const char* GetName() const override

GetSampleRate

C++
uint32_t GetSampleRate() const override

GetFrameSamples

C++
uint32_t GetFrameSamples() const override

GetMaxEncodedBytes

C++
uint32_t GetMaxEncodedBytes() const override

CreateDecoder

C++
std::unique_ptr<IVoiceDecoder> CreateDecoder() const override

A stream decoder with its own Opus state, FEC, deep redundancy and packet-loss concealment. nullptr when Opus is unavailable.

EncodeFrame

C++
bool EncodeFrame(const int16_t* samples, uint32_t sampleCount, std::vector<uint8_t>& out) override

DecodeFrame

C++
bool DecodeFrame(const uint8_t* data, size_t len, std::vector<int16_t>& out) override

SupportsInbandFec

C++
bool SupportsInbandFec() const override

DecodeFecFrame

C++
bool DecodeFecFrame(const uint8_t* nextPacket, size_t len, std::vector<int16_t>& out) override

SetBitrate

C++
void SetBitrate(uint32_t bitsPerSecond)

Target bitrate for the VBR encoder, redundancy included. It leaves the 12 KB/s per-client budget mostly unspent.

GetBitrate

C++
uint32_t GetBitrate() const

SetInbandFecEnabled

C++
void SetInbandFecEnabled(bool enabled)

IsInbandFecEnabled

C++
bool IsInbandFecEnabled() const

SetDtxEnabled

C++
void SetDtxEnabled(bool enabled)

IsDtxEnabled

C++
bool IsDtxEnabled() const

SetExpectedPacketLoss

C++
void SetExpectedPacketLoss(uint32_t percent)

What the encoder assumes about the channel. FEC only spends bits when this is non-zero, so a session with no loss pays nothing for it.

GetExpectedPacketLoss

C++
uint32_t GetExpectedPacketLoss() const

SetRedundancyMilliseconds

C++
bool SetRedundancyMilliseconds(uint32_t milliseconds)

Deep redundancy (DRED): up to this many milliseconds of past speech ride in every packet at a low bitrate, so a burst of loss is rebuilt from the first packet after it instead of concealed. 0 turns it off. Returns false when the linked Opus was built without DRED.

GetRedundancyMilliseconds

C++
uint32_t GetRedundancyMilliseconds() const

GetDtxFrameCount

C++
uint64_t GetDtxFrameCount() const
Generated from VoiceChat/FVoiceOpusCodec.h via voicechat.json · Oct 26, 2026Version 1.0.0