mirror of
https://github.com/livekit/livekit.git
synced 2026-04-15 06:25:40 +00:00
rtcpThrottle -> pliThrottle
This commit is contained in:
@@ -36,6 +36,14 @@ rtc:
|
||||
# # LiveKit will automatically configure connected clients to use the same STUN servers
|
||||
# stun_servers:
|
||||
# - server1
|
||||
# # minimum amount of time between pli/fir rtcp packets being sent to an individual
|
||||
# # producer. Increasing these times can lead to longer black screens when participants join,
|
||||
# # while reducing them can lead to higher producer bitrates.
|
||||
# pli_throttle:
|
||||
# low_quality: 1s
|
||||
# mid_quality: 2s
|
||||
# high_quality: 3s
|
||||
|
||||
|
||||
# API key / secret pairs.
|
||||
# Keys are used for JWT authentication, server APIs would require a keypair in order to generate access tokens
|
||||
|
||||
@@ -39,11 +39,11 @@ type RTCConfig struct {
|
||||
// Max bitrate for REMB
|
||||
MaxBitrate uint64 `yaml:"max_bitrate"`
|
||||
|
||||
// Throttle periods for rtcp packets
|
||||
Throttle RTCPThrottleConfig `yaml:"rtcp_throttle"`
|
||||
// Throttle periods for pli/fir rtcp packets
|
||||
PLIThrottle PLIThrottleConfig `yaml:"pli_throttle"`
|
||||
}
|
||||
|
||||
type RTCPThrottleConfig struct {
|
||||
type PLIThrottleConfig struct {
|
||||
LowQuality time.Duration `yaml:"low_quality"`
|
||||
MidQuality time.Duration `yaml:"mid_quality"`
|
||||
HighQuality time.Duration `yaml:"high_quality"`
|
||||
@@ -93,7 +93,7 @@ func NewConfig(confString string) (*Config, error) {
|
||||
},
|
||||
MaxBitrate: 3 * 1024 * 1024, // 3 mbps
|
||||
PacketBufferSize: 500,
|
||||
Throttle: RTCPThrottleConfig{
|
||||
PLIThrottle: PLIThrottleConfig{
|
||||
LowQuality: time.Second,
|
||||
MidQuality: time.Second * 2,
|
||||
HighQuality: time.Second * 3,
|
||||
|
||||
@@ -37,7 +37,7 @@ type ParticipantParams struct {
|
||||
AudioConfig config.AudioConfig
|
||||
ProtocolVersion types.ProtocolVersion
|
||||
Stats *RoomStatsReporter
|
||||
ThrottleConfig config.RTCPThrottleConfig
|
||||
ThrottleConfig config.PLIThrottleConfig
|
||||
}
|
||||
|
||||
type ParticipantImpl struct {
|
||||
@@ -50,7 +50,7 @@ type ParticipantImpl struct {
|
||||
state atomic.Value // livekit.ParticipantInfo_State
|
||||
updateAfterActive atomic.Value // bool
|
||||
rtcpCh chan []rtcp.Packet
|
||||
rtcpThrottle *rtcpThrottle
|
||||
pliThrottle *pliThrottle
|
||||
|
||||
// reliable and unreliable data channels
|
||||
reliableDC *webrtc.DataChannel
|
||||
@@ -91,7 +91,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
params: params,
|
||||
id: utils.NewGuid(utils.ParticipantPrefix),
|
||||
rtcpCh: make(chan []rtcp.Packet, 50),
|
||||
rtcpThrottle: newRtcpThrottle(params.ThrottleConfig),
|
||||
pliThrottle: newPLIThrottle(params.ThrottleConfig),
|
||||
subscribedTracks: make(map[string][]types.SubscribedTrack),
|
||||
publishedTracks: make(map[string]types.PublishedTrack, 0),
|
||||
pendingTracks: make(map[string]*livekit.TrackInfo),
|
||||
@@ -401,7 +401,7 @@ func (p *ParticipantImpl) Close() error {
|
||||
if onClose != nil {
|
||||
onClose(p)
|
||||
}
|
||||
p.rtcpThrottle.close()
|
||||
p.pliThrottle.close()
|
||||
p.publisher.Close()
|
||||
p.subscriber.Close()
|
||||
close(p.rtcpCh)
|
||||
@@ -739,7 +739,7 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
}
|
||||
|
||||
ssrc := uint32(track.SSRC())
|
||||
p.rtcpThrottle.addTrack(ssrc, track.RID())
|
||||
p.pliThrottle.addTrack(ssrc, track.RID())
|
||||
if p.twcc == nil {
|
||||
p.twcc = twcc.NewTransportWideCCResponder(ssrc)
|
||||
p.twcc.OnFeedback(func(pkt rtcp.RawPacket) {
|
||||
@@ -840,7 +840,7 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
|
||||
p.onTrackUpdated(p, track)
|
||||
}
|
||||
if mt, ok := track.(*MediaTrack); ok {
|
||||
p.rtcpThrottle.removeTrack(uint32(mt.ssrc))
|
||||
p.pliThrottle.removeTrack(uint32(mt.ssrc))
|
||||
}
|
||||
track.OnClose(nil)
|
||||
})
|
||||
@@ -958,7 +958,7 @@ func (p *ParticipantImpl) rtcpSendWorker() {
|
||||
continue
|
||||
}
|
||||
|
||||
p.rtcpThrottle.add(mediaSSRC, func() { write([]rtcp.Packet{pkt}) })
|
||||
p.pliThrottle.add(mediaSSRC, func() { write([]rtcp.Packet{pkt}) })
|
||||
}
|
||||
|
||||
if len(fwdPkts) > 0 {
|
||||
|
||||
@@ -173,7 +173,7 @@ func newParticipantForTest(identity string) *ParticipantImpl {
|
||||
Config: rtcConf,
|
||||
Sink: &routingfakes.FakeMessageSink{},
|
||||
ProtocolVersion: 0,
|
||||
ThrottleConfig: conf.RTC.Throttle,
|
||||
ThrottleConfig: conf.RTC.PLIThrottle,
|
||||
})
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
)
|
||||
|
||||
type rtcpThrottle struct {
|
||||
config config.RTCPThrottleConfig
|
||||
type pliThrottle struct {
|
||||
config config.PLIThrottleConfig
|
||||
mu sync.RWMutex
|
||||
throttles map[uint32]func(func())
|
||||
}
|
||||
@@ -22,14 +22,14 @@ const (
|
||||
quarterResolution = "q"
|
||||
)
|
||||
|
||||
func newRtcpThrottle(conf config.RTCPThrottleConfig) *rtcpThrottle {
|
||||
return &rtcpThrottle{
|
||||
func newPLIThrottle(conf config.PLIThrottleConfig) *pliThrottle {
|
||||
return &pliThrottle{
|
||||
config: conf,
|
||||
throttles: make(map[uint32]func(func())),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *rtcpThrottle) addTrack(ssrc uint32, rid string) {
|
||||
func (t *pliThrottle) addTrack(ssrc uint32, rid string) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
@@ -48,7 +48,7 @@ func (t *rtcpThrottle) addTrack(ssrc uint32, rid string) {
|
||||
t.throttles[ssrc] = throttle.New(duration)
|
||||
}
|
||||
|
||||
func (t *rtcpThrottle) add(ssrc uint32, f func()) {
|
||||
func (t *pliThrottle) add(ssrc uint32, f func()) {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
|
||||
@@ -57,7 +57,7 @@ func (t *rtcpThrottle) add(ssrc uint32, f func()) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *rtcpThrottle) removeTrack(ssrc uint32) {
|
||||
func (t *pliThrottle) removeTrack(ssrc uint32) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
@@ -67,7 +67,7 @@ func (t *rtcpThrottle) removeTrack(ssrc uint32) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *rtcpThrottle) close() {
|
||||
func (t *pliThrottle) close() {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
@@ -261,7 +261,7 @@ func (r *RoomManager) StartSession(roomName string, pi routing.ParticipantInit,
|
||||
AudioConfig: r.config.Audio,
|
||||
ProtocolVersion: pv,
|
||||
Stats: room.GetStatsReporter(),
|
||||
ThrottleConfig: r.config.RTC.Throttle,
|
||||
ThrottleConfig: r.config.RTC.PLIThrottle,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Errorw("could not create participant", err)
|
||||
|
||||
Reference in New Issue
Block a user