Allow for strict ACKs to be disabled or subscriber peer connections (#1410)

This commit is contained in:
Trey Hakanson
2023-02-10 22:51:03 +05:30
committed by GitHub
parent 3e08ff1043
commit ce07914e44
8 changed files with 86 additions and 78 deletions
+2
View File
@@ -82,6 +82,7 @@ type RTCConfig struct {
IPs IPsConfig `yaml:"ips"`
EnableLoopbackCandidate bool `yaml:"enable_loopback_candidate"`
UseMDNS bool `yaml:"use_mdns"`
StrictACKs bool `yaml:"strict_acks"`
// Number of packets to buffer for NACK
PacketBufferSize int `yaml:"packet_buffer_size,omitempty"`
@@ -273,6 +274,7 @@ func NewConfig(confString string, strictMode bool, c *cli.Context, baseFlags []c
ICEPortRangeEnd: 0,
STUNServers: []string{},
PacketBufferSize: 500,
StrictACKs: true,
PLIThrottle: PLIThrottleConfig{
LowQuality: 500 * time.Millisecond,
MidQuality: time.Second,
+3
View File
@@ -57,6 +57,7 @@ type RTCPFeedbackConfig struct {
type DirectionConfig struct {
RTPHeaderExtension RTPHeaderExtensionConfig
RTCPFeedback RTCPFeedbackConfig
StrictACKs bool
}
const (
@@ -193,6 +194,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
// publisher configuration
publisherConfig := DirectionConfig{
StrictACKs: true, // publisher is dialed, and will always reply with ACK
RTPHeaderExtension: RTPHeaderExtensionConfig{
Audio: []string{
sdp.SDESMidURI,
@@ -222,6 +224,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
// subscriber configuration
subscriberConfig := DirectionConfig{
StrictACKs: conf.RTC.StrictACKs,
RTPHeaderExtension: RTPHeaderExtensionConfig{
Video: []string{dd.ExtensionUrl},
},
+28 -16
View File
@@ -728,28 +728,40 @@ func (t *PCTransport) CreateDataChannel(label string, dci *webrtc.DataChannelIni
return err
}
reliableDCReadyHandler := func() {
t.params.Logger.Debugw("reliable data channel open")
t.lock.Lock()
t.reliableDCOpened = true
t.lock.Unlock()
t.maybeNotifyFullyEstablished()
}
lossyDCReadyHanlder := func() {
t.params.Logger.Debugw("lossy data channel open")
t.lock.Lock()
t.lossyDCOpened = true
t.lock.Unlock()
t.maybeNotifyFullyEstablished()
}
t.lock.Lock()
switch dc.Label() {
case ReliableDataChannel:
t.reliableDC = dc
t.reliableDC.OnOpen(func() {
t.params.Logger.Debugw("reliable data channel open")
t.lock.Lock()
t.reliableDCOpened = true
t.lock.Unlock()
t.maybeNotifyFullyEstablished()
})
if t.params.DirectionConfig.StrictACKs {
t.reliableDC.OnOpen(reliableDCReadyHandler)
} else {
t.reliableDC.OnDial(reliableDCReadyHandler)
}
case LossyDataChannel:
t.lossyDC = dc
t.lossyDC.OnOpen(func() {
t.params.Logger.Debugw("lossy data channel open")
t.lock.Lock()
t.lossyDCOpened = true
t.lock.Unlock()
t.maybeNotifyFullyEstablished()
})
if t.params.DirectionConfig.StrictACKs {
t.lossyDC.OnOpen(lossyDCReadyHanlder)
} else {
t.lossyDC.OnDial(lossyDCReadyHanlder)
}
default:
t.params.Logger.Errorw("unknown data channel label", nil, "label", dc.Label())
}
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"io"
"sync"
"github.com/pion/transport/packetio"
"github.com/pion/transport/v2/packetio"
"github.com/livekit/mediatransportutil/pkg/bucket"
)
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"github.com/pion/rtcp"
"github.com/pion/rtp"
"github.com/pion/sdp/v3"
"github.com/pion/transport/packetio"
"github.com/pion/transport/v2/packetio"
"github.com/pion/webrtc/v3"
"go.uber.org/atomic"