forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingengine.go
49 lines (41 loc) · 1.4 KB
/
settingengine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package webrtc
import "github.com/pions/webrtc/pkg/ice"
var defaultSettingEngine = newSettingEngine()
// 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.
func SetEphemeralUDPPortRange(portMin, portMax uint16) error {
if portMax < portMin {
return ice.ErrPort
}
defaultSettingEngine.EphemeralUDP.PortMin = portMin
defaultSettingEngine.EphemeralUDP.PortMax = portMax
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)
}