Add an engine for global webrtc settings

* hook up UDP limitation to it.
This was Michiel De Backker's suggestion

relates to #281
This commit is contained in:
Woodrow Douglass
2018-12-20 10:34:45 -05:00
committed by Michiel De Backker
parent a6df5427f7
commit a2819a1b93
4 changed files with 35 additions and 8 deletions

28
settingengine.go Normal file
View File

@@ -0,0 +1,28 @@
package webrtc
import "github.com/pions/webrtc/pkg/ice"
var defaultSettingEngine = newSettingEngine()
type settingEngine struct {
EphemeralUDP struct {
PortMin uint16
PortMax uint16
}
}
// SetEphemeralUDPPortRange limits the pool of ephemeral ports that
// ICE UDP connections can allocate from
func SetEphemeralUDPPortRange(portMin, portMax uint16) error {
if portMax < portMin {
return ice.ErrPort
}
defaultSettingEngine.EphemeralUDP.PortMin = portMin
defaultSettingEngine.EphemeralUDP.PortMax = portMax
return nil
}
func newSettingEngine() *settingEngine {
return new(settingEngine)
}