#[repr(C)]pub struct AlecEncoderConfig {
pub history_size: u32,
pub max_patterns: u32,
pub max_memory_bytes: u32,
pub keyframe_interval: u32,
pub smart_resync: bool,
pub num_channels: u32,
}Expand description
Runtime configuration for a new ALEC encoder.
Mirrors the Milesight-integration defaults (history=20, patterns=256, memory=2048B, keyframe=50, smart_resync=true).
Pass a NULL pointer to alec_encoder_new_with_config to use all
defaults. Any numeric field set to 0 is replaced by its default, so
callers can opt in to a single override while keeping the rest.
num_channels is the only documented exception — 0 means “do not
pre-warm” (legacy behaviour), any positive value activates the
init-time pre-warm described below.
Fields§
§history_size: u32Per-source history window size. Default: 20.
max_patterns: u32Maximum patterns retained in the context dictionary. Default: 256.
max_memory_bytes: u32Maximum memory budget for the context in bytes. Default: 2048.
keyframe_interval: u32Interval (in messages) between forced Raw32 keyframes. Default: 50. Set to 0 to disable periodic keyframes.
smart_resync: boolIf true, the encoder honours downlink-driven resync requests
(via alec_force_keyframe). Default: true.
num_channels: u32v1.3.9 addition. Number of fixed channels to pre-allocate at
encoder-creation time. When > 0, alec_encoder_new_with_config
immediately allocates one SourceStats entry per channel (ids
1..=num_channels, matching the fixed_channel_source_id
convention), so the first call to alec_encode_multi_fixed
performs ZERO heap allocations.
Set to the number of channels your firmware uses (5 for the
Milesight EM500-CO2). 0 disables the pre-warm and keeps the
pre-v1.3.9 behaviour — the first encode allocates on demand,
which can panic on heaps partially consumed between
alec_encoder_new_with_config and the first encode.
Upper bound: 64 (matches Encoder::encode_multi_fixed’s
channel cap). Values above 64 are treated as 0.