Skip to content

fix(webrtc): size H.264 to the negotiated level instead of a fixed cap - #167

Open
gwdp wants to merge 1 commit into
expofrom
gwdp/h264-encode-level-cap
Open

gwdp wants to merge 1 commit into
expofrom
gwdp/h264-encode-level-cap

Conversation

@gwdp

@gwdp gwdp commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Why

The temporary 1280 cap from #161 was a guess at a symptom. The cause is the negotiated level: libwebrtc builds its VideoToolbox session from profile-level-id in the offer, and past that level's frame size (MaxFS, H.264 Table A-1) it encodes zero frames while the session stays connected.

Browsers advertise Level 3.1, which allows 3600 macroblocks. A 1206x2622 screen is 12464.

Level limits were listed as ruled out in #161. That was wrong; the earlier test rested on a "1920 holds" datapoint that did not reproduce.

How

  • H264LevelPolicy maps level_idc to MaxFS and finds the largest long edge that fits
  • Read the lowest level advertised in the offer, scale the encode to fit it
  • An explicit --max-dimension is clamped the same way; asking past the level yields no picture rather than a bigger one
  • Remove the temporary 1280 cap and the picker's matching H.264 ceiling. The --max-dimension ceiling from fix(client): cap the max size picker at --max-dimension  #162 stays

Test Plan

@gwdp
gwdp requested a review from szdziedzic September 17, 2026 18:08
@gwdp
gwdp marked this pull request as ready for review September 17, 2026 18:08
@gwdp gwdp changed the title fix(webrtc): bound H.264 encode size by the negotiated level, not a fixed cap fix(webrtc): size H.264 to the negotiated level instead of a fixed cap Sep 17, 2026
@gwdp gwdp self-assigned this Sep 17, 2026
@gwdp gwdp changed the title fix(webrtc): size H.264 to the negotiated level instead of a fixed cap fix(webrtc): size H.264 to the negotiated level instead of a fixed cap (ENG-26485) Sep 17, 2026
@linear-code

linear-code Bot commented Sep 17, 2026

Copy link
Copy Markdown

ENG-26485

@gwdp gwdp removed their assignment Sep 17, 2026
@gwdp gwdp changed the title fix(webrtc): size H.264 to the negotiated level instead of a fixed cap (ENG-26485) fix(webrtc): size H.264 to the negotiated level instead of a fixed cap Sep 17, 2026
@gwdp
gwdp force-pushed the gwdp/h264-encode-level-cap branch 4 times, most recently from 9af9441 to 4b43e82 Compare September 22, 2026 00:16
@gwdp
gwdp force-pushed the gwdp/h264-encode-level-cap branch from 4b43e82 to 97b2c20 Compare September 22, 2026 01:03

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.

1 participant