CbrRateController class

Constructors

CbrRateController({required int targetBitrateBps, required double framerate, int minQi = 4, int maxQi = 63, int startQi = 32, double keyframeBoost = 5.0, double bufferWindowSeconds = 1.0, double qiStepGain = 16.0, int maxQiStepPerFrame = 6, double dropOvershootFullness = 0.75, int maxConsecutiveDrops = 3})

Properties

averageBitrate → double
Average bitrate achieved so far (bits/second).
no setter
bufferBits → double
no setter
bufferWindowSeconds → double
Length of the leaky-bucket window in seconds. Buffer drift is compared against targetBitrateBps * bufferWindowSeconds to derive the qi correction.
final
consecutiveDrops → int
no setter
currentQi → int
no setter
dropOvershootFullness → double
Drop the next inter frame when normalised buffer fullness (bufferBits / windowBits) exceeds this value. Default 0.75 means a frame is dropped once the leaky bucket has overshot by 3/4 of a window — cheaper than encoding at max qi on a starved link, and the canonical VC adaptation when the network can't drain bytes fast enough. Set to a very large value to effectively disable.
final
framerate → double
Nominal framerate in fps. Update via setFramerate when the actual capture/render rate changes.
no setter
framesEncoded → int
no setter
hashCode → int
The hash code for this object.
no setterinherited
keyframeBoost → double
Multiplier applied to the per-frame target budget when the next frame is a keyframe. Typical VP8 keyframes are 4–8x larger than a steady-state inter frame.
final
maxConsecutiveDrops → int
Upper bound on consecutive non-key drops, so a sudden drop in available bandwidth doesn't freeze the receiver indefinitely. The (maxConsecutiveDrops+1)’th frame is forced through even if the buffer is still overfull, letting the encoder visibly catch up.
final
maxQi → int
final
maxQiStepPerFrame → int
Hard clamp on |qi(n) - qi(n-1)| between consecutive frames. Prevents oscillation on transient size spikes.
final
minQi → int
final
qiStepGain → double
Maps normalised buffer fullness (bufferBits / windowBits) to qi units. With the default of 16.0, a buffer that has overshot by one full window worth of bits raises qi by 16 steps — enough to span most of the minQi..maxQi range from a startQi mid-point as fullness saturates at the ±2-window clamp inside update.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
startQi → int
final
targetBitrateBps → int
Target bitrate in bits/second. Update via setTargetBitrate to react to network changes mid-stream.
no setter
targetBitsPerFrame → double
Target bits per non-key frame at steady state.
no setter
totalBitsEmitted → int
no setter
totalDropped → int
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
noteDrop() → void
Record that a frame was dropped (no bits emitted). The buffer still drains by one frame’s worth of target bits because the real-time clock advanced even though we sent nothing.
pickQi({required bool isKey}) → int
Pick a qi for the next frame. Call before encoding.
reset() → void
Reset all in-flight controller state (leaky bucket, frame / byte / drop counters, current qi back to startQi). The configured bitrate / framerate / qi window are NOT touched. Pair with Vp8Encoder.reset when restarting a session.
setFramerate(double newFps) → void
Change the nominal framerate at runtime. The leaky bucket is NOT reset. Throws if newFps <= 0.
setTargetBitrate(int newBps) → void
Change the target bitrate at runtime. Useful for ABR drivers reacting to network feedback. The leaky bucket is NOT reset — existing drift propagates into the new operating point so the controller smoothly transitions. Throws if newBps <= 0.
shouldDrop({required bool isKey}) → bool
Return true if the next non-key frame should be dropped instead of encoded. Keyframes are never dropped (recovery must be possible).
toString() → String
A string representation of this object.
inherited
update({required int frameBytes, required bool isKey}) → void
Update the controller after encoding a frame. frameBytes is the size of the produced bitstream (in bytes).

Operators

operator ==(Object other) → bool
The equality operator.
inherited