Skip to content

Fix AV1 packet trailers#1115

Open
chenosaurus wants to merge 15 commits into
mainfrom
dc/fix_av1_ptf
Open

Fix AV1 packet trailers#1115
chenosaurus wants to merge 15 commits into
mainfrom
dc/fix_av1_ptf

Conversation

@chenosaurus

Copy link
Copy Markdown
Contributor

What this fixes

Fixes AV1 packet trailer delivery when packet trailers are enabled.

Previously, packet trailers were appended as raw bytes at the end of the encoded frame. That works for codecs like VP8, but breaks AV1 because the subscriber-side decoder sees the appended bytes as invalid AV1 bitstream data. This caused AV1 subscribers to fail/loop on recovery behavior when packet trailers were enabled.

What changed

  • Encodes LiveKit packet trailer metadata for AV1 as an AV1 Metadata OBU instead of appending raw trailer bytes.
  • Inserts the metadata OBU after leading AV1 sequence header OBUs when present.
  • Extracts and strips the AV1 metadata OBU on receive before the frame reaches the decoder.
  • Keeps the existing raw trailing trailer behavior for non-AV1 codecs.
  • Adds AV1 coverage to the packet trailer tests.

Validation

  • cargo fmt
  • cargo check -p webrtc-sys
  • cargo test -p livekit --features default,__lk-e2e-test --test packet_trailer_test -- --nocapture --test-threads=1
  • Verified with local SFU using publisher --test-pattern --codec av1 --attach-timestamp --attach-frame-id; subscriber decoded AV1 and reported packet trailer features successfully.

Base automatically changed from dc/exp/video_timing to main May 27, 2026 22:42
@ladvoc

ladvoc commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@chenosaurus, is this ready for review?

@chenosaurus

Copy link
Copy Markdown
Contributor Author

@chenosaurus, is this ready for review?

yea, after I resolve all the conflicts.

# Conflicts:
#	examples/local_video/src/publisher.rs
#	examples/local_video/src/subscriber.rs
#	examples/local_video/src/video_display.rs
#	libwebrtc/src/native/video_stream.rs
#	livekit/src/prelude.rs
#	livekit/src/room/participant/local_participant.rs
#	livekit/src/room/track/local_video_track.rs
#	webrtc-sys/include/livekit/packet_trailer.h
#	webrtc-sys/src/packet_trailer.cpp
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Changeset

The following package versions will be affected by this PR:

Package Bump
libwebrtc patch
livekit patch
livekit-ffi patch
webrtc-sys patch

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.

2 participants