Factor out an API object

Relates to #333
This commit is contained in:
Woodrow Douglass
2019-01-02 12:44:43 -05:00
committed by Michiel De Backker
parent bd7c6ffc25
commit e906728df3
9 changed files with 103 additions and 67 deletions

View File

@@ -6,26 +6,24 @@ 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 {
return defaultSettingEngine.SetEphemeralUDPPortRange(portMin, portMax)
return defaultAPI.settingEngine.SetEphemeralUDPPortRange(portMin, portMax)
}
// 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()
defaultAPI.settingEngine.DetachDataChannels()
}
// SetConnectionTimeout sets the amount of silence needed on a given candidate pair
// before the ICE agent considers the pair timed out.
func SetConnectionTimeout(connectionTimeout, keepAlive time.Duration) {
defaultSettingEngine.SetConnectionTimeout(connectionTimeout, keepAlive)
defaultAPI.settingEngine.SetConnectionTimeout(connectionTimeout, keepAlive)
}
// settingEngine allows influencing behavior in ways that are not
@@ -72,6 +70,6 @@ func (e *settingEngine) SetEphemeralUDPPortRange(portMin, portMax uint16) error
return nil
}
func newSettingEngine() *settingEngine {
return new(settingEngine)
func initSettingEngine(s *settingEngine) {
*s = settingEngine{}
}