FVoiceOpusCodec
- Module
- VoiceChat
- Header
#include "VoiceChat/FVoiceOpusCodec.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kSampleRate | Default 48000. |
static constexpr uint32_t | kFrameSamples | Default 960. |
static constexpr uint32_t | kDefaultBitrate | 32 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_t | kDefaultRedundancyMs | Half 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_t | kMaxEncodedBytes | The 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_t | kDtxMaxBytes | Opus emits one or two bytes for a frame it decided not to transmit. Default 2. |
Constructors
| Signature | Name | Description |
|---|---|---|
~FVoiceOpusCodec() override | ~FVoiceOpusCodec | |
FVoiceOpusCodec(const FVoiceOpusCodec&) = delete | FVoiceOpusCodec |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | IsAvailable | False when the Opus binaries were not vendored for this platform. |
std::unique_ptr<FVoiceOpusCodec> | TryCreate | nullptr when Opus is unavailable or the encoder/decoder refused to come up. |
FVoiceOpusCodec& | operator= | |
EVoiceCodecId | GetCodecId | |
const char* | GetName | |
uint32_t | GetSampleRate | |
uint32_t | GetFrameSamples | |
uint32_t | GetMaxEncodedBytes | |
std::unique_ptr<IVoiceDecoder> | CreateDecoder | A stream decoder with its own Opus state, FEC, deep redundancy and packet-loss concealment. |
bool | EncodeFrame | |
bool | DecodeFrame | |
bool | SupportsInbandFec | |
bool | DecodeFecFrame | |
void | SetBitrate | Target bitrate for the VBR encoder, redundancy included. |
uint32_t | GetBitrate | |
void | SetInbandFecEnabled | |
bool | IsInbandFecEnabled | |
void | SetDtxEnabled | |
bool | IsDtxEnabled | |
void | SetExpectedPacketLoss | What the encoder assumes about the channel. |
uint32_t | GetExpectedPacketLoss | |
bool | SetRedundancyMilliseconds | 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. |
uint32_t | GetRedundancyMilliseconds | |
uint64_t | GetDtxFrameCount |
Function details
~FVoiceOpusCodec
~FVoiceOpusCodec() overrideFVoiceOpusCodec
FVoiceOpusCodec(const FVoiceOpusCodec&) = deleteIsAvailable
static bool IsAvailable()False when the Opus binaries were not vendored for this platform. The class still links; every call simply fails.
TryCreate
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=
FVoiceOpusCodec& operator=(const FVoiceOpusCodec&) = deleteGetCodecId
EVoiceCodecId GetCodecId() const overrideGetName
const char* GetName() const overrideGetSampleRate
uint32_t GetSampleRate() const overrideGetFrameSamples
uint32_t GetFrameSamples() const overrideGetMaxEncodedBytes
uint32_t GetMaxEncodedBytes() const overrideCreateDecoder
std::unique_ptr<IVoiceDecoder> CreateDecoder() const overrideA stream decoder with its own Opus state, FEC, deep redundancy and packet-loss concealment. nullptr when Opus is unavailable.
EncodeFrame
bool EncodeFrame(const int16_t* samples, uint32_t sampleCount, std::vector<uint8_t>& out) overrideDecodeFrame
bool DecodeFrame(const uint8_t* data, size_t len, std::vector<int16_t>& out) overrideSupportsInbandFec
bool SupportsInbandFec() const overrideDecodeFecFrame
bool DecodeFecFrame(const uint8_t* nextPacket, size_t len, std::vector<int16_t>& out) overrideSetBitrate
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
uint32_t GetBitrate() constSetInbandFecEnabled
void SetInbandFecEnabled(bool enabled)IsInbandFecEnabled
bool IsInbandFecEnabled() constSetDtxEnabled
void SetDtxEnabled(bool enabled)IsDtxEnabled
bool IsDtxEnabled() constSetExpectedPacketLoss
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
uint32_t GetExpectedPacketLoss() constSetRedundancyMilliseconds
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
uint32_t GetRedundancyMilliseconds() constGetDtxFrameCount
uint64_t GetDtxFrameCount() const