827 lines
55 KiB
Markdown
827 lines
55 KiB
Markdown
# WebRTC Adaptation And Encoder Reuse
|
||
|
||
Initial review: 2026-09-08. The early review and probes below compare the fixed-output
|
||
candidate with mature encoder adaptation. The later [Windows product attachment](#windows-product-attachment)
|
||
and [compatible output groups](#compatible-output-groups) record the published integration.
|
||
[ADR-0013](../adr/0013-embedded-node-local-media.md) owns the direct-child/shared-output
|
||
model; [media quality](../standards/media-quality.md) owns current behavior.
|
||
|
||
## Pinned Baseline
|
||
|
||
The initial review used Chrome 152.0.7977.82. Its [DEPS][chromium-deps] pins libwebrtc
|
||
to `6f37672d358475cd17544121a12494da454d85fb`; WebRTC references below use that
|
||
revision, not a floating upstream branch. Source shows available mechanisms,
|
||
not which field trials or hardware encoder a particular runtime selected.
|
||
The initial Piik comparison used the `3c192ddd` candidate, not production.
|
||
|
||
## Actual Control Ownership
|
||
|
||
```text
|
||
receiver transport feedback
|
||
-> GoogCC: network target, pacing, probes, congestion-window updates
|
||
-> Call / BitrateAllocator: per-media allocation
|
||
-> RtpVideoSender: transport, RTP, packetization and NACK/FEC costs
|
||
-> VideoStreamEncoder: layer rates and encoder feedback
|
||
-> VideoEncoder: encode, SetRates, encoded callback
|
||
-> RTP packetization / pacer -> network
|
||
|
||
encoded QP, bytes, drops and completion timing
|
||
-> quality/bandwidth scaler and encode-usage resource
|
||
-> ResourceAdaptationProcessor / VideoStreamAdapter
|
||
-> source pixel/FPS restrictions -> adapted input / encoder reconfiguration
|
||
```
|
||
|
||
These are connected but different owners:
|
||
|
||
| Owner | What it actually decides |
|
||
| --- | --- |
|
||
| [Transport controller][transport] / GoogCC | Estimates network capacity and drives pacing/probing, not a pixel-size ladder. |
|
||
| [RtpVideoSender][rtp-budget] | Computes the video payload budget after transport and protection costs. Network BWE is not the encoder's payload target. |
|
||
| [SimulcastRateAllocator][simulcast-rates] | Allocates among configured layers with activation minima/hysteresis and temporal rates. It does not derive their dimensions from BWE. |
|
||
| [VideoStreamEncoder][vse] | Applies target/adjusted rates, optional overshoot correction, queue/frame dropping and encoded feedback. One instance has one resource-adaptation chain, not one complete controller per RID. |
|
||
| [Resource manager][resources] | Uses trusted QP and drops, or eligible bandwidth-quality scaling, plus encode-time pressure. These paths depend on actual encoder capabilities and configuration. |
|
||
| [VideoStreamAdapter][video-adapter] | Requests fewer pixels or FPS according to degradation preference and resource constraints; a pre-encoded fixed tier is not required. |
|
||
|
||
For example, the adapter can request at most 3/5 of the current pixel count or
|
||
reduce FPS to 2/3 under the corresponding preference. These are upstream rules,
|
||
not proposed Piik constants. The default [encoder minimum][encoder-api] is
|
||
320x180 pixels and can be overridden; no universal 108p floor is established.
|
||
VP8's [libvpx adapter][vp8] disables libvpx internal resizing because WebRTC owns
|
||
that work outside the codec. Turning on libvpx resizing alone does not restore
|
||
the omitted control chain.
|
||
|
||
### Motion And Simulcast Are Not Synonyms
|
||
|
||
Piik's `motion` hint becomes `kFluid` in the [Chromium sink][chromium-hint].
|
||
[VideoRtpSender][sender-hint] then sets `is_screencast=false`; this follows the
|
||
realtime-video path even for display capture. Explicit degradation preference
|
||
still has precedence over the hint's default. Do not assume all display capture
|
||
uses WebRTC's special screen-content policy.
|
||
|
||
At this pin, the [media engine][media-engine] permits its automatic quality
|
||
resizing path only when eligible and there is one configured SSRC or one active
|
||
stream. Multiple active simulcast outputs therefore do not each acquire an
|
||
independent version of that resizing path. The [simulcast encoder adapter][simulcast-encoder]
|
||
coordinates per-output codecs, rates, scaling and keyframes; it is not a pool
|
||
across independent PeerConnections. Adding a third preset cannot establish parity.
|
||
|
||
## Fixed-Output Native Gap (2026-09-08)
|
||
|
||
`nativecapture.ScreenShareOutputs` constructs original plus half-size outputs
|
||
at the same FPS. `mediaedge.Source.BeginFrame` chooses activation and lowers the
|
||
lowest encoder's bitrate from its consumers' budgets. Windows `OutputWorker`
|
||
keeps one fixed profile for its lifetime. At 1080p the lowest nominal output is
|
||
960x540, not a dynamically shrinking fallback. Bounded raw mailboxes isolate
|
||
overload but do not automatically reduce the requested encoding work.
|
||
|
||
Pion supplies transport; LiveKit media components supply BWE, forwarding,
|
||
allocation, recovery and pacing. They do not supply the omitted libwebrtc raw
|
||
source/encoder resource-adaptation chain. That candidate's source-RTP cost adjustment
|
||
also is not the full `RtpVideoSender` overhead/protection calculation. These are
|
||
concrete missing integrations, not evidence that either library is defective.
|
||
The existing constrained-codec recovery evidence remains valid within its scope,
|
||
but cannot establish Browser-equivalent behavior below the fixed lowest size.
|
||
|
||
## Where A Pool Can Fit
|
||
|
||
[VideoEncoderFactory][encoder-factory] is a real native injection point. Its
|
||
`Create(env, format)` returns a `VideoEncoder`; it is not exposed by Browser JS
|
||
and does not receive a source/stream identifier. A source-scoped integration
|
||
must establish that identity without guessing from dimensions or timestamps.
|
||
Pion currently has no libwebrtc encoder factory to override: retaining the full
|
||
chain requires a native-library integration decision, not only a new Go cache.
|
||
|
||
Shared encoded payload buffers are supported by [EncodedImage][encoded-image].
|
||
That makes payload reuse possible, not automatically correct. The narrow
|
||
adapter would have to preserve all of the following:
|
||
|
||
1. **Compatible demands.** Codec/profile, source generation, dimensions,
|
||
cadence, rate allocation and reference state must agree. `SetRates` applies
|
||
until replaced; last-writer-wins, unconditional minimum, or unconditional
|
||
maximum would violate another consumer's quality or budget. Resolution-only
|
||
keys are insufficient. Exact compatibility may produce little reuse and
|
||
needs measurement before introducing any grouping heuristic.
|
||
2. **Compatible frame dependencies.** Each VSE can drop different inputs before
|
||
calling `Encode`. If A encoded frame F but B skipped it, a later shared
|
||
interframe may reference F that B never received. Skipping a whole input is
|
||
not equivalent to ordinary packet loss that NACK can repair. Splitting and
|
||
rejoining must use codec-safe recovery, not arbitrary callback suppression.
|
||
3. **Separate callback ownership.** Each virtual encoder owns initialization,
|
||
keyframe requests, release and its callback. Reuse immutable payload bytes,
|
||
not one mutable metadata object. Preserve each caller's RTP/input identity,
|
||
codec descriptors, QP and completion semantics.
|
||
4. **Honest resource feedback.** [Frame metadata][frame-metadata] matches the
|
||
caller's timestamp and measures its encode-start/completion interval. A cache
|
||
hit can appear cheap despite a busy shared physical encoder. Validate the
|
||
resulting resource decisions; do not fabricate CPU/QP evidence to keep reuse.
|
||
5. **Unadapted source availability.** [VideoBroadcaster][broadcaster] aggregates
|
||
minimum maximum-pixel/FPS restrictions across sinks; requested-resolution
|
||
aggregation is a separate path. A pool cannot recreate input detail already
|
||
removed upstream. Retain original capture and validate sibling isolation.
|
||
|
||
Therefore the owner's abstraction is useful, but a transparent cross-sender
|
||
pool preserving every independent control decision is not established by the
|
||
factory API alone. The experiment below distinguishes that from a pool owning
|
||
the physical encoder's correction state.
|
||
Per-node encoding cost follows the number of compatible active representations,
|
||
not automatically a fixed three encodes regardless of downstream conditions.
|
||
Already-encoded Native relay/SFU forwarding must remain zero-encode when usable;
|
||
an encoder factory by itself does not implement that bypass.
|
||
|
||
## Mature Precedent And Reuse
|
||
|
||
Epic's [Pixel Streaming 2 migration guide][epic-migration] records removal of
|
||
its former one-stream/one-quality-controller sharing because of stalls and
|
||
freezes, recommending per-peer encoding or its SFU. The older
|
||
[settings guide][epic-settings] explicitly describes mismatched client quality
|
||
under that design. This is a warning against selecting one peer's conditions
|
||
for everyone, not proof that a compatible-output pool cannot work.
|
||
|
||
Reuse upstream encoder factories, codec adapters, simulcast allocation,
|
||
resource adaptation and projection where their contracts fit. No reviewed
|
||
source supplies a production-ready pool with all five obligations above.
|
||
The WebRTC [test proxy factory][test-proxy] simply delegates to one encoder;
|
||
it supplies no callback/rate arbitration or frame deduplication. An embedded
|
||
forwarding SFU should keep the current mature forwarding components; it normally does not
|
||
encode, so sharing representations/demand is the common boundary, not forcing
|
||
every SFU subscriber through a codec factory.
|
||
|
||
The libwebrtc [build guide][webrtc-build] describes a native GN/Ninja dependency
|
||
build. Its headers are not a stable Go plug-in ABI. Evaluate reproducible build,
|
||
update and package cost before replacing the Native media engine. WebRTC code
|
||
retains its BSD-style license and PATENTS grant, dependencies their own notices.
|
||
Epic's infrastructure MIT license does not license Unreal Engine/EpicRtc code.
|
||
This review copies no upstream implementation and adds no product dependency.
|
||
The opt-in probe linked the pinned SDK only under the ignored build directory.
|
||
|
||
## Executed Feasibility Probe
|
||
|
||
The [archived 2.x source and build recipe](https://github.com/TNTcraftHIM/Piik/blob/eef70ffda0ffddce6aec109521ab70871e5b7c2f/native/probes/encoder-pool/README.md)
|
||
used Shiguredo `m152.7977.0.2`, whose WebRTC revision exactly matches the pin
|
||
above. Its relevant vendor differences are disabled built-in H264 and disabled
|
||
pacer keyframe flushing; this VP8 encoder-only probe uses neither path.
|
||
Matching SDK headers/static library and official MSVC libraries/linker were
|
||
used. No desktop capture, ports, game, production service or CI job was involved.
|
||
|
||
Two actual VSEs receive one synthetic 640x360@30 source through separate stock
|
||
VideoAdapters. Both receive identical 2 Mbps budgets/feedback cadence; B alone
|
||
gets 100 kbps for 15 seconds and then returns to 2 Mbps for 25 seconds.
|
||
Degradation preference is maintain-framerate to expose spatial adaptation.
|
||
This supplies encoder budgets, not a simulated full GoogCC/packet network.
|
||
The driver drains queues between inputs, so it is not a throughput benchmark.
|
||
|
||
The factory starts with exact codec/rate compatibility and one cached access
|
||
unit per physical encoder. Different requests split, compatible streams rejoin
|
||
on a keyframe, and each VSE gets its own metadata/callback with shared payload.
|
||
Attempted input and successful reference identity are separate so a codec drop
|
||
is not submitted twice. RTT/loss are excluded only because the guarded realtime
|
||
VP8 L1T1 implementation's [DefaultTemporalLayers][vp8-default-temporal] ignores them.
|
||
|
||
Three forms were exercised, plus an explicit disabled-adjuster ablation:
|
||
|
||
| Form | Healthy 6-second physical Encode calls | Delivered frames per consumer | Result |
|
||
| --- | ---: | ---: | --- |
|
||
| Independent encoders, stock VSE correction | 360 | 180 / 180 | Control |
|
||
| Shared factory, separate unchanged VSE correction | 337 | 180 / 180 | Only 23 reuses; independent adjusted targets soon differ |
|
||
| Shared factory and one upstream corrector per physical encoder | 187 | 180 / 180 | 173 reuses, about 48% fewer calls in this phase |
|
||
|
||
Both VSEs can have the same 2 Mbps logical target but ask their encoder for
|
||
different corrected rates, such as about 1.67 versus 1.59 Mbps. The upstream
|
||
[EncoderBitrateAdjuster][bitrate-adjuster] observes encoded size/timing to
|
||
correct overshoot; it is not a resolution selector or a receiver-supplied QP.
|
||
Disabling it only for diagnosis restored healthy reuse, locating the conflict.
|
||
The viable probe form instead instantiates that same library class per physical
|
||
encoder and feeds each physical output once. It does not delete correction or
|
||
choose one peer as quality authority.
|
||
|
||
In the final paired full runs, both forms first reduced B at about 4.04 seconds,
|
||
reached 320x180, and first returned to 640x360 about 24.05 seconds after release.
|
||
A remained full-size at about 30 fps. The pooled form resumed shared output after
|
||
recovery and reused 87 frames in the following 3-second, single-skipped-input
|
||
phase. Both groups fully retired, with at most two live physical encoders.
|
||
Repeated earlier runs showed the same broad transitions. This does not promise
|
||
fast or seamless recovery: the measured upward delay was substantial in both.
|
||
|
||
Weak-phase delivery was not identical: the final control decoded 154 frames
|
||
(10.27 fps, 85.3 kbps), versus 142 (9.47 fps, 95.1 kbps) for the pooled form.
|
||
Splitting/rejoining also produces extra keyframes. Do not infer perceptual or
|
||
congested-network parity from matching dimensions and transition times.
|
||
|
||
WebRTC decoding checked usability; raw libvpx with postprocessing disabled
|
||
checked matching-payload reference correctness. The [stock VP8 decoder][vp8-decoder]
|
||
enables history-dependent MFQE on x64, so comparing its postprocessed pixels
|
||
after different histories produced one misleading mismatch during development.
|
||
The corrected final full pooled run compared 288 shared payloads with zero raw
|
||
pixel mismatches. Removing reference-continuity protection in a negative
|
||
control produced 29 mismatches despite successful decoder calls. The guard is
|
||
necessary, not decorative defensive code. [Structured results](./data/webrtc-encoder-pool.json)
|
||
contain no frame payloads or private identifiers.
|
||
|
||
### Verdict And Remaining Scope
|
||
|
||
- **An unchanged factory cache alone does not meet the goal.** Independent
|
||
encoder-side correction fragments otherwise equal nominal demands.
|
||
- **The shared-encoder abstraction passes a narrow executable feasibility
|
||
check when physical correction state shares that owner.** It reuses real
|
||
encoding, retains stock spatial adaptation and can split/rejoin safely in
|
||
this VP8 case. At that point, no engine replacement had been selected or integrated.
|
||
- The group invokes correction on actual frames, with rate-write deduplication;
|
||
stock VSE does so on rate/configuration/FPS updates. The algorithm is reused,
|
||
but this cadence change must not be described as an otherwise identical move.
|
||
- Default VP8 trusts its rate controller, so pre-encoder media-optimization
|
||
dropping is inactive here. Other encoders need the corresponding drop feedback:
|
||
it is outside VideoEncoder's callbacks. Codec drops must not impersonate it.
|
||
- Per-VSE encode timing still differs for a physical encode and a cache hit.
|
||
H264 hardware/asynchronous execution, actual resource overload, transport
|
||
overhead, received-source bypass and perceptual parity remain unverified.
|
||
These are integration gates, not reasons to disable mature adaptation.
|
||
|
||
The reusable boundary is an encoding instance plus its encoder-side state, not
|
||
just `Encode(frame)`. Before product replacement, resolve those remaining
|
||
feedback owners through upstream interfaces; do not accumulate quality formulas
|
||
or silently reintroduce per-child encoders as the ordinary product model.
|
||
|
||
## Cross-Level Reuse
|
||
|
||
The shared boundary already exists in `mediaedge.Source`. A Native Receiver
|
||
feeds received packets directly through `Source.WriteRTP` into LiveKit buffers
|
||
and DownTrack projection. It does not call a decoder or encoder to forward an
|
||
available representation. Local capture/derivation instead supplies complete
|
||
codec output through `Source.WriteVideo`. The pool fits behind that second
|
||
entry, not in front of every received packet:
|
||
|
||
```text
|
||
received original -> existing per-child RTP forwarding -> healthy descendants
|
||
-> missing direct-child output only
|
||
-> one real decode -> VSE / shared physical encoder
|
||
-> Source.WriteVideo -> child transport
|
||
```
|
||
|
||
The factory's first 180 real VP8 output AUs were exported and replayed through
|
||
five actual loopback Pion connections: Host to R1 to R2, with one leaf attached
|
||
at each source. Both Native receivers had normal derivation capability and
|
||
profiles enabled. The final trace delivered 180, 167 and 167 contiguous AUs at
|
||
the three leaves, starting at indexes 0, 13 and 13 respectively. Every received
|
||
AU matched an original SHA-256 hash, beginning with independent recovery; no
|
||
derivation run was observed at either relay. Earlier runs began at the later
|
||
recovery index 19. The prerecorded source cannot answer live PLI requests, so
|
||
this startup interval is not a capture/join-latency measurement.
|
||
|
||
An extension to the existing Native derivation fixture separately verified
|
||
640x360 original forwarding alongside one 320x180 derived output, then two
|
||
compatible low consumers sharing the same live derivation process. Retiring
|
||
one low consumer left the other receiving new frames; retiring the last stopped
|
||
the process. The original input stayed encoded. Target layers/budgets in this
|
||
fixture are forced to test ownership, not prove automatic network selection.
|
||
Both checks passed together and cleaned up. The test awaits Pion's graceful
|
||
completion outside callbacks rather than equating concurrent `Close()` return
|
||
with completed transport teardown. [Recorded evidence](./data/webrtc-encoder-chain.json)
|
||
contains counters and hashes, not media or private connection identifiers.
|
||
|
||
These measurements establish zero additional encoding on the observed healthy
|
||
Native hops, and local sharing of a genuinely missing output. They do not yet
|
||
connect the new VSE pool to that native derivation process: the source-pool,
|
||
network replay and existing-codec derivation are separate verified boundaries.
|
||
The original AUs were already decoded in the C++ probe; byte-identical contiguous
|
||
forwarding is not another Browser playback, original-clock or loss-recovery gate.
|
||
|
||
"One encoding for the whole tree" requires one active source representation
|
||
and Native/SFU intermediate forwarding nodes. Pure Browser intermediate nodes
|
||
still encode through their normal senders; Browser leaves add decoding only.
|
||
If Host keeps pre-encoded lower standby outputs, those encodes must also be
|
||
counted. The current packaged producer still constructs original plus half-size;
|
||
neither this one-output replay nor a no-extra-hop result silently changes the
|
||
accepted envelope policy. The pool probe also has occasional split/rejoin work,
|
||
so its healthy case is close to one encode per frame, not an unconditional bound.
|
||
|
||
### Initial Integration Direction
|
||
|
||
Keep the existing Pion/LiveKit transport, estimator, pacer and projection per
|
||
edge. Codec-only `VideoStreamEncoder::OnBitrateUpdated` accepts an external
|
||
budget without constructing a GoogCC controller, Call or PeerConnection.
|
||
`relayPlan` already recognizes missing output from observed positive bandwidth
|
||
and paused/lower forwarding demand. It does not need to choose pixel dimensions;
|
||
VSE and stock `VideoAdapter` can make that decision from the actual raw input.
|
||
A healthy original consumer needs neither VSE nor a fabricated raw frame.
|
||
|
||
The owning source can reuse `OnDemandChanged` to signal work, never reenter
|
||
transport synchronously under its locks. This callback is not currently wired
|
||
by Native `NewEdge`; current relay demand is reevaluated at input markers.
|
||
Budget-to-payload conversion, dynamic output association in bounded source slots,
|
||
physical resource feedback and decoder-safe switching remain concrete integration
|
||
work. Connecting those owners is narrower than replacing the transport engine,
|
||
but its total change/maintenance cost is not yet measured. A low-quality received
|
||
source still cannot manufacture missing detail; higher input or the existing
|
||
bounded topology operation must supply it. No subtree quality minimum or new
|
||
congestion algorithm is introduced by this direction.
|
||
|
||
## Scheduling And Resource Follow-Up
|
||
|
||
The initial probe drained each VSE queue between consumers. A later
|
||
`--realtime` arm keeps the 30 fps source cadence without that drain and flushes
|
||
queues only at phase boundaries. Its healthy six seconds used exactly 180
|
||
physical encodes for two 180-frame receivers, with zero decoded-hash mismatch.
|
||
This improves the fixture's scheduling realism, not a one-encode guarantee for
|
||
all devices, rates or source histories.
|
||
|
||
The bounded `--latency-probe` inserts 45 ms before each physical VP8 encode at
|
||
640x360, proportional to pixel area at lower sizes. It is a synthetic service
|
||
delay, not CPU saturation, desktop capture or a hardware-driver test. The
|
||
prototype's registry mutex serializes physical groups, so this arm stresses
|
||
ownership and is not a performance comparison with independent parallel codecs.
|
||
|
||
Under that delay, the two-VSE shared-codec form developed repeated independent
|
||
input-drop divergence. During 30 seconds, A/B decoded 391/378 frames and produced
|
||
146/149 keyframes; the full trace created 115 codec groups and made 218 group
|
||
changes. Reference protection kept the decoded payloads correct, but this churn
|
||
is not acceptable product behavior. Both returned to about 30 fps after release.
|
||
This is a counterexample to accepting the factory-cache boundary from its
|
||
healthy result alone, not proof that all shared encoders must behave this way.
|
||
|
||
A `--shared-pipeline` control instead gives both consumers one complete stock
|
||
VSE/source-adaptation/encoder pipeline. It has no per-consumer encoder factory
|
||
cache and leaves upstream overshoot/resource handling enabled. In the same
|
||
delay trace, both decoded the same 484 frames with no new keyframe during the
|
||
delayed phase; the whole trace created three encoder instances, only for normal
|
||
configuration changes, and no split/rejoin cycle. Both consumers' resource
|
||
fields in this control refer to the same pipeline, not two independent sensors.
|
||
|
||
Neither delayed arm delivered a smaller picture until after latency was
|
||
released; both subsequently showed 480x270 and recovered full size. Do not claim
|
||
complete overload adaptation or perceptual parity from these runs. The useful
|
||
result is narrower: shared input admission and shared resource ownership avoid
|
||
one source of duplicate-controller churn. Different-child-budget grouping,
|
||
transport coupling and actual hardware still need evidence.
|
||
[Structured traces](./data/webrtc-encoder-latency.json) retain those limits.
|
||
|
||
The pinned library also has `EncodeUsageResource`, `OveruseFrameDetector` and
|
||
`BroadcastResourceListener` for one resource feeding multiple send streams.
|
||
VSE exposes `AddAdaptationResource` but no public removal counterpart; registering
|
||
a new resource after each group change would retain old restrictions until
|
||
Stop. A stable per-VSE forwarding resource can avoid that, but is additional
|
||
coordination, not a reason to add it before the simpler shared-pipeline boundary
|
||
has been evaluated. Do not disable local CPU detection unless an honest shared
|
||
measurement replaces it, or replay a cached frame's timing as physical work.
|
||
|
||
Windows H264 need not be rewritten: existing `LiveEncoder` already has bounded
|
||
Encode, SetBitrate and retirement around MFT. A shared extraction plus an adapter
|
||
can preserve that implementation. Truthful codec information, requested FPS,
|
||
actual QP availability, and dynamic output dimensions remain integration work;
|
||
the old fixed `OutputWorker` policy is not a requirement to restart WGC capture.
|
||
The following H264 step first verified that extraction and opt-in adapter;
|
||
the subsequent product attachment is recorded below.
|
||
|
||
### Hardware H264 Adapter Check
|
||
|
||
The 2.x Windows `LiveEncoder` and its MFT/device helpers shared one
|
||
[H264 implementation](https://github.com/TNTcraftHIM/Piik/blob/72ca6f2bc97df88e216a392721250309aa53bc39/native/capture/windows/h264_encoder.cpp). Both
|
||
the capture binary and the opt-in probe linked it; WGC, source selection, audio,
|
||
profile application and capture retirement retain their existing owners.
|
||
The probe adapter converts synthetic I420 to NV12 and uploads it for MFT.
|
||
This validates the native encoder interface, not a zero-copy capture path.
|
||
|
||
One complete stock VSE owns rates, pre-encoder dropping, correction and resource
|
||
feedback. The adapter reports untrusted hardware rate control and unavailable
|
||
QP, rather than claiming the VP8-specific cache feedback applies to H264.
|
||
It preserves callback timestamps and shares immutable encoded bytes. SetRates
|
||
uses the configured/requested-FPS bitrate compensation in Chromium's
|
||
[Media Foundation adapter][chromium-mf]; zero budget pauses instead of writing
|
||
an invalid MFT bitrate. WebRTC's [codec initializer][codec-initializer] owns
|
||
default H264 settings and the single temporal layer.
|
||
|
||
The bounded 640x360@30 run produced 174 physical encodes during six seconds,
|
||
delivering 174 byte-identical AUs to each consumer. First output took about
|
||
275 ms. Removing B left A receiving 60 further frames over two seconds.
|
||
One physical encoder was created and all resources retired; there was no
|
||
split/rejoin. The pinned SDK has no H264 decoder, so its C++ decoded counters
|
||
are explicitly zero. Two Chrome WebCodecs decoders subsequently each decoded
|
||
the exported first 180 AUs with the expected dimensions/timestamps and no
|
||
reported errors. The last six exported AUs followed B's retirement; this is
|
||
bitstream validation, not a claim that both actual consumers received 180.
|
||
|
||
[Structured results](./data/webrtc-h264-pipeline.json) retain that narrow scope.
|
||
These initial checks do not establish independent weak-child adaptation,
|
||
overload, actual capture throughput, transport overhead or App integration.
|
||
|
||
The concrete product attachment is `OutputWorker::Run`, shared by WGC and
|
||
encoded-input derivation. Its fixed-size/FPS/direct-rate block can become a
|
||
complete VSE while retaining the bounded mailbox, generation fence and
|
||
stop/join lifecycle. Bind the H264 adapter to the existing D3D device and reuse
|
||
`FrameConverter`/owned decoded NV12, rather than introducing the probe's CPU
|
||
round-trip into normal capture. Preserve one timestamp domain across Begin and
|
||
AUs: rounding a 100 ns capture timestamp down to WebRTC microseconds can put
|
||
the first AU before its Begin anchor. Dynamic output sizes must update the
|
||
forwarding format metadata as well as `Source.SetFormat`; ordinary adaptation
|
||
must not rebase the whole source generation.
|
||
|
||
The remaining grouping boundary is not transport-independent bookkeeping yet:
|
||
the initial `OutputPlan`/`relayPlan` collapsed demand into one lowest bitrate.
|
||
The grouped integration below replaces that owner. The SDK's bundled libvpx
|
||
and notices now replace the separate capture dependency. Those were concrete
|
||
implementation costs, not solved by the healthy two-callback check above.
|
||
|
||
### Windows Product Attachment
|
||
|
||
`OutputWorker` now uses one complete stock VSE/VideoAdapter per shared local
|
||
output, for both WGC and encoded-input derivation. The original capture, bounded
|
||
mailbox, generation checks and cancellable pipe writer remain. H264 receives
|
||
same-device NV12 directly; stock VP8 uses I420 readback. The returned AU retains
|
||
its exact input timestamp rather than rounding it through WebRTC microseconds.
|
||
The source publishes adapted dimensions through an immutable metadata snapshot;
|
||
calling LiveKit's full track-info update for each size change would reset every
|
||
active layer's bitrate tracker and was rejected by a focused regression.
|
||
|
||
The product build now links the same pinned SDK, including its libvpx, instead
|
||
of a second standalone libvpx build. The Windows capture executable is about
|
||
8.0 MB and imports only Windows system DLLs/API sets. Cached SDK and official
|
||
MSVC archives total about 816 MB, not package payload. SDK notices are retained
|
||
in the package; no new daemon or runtime service is added.
|
||
|
||
The opt-in `TestAdaptiveOutputFixture` sends synthetic encoded input through the
|
||
actual capture executable: six seconds at 2 Mbps, fifteen at 100 kbps, then
|
||
restoration to 2 Mbps. VP8 delivered 178 full-size healthy frames, 94 reduced
|
||
frames during the limited interval and 26 full-size restored frames within
|
||
the first 25 seconds after release. Source timestamps remained ordered.
|
||
|
||
H264 exposed two interface differences. Unconditionally marking QP untrusted
|
||
selected the bandwidth-quality scaler rather than Chromium's usual parsed-QP
|
||
path. The adapter now allows VSE's existing H264 parser and uses upstream
|
||
24/37 quality-scaler thresholds, without a custom controller. The existing MFT
|
||
implementation also forced a one-frame VBV at initialization. Updating only
|
||
mean bitrate left about 118 kbps output after restoration; attempting to change
|
||
VBV dynamically failed driver readback and was removed. Chromium does not set
|
||
that VBV override. Deleting the override and its exact-value assertion restored
|
||
about 1.9 Mbps while retaining CBR and low-latency mode.
|
||
|
||
The remaining delay was visible in upstream logs: parsed QP fell to 22-25 but
|
||
the low-QP smoother remained above the 24 upscale threshold. In a 76-second run,
|
||
resolution returned via 480x270 to 640x360 around 50-55 seconds from start,
|
||
about 29-34 seconds after budget restoration. Counts were 178 healthy full-size,
|
||
265 limited reduced-size and 686 restored full-size frames, 2,105 total. No
|
||
connection/pipeline reset or new timer forced recovery. Temporary internal
|
||
tracing was removed after this diagnosis. This is eventual recovery, not a
|
||
low-latency recovery guarantee; Intel-specific QP capability quirks and actual
|
||
overload still need hardware evidence.
|
||
|
||
Auto VP8 measurement now uses the actual VSE path rather than benchmarking an
|
||
encoder with different live settings. H264's existing successful-hardware probe
|
||
path remains. The four-second decision budget is unchanged. Current grouping
|
||
at that point still folded multiple weak consumers into one low budget; the
|
||
following integration addresses that independent requirement.
|
||
|
||
#### H264 Burst And Recovery
|
||
|
||
A 2026-11-03 Windows 2.x control traced Native H264 scene-change delay through
|
||
normal Host approval, real clicks on an owned window, capture and Browser
|
||
presentation. At a 5 Mbps / 30 fps ceiling, the actual 826×612 output supplied
|
||
six AUs of 170–181 KB, each marked `Recovery=false`.
|
||
Matching source packets and received frame timestamps placed 154–168 ms in the
|
||
send queue before dequeue; the segmented writer control observed no synchronous
|
||
write over 5 ms. The five-click input-to-compositor median was 235.1 ms.
|
||
|
||
A follow-up with the original settings parsed all six 172–182 KB AUs through
|
||
Pion's H264 reader with SEI included. Each contained one type-1 non-IDR VCL NAL;
|
||
AUD, prefix NAL and Annex-B start codes accounted for only 19 bytes. There was
|
||
no SEI or trailing zero padding. All 139 observed wire markers matched their
|
||
source AU uniquely, and the six large AUs spent 155–170 ms in the send queue.
|
||
The burst is coded picture data, not removable filler. `Recovery=false` remains
|
||
an independent encoder flag; a type-1 NAL does not identify its slice type.
|
||
|
||
A candidate applied optional H264
|
||
[HRD buffer size](https://learn.microsoft.com/en-us/windows/win32/directshow/avenccommonbuffersize-property)
|
||
in bytes, using one frame of the current rate at initialization and live updates.
|
||
In the same control it reduced the largest AU to 38 KB and the median to
|
||
54.5 ms, with matching sampled colours. The existing 76-second
|
||
`TestAdaptiveOutputFixture` then rejected it: after 2 Mbps → 100 kbps → 2 Mbps,
|
||
output remained 320×180 at about 120–124 kbps through the end, with no restored
|
||
full-size frames. Optional setters did not avoid the earlier recovery failure.
|
||
The candidate was removed and was not applied to the Rust MF owner. Its latency
|
||
gain does not justify restoring the one-frame HRD override; the existing
|
||
encoding and pacing settings remain.
|
||
|
||
On 2026-11-04, normal Rust App controls used the same owned 826×612 textured
|
||
window at a 5 Mbps / 30 fps ceiling. All twelve scene changes reached Browser
|
||
presentation in each run. The existing MF settings produced a 274 ms median
|
||
paint-to-presentation delay; an optional `CODECAPI_AVLowLatencyMode` request
|
||
produced 259 ms, with maxima of 333 and 360 ms respectively. These measurements
|
||
cover the combined capture-to-presentation path, without assigning that delay
|
||
to one stage or treating receive-counter intervals as exact AU sizes.
|
||
|
||
A same-SDK WGC/encoding/transport control changed only that MF request, using
|
||
8 Mbps → 600 kbps → 8 Mbps and an independent healthy connection. Without the
|
||
request, both weak-connection feeds stayed on Original from about 3–4 seconds
|
||
after restoration; with it, one remained Limited at the 20-second endpoint.
|
||
The latter's lower allocation matched its observed transport budget, so this
|
||
pair does not establish an MF rate-control defect. The optional request was
|
||
removed: it supplied no clear presentation benefit and did not pass the
|
||
restoration target.
|
||
|
||
With the restored settings, a normal App's twelve scene changes had a 260 ms
|
||
median paint-to-last-packet delay and 4.9 ms from reception to composition.
|
||
A separate metadata-only Native build uniquely matched twelve presented RTP
|
||
timestamps through the same capture, encoder, IPC and sender. MF input-to-output
|
||
took a median 1.0 ms; the dominant cost was outgoing burst serialization.
|
||
Eight 215–225 KB access units took 179–265 ms from SDK admission to successful
|
||
primary-marker UDP submission, with observed connection feedback of 5.57–7.35 Mbps.
|
||
Three 9–11 KB units instead waited 223–244 ms for the preceding large AU to drain,
|
||
then entered the SDK within 0.1 ms of its marker submission. This follows the
|
||
existing whole-AU admission owner and upstream's
|
||
[bandwidth-based pacer](https://github.com/algesten/str0m/blob/3b5b7ed1ff25d9432a87336a20bc2de336896db3/src/pacer/control.rs).
|
||
The workload, default media settings and SDK policy stayed unchanged.
|
||
|
||
The same hardware accepted `LowDelayVBR` and retained it after format setup.
|
||
Across the 65-second control, its largest source AU fell from 226 KB to 116 KB;
|
||
the twelve scene changes had a 121 ms median paint-to-composition delay versus
|
||
259 ms with CBR. BWE remained in the same range, with a somewhat higher median.
|
||
This establishes smaller encoded bursts and faster presentation for this workload.
|
||
Its first bandwidth-restoration control still ended Limited: the 1.24 Mbps
|
||
estimate stayed below the 2.69 Mbps original supply cost.
|
||
|
||
Piik now passes selected original supply cost to the existing SDK
|
||
[`minimum` transmit demand](https://github.com/algesten/str0m/blob/3b5b7ed1ff25d9432a87336a20bc2de336896db3/src/bwe/api.rs),
|
||
separately from configured desired capacity. The SDK fills the media gap within
|
||
its estimate and owns congestion suppression and probing. With that adapter,
|
||
the same control first adopted both Original feeds 6–7 seconds after bandwidth
|
||
restoration and kept them from 9–10 seconds onward. Temporary encoders retired;
|
||
the healthy connection kept both Original feeds throughout restoration. This
|
||
SDK demand input remains independent of the hardware rate-control mode.
|
||
|
||
Low-rate startup rejected the low-delay VBR candidate. Two fixed-size controls
|
||
used the same 640×360 input and live 100 kbps → 2 Mbps update. With a 2 Mbps
|
||
initialization, Mode4 returned to about 2 Mbps; initialized at 100 kbps, it stayed
|
||
near 207 kbps after the same update. Both kept their MFT and decoded every AU.
|
||
Offline parsing with the pinned WebRTC H264 parser found a restored-window QP
|
||
median of 18 versus 50. Even the high-start control's low-budget phase retained
|
||
QP 17 while dropping frames, so its payload-rate recovery did not establish
|
||
dynamic hardware quality control. The separate 2.x VSE control also received
|
||
the restored allocation and valid QP, but retained QP near 51 and 320×180 output.
|
||
|
||
Changing only the low-start control's rate mode to CBR restored about 2.07 Mbps
|
||
at 30 fps, with QP median 17 and all 341 AUs decoded. Mean-property readback
|
||
alone was insufficient evidence; the unchanged 1.728 Mbps Max-property readback
|
||
also did not explain the Mode4 result. Windows therefore retains one CBR path
|
||
and the existing SDK demand adapter. The low-delay VBR candidate was removed;
|
||
its measured scene-change benefit does not meet the live-quality contract.
|
||
|
||
A `PeakConstrainedVBR` control followed Chromium's
|
||
[paired Mean/Max updates](https://chromium.googlesource.com/chromium/src/+/cf3aaf4828707a1c8cc3c6e8f6df91d37bea418b/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc#1106),
|
||
using the same budget for both properties. On this MFT, the Rust binding reported
|
||
success for the live update, but Max remained at its initial 100 kbps while Mean
|
||
read back 2 Mbps. Output stayed near 208 kbps with QP 50; all 342 AUs decoded.
|
||
This candidate also failed the low-start recovery contract and was not retained.
|
||
|
||
The 2026-11-05 API review confirmed that Microsoft's
|
||
[coded access-unit size property](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/codecapi/avencvideocodedvideoaccessunitsize-property.md)
|
||
applies only to VBR. The pinned SDK's
|
||
[pacing factor](https://github.com/algesten/str0m/blob/3b5b7ed1ff25d9432a87336a20bc2de336896db3/src/pacer/control.rs)
|
||
is internal SDK policy. CBR retains the existing encoder and SDK demand adapter.
|
||
|
||
### Budget Restoration
|
||
|
||
Transport allocation and encoder resolution recover separately. Replaying the
|
||
[publication budget repair](./node-local-media-design.md#send-queue-recovery)
|
||
through unchanged synthetic 1080p30 input restored full resolution where the old
|
||
trace retained 360p. The adapter also reports its clamped encoder target through
|
||
`OnSetEncoderTargetRate`, as
|
||
[VideoSendStream does](https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/video/video_send_stream_impl.cc#1016);
|
||
that correction fixes zero-valued diagnostics, not adaptation policy.
|
||
|
||
The 2026-10-16 comparison isolates a second delay in the pinned WebRTC
|
||
[quality scaler](https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/modules/video_coding/utility/quality_scaler.cc).
|
||
Its default down/up QP smoothers cover roughly two/ten seconds, and subsequent
|
||
checks normally wait five seconds. Requiring 60 new frames further delays a
|
||
low-cadence stream after each adaptation. Windows now supplies existing field
|
||
trials for symmetric five-second smoothing, two-second base checks and 30
|
||
required frames. Codec QP thresholds, drop handling and CPU adaptation retain
|
||
their library defaults. There is no extra controller, quality floor or reset.
|
||
|
||
The controls use the same actual NV12/MFT H264 encoder and 1080p30 synthetic
|
||
motion at a 5 Mbps ceiling. A direct-budget run constrains the encoder to
|
||
400 kbps; the coupled run constrains a 12 Mbps Pion vnet link with 20 ms router
|
||
delay to 400 kbps and feeds real TWCC allocation back to the encoder.
|
||
|
||
| Control | Previous settings | Selected settings |
|
||
| --- | --- | --- |
|
||
| Direct budget: three one-second limits | 720p after each pulse; 1080p about six seconds after release | Retained 1080p through all three pulses |
|
||
| Direct budget: fifteen-second limit | 1080p 17 seconds after release | 1080p 11 seconds after release |
|
||
| Coupled P2P: three one-second limits | Stable 1080p 26.6 seconds after final release | Stable 1080p 1.9 seconds after final release |
|
||
| Coupled P2P: fifteen-second limit | Stable 1080p 22.3 seconds after release | Stable 1080p 22.2 seconds after release |
|
||
| Coupled P2P: healthy link | Retained 1080p | Retained 1080p, about 30 fps, no router drops |
|
||
|
||
Stable recovery requires five consecutive one-second samples at 1080p and at
|
||
least 20 fps. The sustained coupled run did not improve total recovery time:
|
||
its transport budget recovered after 7.0 seconds versus 2.8 seconds, while the
|
||
following encoder delay shortened from 19.5 to 15.2 seconds. The constrained
|
||
outputs reached 180p and 360p respectively; neither policy forces a minimum
|
||
resolution. These single synthetic controls establish the selected behavior,
|
||
not a network success rate, perceptual ranking or diagnosis of field reports.
|
||
|
||
Chrome WebCodecs decoded all 2,871 and 3,425 received picture AUs in the selected
|
||
sustained and periodic runs, preserving each reported dimension and timestamp.
|
||
Parameter-set-only H264 packets are configuration, not pictures. The actual
|
||
packaged capture helper also passed the existing VP8 and H264 640x360
|
||
adapt/recover fixture with continuous ordered output. Encoder, source and
|
||
PeerConnection identities remained intact. Browser WebRTC playout, physical
|
||
capture and unrelated GPU drivers are outside these synthetic checks; page
|
||
scripts cannot apply these native field trials to the user's Browser encoder.
|
||
|
||
### Compatible Output Groups
|
||
|
||
The source now retains per-consumer demand instead of taking a minimum across
|
||
weak children. Effective connection budgets are bounded by the same output
|
||
ceiling; equal requests share one complete pipeline, while differing requests
|
||
are isolated. The group's rates change in place, so a changing estimate is not
|
||
a new encoder identity. Stable slot selection avoids changing groups due to
|
||
map iteration. Two logical representations remain visible to a connection:
|
||
original plus its assigned adaptive output. Additional physical codec slots
|
||
are bounded by source admission and do not become new product quality presets.
|
||
|
||
The existing forwarding source is reused per group. This duplicates bounded
|
||
RTP buffering/projection of the original, not original encoding or decoding.
|
||
LiveKit's `DownTrack.SetReceiver` retains the transport; the adapter preserves
|
||
its own callback wrapper and clears old input clock references before retarget.
|
||
Detached packet, sender-report and closure callbacks cannot mutate the new
|
||
attachment. A source handoff follows an accepted recovery AU and requests
|
||
recovery for the new attachment; pending members keep their current output.
|
||
Unneeded physical codec slots stop, and a Native relay still owns one decoder
|
||
process for all locally derived groups. Source-generation changes and rejected
|
||
timestamps are fenced before attachment changes.
|
||
|
||
The internal capture v7 contract supports encoded AUs up to 4 MiB and independent
|
||
per-slot activation in place
|
||
of the old prefix count, permitting equal-ceiling outputs with different
|
||
budgets. All three platform producers implement that contract. Windows builds
|
||
and normal tests pass; Linux production compilation and CPU-only GStreamer
|
||
slot retirement checks pass. The macOS change is source-reviewed, not SDK or
|
||
physical acceptance. No Browser/server signaling change is needed for private
|
||
encoder grouping; matched App and capture artifacts are required.
|
||
|
||
Actual VP8 relay checks exercise two equal 300 kbps consumers sharing one
|
||
derived output, splitting to 80/300 kbps and rejoining at 300/300 kbps. Both
|
||
consumers keep receiving and the decoder process remains the same. Independent
|
||
consumer and final-process retirement pass. A separate 1280x720 moving-input
|
||
trace keeps one child at a 1.25 Mbps derived budget while the other receives
|
||
80 kbps: the latter reaches 320x180 and the former stays at 640x360. Over the
|
||
roughly 20-second weak phase they receive 45 and 596 frames respectively;
|
||
Chrome WebCodecs decodes every exported frame with its expected dimensions
|
||
and timestamp. This proves spatial isolation and valid delivery, not weak-path
|
||
cadence parity. Budgets in these grouping fixtures are explicit transport
|
||
inputs; the separate shaped-network gate owns automatic estimator evidence.
|
||
|
||
A subsequent [native encoder experiment](./realtime-quality-adaptation.md#native-encoder-policy-experiments)
|
||
tested replacing this partition with one common output: either the maximum or
|
||
the harmonic mean of the active requests. These are policy ablations, not a
|
||
a replacement for independent receiver eligibility and dependency ownership.
|
||
The real Native VP8 fixture supplied 1280x720 motion, with requests of
|
||
80 kbps and 1.25 Mbps for twenty seconds, then equal requests and retirement.
|
||
The independent groups retained the healthy receiver's 640x360 output at
|
||
roughly 1.08 Mbps during the final ten constrained seconds. A common harmonic
|
||
output reduced its delivered payload to about 138 kbps; a common maximum sent
|
||
about 1.20 Mbps even to the 80 kbps consumer. Both alternatives reduced the
|
||
derived encoder count but lost independent budget ownership. All variants
|
||
kept the decoder process while demand changed, then retired it after the last
|
||
consumer left. Chrome WebCodecs decoded every exported picture. This bounded,
|
||
forced-demand comparison does not measure real link capacity, perceptual
|
||
quality or another application's runtime performance; it supports retaining the current
|
||
partition rather than replacing it with one aggregate rate.
|
||
|
||
The full H264 Windows Host/Viewer gate also passes live and paused profile
|
||
changes, background-profile recovery, source replacement and restart while
|
||
preserving media identity. SFU retarget has real loopback tests for clock,
|
||
per-RID counters, recovery and late old-source callbacks. Complete network,
|
||
hardware-overload, multi-room and platform acceptance remain distinct work.
|
||
The Native H264 embedded-SFU gate additionally decodes 300 720p frames, applies
|
||
a live 480p change, retains decoded Opus and closes publication/capture/UDP
|
||
resources. Its Vite server disables file watching: scanning the growing ignored
|
||
build tree had blocked the test's in-process event loop and CDP navigation
|
||
before media started. No Browser media deadline was relaxed to obtain the pass.
|
||
|
||
The subsequent automatic-BWE relay checks are mixed: one 120 kbps constrained
|
||
run retained a roughly 49 kbps estimate throughout the twelve seconds after
|
||
release; an instrumented repeat, with no runtime correction, returned to the
|
||
original 640x360 output about 1.3 seconds after release. That successful trace
|
||
shows valid higher-output demand and the stock congestion guard clearing, not
|
||
proof of why the earlier run stayed low. The fixture's 6 Mbps value is link
|
||
capacity, not payload rate: its replayed original is roughly 157 kbps and its
|
||
bounded queue makes keyframe/retransmission bursts relevant. Temporary probe
|
||
instrumentation was removed. Observation files now follow each received-output
|
||
path and counters follow the actually attached group, preserving failed runs
|
||
and avoiding stale-group attribution. This is an unresolved repeatability
|
||
boundary, not evidence for a new recovery timer or a permanent deadlock.
|
||
|
||
A 75-second follow-up on the 4,096-packet candidate kept the same 5-to-18-second
|
||
120 kbps constraint and restored the original at 19.535 seconds, 1.535 seconds
|
||
after release. The stock congestion guard cleared, a 200 ms padding probe
|
||
requested 315,957 bps, and the estimate rose to 400,717 bps. Both children then
|
||
held about 30 fps through the remaining run; the healthy original delivered
|
||
2,241 frames with no assembly loss, while the constrained child delivered 1,941
|
||
frames with 25 assembly gaps during congestion. The sampled pacer queue peaked
|
||
at 57 packets and stayed at two or fewer after recovery. This demonstrates
|
||
sustained stock recovery in that run, without an algorithm change; it does not
|
||
identify the earlier missed recovery as either a long cooldown or a permanent
|
||
stall. Temporary tracing and the extended fixture duration were removed, and
|
||
all capture/test processes exited.
|
||
|
||
A bounded CPU-affinity check retained the original 1280x720 child and two
|
||
compatible 640x360 consumers through fifteen seconds with only the capture
|
||
subprocess restricted to one core, then restored its original affinity. All
|
||
three received about 30 fps with the same shared group and decoder process.
|
||
The subprocess used only about 11.5% of that core during the restriction, so
|
||
this did not induce overload and cannot establish resource-adaptation parity.
|
||
The temporary fixture was removed and process/affinity cleanup verified.
|
||
|
||
A later 46-second VP8 check used the actual `AdaptiveEncoder` and mailbox at
|
||
2560x1440, 60 fps and 12 Mbps, with an independent raw-input producer. An
|
||
ignored source copy added only `GetStats()` observations. The eight-second
|
||
baseline already averaged about 33 encoded fps and reduced to 1920x1080 for
|
||
bandwidth/quality. Restricting the already initialized process to one core for
|
||
18 seconds used about 88% of that core but delivered only about 0.24 fps;
|
||
average encode time reached 1.4-3.8 seconds. Restoring affinity recovered about
|
||
60 fps at 1280x720 during the final 20 seconds. Stock statistics recorded two
|
||
quality adaptations and no CPU adaptations. This exposes a severe overload
|
||
limit, not CPU-adaptation parity. The helper reported affinity restoration and
|
||
normal completion; its PowerShell wrapper failed to retain an exit-code handle,
|
||
so an OS exit-code pass is not claimed. No product code was changed.
|
||
|
||
The pinned [CPU detector][cpu-detector] explains why large encode times do not
|
||
necessarily produce a CPU adaptation. Its default software thresholds are
|
||
85/42%, with 120 frame samples, three initial checks and two consecutive high
|
||
checks; checks run every five seconds after an initial 100 ms check. A change
|
||
in pixel count or a gap above 1,500 ms between frames entering encoding resets
|
||
the samples and initial-check count. Before enough samples exist, usage returns
|
||
the threshold midpoint rounded to 64%, matching the repeated 64% observations
|
||
after the multi-second stalls. The [resource manager][resources] is connected:
|
||
built-in VP8 retains the [encoder default][encoder-default] CPU opt-in and is a
|
||
software encoder. VSE invokes `OnEncodeStarted` on its encoder queue just
|
||
before the codec call; raw arrival and `OnDiscardedFrame` do not supply CPU
|
||
samples. Replaying dropped inputs as encoded work would misrepresent feedback.
|
||
|
||
Piik's synchronous drain and latest-input mailbox reduce arrivals into VSE
|
||
under this load, but the [same pinned VSE][vse] also skips queued frames before
|
||
calling the CPU observer. Therefore moving admission or reporting source drops
|
||
alone is not an established fix for multi-second encode gaps. Chromium's pinned
|
||
Call also [caches system core count][cpu-count]; changing process affinity after
|
||
encoder initialization is an extreme constraint, not a measured one-core-device
|
||
or Chrome comparison. The 0.24 fps result belongs only to this helper. Keep
|
||
overload acceptance open without changing stock thresholds or adding a custom
|
||
CPU controller.
|
||
|
||
## Initial Replacement And Preservation Map
|
||
|
||
| Owner at the initial review | Planned treatment |
|
||
| --- | --- |
|
||
| Go room/controller, embedded STUN, SFU service lifecycle | Preserve. A codec experiment does not alter authority, NAT policy or single-operation routing. |
|
||
| LiveKit forwarding/BWE/projection and Pion transport | Keep for existing encoded forwarding. Replace a Native endpoint owner only if the new library actually assumes that responsibility; never run two controllers on one edge. |
|
||
| Native output construction, `Source.BeginFrame`, codec workers | Review together against the replacement's capabilities. Remove superseded activation, rate and switching policy in the same integration, not through a permanent legacy path. |
|
||
| Native profile handoff, source clock, bounded queues and retirement | Preserve their verified behavior even if their implementation moves. Do not lose the profile-install acknowledgement or reintroduce double FPS limiting. |
|
||
| App sessions, Global Link, UI, diagnostics and packaging | Outside an encoder-policy replacement. Preserve the separately useful fixes/enhancements recorded in TODO and Git. |
|
||
|
||
An engine migration must also retain direct Native SFU publication, independent
|
||
Native room sessions, native ICE improvements and mixed Browser/App relay.
|
||
Changing transport libraries does not automatically preserve these APIs. No
|
||
unrelated page rewrite or platform-adapter deletion is justified by this review.
|
||
|
||
## Initial Integration Gate Record
|
||
|
||
The September 8 review required a complete shared encoding pipeline after the
|
||
per-sender cache failed the delayed-codec control. It also required received
|
||
encoded bypass, missing-output derivation, budget conversion, safe switching
|
||
and source retirement to retain their existing owners. The Windows product
|
||
attachment and compatible-output sections above record the resulting integration.
|
||
|
||
That initial feasibility pass was not release approval. Current device,
|
||
overload, perceptual-quality and public-network limits remain owned by
|
||
[verification status](../verification-status.md); [TODO](../todo.md) owns pending
|
||
work. The retained experiments and negative controls explain the selected
|
||
boundary without prescribing another completed migration.
|
||
|
||
[chromium-deps]: https://chromium.googlesource.com/chromium/src/+/refs/tags/152.0.7977.82/DEPS
|
||
[chromium-hint]: https://chromium.googlesource.com/chromium/src/+/refs/tags/152.0.7977.82/third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc
|
||
[transport]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/call/rtp_transport_controller_send.cc
|
||
[rtp-budget]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/call/rtp_video_sender.cc
|
||
[simulcast-rates]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/modules/video_coding/utility/simulcast_rate_allocator.cc
|
||
[vse]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/video/video_stream_encoder.cc
|
||
[resources]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/video/adaptation/video_stream_encoder_resource_manager.cc
|
||
[cpu-detector]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/video/adaptation/overuse_frame_detector.cc
|
||
[encoder-default]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/api/video_codecs/video_encoder.cc
|
||
[cpu-count]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/rtc_base/cpu_info.cc
|
||
[video-adapter]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/call/adaptation/video_stream_adapter.cc
|
||
[vp8]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
|
||
[sender-hint]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/pc/rtp_sender.cc
|
||
[media-engine]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/media/engine/webrtc_video_engine.cc
|
||
[simulcast-encoder]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/media/engine/simulcast_encoder_adapter.cc
|
||
[encoder-factory]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/api/video_codecs/video_encoder_factory.h
|
||
[encoder-api]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/api/video_codecs/video_encoder.h
|
||
[encoded-image]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/api/video/encoded_image.h
|
||
[frame-metadata]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/video/frame_encode_metadata_writer.cc
|
||
[broadcaster]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/api/video/video_broadcaster.cc
|
||
[test-proxy]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/test/video_encoder_proxy_factory.h
|
||
[bitrate-adjuster]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/video/encoder_bitrate_adjuster.cc
|
||
[vp8-default-temporal]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/modules/video_coding/codecs/vp8/default_temporal_layers.cc
|
||
[vp8-decoder]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
|
||
[epic-migration]: https://github.com/EpicGames/PixelStreamingInfrastructure/blob/f826b19279ef5a8401341bc046129f1726999db2/Docs/pixel-streaming-2-migration-guide.md#L319
|
||
[epic-settings]: https://github.com/EpicGames/PixelStreamingInfrastructure/blob/f826b19279ef5a8401341bc046129f1726999db2/Frontend/Docs/Settings%20Panel.md
|
||
[webrtc-build]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/docs/native-code/development/README.md
|
||
[codec-initializer]: https://webrtc.googlesource.com/src/+/6f37672d358475cd17544121a12494da454d85fb/modules/video_coding/video_codec_initializer.cc
|
||
[chromium-mf]: https://chromium.googlesource.com/chromium/src/+/refs/tags/152.0.7977.82/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc
|