Skip to content

sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent - #4976

Merged
boks1971 merged 2 commits into
masterfrom
raja/vp8-dd-munger
Oct 11, 2026
Merged

boks1971 merged 2 commits into
masterfrom
raja/vp8-dd-munger

Conversation

@boks1971

Copy link
Copy Markdown
Contributor

Follows #4974 (#4973).

Problem

With the dependency descriptor, libwebrtc sends a one byte VP8 payload descriptor: no picture ID. The VP8 munger has nothing to rewrite, but its temporal drop logic keys on the picture ID, which is now always 0.

  • One gap stops filtering. A gap on a filtered layer puts picture ID 0 in the exempted set. Every later filtered packet then counts as exempted and is forwarded, until the next spatial switch.
  • Late packets pass at any layer. After the first gap, every out-of-order packet hits the picture ID cache.

Fix

New codecmunger.VP8DD for dependency descriptor streams:

  • leaves the header unchanged

  • decides once per frame, from the descriptor's frame number and temporal ID

  • applies that decision to every packet of the frame, late ones included (64-frame window)

  • needs no gap exemption

  • Wiring: the forwarder picks it for a negotiated extension.

  • Fallback: the existing fallback puts the VP8 munger back. After start, it seeds that munger with SetLast.

⚠️ Known gap

  • A late packet of a filtered frame is now dropped, and its outgoing sequence number slot stays empty.
  • A VP8 subscriber gets no descriptor and no picture ID, so libwebrtc finds references by sequence number. An empty slot stalls it until a key frame.
  • The old munger had the same hole for late packets of already dropped pictures.
  • A follow-up PR fills these slots with padding. Merge it with this one.

Tests

  • codecmunger/vp8dd_test.go: layer filter, gap, late packets after a layer change, window, layer switch, padding
  • TestForwarderVP8DDTemporalFilterAfterGap: gap then contiguous frames through GetTranslationParams. Fails without this change.
  • forwarder test: munger type before and after the fallback

🤖 Generated with Claude Code

…or is sent

With the dependency descriptor, libwebrtc sends a one byte VP8 payload
descriptor without a picture ID, so the VP8 munger's picture ID based
temporal drop logic stops filtering after the first gap. A new VP8DD codec
munger decides once per frame from the descriptor's frame number and
temporal ID and applies that decision to every packet of the frame.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 found 2 potential issues.

Devin Review

Comment on lines +82 to +83
case snOutOfOrder:
return 0, hdr, 0, ErrFilteredVP8OutOfOrder

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.

🔴 Late filtered frames stall VP8 playback

When a filtered frame arrives late, VP8DD drops its packet without filling the reserved RTP sequence slot. The subscriber cannot recover that slot and can stall until a key frame.

Learn more

The RTP munger maps out-of-order incoming packets onto outgoing sequence numbers before the codec munger filters them. An out-of-order filtered packet therefore leaves a hole in the subscriber's RTP sequence space. translateCodecHeader suppresses this error without repairing that hole; unlike an in-order drop, the existing PacketDropped operation cannot roll back an older slot. The subscriber does not receive VP8 picture IDs in the minimized payload, so a missing sequence number can block decoding until a key frame.

Example: Send frame 10 at sequence 100, skip sequence 101, then send frame 12 at sequence 102. If late sequence 101 belongs to filtered frame 11, it is dropped while its outgoing slot remains missing; the subscriber keeps requesting it instead of decoding subsequent frames.

Recommended fix: Before dropping an out-of-order filtered packet, arrange for a subscriber-visible padding packet to fill its mapped outgoing sequence number. Preserve RTP timestamp and ordering from the translation and check retransmission handling for the filled slot.

Devin Review


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(Claude replying on Raja's behalf.) Right, this is the known gap in the description. A follow-up stacked on this PR fills such slots: when the forwarder drops a late packet that already has an outgoing slot, the downtrack sends a one byte padding only packet with that sequence number and timestamp. That covers this munger's late drops, the VP8 munger's picture ID cache miss, and the video layer selector's late drops. The two should merge together.

Comment thread pkg/sfu/forwarder.go
Comment on lines +400 to +403
if f.isDDAvailable {
f.codecMunger = codecmunger.NewVP8DD(f.logger)
} else {
f.codecMunger = codecmunger.NewVP8FromOther(f.codecMunger, f.logger)

@devin-ai-integration devin-ai-integration Bot Oct 10, 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.

🔴 VP8 picture IDs break across switches

When a DD publisher also sends VP8 picture IDs, VP8DD forwards them unchanged through temporal filtering and spatial switches. Subscribers receive discontinuous picture IDs instead of the translated sequence required for decoding.

Learn more

Negotiating the dependency-descriptor extension does not establish that every VP8 packet uses the one-byte payload descriptor. The buffer still parses the VP8 payload and stores its optional picture ID and TL0PICIDX in processVideoPacket. VP8DD never rewrites either field, while VP8.UpdateAndGet rewrites picture IDs across filtered frames and switches between simulcast feeds. If a publisher sends both DD and an extended VP8 descriptor, these identifiers now retain the publisher's discontinuities on the subscriber stream.

Example: A publisher uses VP8 picture IDs 100, 101, 102 with a DD; frame 101 is filtered. The subscriber sees 100 then 102, whereas the old VP8 munger emits contiguous translated IDs. A simulcast switch can similarly jump to another feed's unrelated picture ID.

Recommended fix: Keep the frame-based DD filtering, but retain picture ID, TL0PICIDX and key-index rewriting when the incoming VP8 payload descriptor actually contains those fields. Account for a transition between minimized and extended headers and source-switch offsets.

Devin Review


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(Claude replying on Raja's behalf.) Right in principle. libwebrtc minimizes the VP8 payload descriptor whenever it sends the dependency descriptor, and the Go SDK sends picture IDs without the descriptor, so no current sender sends both. A sender that did would lose picture ID rewriting, so 78a7e45 switches to the VP8 munger when a packet with the descriptor carries a picture ID, and keeps switching temporal layers with the dependency descriptor.

…criptor

VP8DD needs the one byte VP8 payload descriptor that libwebrtc sends with
the dependency descriptor. If a publisher keeps picture IDs next to the
descriptor, they need rewriting, so the forwarder switches to the VP8
munger and keeps switching temporal layers with the descriptor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 1 new potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread pkg/sfu/forwarder.go
Comment on lines +2192 to +2195
f.codecMunger = codecmunger.NewVP8FromOther(f.codecMunger, f.logger)
if f.started {
f.codecMunger.SetLast(extPkt)
}

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.

🔴 Intermittent picture IDs break temporal filtering

If a publisher stops sending picture IDs, codecMunger remains a VP8 munger despite receiving dependency descriptors. Its gap exemption then treats every ID-less frame as picture zero, forwarding excluded temporal layers indefinitely.

Learn more

The VP8 payload descriptor's picture ID is optional. This branch permanently replaces the frame-number-based munger after the first packet carrying one, even if later packets retain the dependency descriptor but omit picture IDs. In UpdateAndGet, packets without an ID have picture ID zero. A sequence gap on a filtered layer adds that ID to the exemption cache; subsequent filtered frames with no ID use the same exemption and pass through.

Example: A sender supplies picture ID 10 on frame 10, then sends frames 11 onward with dependency descriptors but no picture IDs. A sequence gap precedes an excluded TL2 frame. The VP8 munger exempts picture zero and forwards that frame and later TL2 frames to a TL0 subscriber.

Recommended fix: Keep descriptor-frame filtering independent of VP8 picture-ID rewriting, or restore the frame-number munger when picture IDs disappear while DD remains present. Preserve outgoing picture-ID continuity across changes in header format.

Devin Review


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(Claude replying on Raja's behalf.) This needs two unusual steps: a sender that puts picture IDs next to the dependency descriptor, which no current SDK does, and then that sender dropping them mid stream. RFC 7741 treats the picture ID as a property of the stream, so the guard makes a one-time choice. A sender that toggles picture IDs is outside what the VP8 munger handles, with or without the descriptor. A non-DD sender that toggles them hits the same picture ID 0 exemption today. The frame number munger covers the real case, libwebrtc's minimized header.

@boks1971
boks1971 merged commit 152328c into master Oct 11, 2026
7 checks passed
@boks1971
boks1971 deleted the raja/vp8-dd-munger branch October 11, 2026 05:46
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Oct 14, 2026
…9 ➔ v1.13.10) (#2338)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` |

---

### Release Notes

<details>
<summary>livekit/livekit (docker.io/livekit/livekit-server)</summary>

### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10)

[Compare Source](livekit/livekit@v1.13.9...v1.13.10)

##### Changed

- sfu: forward the dependency descriptor for VP8 simulcast ([#&#8203;4987](livekit/livekit#4987))
- sfu: keep VP8 descriptor frame numbers across migration ([#&#8203;4989](livekit/livekit#4989))
- sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#&#8203;4991](livekit/livekit#4991))
- sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#&#8203;4976](livekit/livekit#4976))
- sfu: switch VP8 temporal layers up with the dependency descriptor ([#&#8203;4974](livekit/livekit#4974))
- sfu: pad the slot of a filtered packet that follows a sequence number gap ([#&#8203;4983](livekit/livekit#4983))
- sfu: send padding in the slot of a dropped out-of-order packet ([#&#8203;4979](livekit/livekit#4979))
- sfu: parse VP8 and VP9 payload descriptors without an allocation ([#&#8203;4981](livekit/livekit#4981))
- DownTrack: arm key frame requester timer only while a layer lock is pending ([#&#8203;4980](livekit/livekit#4980))
- turn: refuse TCP relays and limit relays to this host to media ports ([#&#8203;4992](livekit/livekit#4992))
- agent endpoints: address an unnamed deployment as "\_" ([#&#8203;4997](livekit/livekit#4997))
- Add OSS Scanner build image and threat model ([#&#8203;4995](livekit/livekit#4995))
- Update golang Docker tag to v1.27.1 ([#&#8203;4985](livekit/livekit#4985))
- Update alpine Docker tag to v3.24.2 ([#&#8203;4984](livekit/livekit#4984))
- Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#&#8203;4915](livekit/livekit#4915))

##### Fixed

- Send NACKs when processing RTX packets ([#&#8203;5000](livekit/livekit#5000))
- sfu: send padding-only packets with no payload ([#&#8203;4993](livekit/livekit#4993))
- rtc: release timed out pending tracks at the pending track limit ([#&#8203;4998](livekit/livekit#4998))
- Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#&#8203;4806](livekit/livekit#4806))
- rtc: keep update cache eviction order when listing recent disconnects ([#&#8203;4975](livekit/livekit#4975))
- fix(cli): return non-zero exit status on command errors ([#&#8203;4888](livekit/livekit#4888))
- Disable AV1 for Firefox clients before 157 ([#&#8203;4962](livekit/livekit#4962))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNTEuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE1MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/2338
hbjydev pushed a commit to hbjydev/phoebe that referenced this pull request Oct 20, 2026
…v1.13.10) (#884)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` |

---

### Release Notes

<details>
<summary>livekit/livekit (docker.io/livekit/livekit-server)</summary>

### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10)

[Compare Source](livekit/livekit@v1.13.9...v1.13.10)

##### Changed

- sfu: forward the dependency descriptor for VP8 simulcast ([#&#8203;4987](livekit/livekit#4987))
- sfu: keep VP8 descriptor frame numbers across migration ([#&#8203;4989](livekit/livekit#4989))
- sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#&#8203;4991](livekit/livekit#4991))
- sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#&#8203;4976](livekit/livekit#4976))
- sfu: switch VP8 temporal layers up with the dependency descriptor ([#&#8203;4974](livekit/livekit#4974))
- sfu: pad the slot of a filtered packet that follows a sequence number gap ([#&#8203;4983](livekit/livekit#4983))
- sfu: send padding in the slot of a dropped out-of-order packet ([#&#8203;4979](livekit/livekit#4979))
- sfu: parse VP8 and VP9 payload descriptors without an allocation ([#&#8203;4981](livekit/livekit#4981))
- DownTrack: arm key frame requester timer only while a layer lock is pending ([#&#8203;4980](livekit/livekit#4980))
- turn: refuse TCP relays and limit relays to this host to media ports ([#&#8203;4992](livekit/livekit#4992))
- agent endpoints: address an unnamed deployment as "\_" ([#&#8203;4997](livekit/livekit#4997))
- Add OSS Scanner build image and threat model ([#&#8203;4995](livekit/livekit#4995))
- Update golang Docker tag to v1.27.1 ([#&#8203;4985](livekit/livekit#4985))
- Update alpine Docker tag to v3.24.2 ([#&#8203;4984](livekit/livekit#4984))
- Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#&#8203;4915](livekit/livekit#4915))

##### Fixed

- Send NACKs when processing RTX packets ([#&#8203;5000](livekit/livekit#5000))
- sfu: send padding-only packets with no payload ([#&#8203;4993](livekit/livekit#4993))
- rtc: release timed out pending tracks at the pending track limit ([#&#8203;4998](livekit/livekit#4998))
- Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#&#8203;4806](livekit/livekit#4806))
- rtc: keep update cache eviction order when listing recent disconnects ([#&#8203;4975](livekit/livekit#4975))
- fix(cli): return non-zero exit status on command errors ([#&#8203;4888](livekit/livekit#4888))
- Disable AV1 for Firefox clients before 157 ([#&#8203;4962](livekit/livekit#4962))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/London)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNjcuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjE2Ny41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.hayden.moe/hayden/phoebe/pulls/884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants