From 85903830c4963ff84dc1486629c800ca9a904f87 Mon Sep 17 00:00:00 2001 From: Yutaka Takeda Date: Sat, 23 Apr 2022 13:27:32 -0700 Subject: [PATCH] Max recv buf size via SettingEngine Relates to pion/sctp#218 --- sctptransport.go | 5 +++-- settingengine.go | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sctptransport.go b/sctptransport.go index 27e02ea65de..a379a96b1e1 100644 --- a/sctptransport.go +++ b/sctptransport.go @@ -103,8 +103,9 @@ func (r *SCTPTransport) Start(remoteCaps SCTPCapabilities) error { } sctpAssociation, err := sctp.Client(sctp.Config{ - NetConn: dtlsTransport.conn, - LoggerFactory: r.api.settingEngine.LoggerFactory, + NetConn: dtlsTransport.conn, + MaxReceiveBufferSize: r.api.settingEngine.sctp.maxReceiveBufferSize, + LoggerFactory: r.api.settingEngine.LoggerFactory, }) if err != nil { return err diff --git a/settingengine.go b/settingengine.go index a2f5ef41882..7cd0bb30881 100644 --- a/settingengine.go +++ b/settingengine.go @@ -54,6 +54,9 @@ type SettingEngine struct { dtls struct { retransmissionInterval time.Duration } + sctp struct { + maxReceiveBufferSize uint32 + } sdpMediaLevelFingerprints bool answeringDTLSRole DTLSRole disableCertificateFingerprintVerification bool @@ -304,3 +307,9 @@ func (e *SettingEngine) SetReceiveMTU(receiveMTU uint) { func (e *SettingEngine) SetDTLSRetransmissionInterval(interval time.Duration) { e.dtls.retransmissionInterval = interval } + +// SetSCTPMaxReceiveBufferSize sets the maximum receive buffer size. +// Leave this 0 for the default maxReceiveBufferSize. +func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) { + e.sctp.maxReceiveBufferSize = maxReceiveBufferSize +}