Skip to content

Add Windows hardware H264 encode/decode via MediaFoundation - #1282

Open
danryu wants to merge 5 commits into
livekit:mainfrom
danryu:feature/mf-h264-backend
Open

danryu wants to merge 5 commits into
livekit:mainfrom
danryu:feature/mf-h264-backend

Conversation

@danryu

@danryu danryu commented Jul 26, 2026 •

Copy link
Copy Markdown

PR description

Adds a hardware H264 encoder + decoder backend for Windows, using Media Foundation.

I need to run LiveKit with hardware acceleration for video en/decoding if at all possible,
and found this was not possible on Windows. Without prior experience in LiveKit dev, I
attempted to fill in this gap using LLMs: this PR was created through guided steps with Fable 5.

Windows currently compiles no hardware video factory at all — the NVENC backend
is Linux-only (it dlopens libnvidia-encode.so.1), and the vaapi-windows
experiment in build.rs is commented out. On a typical Intel- or AMD-iGPU
workstation, H264 therefore runs on OpenH264/FFmpeg in software.

This PR adds an encoder and decoder built on the Media Foundation transform
(MFT) registered by the GPU driver. One implementation covers Intel
QuickSync, AMD VCN, and NVIDIA
— NVIDIA's Windows driver registers an encoder
MFT like the other vendors, so it is included even though the NVENC backend
isn't available on this platform. It links only static Windows GUID libraries
(mfuuid, dxguid) and loads mfplat.dll dynamically from System32 at runtime:
no third-party dependencies, nothing downloaded, no custom libwebrtc build, and
Windows N editions without the Media Feature Pack still load cleanly and fall
back to software.

Layout (mirrors webrtc-sys/src/nvidia/)

webrtc-sys/src/mf/
  mf_common.h/.cpp          dynamic mfplat.dll loader, per-thread COM init, MFStartup,
                            LK_DISABLE_MF check, CODECAPI GUID instantiation
  mf_encoder_factory.h/.cpp MFTEnumEx(HARDWARE) probe + level probe + Create()
  h264_encoder_impl.h/.cpp  webrtc::VideoEncoder over the async encoder MFT
  mf_decoder_factory.h/.cpp inbox-decoder + D3D11 availability probe
  h264_decoder_impl.h/.cpp  webrtc::VideoDecoder over CLSID_CMSH264DecoderMFT
                            (DXVA via D3D11 device manager, staging readback)

Integration is three small edits: AddMfFactory under
#if defined(USE_MF_VIDEO_CODEC) in video_encoder_factory.cpp (registered as
the generic VideoEncoderBackend::Hardware after NVENC/VAAPI, like the
Jetson/Android backends, so there are no cxx bridge changes), one push_back in
video_decoder_factory.cpp, and five files + /DUSE_MF_VIDEO_CODEC=1 + static
GUID libs (mfuuid, dxguid) in the build.rs "windows" arm. Every failure
path falls through to the existing software fallback, and LK_DISABLE_MF
disables the backend at runtime.

Design notes

  • Encoder. Hardware MFTs are asynchronous, so Encode() runs a bounded
    synchronous event pump — no extra threads, at most 4 frames in flight. CBR via
    ICodecAPI, B-frames disabled (warning-only under Baseline for drivers like
    NVIDIA's MFT that reject CODECAPI_AVEncMPVDefaultBPictureCount),
    effectively-infinite GOP (webrtc drives IDRs through AVEncVideoForceKeyFrame),
    AVLowLatencyMode. Bitrate is updated at runtime where the driver accepts it,
    otherwise by re-init behind a >20% hysteresis. A cached
    MF_MT_MPEG_SEQUENCE_HEADER is prepended to IDRs for vendor MFTs that don't
    inline SPS/PPS. Annex-B output feeds the same NALU-scan /
    H264BitstreamParser post-processing as the NVENC implementation.
  • Format advertisement. The factory probes the level the MFT actually
    accepts (MFT_SET_TYPE_TEST_ONLY, 4.2 → 4.0 → 3.1) rather than hardcoding
    42e01f, so 1080p can be negotiated. Constrained Baseline only, matching the
    existing default interop posture.
  • Decoder. The inbox CLSID_CMSH264DecoderMFT fronts DXVA for every vendor
    when given a D3D11 device manager. Without one it silently decodes on the CPU,
    which would be strictly worse than the existing decoder path — so the factory
    only registers when a video-capable D3D11 device exists. Handles
    MF_E_TRANSFORM_STREAM_CHANGE and the coded-size display aperture (1080p
    arrives as 1920×1088). NV12 texture → staging texture → pooled I420.
  • COM & mfplat.dll. mfplat.dll is loaded dynamically from System32 on
    first MF probe/use; COM is initialized per-thread (MTA, STA-tolerant), since
    webrtc calls in on its own task queues; MFStartup is process-wide start-once.

Known limitations

  • AMD VCN takes the identical code path by design, but was not run on
    physical hardware (no machine available). Intel QuickSync and NVIDIA
    (reported by @wemerson-silva-kz on an RTX 4060 Ti, 1920×1032@60fps +
    simulcast) have been validated on real hardware.
  • System-memory NV12 input (no D3D11 texture input) and CPU readback on decode,
    i.e. the same copy costs as the NVENC backend. Zero-copy is a possible
    follow-up.
  • H264 only; H265 and AV1 are out of scope here.

Breaking changes

None. The change is additive and Windows-only: new files under
webrtc-sys/src/mf/, two guarded dispatch registrations, and a build.rs
"windows" arm. There are no Rust or FFI API changes, no cxx bridge changes and
no new dependencies. On every other platform the diff compiles to nothing, and
on Windows the backend only registers when mfplat.dll and a hardware MFT (and,
for decode, a video-capable D3D11 device) are actually present and LK_DISABLE_MF
is unset — otherwise behaviour is unchanged.

MSRV

Unchanged. No Rust language or dependency changes; the only Rust touched is
build.rs link/source declarations.

Async

No async Rust is involved — this is C++ inside webrtc-sys, called on webrtc's
own encoder/decoder task queues. Nothing in livekit-runtime is used or needed,
and no Tokio dependency is introduced. The MFT event pump is synchronous and
bounded, and holds no locks shared with application threads.

Testing

I want to be straight about this: there are no unit tests in this PR, and I
don't think there is an honest way to add meaningful ones. The code under test
is a driver-registered hardware transform — there is nothing to assert against
without a GPU, and a test that mocked the MFT away would only be asserting that
the mock behaves like the mock. CI has no GPU on the windows-latest runners,
so anything I added would either be skipped there or would emulate exactly the
happy path the contributing guidelines ask us not to emulate. This matches the
existing NVENC, VAAPI and Jetson backends, which likewise ship without unit
tests.

What I did instead was validate on real hardware, deliberately choosing a
worst-case old machine — a Dell OptiPlex 7010: i5-3470, Ivy Bridge HD 2500,
driver 10.18.10.5161 (2020, the final Ivy Bridge branch), Windows 10. If it
works there, the driver floor is Ivy Bridge and up.

Standalone probe (a small cl.exe executable driving the MFTs directly):

Check Result
QSV encoder MFT enumerates + activates yes (async MFT, ICodecAPI ok)
1080p30 CBR low-latency encode 60/60 frames
Levels accepted at 1080p (TEST_ONLY) 3.1, 4.0, 4.1, 4.2, 5.1 all accepted
SPS emitted at 1080p profile_idc=66, level_idc=40
SPS/PPS inline on IDR yes (prepend fallback not needed on Intel)
ForceKeyFrame → IDR yes
Runtime bitrate update accepted (re-init fallback not needed on Intel)
Decode with D3D11 manager DXVA engaged, 60/60 DXGI-texture samples, 1.3 ms/frame
Decode without manager (software baseline) 9.4–9.7 ms/frame

Build and runtime (same machine, MSVC 14.44 / SDK 10.0.26100, stable Rust):

  • cargo build -p webrtc-sys — clean.
  • cargo build -p livekit-ffi — full livekit_ffi.dll cdylib link clean, which
    is what validates the CODECAPI GUID instantiation and System32 dynamic
    mfplat.dll loading.
  • Runtime smoke through the cxx bridge: video_encoder_backend_list() returns
    [Auto, Software, Hardware], i.e. MFVideoEncoderFactory::IsSupported()
    enumerated and activated the QSV MFT through the real dispatch path.

End to end: a live session between a macOS client and a Windows client, both
built on this SDK with H264 selected, camera video flowing in both directions.
Process-module snapshots confirm the Intel hardware encoder MFT
(mfx_mft_h264ve_64.dll + libmfxhw64.dll) and the inbox decoder
(msmpeg2vdec.dll) are loaded in-process on the Windows side for the duration.
Additionally, @wemerson-silva-kz verified the branch on Windows 11 with an
NVIDIA RTX 4060 Ti (driver 610.88) encoding 1920×1032@60fps with simulcast.

Three hardware behaviours were only discovered by running on a real GPU, and are
now baked into the code:

  1. Async MFTs re-signal METransformHaveOutput after
    MF_E_TRANSFORM_STREAM_CHANGE
    — an inline ProcessOutput retry returns
    E_UNEXPECTED on QSV. The encoder now waits for the re-signal; synchronous
    MFTs keep the inline retry. Without this the first frame would have dropped
    the whole backend to software.
  2. d3d10.h before d3d10_1.h is a hard error on current SDKs (SAL ordering) —
    include d3d10_1.h for ID3D10Multithread.
  3. GUID_NULL requires cguid.h; zero-initialization is used instead.

Windows ARM64 (aarch64-pc-windows-msvc): CI now builds and passes for
aarch64-pc-windows-msvc as well as x86_64-pc-windows-msvc. There is no
architecture-specific code in webrtc-sys/src/mf/, though runtime execution on
physical Windows ARM64 hardware has not been tested. Happy to gate it to
x86_64 if preferred.

Notes for review

A few questions I expect, answered up front:

  • Why no LIVEKIT_PREFERRED_HW_ENCODER support? It parses nvenc|vaapi
    only, and MF registers as the generic Hardware backend after NVENC/VAAPI
    (so native NVENC takes precedence if also compiled on Windows). Worth
    extending if needed.
  • Why advertise Baseline only? It matches the current OpenH264/NVENC interop
    posture. High profile is a straightforward follow-up — the
    eAVEncH264VProfile_High mapping already exists in the implementation.
  • Why does the decoder factory require D3D11? Without DXVA the inbox MFT
    decodes on the CPU, which is strictly worse than the built-in decoder path, so
    registering unconditionally would be a silent regression.
  • Rebase: the branch is rebased onto current main (webrtc-a545de4 /
    verwalter) and all CI checks pass.

@CLAassistant

CLAassistant commented Jul 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@wemerson-silva-kz

Copy link
Copy Markdown

Thanks for this PR. We're using it (backported onto webrtc-sys 0.3.52 via [patch.crates-io]) to screen share from a Tauri desktop app on Windows. It works well: on an RTX 4060 Ti, driver 610.88, Windows 11, NVIDIA H.264 Encoder MFT encodes 1920×1032 at 60 fps, and with simulcast both layers go through the MFT. We hit two problems you may want to fold in:

1. The NVIDIA MFT rejects CODECAPI_AVEncMPVDefaultBPictureCount and the encoder fails to init

h264_encoder_impl.cpp:411 treats a failure there as fatal:

Failed to disable B-frames: 0x80070057

With the Baseline profile the NVIDIA MFT returns E_INVALIDARG for this property. InitEncode then returns WEBRTC_VIDEO_CODEC_ERROR, and the session silently falls back to OpenH264. Baseline has no B-frames anyway, so logging a warning and continuing fixes it for us:

hr = SetCodecApiUInt32(codec_api_.Get(), CODECAPI_AVEncMPVDefaultBPictureCount, 0);
if (FAILED(hr)) {
  RTC_LOG(LS_WARNING) << "Encoder MFT rejected B-frame count (baseline has none): "
                      << HResultToString(hr);
}

2. A frame with a size different from configuration_ (likely the cause of a crash we saw)

The size check in Encode() is only RTC_DCHECK_EQ (line 685), so release builds don't check it. CreateInputSample sizes the NV12 buffer from the frame, while the MFT's media types use the size from InitEncode. Screen capture changes size easily (window resized, first frame before reconfiguration). In that situation the app died with STATUS_ACCESS_VIOLATION right after the encoder started. We didn't capture a dump, so we can't fully confirm the cause. After we added this guard, the crash hasn't come back in our tests:

if (static_cast<int>(configuration_.width) != frame_buffer->width() ||
    static_cast<int>(configuration_.height) != frame_buffer->height()) {
  RTC_LOG(LS_WARNING) << "Frame size " << frame_buffer->width() << "x"
                      << frame_buffer->height() << " != encoder "
                      << configuration_.width << "x" << configuration_.height
                      << "; dropping frame.";
  return WEBRTC_VIDEO_CODEC_NO_OUTPUT;
}

Not a bug, just a note: a driver crash can't be caught in-process. Some kind of opt-out (we use an environment variable checked in MFVideoEncoderFactory::IsSupported()) lets apps turn the MF backend off on bad drivers without a new release.

We haven't tested AMD or Intel yet. We'll report back here if those show problems.

danryu and others added 3 commits November 28, 2026 10:50
Adds a Windows hardware H264 backend using the Media Foundation transform
registered by the GPU driver, covering Intel QuickSync, AMD VCN and NVIDIA
NVENC through a single implementation with no third-party dependencies
(system libraries only: mfplat, mfuuid, mf, dxguid).

Follows the src/nvidia/ backend layout:

- mf_encoder_factory: MFTEnumEx(HARDWARE) probe with an activation check
  (registration alone does not guarantee a working driver), registered under
  the generic VideoEncoderBackend::Hardware like the Jetson/Android backends.
  Advertises the H264 level the MFT actually accepts (4.2 -> 4.0 -> 3.1 via
  MFT_SET_TYPE_TEST_ONLY) instead of a hardcoded 42e01f, so 1080p can be
  negotiated.
- h264_encoder_impl: webrtc::VideoEncoder over the async hardware MFT with a
  bounded synchronous event pump (no extra threads). CBR via ICodecAPI,
  B-frames disabled, effectively-infinite GOP (webrtc drives IDRs),
  low-latency mode, runtime bitrate updates with a re-init-plus-hysteresis
  fallback for drivers that reject them, and cached-SPS/PPS prepend for MFTs
  that do not inline the sequence header on IDR frames.
- mf_decoder_factory + h264_decoder_impl: the inbox CLSID_CMSH264DecoderMFT
  fronting DXVA for all vendors when given a D3D11 device manager; NV12
  texture output is copied back through a staging texture into pooled I420
  buffers. Falls back to (and reports) software decode when no video-capable
  D3D11 device exists; handles MF_E_TRANSFORM_STREAM_CHANGE and the
  1088-line coded-height display aperture.

Windows previously compiled no hardware video factory at all; failures at
any point fall back to OpenH264/FFmpeg through the existing dispatch layer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Validated on a Windows 10 box with Intel HD Graphics (Ivy Bridge i5-3470,
QSV driver 10.18.10.5161): cargo build -p webrtc-sys and the livekit-ffi
cdylib link both pass under MSVC 14.44 / SDK 10.0.26100, and
video_encoder_backend_list() lists Hardware at runtime (the QSV encoder
MFT enumerates and activates through MFVideoEncoderFactory::IsSupported).

- async MFTs re-signal METransformHaveOutput after
  MF_E_TRANSFORM_STREAM_CHANGE; an inline ProcessOutput retry returns
  E_UNEXPECTED on Intel QSV. Wait for the re-signal instead (sync MFTs
  keep the inline retry).
- include d3d10_1.h, not d3d10.h, for ID3D10Multithread (d3d10.h before
  d3d10_1.h is a hard error on current SDKs due to SAL ordering).
- GUID_NULL needs cguid.h; use zero-initialization instead.
- fix ProbeTransform call sites left behind by the probe-cleanup refactor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@danryu
danryu force-pushed the feature/mf-h264-backend branch from aa0c41a to 6090b75 Compare November 28, 2026 08:53

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 6 new potential issues.

4 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread webrtc-sys/build.rs Resolved
Comment on lines +696 to +701
if (pending_bitrate_reinit_) {
int32_t ret = ReinitTransform();
if (ret != WEBRTC_VIDEO_CODEC_OK) {
ReportError();
return ret;
}

@devin-ai-integration devin-ai-integration Bot Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Encoder fallback aborts debug builds

When an Auto H264 sender fails to rebuild after a bitrate change, Encode requests a WebRTC encoder switch. The default switch passes no format and disallows default fallback, which trips ApplyEncoderSwitch’s assertion when checks are enabled.

Learn more

ApplyBitrate schedules a rebuild when a driver rejects a runtime bitrate update and the target moves by more than 20%. ReinitTransform releases the old encoder before creating and configuring the replacement. The pinned WebRTC release treats WEBRTC_VIDEO_CODEC_ENCODER_FAILURE as a request to switch encoders. Auto mode clears the sender’s encoder selector, so the default codec-preference path calls the switch callback with std::nullopt and allow_default_fallback = false. WebRtcVideoSendChannel::ApplyEncoderSwitch asserts format.has_value() || allow_default_fallback before handling the request. The Windows build script supports debug builds, where that assertion terminates the process.

Example: An Auto H264 sender increases its bitrate from 1 Mbps to 1.5 Mbps. If the driver rejects the live update and then refuses to configure the replacement, a build with WebRTC assertions enabled aborts before trying another encoder.

Recommended fix: Give Auto Media Foundation H264 a same-format software fallback in the encoder factory, and signal WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE to that wrapper when the rebuild fails. Preserve the explicitly selected backend policy, and exercise the failed-rebuild path with WebRTC assertions enabled.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +806 to +812
if (is_async_) {
need_input_credits_--;
// Collect whatever the MFT already produced; block only when too many
// frames are in flight so encoder latency stays bounded.
return PumpEvents(kOutputWaitTimeoutMs, /*until_need_input=*/false,
/*until_pending_at_most=*/kMaxPendingFrames);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Last video update stays unsent

When an app stops submitting frames, Encode can return before the hardware finishes its last update. Nothing reads the output event until another frame arrives, so viewers never see that update.

Learn more

NativeVideoSource::capture_frame lets an application submit raw frames on demand. Once a real frame arrives, the keepalive task stops supplying black frames. PumpEvents returns immediately when there is no event ready and the pending-count limit is satisfied. An asynchronous transform can post METransformHaveOutput after that return. No consumer runs again until another Encode call.

Example: A source publishes a new slide, then waits for the next slide change. The GPU finishes encoding just after the nonblocking poll, leaving viewers on the previous slide for the entire pause.

Recommended fix: Collect hardware output independently of future input calls, using a serialized event consumer with deterministic shutdown. If keeping a synchronous design, wait for output only under a transform contract that guarantees progress without additional input.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread webrtc-sys/src/mf/h264_encoder_impl.cpp Resolved
Comment thread webrtc-sys/src/mf/h264_encoder_impl.cpp Resolved
Comment on lines +374 to +385
MFSetAttributeSize(output_type.Get(), MF_MT_FRAME_SIZE, configuration_.width,
configuration_.height);
MFSetAttributeRatio(output_type.Get(), MF_MT_FRAME_RATE, fps, 1);
output_type->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
output_type->SetUINT32(MF_MT_MPEG2_PROFILE, H264ProfileToMFProfile(profile_));
output_type->SetUINT32(MF_MT_MPEG2_LEVEL, H264LevelToMFLevel(level_));

hr = transform_->SetOutputType(output_stream_id_, output_type.Get(), 0);
if (FAILED(hr)) {
// Some drivers reject an explicit level; let the MFT derive it.
output_type->DeleteItem(MF_MT_MPEG2_LEVEL);
hr = transform_->SetOutputType(output_stream_id_, output_type.Get(), 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 H.264 output exceeds negotiated level

For 1080p30 negotiated at level 3.1, ConfigureTransform keeps the source dimensions and drops the level constraint if rejected. The resulting stream exceeds the receiver’s negotiated decoding limit.

Learn more

The encoder parses the negotiated profile and level in MFH264EncoderImpl. WebRTC can select this factory for the same H.264 profile and packetization mode at a lower peer-advertised level; FormatSupportedByBackendFactory matches using IsSameCodec, which does not compare H.264 levels. The configuration forwards the source dimensions and frame rate without enforcing the negotiated limit, and a rejected level is removed on retry.

Example: A Windows publisher captures 1920×1080 at 30 fps and selects constrained baseline against a receiver advertising 42e01f. A transform accepting the unrestricted retry can emit level 4.0 video, even though the receiver only advertised level 3.1. A 1080p picture alone exceeds level 3.1’s macroblocks-per-frame limit.

Recommended fix: Enforce the negotiated level’s picture size, processing rate, and bitrate limits before opening the transform. Arrange for compliant input adaptation or select a compliant fallback rather than retrying with an unrestricted type.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@danryu
danryu force-pushed the feature/mf-h264-backend branch from 6090b75 to 1f68486 Compare November 28, 2026 09:21
@danryu
danryu force-pushed the feature/mf-h264-backend branch from 1f68486 to 6f67812 Compare November 28, 2026 09:45
@danryu

danryu commented Nov 28, 2026

Copy link
Copy Markdown
Author

Thanks @wemerson-silva-kz for testing this on an RTX 4060 Ti and reporting those two issues!

I've rebased the PR onto current main and pushed updates addressing the CI blockers, your field report, recent upstream parity fixes, and the Devin Review findings:

Fixes & Updates

  • libwebrtc M150 + verwalter changeset: Updated H264::FindNaluIndices(packet) (removing MakeArrayView) and formatted .changeset/mf-h264-windows-backend.md as webrtc-sys: patch for verwalter.
  • NVIDIA MFT B-frame init fix (from @wemerson-silva-kz): Treat CODECAPI_AVEncMPVDefaultBPictureCount failure as a warning under Baseline/Constrained Baseline rather than failing InitEncode.
  • Runtime frame-size guard (from @wemerson-silva-kz): Replaced the RTC_DCHECK_EQ dimension check in Encode() with a runtime guard returning WEBRTC_VIDEO_CODEC_NO_OUTPUT (and moved it before clearing key_frame_request) so dynamic capture resizes don't feed mismatched NV12 buffers to the MFT.
  • Runtime opt-out (LK_DISABLE_MF): Added LK_DISABLE_MF (matching LK_DISABLE_NVDEC) checked in MFVideoEncoderFactory::IsSupported() / MFVideoDecoderFactory::IsSupported().
  • Dynamic mfplat.dll loading (Devin Review): Removed mfplat and mf import library links from webrtc-sys/build.rs and resolved the 8 mfplat.dll entry points via LoadLibraryExW(..., LOAD_LIBRARY_SEARCH_SYSTEM32) + GetProcAddress, so Windows N editions without the Media Feature Pack still load and fall back to software.
  • Upstream parity & lifecycle fixes:
    • Don't return WEBRTC_VIDEO_CODEC_ERROR after OnEncodedImage fails (matches #1551 to avoid SimulcastEncoderAdapter aborting on dynacast pause/unpublish).
    • Match #1297 SetRates() validation (std::isfinite, kbps units for codec_.maxBitrate, monotonic next_sample_time_100ns_ across fps changes).
    • Return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE if ReinitTransform() fails during Encode() so WebRTC can fall back to software rather than stalling.
    • Set requested_resolution_alignment = 2 and apply_alignment_to_all_simulcast_layers = true for NV12.
    • Don't abort PumpEvents() when async MF_E_TRANSFORM_STREAM_CHANGE returns WEBRTC_VIDEO_CODEC_NO_OUTPUT; add partial-init Release() cleanup, multi-adapter enumeration fallback, single cached factory level probe, decoder aperture/buffer bounds checks, and register AddMfFactory after NVENC/VAAPI.

Regarding the two remaining Devin Review notes:

  1. Bounded synchronous pump (kMaxPendingFrames = 4): Leaving this as a single-threaded synchronous pump in Encode() for now to avoid extra COM/MFT worker thread lifecycle complexity; happy to convert to an async IMFAsyncCallback / drain thread if maintainers prefer.
  2. Negotiated H264 level retry: Resolution/bitrate adaptation to peer SDP limits is handled by WebRTC above the encoder (matching NVENC/VAAPI/OpenH264); the DeleteItem(MF_MT_MPEG2_LEVEL) retry only avoids rejecting drivers that disallow explicit level attributes.

@cloudwebrtc All 34 CI checks are now green (including x86_64-pc-windows-msvc, aarch64-pc-windows-msvc, Changeset Check, Formatting, and Devin Review). Ready for review when you have a chance!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants