api_js.go 678 B

1234567891011121314151617181920212223242526272829303132
  1. //go:build js && wasm
  2. // +build js,wasm
  3. package webrtc
  4. // API bundles the global funcions of the WebRTC and ORTC API.
  5. type API struct {
  6. settingEngine *SettingEngine
  7. }
  8. // NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects
  9. func NewAPI(options ...func(*API)) *API {
  10. a := &API{}
  11. for _, o := range options {
  12. o(a)
  13. }
  14. if a.settingEngine == nil {
  15. a.settingEngine = &SettingEngine{}
  16. }
  17. return a
  18. }
  19. // WithSettingEngine allows providing a SettingEngine to the API.
  20. // Settings should not be changed after passing the engine to an API.
  21. func WithSettingEngine(s SettingEngine) func(a *API) {
  22. return func(a *API) {
  23. a.settingEngine = &s
  24. }
  25. }