mirror of
https://github.com/pion/webrtc.git
synced 2025-10-07 08:01:27 +08:00

Fixes #515 This includes a few small and closely related changes: 1. All occurrences of the build tag `+build js` have been changed to the more precise `+build js,wasm`. This will exclude the files from being included by third-party compilers like GopherJS, with which they are incompatible. 2. Some files which are incompatible with JavaScript/Wasm now have the correct build tag (`+build -js`) so they will be excluded from Wasm builds. 3. Some configuration options which are incompatible with JavaScript/Wasm (or at least the current bindings) will now no longer appear in Wasm builds. This meant creating new files with new struct definitions and the appropriate build tags.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// +build !js
|
|
|
|
package webrtc
|
|
|
|
// 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
|
|
// may be phased out in the future.
|
|
type API struct {
|
|
settingEngine *SettingEngine
|
|
mediaEngine *MediaEngine
|
|
}
|
|
|
|
// NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects
|
|
func NewAPI(options ...func(*API)) *API {
|
|
a := &API{}
|
|
|
|
for _, o := range options {
|
|
o(a)
|
|
}
|
|
|
|
if a.settingEngine == nil {
|
|
a.settingEngine = &SettingEngine{}
|
|
}
|
|
|
|
if a.mediaEngine == nil {
|
|
a.mediaEngine = &MediaEngine{}
|
|
}
|
|
|
|
return a
|
|
}
|
|
|
|
// WithMediaEngine allows providing a MediaEngine to the API.
|
|
// Settings should not be changed after passing the engine to an API.
|
|
func WithMediaEngine(m MediaEngine) func(a *API) {
|
|
return func(a *API) {
|
|
a.mediaEngine = &m
|
|
}
|
|
}
|
|
|
|
// WithSettingEngine allows providing a SettingEngine to the API.
|
|
// Settings should not be changed after passing the engine to an API.
|
|
func WithSettingEngine(s SettingEngine) func(a *API) {
|
|
return func(a *API) {
|
|
a.settingEngine = &s
|
|
}
|
|
}
|