Refactor video layer selector (#1588)
* WIP commit * WIP commit * fix test * FPS for VP9 * WIP commit * test changes * WIP commit * h264 * codec munger * forwarder state * clean up a bit * dd interface * WIP commit * WIP commit * WIP commit * WIP commit * more TODO notes * overshoot interface * clean up * clean up isTemporalSupported * wait for key frame to resume * clean up VP8 payload descriptor stuff * temporal layer selector * comment out vp9 and av1 * space * fix test compile * append bytes * fix tests * fix test
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package temporallayerselector
|
||||
|
||||
import (
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
)
|
||||
|
||||
type Null struct{}
|
||||
|
||||
func NewNull() *Null {
|
||||
return &Null{}
|
||||
}
|
||||
|
||||
func Select(_extPkt *buffer.ExtPacket, current int32, _target int32) (this int32, next int32) {
|
||||
this = current
|
||||
next = current
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package temporallayerselector
|
||||
|
||||
import "github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
|
||||
type TemporalLayerSelector interface {
|
||||
Select(extPkt *buffer.ExtPacket, current int32, target int32) (this int32, next int32)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package temporallayerselector
|
||||
|
||||
import (
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
type VP8 struct {
|
||||
logger logger.Logger
|
||||
}
|
||||
|
||||
func NewVP8(logger logger.Logger) *VP8 {
|
||||
return &VP8{
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
func (v *VP8) Select(extPkt *buffer.ExtPacket, current int32, target int32) (this int32, next int32) {
|
||||
this = current
|
||||
next = current
|
||||
if current == target {
|
||||
return
|
||||
}
|
||||
|
||||
vp8, ok := extPkt.Payload.(buffer.VP8)
|
||||
if !ok || !vp8.T {
|
||||
return
|
||||
}
|
||||
|
||||
tid := int32(vp8.TID)
|
||||
if current < target {
|
||||
if tid > current && tid <= target && vp8.S && vp8.Y {
|
||||
this = tid
|
||||
next = tid
|
||||
}
|
||||
} else {
|
||||
if tid < current && tid >= target && extPkt.Packet.Marker {
|
||||
next = tid
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user