Skip to content

Commit 1846813

Browse files
committed
DTLS retransmission interval setting
Add SetDTLSRetranmissionInterval setting to SettingEngine. Add test for SetDTLSRetransmissionInterval
1 parent 8da9a67 commit 1846813

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

dtlstransport.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
327327
dtlsConfig.ReplayProtectionWindow = int(*t.api.settingEngine.replayProtection.DTLS)
328328
}
329329

330+
if t.api.settingEngine.dtls.retransmissionInterval != 0 {
331+
dtlsConfig.FlightInterval = t.api.settingEngine.dtls.retransmissionInterval
332+
}
333+
330334
// Connect as DTLS Client/Server, function is blocking and we
331335
// must not hold the DTLSTransport lock
332336
if role == DTLSRoleClient {

settingengine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ type SettingEngine struct {
5151
SRTP *uint
5252
SRTCP *uint
5353
}
54+
dtls struct {
55+
retransmissionInterval time.Duration
56+
}
5457
sdpMediaLevelFingerprints bool
5558
answeringDTLSRole DTLSRole
5659
disableCertificateFingerprintVerification bool
@@ -296,3 +299,8 @@ func (e *SettingEngine) DisableMediaEngineCopy(isDisabled bool) {
296299
func (e *SettingEngine) SetReceiveMTU(receiveMTU uint) {
297300
e.receiveMTU = receiveMTU
298301
}
302+
303+
// SetDTLSRetransmissionInterval sets the retranmission interval for DTLS.
304+
func (e *SettingEngine) SetDTLSRetransmissionInterval(interval time.Duration) {
305+
e.dtls.retransmissionInterval = interval
306+
}

settingengine_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,23 @@ func TestSettingEngine_SetDisableMediaEngineCopy(t *testing.T) {
213213
closePairNow(t, offerer, answerer)
214214
})
215215
}
216+
217+
func TestSetDTLSRetransmissionInterval(t *testing.T) {
218+
s := SettingEngine{}
219+
220+
if s.dtls.retransmissionInterval != 0 {
221+
t.Fatalf("SettingEngine defaults aren't as expected.")
222+
}
223+
224+
s.SetDTLSRetransmissionInterval(100 * time.Millisecond)
225+
if s.dtls.retransmissionInterval == 0 ||
226+
s.dtls.retransmissionInterval != 100*time.Millisecond {
227+
t.Errorf("Failed to set DTLS retransmission interval")
228+
}
229+
230+
s.SetDTLSRetransmissionInterval(1 * time.Second)
231+
if s.dtls.retransmissionInterval == 0 ||
232+
s.dtls.retransmissionInterval != 1*time.Second {
233+
t.Errorf("Failed to set DTLS retransmission interval")
234+
}
235+
}

0 commit comments

Comments
 (0)