Add EnableDataChannelBlockWrite to SettingEngine

The settingengine can enabled block write if
datachannel is detached, makes it working like
a normal net.Conn.
This commit is contained in:
cnderrauber
2024-12-16 11:14:26 +08:00
committed by cnderrauber
parent 6a3f35505c
commit 9cfda8be16
4 changed files with 58 additions and 1 deletions

View File

@@ -103,6 +103,7 @@ type SettingEngine struct {
iceMaxBindingRequests *uint16
fireOnTrackBeforeFirstRTP bool
disableCloseByDTLS bool
dataChannelBlockWrite bool
}
// getReceiveMTU returns the configured MTU. If SettingEngine's MTU is configured to 0 it returns the default
@@ -121,6 +122,12 @@ func (e *SettingEngine) DetachDataChannels() {
e.detach.DataChannels = true
}
// EnableDataChannelBlockWrite allows data channels to block on write,
// it only works if DetachDataChannels is enabled
func (e *SettingEngine) EnableDataChannelBlockWrite(nonblockWrite bool) {
e.dataChannelBlockWrite = nonblockWrite
}
// SetSRTPProtectionProfiles allows the user to override the default SRTP Protection Profiles
// The default srtp protection profiles are provided by the function `defaultSrtpProtectionProfiles`
func (e *SettingEngine) SetSRTPProtectionProfiles(profiles ...dtls.SRTPProtectionProfile) {