fix: bound data-track buffering under downlink congestion (targetLatency) (#4667)
* fix: bound data-track buffering under downlink congestion The SFU data-track down-channel writer was constructed with targetLatency=0, which disables the buffered-amount/latency-based drop in writeUnreliable. Under subscriber downlink congestion, frames were queued unbounded and in order in the per-subscriber SCTP send buffer instead of being dropped, so end-to-end latency grew without limit and only drained once congestion cleared. This contradicts data tracks being a low-latency, lossy transport. Wire a dedicated `datachannel_data_track_target_latency` config through to both data-track writer call sites (mirroring how `datachannel_lossy_target_latency` controls the lossy publishData channel), reusing lossyDataChannelMinBufferedAmount as the drop floor. Defaults to 100ms so data tracks are latency-bounded out of the box; set to 0 to restore the previous unbounded behavior. Fixes #4666 * fix: track drained bytes on successful unreliable data channel writes writeUnreliable only called BitrateCalculator.AddBytes when a write failed, so on the common success path the calculator never received samples. As a result Bitrate() had no data and the latency-based drop threshold collapsed to the static minBufferedAmount floor, making the per-subscriber latency control (datachannel_lossy_target_latency and the new datachannel_data_track_target_latency) effectively inert. Call AddBytes after every write, matching writeReliable.
This commit is contained in:
@@ -166,6 +166,10 @@ rtc:
|
|||||||
# # max number of bytes to buffer for data channel. 0 means unlimited.
|
# # max number of bytes to buffer for data channel. 0 means unlimited.
|
||||||
# # when this limit is breached, data messages will be dropped till the buffered amount drops below this limit.
|
# # when this limit is breached, data messages will be dropped till the buffered amount drops below this limit.
|
||||||
# data_channel_max_buffered_amount: 0
|
# data_channel_max_buffered_amount: 0
|
||||||
|
# # target latency for data track channels. under downlink congestion, frames are dropped
|
||||||
|
# # to keep the per-subscriber buffer bounded (a fresh frame is preferable to a stale queued one).
|
||||||
|
# # 0 disables buffering control (unbounded buffering). defaults to 100ms.
|
||||||
|
# datachannel_data_track_target_latency: 100ms
|
||||||
|
|
||||||
# when enabled, LiveKit will expose prometheus metrics on :6789/metrics
|
# when enabled, LiveKit will expose prometheus metrics on :6789/metrics
|
||||||
# prometheus_port: 6789
|
# prometheus_port: 6789
|
||||||
|
|||||||
+11
-4
@@ -150,6 +150,12 @@ type RTCConfig struct {
|
|||||||
// Target latency for lossy data channels, used to drop packets to reduce latency.
|
// Target latency for lossy data channels, used to drop packets to reduce latency.
|
||||||
DatachannelLossyTargetLatency time.Duration `yaml:"datachannel_lossy_target_latency,omitempty"`
|
DatachannelLossyTargetLatency time.Duration `yaml:"datachannel_lossy_target_latency,omitempty"`
|
||||||
|
|
||||||
|
// Target latency for data track channels, used to drop packets to keep the
|
||||||
|
// per-subscriber buffer bounded under downlink congestion. Data tracks are a
|
||||||
|
// low-latency lossy transport, so a stale queued frame is worse than a dropped
|
||||||
|
// one. Set to 0 to disable buffering control (unbounded buffering).
|
||||||
|
DatachannelDataTrackTargetLatency time.Duration `yaml:"datachannel_data_track_target_latency,omitempty"`
|
||||||
|
|
||||||
ForwardStats ForwardStatsConfig `yaml:"forward_stats,omitempty"`
|
ForwardStats ForwardStatsConfig `yaml:"forward_stats,omitempty"`
|
||||||
|
|
||||||
// enable rtp stream restart detection for published tracks
|
// enable rtp stream restart detection for published tracks
|
||||||
@@ -454,10 +460,11 @@ var DefaultConfig = Config{
|
|||||||
ICEPortRangeEnd: 0,
|
ICEPortRangeEnd: 0,
|
||||||
STUNServers: []string{},
|
STUNServers: []string{},
|
||||||
},
|
},
|
||||||
PacketBufferSize: 500,
|
PacketBufferSize: 500,
|
||||||
PacketBufferSizeVideo: 500,
|
PacketBufferSizeVideo: 500,
|
||||||
PacketBufferSizeAudio: 200,
|
PacketBufferSizeAudio: 200,
|
||||||
PLIThrottle: sfu.DefaultPLIThrottleConfig,
|
PLIThrottle: sfu.DefaultPLIThrottleConfig,
|
||||||
|
DatachannelDataTrackTargetLatency: 100 * time.Millisecond,
|
||||||
CongestionControl: CongestionControlConfig{
|
CongestionControl: CongestionControlConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
AllowPause: false,
|
AllowPause: false,
|
||||||
|
|||||||
+84
-82
@@ -174,61 +174,62 @@ type ParticipantParams struct {
|
|||||||
PLIThrottleConfig sfu.PLIThrottleConfig
|
PLIThrottleConfig sfu.PLIThrottleConfig
|
||||||
CongestionControlConfig config.CongestionControlConfig
|
CongestionControlConfig config.CongestionControlConfig
|
||||||
// codecs that are enabled for this room
|
// codecs that are enabled for this room
|
||||||
PublishEnabledCodecs []*livekit.Codec
|
PublishEnabledCodecs []*livekit.Codec
|
||||||
SubscribeEnabledCodecs []*livekit.Codec
|
SubscribeEnabledCodecs []*livekit.Codec
|
||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
LoggerResolver logger.DeferredFieldResolver
|
LoggerResolver logger.DeferredFieldResolver
|
||||||
Reporter roomobs.ParticipantSessionReporter
|
Reporter roomobs.ParticipantSessionReporter
|
||||||
ReporterResolver roomobs.ParticipantReporterResolver
|
ReporterResolver roomobs.ParticipantReporterResolver
|
||||||
SimTracks map[uint32]interceptor.SimulcastTrackInfo
|
SimTracks map[uint32]interceptor.SimulcastTrackInfo
|
||||||
Grants *auth.ClaimGrants
|
Grants *auth.ClaimGrants
|
||||||
TokenExpiresAt time.Time
|
TokenExpiresAt time.Time
|
||||||
InitialVersion uint32
|
InitialVersion uint32
|
||||||
ClientConf *livekit.ClientConfiguration
|
ClientConf *livekit.ClientConfiguration
|
||||||
ClientInfo ClientInfo
|
ClientInfo ClientInfo
|
||||||
Region string
|
Region string
|
||||||
Migration bool
|
Migration bool
|
||||||
Reconnect bool
|
Reconnect bool
|
||||||
AdaptiveStream bool
|
AdaptiveStream bool
|
||||||
AllowTCPFallback bool
|
AllowTCPFallback bool
|
||||||
TCPFallbackRTTThreshold int
|
TCPFallbackRTTThreshold int
|
||||||
AllowUDPUnstableFallback bool
|
AllowUDPUnstableFallback bool
|
||||||
TURNSEnabled bool
|
TURNSEnabled bool
|
||||||
ParticipantListener types.LocalParticipantListener
|
ParticipantListener types.LocalParticipantListener
|
||||||
ParticipantHelper types.LocalParticipantHelper
|
ParticipantHelper types.LocalParticipantHelper
|
||||||
DisableSupervisor bool
|
DisableSupervisor bool
|
||||||
ReconnectOnPublicationError bool
|
ReconnectOnPublicationError bool
|
||||||
ReconnectOnSubscriptionError bool
|
ReconnectOnSubscriptionError bool
|
||||||
ReconnectOnDataChannelError bool
|
ReconnectOnDataChannelError bool
|
||||||
VersionGenerator utils.TimedVersionGenerator
|
VersionGenerator utils.TimedVersionGenerator
|
||||||
DisableDynacast bool
|
DisableDynacast bool
|
||||||
SubscriberAllowPause bool
|
SubscriberAllowPause bool
|
||||||
SubscriptionLimitAudio int32
|
SubscriptionLimitAudio int32
|
||||||
SubscriptionLimitVideo int32
|
SubscriptionLimitVideo int32
|
||||||
PlayoutDelay *livekit.PlayoutDelay
|
PlayoutDelay *livekit.PlayoutDelay
|
||||||
SyncStreams bool
|
SyncStreams bool
|
||||||
ForwardStats *sfu.ForwardStats
|
ForwardStats *sfu.ForwardStats
|
||||||
DisableSenderReportPassThrough bool
|
DisableSenderReportPassThrough bool
|
||||||
MetricConfig metric.MetricConfig
|
MetricConfig metric.MetricConfig
|
||||||
UseOneShotSignallingMode bool
|
UseOneShotSignallingMode bool
|
||||||
EnableMetrics bool
|
EnableMetrics bool
|
||||||
DataChannelMaxBufferedAmount uint64
|
DataChannelMaxBufferedAmount uint64
|
||||||
DatachannelSlowThreshold int
|
DatachannelSlowThreshold int
|
||||||
DatachannelLossyTargetLatency time.Duration
|
DatachannelLossyTargetLatency time.Duration
|
||||||
FireOnTrackBySdp bool
|
DatachannelDataTrackTargetLatency time.Duration
|
||||||
DisableCodecRegression bool
|
FireOnTrackBySdp bool
|
||||||
LastPubReliableSeq uint32
|
DisableCodecRegression bool
|
||||||
Country string
|
LastPubReliableSeq uint32
|
||||||
PreferVideoSizeFromMedia bool
|
Country string
|
||||||
UseSinglePeerConnection bool
|
PreferVideoSizeFromMedia bool
|
||||||
EnableDataTracks bool
|
UseSinglePeerConnection bool
|
||||||
EnableRTPStreamRestartDetection bool
|
EnableDataTracks bool
|
||||||
ForceBackupCodecPolicySimulcast bool
|
EnableRTPStreamRestartDetection bool
|
||||||
DisableTransceiverReuseForE2EE bool
|
ForceBackupCodecPolicySimulcast bool
|
||||||
EnableParticipantDataBlob bool
|
DisableTransceiverReuseForE2EE bool
|
||||||
EnableStartAtDesiredQuality bool
|
EnableParticipantDataBlob bool
|
||||||
MigrationWaitDuration time.Duration
|
EnableStartAtDesiredQuality bool
|
||||||
ExcludeIPv6LocalCandidates bool
|
MigrationWaitDuration time.Duration
|
||||||
|
ExcludeIPv6LocalCandidates bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ParticipantImpl struct {
|
type ParticipantImpl struct {
|
||||||
@@ -2035,33 +2036,34 @@ func (p *ParticipantImpl) setupTransportManager() error {
|
|||||||
params := TransportManagerParams{
|
params := TransportManagerParams{
|
||||||
// primary connection does not change, canSubscribe can change if permission was updated
|
// primary connection does not change, canSubscribe can change if permission was updated
|
||||||
// after the participant has joined
|
// after the participant has joined
|
||||||
SubscriberAsPrimary: subscriberAsPrimary,
|
SubscriberAsPrimary: subscriberAsPrimary,
|
||||||
UseSinglePeerConnection: p.params.UseSinglePeerConnection,
|
UseSinglePeerConnection: p.params.UseSinglePeerConnection,
|
||||||
Config: p.params.Config,
|
Config: p.params.Config,
|
||||||
Twcc: p.twcc,
|
Twcc: p.twcc,
|
||||||
ProtocolVersion: p.params.ProtocolVersion,
|
ProtocolVersion: p.params.ProtocolVersion,
|
||||||
CongestionControlConfig: p.params.CongestionControlConfig,
|
CongestionControlConfig: p.params.CongestionControlConfig,
|
||||||
EnabledPublishCodecs: p.enabledPublishCodecs,
|
EnabledPublishCodecs: p.enabledPublishCodecs,
|
||||||
EnabledSubscribeCodecs: p.enabledSubscribeCodecs,
|
EnabledSubscribeCodecs: p.enabledSubscribeCodecs,
|
||||||
SimTracks: p.params.SimTracks,
|
SimTracks: p.params.SimTracks,
|
||||||
ClientInfo: p.params.ClientInfo,
|
ClientInfo: p.params.ClientInfo,
|
||||||
Migration: p.params.Migration,
|
Migration: p.params.Migration,
|
||||||
AllowTCPFallback: p.params.AllowTCPFallback,
|
AllowTCPFallback: p.params.AllowTCPFallback,
|
||||||
TCPFallbackRTTThreshold: p.params.TCPFallbackRTTThreshold,
|
TCPFallbackRTTThreshold: p.params.TCPFallbackRTTThreshold,
|
||||||
AllowUDPUnstableFallback: p.params.AllowUDPUnstableFallback,
|
AllowUDPUnstableFallback: p.params.AllowUDPUnstableFallback,
|
||||||
TURNSEnabled: p.params.TURNSEnabled,
|
TURNSEnabled: p.params.TURNSEnabled,
|
||||||
AllowPlayoutDelay: p.params.PlayoutDelay.GetEnabled(),
|
AllowPlayoutDelay: p.params.PlayoutDelay.GetEnabled(),
|
||||||
DataChannelMaxBufferedAmount: p.params.DataChannelMaxBufferedAmount,
|
DataChannelMaxBufferedAmount: p.params.DataChannelMaxBufferedAmount,
|
||||||
DatachannelSlowThreshold: p.params.DatachannelSlowThreshold,
|
DatachannelSlowThreshold: p.params.DatachannelSlowThreshold,
|
||||||
DatachannelLossyTargetLatency: p.params.DatachannelLossyTargetLatency,
|
DatachannelLossyTargetLatency: p.params.DatachannelLossyTargetLatency,
|
||||||
Logger: p.params.Logger.WithComponent(sutils.ComponentTransport),
|
DatachannelDataTrackTargetLatency: p.params.DatachannelDataTrackTargetLatency,
|
||||||
PublisherHandler: pth,
|
Logger: p.params.Logger.WithComponent(sutils.ComponentTransport),
|
||||||
SubscriberHandler: sth,
|
PublisherHandler: pth,
|
||||||
DataChannelStats: p.dataChannelStats,
|
SubscriberHandler: sth,
|
||||||
UseOneShotSignallingMode: p.params.UseOneShotSignallingMode,
|
DataChannelStats: p.dataChannelStats,
|
||||||
FireOnTrackBySdp: p.params.FireOnTrackBySdp,
|
UseOneShotSignallingMode: p.params.UseOneShotSignallingMode,
|
||||||
EnableDataTracks: p.params.EnableDataTracks,
|
FireOnTrackBySdp: p.params.FireOnTrackBySdp,
|
||||||
ExcludeIPv6LocalCandidates: p.params.ExcludeIPv6LocalCandidates,
|
EnableDataTracks: p.params.EnableDataTracks,
|
||||||
|
ExcludeIPv6LocalCandidates: p.params.ExcludeIPv6LocalCandidates,
|
||||||
}
|
}
|
||||||
if p.params.SyncStreams && p.params.PlayoutDelay.GetEnabled() && p.params.ClientInfo.isFirefox() {
|
if p.params.SyncStreams && p.params.PlayoutDelay.GetEnabled() && p.params.ClientInfo.isFirefox() {
|
||||||
// we will disable playout delay for Firefox if the user is expecting
|
// we will disable playout delay for Firefox if the user is expecting
|
||||||
|
|||||||
+24
-23
@@ -303,27 +303,28 @@ type PCTransport struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TransportParams struct {
|
type TransportParams struct {
|
||||||
Handler transport.Handler
|
Handler transport.Handler
|
||||||
ProtocolVersion types.ProtocolVersion
|
ProtocolVersion types.ProtocolVersion
|
||||||
Config *WebRTCConfig
|
Config *WebRTCConfig
|
||||||
Twcc *lktwcc.Responder
|
Twcc *lktwcc.Responder
|
||||||
DirectionConfig DirectionConfig
|
DirectionConfig DirectionConfig
|
||||||
CongestionControlConfig config.CongestionControlConfig
|
CongestionControlConfig config.CongestionControlConfig
|
||||||
EnabledPublishCodecs []*livekit.Codec
|
EnabledPublishCodecs []*livekit.Codec
|
||||||
EnabledSubscribeCodecs []*livekit.Codec
|
EnabledSubscribeCodecs []*livekit.Codec
|
||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
Transport livekit.SignalTarget
|
Transport livekit.SignalTarget
|
||||||
SimTracks map[uint32]sfuinterceptor.SimulcastTrackInfo
|
SimTracks map[uint32]sfuinterceptor.SimulcastTrackInfo
|
||||||
ClientInfo ClientInfo
|
ClientInfo ClientInfo
|
||||||
IsOfferer bool
|
IsOfferer bool
|
||||||
IsSendSide bool
|
IsSendSide bool
|
||||||
AllowPlayoutDelay bool
|
AllowPlayoutDelay bool
|
||||||
UseOneShotSignallingMode bool
|
UseOneShotSignallingMode bool
|
||||||
ExcludeIPv6LocalCandidates bool
|
ExcludeIPv6LocalCandidates bool
|
||||||
FireOnTrackBySdp bool
|
FireOnTrackBySdp bool
|
||||||
DataChannelMaxBufferedAmount uint64
|
DataChannelMaxBufferedAmount uint64
|
||||||
DatachannelSlowThreshold int
|
DatachannelSlowThreshold int
|
||||||
DatachannelLossyTargetLatency time.Duration
|
DatachannelLossyTargetLatency time.Duration
|
||||||
|
DatachannelDataTrackTargetLatency time.Duration
|
||||||
|
|
||||||
// for development test
|
// for development test
|
||||||
DatachannelMaxReceiverBufferSize int
|
DatachannelMaxReceiverBufferSize int
|
||||||
@@ -914,7 +915,7 @@ func (t *PCTransport) onDataChannel(dc *webrtc.DataChannel) {
|
|||||||
if t.dataTrackDC != nil {
|
if t.dataTrackDC != nil {
|
||||||
t.dataTrackDC.Close()
|
t.dataTrackDC.Close()
|
||||||
}
|
}
|
||||||
t.dataTrackDC = datachannel.NewDataChannelWriterUnreliable(dc, rawDC, 0, 0)
|
t.dataTrackDC = datachannel.NewDataChannelWriterUnreliable(dc, rawDC, t.params.DatachannelDataTrackTargetLatency, uint64(lossyDataChannelMinBufferedAmount))
|
||||||
}
|
}
|
||||||
|
|
||||||
case kind == livekit.DataPacket_RELIABLE:
|
case kind == livekit.DataPacket_RELIABLE:
|
||||||
@@ -1300,7 +1301,7 @@ func (t *PCTransport) CreateDataChannel(label string, dci *webrtc.DataChannelIni
|
|||||||
case dcPtr == &t.lossyDC:
|
case dcPtr == &t.lossyDC:
|
||||||
*dcPtr = datachannel.NewDataChannelWriterUnreliable(dc, rawDC, t.params.DatachannelLossyTargetLatency, uint64(lossyDataChannelMinBufferedAmount))
|
*dcPtr = datachannel.NewDataChannelWriterUnreliable(dc, rawDC, t.params.DatachannelLossyTargetLatency, uint64(lossyDataChannelMinBufferedAmount))
|
||||||
case dcPtr == &t.dataTrackDC:
|
case dcPtr == &t.dataTrackDC:
|
||||||
*dcPtr = datachannel.NewDataChannelWriterUnreliable(dc, rawDC, 0, 0)
|
*dcPtr = datachannel.NewDataChannelWriterUnreliable(dc, rawDC, t.params.DatachannelDataTrackTargetLatency, uint64(lossyDataChannelMinBufferedAmount))
|
||||||
}
|
}
|
||||||
if dcReady != nil {
|
if dcReady != nil {
|
||||||
*dcReady = true
|
*dcReady = true
|
||||||
|
|||||||
+69
-66
@@ -72,33 +72,34 @@ func (h TransportManagerTransportHandler) OnFailed(isShortLived bool, iceConnect
|
|||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
type TransportManagerParams struct {
|
type TransportManagerParams struct {
|
||||||
SubscriberAsPrimary bool
|
SubscriberAsPrimary bool
|
||||||
UseSinglePeerConnection bool
|
UseSinglePeerConnection bool
|
||||||
Config *WebRTCConfig
|
Config *WebRTCConfig
|
||||||
Twcc *twcc.Responder
|
Twcc *twcc.Responder
|
||||||
ProtocolVersion types.ProtocolVersion
|
ProtocolVersion types.ProtocolVersion
|
||||||
CongestionControlConfig config.CongestionControlConfig
|
CongestionControlConfig config.CongestionControlConfig
|
||||||
EnabledSubscribeCodecs []*livekit.Codec
|
EnabledSubscribeCodecs []*livekit.Codec
|
||||||
EnabledPublishCodecs []*livekit.Codec
|
EnabledPublishCodecs []*livekit.Codec
|
||||||
SimTracks map[uint32]interceptor.SimulcastTrackInfo
|
SimTracks map[uint32]interceptor.SimulcastTrackInfo
|
||||||
ClientInfo ClientInfo
|
ClientInfo ClientInfo
|
||||||
Migration bool
|
Migration bool
|
||||||
AllowTCPFallback bool
|
AllowTCPFallback bool
|
||||||
TCPFallbackRTTThreshold int
|
TCPFallbackRTTThreshold int
|
||||||
AllowUDPUnstableFallback bool
|
AllowUDPUnstableFallback bool
|
||||||
TURNSEnabled bool
|
TURNSEnabled bool
|
||||||
AllowPlayoutDelay bool
|
AllowPlayoutDelay bool
|
||||||
DataChannelMaxBufferedAmount uint64
|
DataChannelMaxBufferedAmount uint64
|
||||||
DatachannelSlowThreshold int
|
DatachannelSlowThreshold int
|
||||||
DatachannelLossyTargetLatency time.Duration
|
DatachannelLossyTargetLatency time.Duration
|
||||||
Logger logger.Logger
|
DatachannelDataTrackTargetLatency time.Duration
|
||||||
PublisherHandler transport.Handler
|
Logger logger.Logger
|
||||||
SubscriberHandler transport.Handler
|
PublisherHandler transport.Handler
|
||||||
DataChannelStats *BytesTrackStats
|
SubscriberHandler transport.Handler
|
||||||
UseOneShotSignallingMode bool
|
DataChannelStats *BytesTrackStats
|
||||||
FireOnTrackBySdp bool
|
UseOneShotSignallingMode bool
|
||||||
EnableDataTracks bool
|
FireOnTrackBySdp bool
|
||||||
ExcludeIPv6LocalCandidates bool
|
EnableDataTracks bool
|
||||||
|
ExcludeIPv6LocalCandidates bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransportManager struct {
|
type TransportManager struct {
|
||||||
@@ -149,27 +150,28 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
|
|||||||
publisherSubscribeCodecs = params.EnabledSubscribeCodecs
|
publisherSubscribeCodecs = params.EnabledSubscribeCodecs
|
||||||
}
|
}
|
||||||
publisher, err := NewPCTransport(TransportParams{
|
publisher, err := NewPCTransport(TransportParams{
|
||||||
ProtocolVersion: params.ProtocolVersion,
|
ProtocolVersion: params.ProtocolVersion,
|
||||||
Config: params.Config,
|
Config: params.Config,
|
||||||
Twcc: params.Twcc,
|
Twcc: params.Twcc,
|
||||||
DirectionConfig: params.Config.Publisher,
|
DirectionConfig: params.Config.Publisher,
|
||||||
CongestionControlConfig: params.CongestionControlConfig,
|
CongestionControlConfig: params.CongestionControlConfig,
|
||||||
EnabledPublishCodecs: params.EnabledPublishCodecs,
|
EnabledPublishCodecs: params.EnabledPublishCodecs,
|
||||||
EnabledSubscribeCodecs: publisherSubscribeCodecs,
|
EnabledSubscribeCodecs: publisherSubscribeCodecs,
|
||||||
Logger: lgr,
|
Logger: lgr,
|
||||||
SimTracks: params.SimTracks,
|
SimTracks: params.SimTracks,
|
||||||
ClientInfo: params.ClientInfo,
|
ClientInfo: params.ClientInfo,
|
||||||
IsSendSide: params.UseOneShotSignallingMode || params.UseSinglePeerConnection,
|
IsSendSide: params.UseOneShotSignallingMode || params.UseSinglePeerConnection,
|
||||||
AllowPlayoutDelay: params.AllowPlayoutDelay,
|
AllowPlayoutDelay: params.AllowPlayoutDelay,
|
||||||
Transport: livekit.SignalTarget_PUBLISHER,
|
Transport: livekit.SignalTarget_PUBLISHER,
|
||||||
Handler: TransportManagerTransportHandler{params.PublisherHandler, t, lgr},
|
Handler: TransportManagerTransportHandler{params.PublisherHandler, t, lgr},
|
||||||
UseOneShotSignallingMode: params.UseOneShotSignallingMode,
|
UseOneShotSignallingMode: params.UseOneShotSignallingMode,
|
||||||
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
|
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
|
||||||
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
||||||
DatachannelLossyTargetLatency: params.DatachannelLossyTargetLatency,
|
DatachannelLossyTargetLatency: params.DatachannelLossyTargetLatency,
|
||||||
FireOnTrackBySdp: params.FireOnTrackBySdp,
|
DatachannelDataTrackTargetLatency: params.DatachannelDataTrackTargetLatency,
|
||||||
EnableDataTracks: params.EnableDataTracks,
|
FireOnTrackBySdp: params.FireOnTrackBySdp,
|
||||||
ExcludeIPv6LocalCandidates: params.ExcludeIPv6LocalCandidates,
|
EnableDataTracks: params.EnableDataTracks,
|
||||||
|
ExcludeIPv6LocalCandidates: params.ExcludeIPv6LocalCandidates,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -179,24 +181,25 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
|
|||||||
if !t.params.UseOneShotSignallingMode && !t.params.UseSinglePeerConnection {
|
if !t.params.UseOneShotSignallingMode && !t.params.UseSinglePeerConnection {
|
||||||
lgr := LoggerWithPCTarget(params.Logger, livekit.SignalTarget_SUBSCRIBER)
|
lgr := LoggerWithPCTarget(params.Logger, livekit.SignalTarget_SUBSCRIBER)
|
||||||
subscriber, err := NewPCTransport(TransportParams{
|
subscriber, err := NewPCTransport(TransportParams{
|
||||||
ProtocolVersion: params.ProtocolVersion,
|
ProtocolVersion: params.ProtocolVersion,
|
||||||
Config: params.Config,
|
Config: params.Config,
|
||||||
DirectionConfig: params.Config.Subscriber,
|
DirectionConfig: params.Config.Subscriber,
|
||||||
CongestionControlConfig: params.CongestionControlConfig,
|
CongestionControlConfig: params.CongestionControlConfig,
|
||||||
EnabledSubscribeCodecs: params.EnabledSubscribeCodecs,
|
EnabledSubscribeCodecs: params.EnabledSubscribeCodecs,
|
||||||
Logger: lgr,
|
Logger: lgr,
|
||||||
ClientInfo: params.ClientInfo,
|
ClientInfo: params.ClientInfo,
|
||||||
IsOfferer: true,
|
IsOfferer: true,
|
||||||
IsSendSide: true,
|
IsSendSide: true,
|
||||||
AllowPlayoutDelay: params.AllowPlayoutDelay,
|
AllowPlayoutDelay: params.AllowPlayoutDelay,
|
||||||
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
|
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
|
||||||
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
||||||
DatachannelLossyTargetLatency: params.DatachannelLossyTargetLatency,
|
DatachannelLossyTargetLatency: params.DatachannelLossyTargetLatency,
|
||||||
Transport: livekit.SignalTarget_SUBSCRIBER,
|
DatachannelDataTrackTargetLatency: params.DatachannelDataTrackTargetLatency,
|
||||||
Handler: TransportManagerTransportHandler{params.SubscriberHandler, t, lgr},
|
Transport: livekit.SignalTarget_SUBSCRIBER,
|
||||||
FireOnTrackBySdp: params.FireOnTrackBySdp,
|
Handler: TransportManagerTransportHandler{params.SubscriberHandler, t, lgr},
|
||||||
EnableDataTracks: params.EnableDataTracks,
|
FireOnTrackBySdp: params.FireOnTrackBySdp,
|
||||||
ExcludeIPv6LocalCandidates: params.ExcludeIPv6LocalCandidates,
|
EnableDataTracks: params.EnableDataTracks,
|
||||||
|
ExcludeIPv6LocalCandidates: params.ExcludeIPv6LocalCandidates,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
+21
-20
@@ -520,26 +520,27 @@ func (r *RoomManager) StartSession(
|
|||||||
room: room,
|
room: room,
|
||||||
codecRegressionThreshold: r.config.Video.CodecRegressionThreshold,
|
codecRegressionThreshold: r.config.Video.CodecRegressionThreshold,
|
||||||
},
|
},
|
||||||
ReconnectOnPublicationError: reconnectOnPublicationError,
|
ReconnectOnPublicationError: reconnectOnPublicationError,
|
||||||
ReconnectOnSubscriptionError: reconnectOnSubscriptionError,
|
ReconnectOnSubscriptionError: reconnectOnSubscriptionError,
|
||||||
ReconnectOnDataChannelError: reconnectOnDataChannelError,
|
ReconnectOnDataChannelError: reconnectOnDataChannelError,
|
||||||
VersionGenerator: r.versionGenerator,
|
VersionGenerator: r.versionGenerator,
|
||||||
SubscriberAllowPause: subscriberAllowPause,
|
SubscriberAllowPause: subscriberAllowPause,
|
||||||
SubscriptionLimitAudio: r.config.Limit.SubscriptionLimitAudio,
|
SubscriptionLimitAudio: r.config.Limit.SubscriptionLimitAudio,
|
||||||
SubscriptionLimitVideo: r.config.Limit.SubscriptionLimitVideo,
|
SubscriptionLimitVideo: r.config.Limit.SubscriptionLimitVideo,
|
||||||
PlayoutDelay: roomInternal.GetPlayoutDelay(),
|
PlayoutDelay: roomInternal.GetPlayoutDelay(),
|
||||||
SyncStreams: roomInternal.GetSyncStreams(),
|
SyncStreams: roomInternal.GetSyncStreams(),
|
||||||
ForwardStats: r.forwardStats,
|
ForwardStats: r.forwardStats,
|
||||||
MetricConfig: r.config.Metric,
|
MetricConfig: r.config.Metric,
|
||||||
UseOneShotSignallingMode: useOneShotSignallingMode,
|
UseOneShotSignallingMode: useOneShotSignallingMode,
|
||||||
DataChannelMaxBufferedAmount: r.config.RTC.DataChannelMaxBufferedAmount,
|
DataChannelMaxBufferedAmount: r.config.RTC.DataChannelMaxBufferedAmount,
|
||||||
DatachannelSlowThreshold: r.config.RTC.DatachannelSlowThreshold,
|
DatachannelSlowThreshold: r.config.RTC.DatachannelSlowThreshold,
|
||||||
DatachannelLossyTargetLatency: r.config.RTC.DatachannelLossyTargetLatency,
|
DatachannelLossyTargetLatency: r.config.RTC.DatachannelLossyTargetLatency,
|
||||||
FireOnTrackBySdp: true,
|
DatachannelDataTrackTargetLatency: r.config.RTC.DatachannelDataTrackTargetLatency,
|
||||||
UseSinglePeerConnection: pi.UseSinglePeerConnection,
|
FireOnTrackBySdp: true,
|
||||||
EnableDataTracks: r.config.EnableDataTracks,
|
UseSinglePeerConnection: pi.UseSinglePeerConnection,
|
||||||
EnableParticipantDataBlob: r.config.EnableParticipantDataBlob,
|
EnableDataTracks: r.config.EnableDataTracks,
|
||||||
EnableRTPStreamRestartDetection: r.config.RTC.EnableRTPStreamRestartDetection,
|
EnableParticipantDataBlob: r.config.EnableParticipantDataBlob,
|
||||||
|
EnableRTPStreamRestartDetection: r.config.RTC.EnableRTPStreamRestartDetection,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
prometheus.IncrementParticipantRtcCanceled(1)
|
prometheus.IncrementParticipantRtcCanceled(1)
|
||||||
|
|||||||
@@ -130,9 +130,10 @@ func (w *DataChannelWriter[T]) writeUnreliable(p []byte) (n int, err error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
n, err = w.rawDC.Write(p)
|
n, err = w.rawDC.Write(p)
|
||||||
if err != nil {
|
// Track drained bytes on every write (not just failures) so the bitrate
|
||||||
w.rate.AddBytes(n, int(w.bufferGetter.BufferedAmount()), mono.Now())
|
// calculator has samples; otherwise Bitrate() has no data and the
|
||||||
}
|
// latency-based drop threshold above collapses to the static minBufferedAmount.
|
||||||
|
w.rate.AddBytes(n, int(w.bufferGetter.BufferedAmount()), mono.Now())
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user