Files
livekit/pkg/sfu/codecmunger/codecmunger.go
T
Raja SubramanianandClaude Opus 5.5 152328c76a sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent (#4976)
* sfu: filter VP8 temporal layers by frame when the dependency descriptor 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 <noreply@anthropic.com>

* sfu: use the VP8 munger when picture IDs come with the dependency descriptor

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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 11:16:34 +05:30

46 lines
1.6 KiB
Go

// Copyright 2023 LiveKit, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package codecmunger
import (
"errors"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
)
var (
ErrNotVP8 = errors.New("not VP8")
ErrOutOfOrderVP8PictureIdCacheMiss = errors.New("out-of-order VP8 picture id not found in cache")
ErrFilteredVP8TemporalLayer = errors.New("filtered VP8 temporal layer")
ErrFilteredVP8OutOfOrder = errors.New("filtered out-of-order VP8 packet")
)
// MaxHeaderSize is the largest codec header the mungers produce (VP8: 6 bytes).
const MaxHeaderSize = 8
type CodecMunger interface {
GetState() any
SeedState(state any)
SetLast(extPkt *buffer.ExtPacket)
UpdateOffsets(extPkt *buffer.ExtPacket)
// UpdateAndGet returns the incoming codec header size and the munged
// header by value, so the per-packet path does not allocate.
UpdateAndGet(extPkt *buffer.ExtPacket, snOutOfOrder bool, snHasGap bool, maxTemporal int32) (int, [MaxHeaderSize]byte, int, error)
UpdateAndGetPadding(newPicture bool) ([]byte, error)
}