Detach: Expose data channel networking

Resolves #277
This commit is contained in:
backkem
2018-12-24 17:46:35 +01:00
committed by Michiel De Backker
parent e3b498b2ba
commit 3762e8a09e
6 changed files with 285 additions and 11 deletions

View File

@@ -4,16 +4,6 @@ import "github.com/pions/webrtc/pkg/ice"
var defaultSettingEngine = newSettingEngine()
// settingEngine allows influencing behavior in ways that are not
// supported by the WebRTC API. This allows us to support additional
// use-cases without deviating from the WebRTC API elsewhere.
type settingEngine struct {
EphemeralUDP struct {
PortMin uint16
PortMax uint16
}
}
// SetEphemeralUDPPortRange limits the pool of ephemeral ports that
// ICE UDP connections can allocate from. This setting currently only
// affects host candidates, not server reflexive candidates.
@@ -27,6 +17,33 @@ func SetEphemeralUDPPortRange(portMin, portMax uint16) error {
return nil
}
// DetachDataChannels enables detaching data channels. When enabled
// data channels have to be detached in the OnOpen callback using the
// RTCDataChannel.Detach method.
func DetachDataChannels() {
defaultSettingEngine.DetachDataChannels()
}
// settingEngine allows influencing behavior in ways that are not
// supported by the WebRTC API. This allows us to support additional
// use-cases without deviating from the WebRTC API elsewhere.
type settingEngine struct {
EphemeralUDP struct {
PortMin uint16
PortMax uint16
}
Detach struct {
DataChannels bool
}
}
// DetachDataChannels enables detaching data channels. When enabled
// data channels have to be detached in the OnOpen callback using the
// RTCDataChannel.Detach method.
func (e *settingEngine) DetachDataChannels() {
e.Detach.DataChannels = true
}
func newSettingEngine() *settingEngine {
return new(settingEngine)
}