diff --git a/api.go b/api.go index cf4442bd..c06120d3 100644 --- a/api.go +++ b/api.go @@ -1,9 +1,5 @@ package webrtc -import ( - "time" -) - // API bundles the global funcions of the WebRTC and ORTC API. // Some of these functions are also exported globally using the // defaultAPI object. Note that the global version of the API @@ -53,26 +49,6 @@ func WithSettingEngine(s SettingEngine) func(a *API) { // in the future. var defaultAPI = NewAPI() -// Setting engine API - -// SetEphemeralUDPPortRange on the default API. -// See SettingEngine for details. -func SetEphemeralUDPPortRange(portMin, portMax uint16) error { - return defaultAPI.settingEngine.SetEphemeralUDPPortRange(portMin, portMax) -} - -// DetachDataChannels on the default API. -// See SettingEngine for details. -func DetachDataChannels() { - defaultAPI.settingEngine.DetachDataChannels() -} - -// SetConnectionTimeout on the default API. -// See SettingEngine for details. -func SetConnectionTimeout(connectionTimeout, keepAlive time.Duration) { - defaultAPI.settingEngine.SetConnectionTimeout(connectionTimeout, keepAlive) -} - // Media Engine API // RegisterCodec on the default API. diff --git a/examples/data-channels-detach-create/main.go b/examples/data-channels-detach-create/main.go index 737a96ef..05468e2c 100644 --- a/examples/data-channels-detach-create/main.go +++ b/examples/data-channels-detach-create/main.go @@ -14,9 +14,15 @@ const messageSize = 15 func main() { // Since this behavior diverges from the WebRTC API it has to be - // enabled using global switch. - // Mixing both behaviors is not supported. - webrtc.DetachDataChannels() + // enabled using a settings engine. Mixing both detached and the + // OnMessage DataChannel API is not supported. + + // Create a SettingEngine and enable Detach + s := webrtc.SettingEngine{} + s.DetachDataChannels() + + // Create an API object with the engine + api := webrtc.NewAPI(webrtc.WithSettingEngine(s)) // Everything below is the pion-WebRTC API! Thanks for using it ❤️. @@ -29,8 +35,8 @@ func main() { }, } - // Create a new RTCPeerConnection - peerConnection, err := webrtc.NewPeerConnection(config) + // Create a new RTCPeerConnection using the API object + peerConnection, err := api.NewPeerConnection(config) if err != nil { panic(err) } @@ -81,7 +87,7 @@ func main() { // Wait for the answer to be pasted answer := webrtc.SessionDescription{} - signal.Decode(signal.MustReadStdin(), answer) + signal.Decode(signal.MustReadStdin(), &answer) // Apply the answer as the remote description err = peerConnection.SetRemoteDescription(answer) diff --git a/examples/data-channels-detach/main.go b/examples/data-channels-detach/main.go index 967af6be..1b8f8f0d 100644 --- a/examples/data-channels-detach/main.go +++ b/examples/data-channels-detach/main.go @@ -14,9 +14,15 @@ const messageSize = 15 func main() { // Since this behavior diverges from the WebRTC API it has to be - // enabled using global switch. - // Mixing both behaviors is not supported. - webrtc.DetachDataChannels() + // enabled using a settings engine. Mixing both detached and the + // OnMessage DataChannel API is not supported. + + // Create a SettingEngine and enable Detach + s := webrtc.SettingEngine{} + s.DetachDataChannels() + + // Create an API object with the engine + api := webrtc.NewAPI(webrtc.WithSettingEngine(s)) // Everything below is the pion-WebRTC API! Thanks for using it ❤️. @@ -29,8 +35,8 @@ func main() { }, } - // Create a new RTCPeerConnection - peerConnection, err := webrtc.NewPeerConnection(config) + // Create a new RTCPeerConnection using the API object + peerConnection, err := api.NewPeerConnection(config) if err != nil { panic(err) } @@ -65,7 +71,7 @@ func main() { // Wait for the offer to be pasted offer := webrtc.SessionDescription{} - signal.Decode(signal.MustReadStdin(), offer) + signal.Decode(signal.MustReadStdin(), &offer) // Set the remote SessionDescription err = peerConnection.SetRemoteDescription(offer)